From 7265d911f13d55cfa54fd9b175464aa205459134 Mon Sep 17 00:00:00 2001 From: Garrett Michael Flynn Date: Wed, 27 Mar 2024 11:05:40 -0700 Subject: [PATCH 1/2] Add a folder viewer to the Conversion Review page --- .../guided-mode/data/GuidedPathExpansion.js | 5 ++- .../guided-mode/results/GuidedResults.js | 44 ++++++++++++++----- 2 files changed, 38 insertions(+), 11 deletions(-) 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 72bb37569..571ae90a1 100644 --- a/src/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js +++ b/src/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js @@ -279,8 +279,9 @@ export class GuidedPathExpansionPage extends Page { // Map existing results to new subject information (if available) const existingResults = Object.values(Object.values(globalState.results ?? {})[0] ?? {})[0] ?? {}; + const existingMetadata = existingResults.metadata; - const existingSourceData = existingResults.source_data; + const existingSourceData =existingResults.source_data; const source_data = {}; for (let key in globalState.interfaces) { @@ -351,6 +352,8 @@ export class GuidedPathExpansionPage extends Page { throw message; } + // globalState.results = {} // Clear existing results + // Save an overall results object organized by subject and session merge({ results }, globalState); diff --git a/src/renderer/src/stories/pages/guided-mode/results/GuidedResults.js b/src/renderer/src/stories/pages/guided-mode/results/GuidedResults.js index d19cba5cf..fc239ae00 100644 --- a/src/renderer/src/stories/pages/guided-mode/results/GuidedResults.js +++ b/src/renderer/src/stories/pages/guided-mode/results/GuidedResults.js @@ -1,13 +1,43 @@ import { html } from "lit"; +import { unsafeSVG } from "lit/directives/unsafe-svg.js"; +import folderOpenSVG from "../../../assets/folder_open.svg?raw"; + import { Page } from "../../Page.js"; +import { getStubArray } from "../options/GuidedStubPreview.js"; +import { getSharedPath } from "../../../preview/NWBFilePreview.js"; + + +import { electron, path } from "../../../../electron/index.js"; +const { ipcRenderer } = electron; export class GuidedResultsPage extends Page { constructor(...args) { super(...args); } + header = { + controls: () => + html` { + if (ipcRenderer) + ipcRenderer.send( + "showItemInFolder", + this.#sharedPath() + ); + }} + >${unsafeSVG(folderOpenSVG)}`, + } + footer = {}; + #sharedPath = () => { + const { conversion } = this.info.globalState; + if (!conversion) return ''; + return getSharedPath(getStubArray(conversion).map((item) => item.file)); + } + updated() { this.save(); // Save the current state } @@ -18,18 +48,12 @@ export class GuidedResultsPage extends Page { if (!conversion) return html`

Your conversion failed. Please try again.

`; + return html`

Your data was successfully converted to NWB!

- ${Object.entries(conversion) - .map(([subject, sessions]) => { - return html`

sub-${subject}

-
    - ${Object.entries(sessions).map(([session, info]) => { - return html`
  1. ses-${session} — ${info.file}
  2. `; - })} -
`; - }) - .flat()} +
    + ${getStubArray(conversion).map(({ file }) => file.split(path.sep).slice(-1)[0]).sort().map((id) => html`
  1. ${id}
  2. `)} +
`; } } From c28efdd9c6ce1e9cfa037a26e49393075b74ed95 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 27 Mar 2024 18:07:35 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../guided-mode/data/GuidedPathExpansion.js | 2 +- .../guided-mode/results/GuidedResults.js | 19 ++++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) 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 571ae90a1..dc5d5fbe4 100644 --- a/src/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js +++ b/src/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js @@ -281,7 +281,7 @@ export class GuidedPathExpansionPage extends Page { const existingResults = Object.values(Object.values(globalState.results ?? {})[0] ?? {})[0] ?? {}; const existingMetadata = existingResults.metadata; - const existingSourceData =existingResults.source_data; + const existingSourceData = existingResults.source_data; const source_data = {}; for (let key in globalState.interfaces) { diff --git a/src/renderer/src/stories/pages/guided-mode/results/GuidedResults.js b/src/renderer/src/stories/pages/guided-mode/results/GuidedResults.js index fc239ae00..0d09797f9 100644 --- a/src/renderer/src/stories/pages/guided-mode/results/GuidedResults.js +++ b/src/renderer/src/stories/pages/guided-mode/results/GuidedResults.js @@ -6,7 +6,6 @@ import { Page } from "../../Page.js"; import { getStubArray } from "../options/GuidedStubPreview.js"; import { getSharedPath } from "../../../preview/NWBFilePreview.js"; - import { electron, path } from "../../../../electron/index.js"; const { ipcRenderer } = electron; @@ -20,23 +19,19 @@ export class GuidedResultsPage extends Page { html` { - if (ipcRenderer) - ipcRenderer.send( - "showItemInFolder", - this.#sharedPath() - ); + if (ipcRenderer) ipcRenderer.send("showItemInFolder", this.#sharedPath()); }} >${unsafeSVG(folderOpenSVG)}`, - } + }; footer = {}; #sharedPath = () => { const { conversion } = this.info.globalState; - if (!conversion) return ''; + if (!conversion) return ""; return getSharedPath(getStubArray(conversion).map((item) => item.file)); - } + }; updated() { this.save(); // Save the current state @@ -48,11 +43,13 @@ export class GuidedResultsPage extends Page { if (!conversion) return html`

Your conversion failed. Please try again.

`; - return html`

Your data was successfully converted to NWB!

    - ${getStubArray(conversion).map(({ file }) => file.split(path.sep).slice(-1)[0]).sort().map((id) => html`
  1. ${id}
  2. `)} + ${getStubArray(conversion) + .map(({ file }) => file.split(path.sep).slice(-1)[0]) + .sort() + .map((id) => html`
  3. ${id}
  4. `)}
`; }