diff --git a/src/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js b/src/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js index c00e89210..15c296767 100644 --- a/src/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js +++ b/src/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js @@ -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 ?? {}; } diff --git a/src/renderer/src/stories/pages/guided-mode/data/GuidedSourceData.js b/src/renderer/src/stories/pages/guided-mode/data/GuidedSourceData.js index 41ef483bb..d220e13bf 100644 --- a/src/renderer/src/stories/pages/guided-mode/data/GuidedSourceData.js +++ b/src/renderer/src/stories/pages/guided-mode/data/GuidedSourceData.js @@ -68,7 +68,7 @@ export class GuidedSourceDataPage extends ManagedPage { backdrop: "rgba(0,0,0, 0.4)", timerProgressBar: false, didOpen: () => { - Swal.showLoading(); + Swal.showLoading(); }, }); }; @@ -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 @@ -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 ], diff --git a/src/renderer/src/stories/pages/guided-mode/data/GuidedStructure.js b/src/renderer/src/stories/pages/guided-mode/data/GuidedStructure.js index 04faffc77..3fc80b22b 100644 --- a/src/renderer/src/stories/pages/guided-mode/data/GuidedStructure.js +++ b/src/renderer/src/stories/pages/guided-mode/data/GuidedStructure.js @@ -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(); }; diff --git a/src/renderer/src/stories/pages/guided-mode/data/utils.js b/src/renderer/src/stories/pages/guided-mode/data/utils.js index 18deee495..08c64e6e2 100644 --- a/src/renderer/src/stories/pages/guided-mode/data/utils.js +++ b/src/renderer/src/stories/pages/guided-mode/data/utils.js @@ -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]; diff --git a/src/renderer/src/stories/pages/guided-mode/options/GuidedInspectorPage.js b/src/renderer/src/stories/pages/guided-mode/options/GuidedInspectorPage.js index de81d1ef6..8294691df 100644 --- a/src/renderer/src/stories/pages/guided-mode/options/GuidedInspectorPage.js +++ b/src/renderer/src/stories/pages/guided-mode/options/GuidedInspectorPage.js @@ -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 = { @@ -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 previous page to fix any issues shared - across files.`, - })} - -
- - ${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 previous page to fix any issues + shared across files.`, + })} + +
+ + ${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; + })(), + "" + )}`; } } diff --git a/src/renderer/src/stories/pages/settings/SettingsPage.js b/src/renderer/src/stories/pages/settings/SettingsPage.js index 0b3b47395..444af4c08 100644 --- a/src/renderer/src/stories/pages/settings/SettingsPage.js +++ b/src/renderer/src/stories/pages/settings/SettingsPage.js @@ -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 diff --git a/src/renderer/src/stories/pages/uploads/UploadsPage.js b/src/renderer/src/stories/pages/uploads/UploadsPage.js index 03b4e2a9e..0df8220a9 100644 --- a/src/renderer/src/stories/pages/uploads/UploadsPage.js +++ b/src/renderer/src/stories/pages/uploads/UploadsPage.js @@ -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); @@ -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"; @@ -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); @@ -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( diff --git a/src/renderer/src/stories/pages/utils.js b/src/renderer/src/stories/pages/utils.js index 59beb7be4..414131d46 100644 --- a/src/renderer/src/stories/pages/utils.js +++ b/src/renderer/src/stories/pages/utils.js @@ -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