Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 9, 2023
1 parent 8d80703 commit b9de158
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class GuidedPathExpansionPage extends Page {

const source_data = {};
for (let key in globalState.interfaces) {
const existing = existingSourceData?.[key]
const existing = existingSourceData?.[key];
if (existing) source_data[key] = existing ?? {};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class GuidedSourceDataPage extends ManagedPage {
backdrop: "rgba(0,0,0, 0.4)",
timerProgressBar: false,
didOpen: () => {
Swal.showLoading();
Swal.showLoading();
},
});
};
Expand All @@ -79,7 +79,6 @@ export class GuidedSourceDataPage extends ManagedPage {

await Promise.all(
Object.values(this.forms).map(async ({ subject, session, form }) => {

const info = this.info.globalState.results[subject][session];

// NOTE: This clears all user-defined results
Expand Down Expand Up @@ -173,8 +172,8 @@ export class GuidedSourceDataPage extends ManagedPage {
const modal = (this.#globalModal = createGlobalFormModal.call(this, {
header: "Global Source Data",
propsToRemove: [
...propsToIgnore,
"folder_path",
...propsToIgnore,
"folder_path",
"file_path",
// NOTE: Still keeping plural path specifications for now
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ export class GuidedStructurePage extends Page {
this.mapSessions(({ info }) => {
Object.keys(info.source_data).forEach((key) => {
if (!this.info.globalState.interfaces[key]) delete info.source_data[key];
})
})
});
});
}

await this.save(undefined, false); // Interrim save, in case the schema request fails
await this.getSchema();
};
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/stories/pages/guided-mode/data/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { merge } from "../../utils.js";

// Merge project-wide data into metadata
export function populateWithProjectMetadata(info, globalState) {
const copy = structuredClone(info)
const copy = structuredClone(info);
const toMerge = Object.entries(globalState.project).filter(([_, value]) => value && typeof value === "object");
toMerge.forEach(([key, value]) => {
let internalMetadata = copy[key];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ export class GuidedInspectorPage extends Page {
super(...args);
this.style.height = "100%"; // Fix main section
Object.assign(this.style, {
display: 'flex',
flexDirection: 'column'
})
display: "flex",
flexDirection: "column",
});
}

header = {
Expand Down Expand Up @@ -87,97 +87,97 @@ export class GuidedInspectorPage extends Page {
)
.flat();
return html` ${new InfoBox({
header: "How do I fix these suggestions?",
content: html`We suggest editing the Global Metadata on the <b>previous page</b> to fix any issues shared
across files.`,
})}
<br>
${until(
(async () => {
if (fileArr.length <= 1) {
const items =
inspector ??
removeFilePaths(
header: "How do I fix these suggestions?",
content: html`We suggest editing the Global Metadata on the <b>previous page</b> to fix any issues
shared across files.`,
})}
<br />
${until(
(async () => {
if (fileArr.length <= 1) {
const items =
inspector ??
removeFilePaths(
(globalState.preview.inspector = await run(
"inspect_file",
{ nwbfile_path: fileArr[0].info.file, ...opts },
{ title }
))
);
if (!inspector) await this.save();
return new InspectorList({ items, emptyMessage });
}
const items = await (async () => {
const path = getSharedPath(fileArr.map((o) => o.info.file));
const report =
inspector ??
(globalState.preview.inspector = await run(
"inspect_file",
{ nwbfile_path: fileArr[0].info.file, ...opts },
{ title }
))
);
if (!inspector) await this.save();
return new InspectorList({ items, emptyMessage });
}
const items = await (async () => {
const path = getSharedPath(fileArr.map((o) => o.info.file));
const report =
inspector ??
(globalState.preview.inspector = await run(
"inspect_folder",
{ path, ...opts },
{ title: title + "s" }
));
if (!inspector) await this.save();
return truncateFilePaths(report, path);
})();
const _instances = fileArr.map(({ subject, session, info }) => {
const file_path = [`sub-${subject}`, `sub-${subject}_ses-${session}`];
const filtered = removeFilePaths(filter(items, { file_path }));
const display = () => new InspectorList({ items: filtered, emptyMessage });
display.status = this.getStatus(filtered);
return {
subject,
session,
display,
"inspect_folder",
{ path, ...opts },
{ title: title + "s" }
));
if (!inspector) await this.save();
return truncateFilePaths(report, path);
})();
const _instances = fileArr.map(({ subject, session, info }) => {
const file_path = [`sub-${subject}`, `sub-${subject}_ses-${session}`];
const filtered = removeFilePaths(filter(items, { file_path }));
const display = () => new InspectorList({ items: filtered, emptyMessage });
display.status = this.getStatus(filtered);
return {
subject,
session,
display,
};
});
const instances = _instances.reduce((acc, { subject, session, display }) => {
const subLabel = `sub-${subject}`;
if (!acc[`sub-${subject}`]) acc[subLabel] = {};
acc[subLabel][`ses-${session}`] = display;
return acc;
}, {});
Object.keys(instances).forEach((subLabel) => {
const subItems = filter(items, { file_path: `${subLabel}${nodePath.sep}${subLabel}_ses-` }); // NOTE: This will not run on web-only now
const path = getSharedPath(subItems.map((o) => o.file_path));
const filtered = truncateFilePaths(subItems, path);
const display = () => new InspectorList({ items: filtered, emptyMessage });
display.status = this.getStatus(filtered);
instances[subLabel] = {
["All Files"]: display,
...instances[subLabel],
};
});
const allDisplay = () => new InspectorList({ items, emptyMessage });
allDisplay.status = this.getStatus(items);
const allInstances = {
["All Files"]: allDisplay,
...instances,
};
});
const instances = _instances.reduce((acc, { subject, session, display }) => {
const subLabel = `sub-${subject}`;
if (!acc[`sub-${subject}`]) acc[subLabel] = {};
acc[subLabel][`ses-${session}`] = display;
return acc;
}, {});
Object.keys(instances).forEach((subLabel) => {
const subItems = filter(items, { file_path: `${subLabel}${nodePath.sep}${subLabel}_ses-` }); // NOTE: This will not run on web-only now
const path = getSharedPath(subItems.map((o) => o.file_path));
const filtered = truncateFilePaths(subItems, path);
const display = () => new InspectorList({ items: filtered, emptyMessage });
display.status = this.getStatus(filtered);
instances[subLabel] = {
["All Files"]: display,
...instances[subLabel],
};
});
const allDisplay = () => new InspectorList({ items, emptyMessage });
allDisplay.status = this.getStatus(items);
const allInstances = {
["All Files"]: allDisplay,
...instances,
};
const manager = new InstanceManager({
instances: allInstances,
});
const manager = new InstanceManager({
instances: allInstances,
});
return manager;
})(),
""
)}`;
return manager;
})(),
""
)}`;
}
}

Expand Down
1 change: 0 additions & 1 deletion src/renderer/src/stories/pages/settings/SettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export class SettingsPage extends Page {
};

render() {

this.localState = structuredClone(global.data);

// NOTE: API Keys and Dandiset IDs persist across selected project
Expand Down
25 changes: 14 additions & 11 deletions src/renderer/src/stories/pages/uploads/UploadsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export async function uploadToDandi(info, type = "project" in info ? "project" :
const staging = isStaging(dandiset_id); // Automatically detect staging IDs

const whichAPIKey = staging ? "staging_api_key" : "main_api_key";
const DANDI = global.data.DANDI
const DANDI = global.data.DANDI;
let api_key = DANDI?.api_keys?.[whichAPIKey];

const errors = await validateDANDIApiKey(api_key, staging);
Expand All @@ -66,7 +66,7 @@ export async function uploadToDandi(info, type = "project" in info ? "project" :

const input = new JSONSchemaInput({
path: [whichAPIKey],
info: dandiGlobalSchema.properties.api_keys.properties[whichAPIKey]
info: dandiGlobalSchema.properties.api_keys.properties[whichAPIKey],
});

input.style.padding = "25px";
Expand All @@ -92,14 +92,17 @@ export async function uploadToDandi(info, type = "project" in info ? "project" :
const errors = await validateDANDIApiKey(input.value, staging);
if (!errors || !errors.length) {
modal.remove();

merge({
DANDI: {
api_keys: {
[whichAPIKey]: value
}
}
}, global.data)

merge(
{
DANDI: {
api_keys: {
[whichAPIKey]: value,
},
},
},
global.data
);

global.save();
resolve(value);
Expand All @@ -118,7 +121,7 @@ export async function uploadToDandi(info, type = "project" in info ? "project" :
document.body.append(modal);
});

console.log(api_key)
console.log(api_key);
}

const result = await run(
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/src/stories/pages/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export function merge(toMerge = {}, target = {}, mergeOpts = {}) {
for (const [k, v] of Object.entries(toMerge)) {
const targetV = target[k];
// if (isPrivate(k)) continue;
if (mergeOpts.arrays && Array.isArray(v) && Array.isArray(targetV)) target[k] = [...targetV, ...v]; // Merge array entries together
if (mergeOpts.arrays && Array.isArray(v) && Array.isArray(targetV))
target[k] = [...targetV, ...v]; // Merge array entries together
else if (v === undefined) {
delete target[k]; // Remove matched values
// if (mergeOpts.remove !== false) delete target[k]; // Remove matched values
Expand Down

0 comments on commit b9de158

Please sign in to comment.