From c98f4ed5fcc18ad7aefbec863c04a5bab3973673 Mon Sep 17 00:00:00 2001 From: Garrett Michael Flynn Date: Mon, 20 May 2024 15:44:39 -0700 Subject: [PATCH 01/16] Ensure users are notified about possible data that the GUIDE misses --- manualActions.json | 12 ++++++ src/renderer/src/stories/CodeBlock.js | 39 +++++++++++++++++-- .../guided-mode/results/GuidedResults.js | 39 +++++++++++++++++++ 3 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 manualActions.json diff --git a/manualActions.json b/manualActions.json new file mode 100644 index 0000000000..e7e5e417d0 --- /dev/null +++ b/manualActions.json @@ -0,0 +1,12 @@ +[ + { + "name": "Annotate Time Intervals", + "description": "Annotating events in time is a common need in neuroscience, e.g. to describe epochs, trials, and invalid times during an experimental session.", + "url": "https://pynwb.readthedocs.io/en/stable/tutorials/general/plot_timeintervals.html#sphx-glr-tutorials-general-plot-timeintervals-py" + }, + { + "name": "Extend NWB", + "description": "The NWB format was designed to be easily extendable, allowing users to add new data types and attributes to the format.", + "url": "https://pynwb.readthedocs.io/en/stable/tutorials/general/extensions.html" + } +] \ No newline at end of file diff --git a/src/renderer/src/stories/CodeBlock.js b/src/renderer/src/stories/CodeBlock.js index 6c1f8c73d5..27ad568cd9 100644 --- a/src/renderer/src/stories/CodeBlock.js +++ b/src/renderer/src/stories/CodeBlock.js @@ -1,12 +1,15 @@ import { LitElement, css, html } from "lit"; +import { Button } from "./Button"; export class CodeBlock extends LitElement { static get styles() { return css` :host { display: block; + position: relative; font-size: 85%; - background: #f2f1f1; + background: #111; + color: whitesmoke; border-radius: 10px; border: 1px solid gray; overflow: hidden; @@ -14,7 +17,7 @@ export class CodeBlock extends LitElement { pre { overflow: auto; - padding: 5px 10px; + padding: 15px; box-sizing: border-box; user-select: text; margin: 0; @@ -28,7 +31,37 @@ export class CodeBlock extends LitElement { } render() { - return html`
${this.text}
`; + const controls = document.createElement("div"); + + setTimeout(() => { + console.log(controls) + }, 1000) + + const copyButton = new Button({ + label: "Copy", + onClick: () => navigator.clipboard.writeText(this.text), + primary: true, + color: "rgba(0, 0, 0, 0.3)", + buttonStyles: { + color: "white", + fontSize: "85%", + borderRadius: "5px", + border: "1px solid rgba(255, 255, 255, 0.5)", + } + }) + + Object.assign(controls.style, { + position: "absolute", + bottom: "10px", + right: "10px", + }) + + controls.append(copyButton); + + return html` + ${controls} +
${this.text}
+ `; } } 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 0d09797f96..7b7d088d4c 100644 --- a/src/renderer/src/stories/pages/guided-mode/results/GuidedResults.js +++ b/src/renderer/src/stories/pages/guided-mode/results/GuidedResults.js @@ -7,6 +7,11 @@ import { getStubArray } from "../options/GuidedStubPreview.js"; import { getSharedPath } from "../../../preview/NWBFilePreview.js"; import { electron, path } from "../../../../electron/index.js"; + +import manualActionsJSON from '../../../../../../../manualActions.json'; + +import { CodeBlock } from "../../../CodeBlock.js"; + const { ipcRenderer } = electron; export class GuidedResultsPage extends Page { @@ -43,6 +48,8 @@ export class GuidedResultsPage extends Page { if (!conversion) return html`

Your conversion failed. Please try again.

`; + + // Show a snippet for how to open the NWB file return html`

Your data was successfully converted to NWB!

    @@ -51,6 +58,38 @@ export class GuidedResultsPage extends Page { .sort() .map((id) => html`
  1. ${id}
  2. `)}
+

But what about my other data?

+

The GUIDE still can't do everything. You may need to manually adjust the NWB file to ensure it contains all the necessary data.

+ ${new CodeBlock({ + text: `from pynwb import NWBHDF5IO, NWBFile, TimeSeries + +filename = "${this.#sharedPath()}" + +# Open the file +with NWBHDF5IO(filename, "r+") as io: + nwbfile = io.read() + + # Adjust the file as needed + # ... + + # Write the modified file + io.write(nwbfile) +`, + + })} +
Related Documentation
+
+ ${ + manualActionsJSON.map(({ name, description, url }) => html` +
+

${name}

+ ${description} +
+ `) + } +
+

For more information, please refer to the PyNWB and MatNWB documentation.

+ `; } } From c58ab28ee8cf7162ef2cd797f41c784e54d2f298 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 22:46:57 +0000 Subject: [PATCH 02/16] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- manualActions.json | 2 +- src/renderer/src/stories/CodeBlock.js | 18 ++++----- .../guided-mode/results/GuidedResults.js | 38 +++++++++++-------- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/manualActions.json b/manualActions.json index e7e5e417d0..6298bffa9f 100644 --- a/manualActions.json +++ b/manualActions.json @@ -9,4 +9,4 @@ "description": "The NWB format was designed to be easily extendable, allowing users to add new data types and attributes to the format.", "url": "https://pynwb.readthedocs.io/en/stable/tutorials/general/extensions.html" } -] \ No newline at end of file +] diff --git a/src/renderer/src/stories/CodeBlock.js b/src/renderer/src/stories/CodeBlock.js index 27ad568cd9..2d99fc0cbb 100644 --- a/src/renderer/src/stories/CodeBlock.js +++ b/src/renderer/src/stories/CodeBlock.js @@ -32,13 +32,13 @@ export class CodeBlock extends LitElement { render() { const controls = document.createElement("div"); - + setTimeout(() => { - console.log(controls) - }, 1000) + console.log(controls); + }, 1000); - const copyButton = new Button({ - label: "Copy", + const copyButton = new Button({ + label: "Copy", onClick: () => navigator.clipboard.writeText(this.text), primary: true, color: "rgba(0, 0, 0, 0.3)", @@ -47,14 +47,14 @@ export class CodeBlock extends LitElement { fontSize: "85%", borderRadius: "5px", border: "1px solid rgba(255, 255, 255, 0.5)", - } - }) - + }, + }); + Object.assign(controls.style, { position: "absolute", bottom: "10px", right: "10px", - }) + }); controls.append(copyButton); 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 7b7d088d4c..504428d92e 100644 --- a/src/renderer/src/stories/pages/guided-mode/results/GuidedResults.js +++ b/src/renderer/src/stories/pages/guided-mode/results/GuidedResults.js @@ -8,7 +8,7 @@ import { getSharedPath } from "../../../preview/NWBFilePreview.js"; import { electron, path } from "../../../../electron/index.js"; -import manualActionsJSON from '../../../../../../../manualActions.json'; +import manualActionsJSON from "../../../../../../../manualActions.json"; import { CodeBlock } from "../../../CodeBlock.js"; @@ -48,7 +48,6 @@ export class GuidedResultsPage extends Page { if (!conversion) return html`

Your conversion failed. Please try again.

`; - // Show a snippet for how to open the NWB file return html`

Your data was successfully converted to NWB!

@@ -59,7 +58,10 @@ export class GuidedResultsPage extends Page { .map((id) => html`
  • ${id}
  • `)}

    But what about my other data?

    -

    The GUIDE still can't do everything. You may need to manually adjust the NWB file to ensure it contains all the necessary data.

    +

    + The GUIDE still can't do everything. You may need to manually adjust the NWB file to ensure it contains + all the necessary data. +

    ${new CodeBlock({ text: `from pynwb import NWBHDF5IO, NWBFile, TimeSeries @@ -75,21 +77,27 @@ with NWBHDF5IO(filename, "r+") as io: # Write the modified file io.write(nwbfile) `, - })}
    Related Documentation
    -
    - ${ - manualActionsJSON.map(({ name, description, url }) => html` -
    -

    ${name}

    - ${description} -
    - `) - } +
    + ${manualActionsJSON.map( + ({ name, description, url }) => html` +
    +

    + ${name} +

    + ${description} +
    + ` + )}
    -

    For more information, please refer to the PyNWB and MatNWB documentation.

    - +

    + For more information, please refer to the + PyNWB and + MatNWB documentation. +

    `; } } From 50bd35ee891eccf454c6ba9e7d22bfff8b05ef4e Mon Sep 17 00:00:00 2001 From: Garrett Michael Flynn Date: Wed, 29 May 2024 12:31:32 -0700 Subject: [PATCH 03/16] Update Dashboard.js --- src/electron/frontend/core/components/Dashboard.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/electron/frontend/core/components/Dashboard.js b/src/electron/frontend/core/components/Dashboard.js index 0b3b96ca57..2d6ad5e33f 100644 --- a/src/electron/frontend/core/components/Dashboard.js +++ b/src/electron/frontend/core/components/Dashboard.js @@ -268,7 +268,15 @@ export class Dashboard extends LitElement { if (previous && previous.info.previous === this.page) await this.page.onTransition(-1); else await this.page.onTransition(1); } - }); + }).catch((e) => { + const previousId = previous?.info?.id + if (previousId) { + page.onTransition(previousId); // Revert back to previous page + page.notify(`

    Previous page loaded after error occured

    ${e}`, "error"); + } + + else reloadPageToHome(); + }) } // Populate the sections tracked for this page by using the global state as a model From 17a1400cd0ba039687710d68583383c57b16e1e4 Mon Sep 17 00:00:00 2001 From: Garrett Michael Flynn Date: Wed, 29 May 2024 12:33:14 -0700 Subject: [PATCH 04/16] Update Dashboard.js --- src/electron/frontend/core/components/Dashboard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/electron/frontend/core/components/Dashboard.js b/src/electron/frontend/core/components/Dashboard.js index 2d6ad5e33f..032caca9c1 100644 --- a/src/electron/frontend/core/components/Dashboard.js +++ b/src/electron/frontend/core/components/Dashboard.js @@ -272,7 +272,7 @@ export class Dashboard extends LitElement { const previousId = previous?.info?.id if (previousId) { page.onTransition(previousId); // Revert back to previous page - page.notify(`

    Previous page loaded after error occured

    ${e}`, "error"); + page.notify(`

    Fallback to previous page after error occured

    ${e}`, "error"); } else reloadPageToHome(); From 5059fcf2ec00ffb5401025c4f87e158fee63c1ee Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Wed, 29 May 2024 15:33:58 -0400 Subject: [PATCH 05/16] Update src/electron/frontend/core/components/Dashboard.js --- src/electron/frontend/core/components/Dashboard.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/electron/frontend/core/components/Dashboard.js b/src/electron/frontend/core/components/Dashboard.js index 032caca9c1..90e15eaefd 100644 --- a/src/electron/frontend/core/components/Dashboard.js +++ b/src/electron/frontend/core/components/Dashboard.js @@ -272,7 +272,8 @@ export class Dashboard extends LitElement { const previousId = previous?.info?.id if (previousId) { page.onTransition(previousId); // Revert back to previous page - page.notify(`

    Fallback to previous page after error occured

    ${e}`, "error"); + page.notify(`

    Fallback to previous page after error occurred

    ${e}`, "error"); + } else reloadPageToHome(); From 35f1f4ce137d372cc9fad711f3b31c31e5c976ce Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 19:35:50 +0000 Subject: [PATCH 06/16] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../frontend/core/components/Dashboard.js | 73 ++++++++++--------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/src/electron/frontend/core/components/Dashboard.js b/src/electron/frontend/core/components/Dashboard.js index 90e15eaefd..6ed8f3d7b9 100644 --- a/src/electron/frontend/core/components/Dashboard.js +++ b/src/electron/frontend/core/components/Dashboard.js @@ -243,41 +243,44 @@ export class Dashboard extends LitElement { this.page.set(toPass, false); - this.page.checkSyncState().then(async () => { - const projectName = info.globalState?.project?.name; - - this.subSidebar.header = projectName - ? `

    ${projectName}

    Conversion Pipeline` - : projectName; - - this.updateSections({ sidebar: false, main: true }); - - if (this.#transitionPromise.value) this.#transitionPromise.trigger(page); // This ensures calls to page.to() can be properly awaited until the next page is ready - - const { skipped } = this.subSidebar.sections[info.section]?.pages?.[info.id] ?? {}; - - if (skipped) { - if (isStorybook) return; // Do not skip on storybook - - // Run skip functions - Object.entries(page.workflow).forEach(([key, state]) => { - if (typeof state.skip === "function") state.skip(); - }); - - // Skip right over the page if configured as such - if (previous && previous.info.previous === this.page) await this.page.onTransition(-1); - else await this.page.onTransition(1); - } - }).catch((e) => { - const previousId = previous?.info?.id - if (previousId) { - page.onTransition(previousId); // Revert back to previous page - page.notify(`

    Fallback to previous page after error occurred

    ${e}`, "error"); - - } - - else reloadPageToHome(); - }) + this.page + .checkSyncState() + .then(async () => { + const projectName = info.globalState?.project?.name; + + this.subSidebar.header = projectName + ? `

    ${projectName}

    Conversion Pipeline` + : projectName; + + this.updateSections({ sidebar: false, main: true }); + + if (this.#transitionPromise.value) this.#transitionPromise.trigger(page); // This ensures calls to page.to() can be properly awaited until the next page is ready + + const { skipped } = this.subSidebar.sections[info.section]?.pages?.[info.id] ?? {}; + + if (skipped) { + if (isStorybook) return; // Do not skip on storybook + + // Run skip functions + Object.entries(page.workflow).forEach(([key, state]) => { + if (typeof state.skip === "function") state.skip(); + }); + + // Skip right over the page if configured as such + if (previous && previous.info.previous === this.page) await this.page.onTransition(-1); + else await this.page.onTransition(1); + } + }) + .catch((e) => { + const previousId = previous?.info?.id; + if (previousId) { + page.onTransition(previousId); // Revert back to previous page + page.notify( + `

    Fallback to previous page after error occurred

    ${e}`, + "error" + ); + } else reloadPageToHome(); + }); } // Populate the sections tracked for this page by using the global state as a model From 07bcb3bc420adedf0ce9b2f42f8ad1949c5b555f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 19:52:03 +0000 Subject: [PATCH 07/16] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../frontend/core/components/CodeBlock.js | 136 +++++------ .../guided-mode/results/GuidedResults.js | 212 +++++++++--------- 2 files changed, 174 insertions(+), 174 deletions(-) diff --git a/src/electron/frontend/core/components/CodeBlock.js b/src/electron/frontend/core/components/CodeBlock.js index 2d99fc0cbb..2858360232 100644 --- a/src/electron/frontend/core/components/CodeBlock.js +++ b/src/electron/frontend/core/components/CodeBlock.js @@ -1,68 +1,68 @@ -import { LitElement, css, html } from "lit"; -import { Button } from "./Button"; - -export class CodeBlock extends LitElement { - static get styles() { - return css` - :host { - display: block; - position: relative; - font-size: 85%; - background: #111; - color: whitesmoke; - border-radius: 10px; - border: 1px solid gray; - overflow: hidden; - } - - pre { - overflow: auto; - padding: 15px; - box-sizing: border-box; - user-select: text; - margin: 0; - } - `; - } - - constructor({ text = "" }) { - super(); - this.text = text; - } - - render() { - const controls = document.createElement("div"); - - setTimeout(() => { - console.log(controls); - }, 1000); - - const copyButton = new Button({ - label: "Copy", - onClick: () => navigator.clipboard.writeText(this.text), - primary: true, - color: "rgba(0, 0, 0, 0.3)", - buttonStyles: { - color: "white", - fontSize: "85%", - borderRadius: "5px", - border: "1px solid rgba(255, 255, 255, 0.5)", - }, - }); - - Object.assign(controls.style, { - position: "absolute", - bottom: "10px", - right: "10px", - }); - - controls.append(copyButton); - - return html` - ${controls} -
    ${this.text}
    - `; - } -} - -customElements.get("code-block") || customElements.define("code-block", CodeBlock); +import { LitElement, css, html } from "lit"; +import { Button } from "./Button"; + +export class CodeBlock extends LitElement { + static get styles() { + return css` + :host { + display: block; + position: relative; + font-size: 85%; + background: #111; + color: whitesmoke; + border-radius: 10px; + border: 1px solid gray; + overflow: hidden; + } + + pre { + overflow: auto; + padding: 15px; + box-sizing: border-box; + user-select: text; + margin: 0; + } + `; + } + + constructor({ text = "" }) { + super(); + this.text = text; + } + + render() { + const controls = document.createElement("div"); + + setTimeout(() => { + console.log(controls); + }, 1000); + + const copyButton = new Button({ + label: "Copy", + onClick: () => navigator.clipboard.writeText(this.text), + primary: true, + color: "rgba(0, 0, 0, 0.3)", + buttonStyles: { + color: "white", + fontSize: "85%", + borderRadius: "5px", + border: "1px solid rgba(255, 255, 255, 0.5)", + }, + }); + + Object.assign(controls.style, { + position: "absolute", + bottom: "10px", + right: "10px", + }); + + controls.append(copyButton); + + return html` + ${controls} +
    ${this.text}
    + `; + } +} + +customElements.get("code-block") || customElements.define("code-block", CodeBlock); diff --git a/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js b/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js index abb4bbd5e5..b7f479a698 100644 --- a/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js +++ b/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js @@ -1,106 +1,106 @@ -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 "../../../../../utils/electron.js"; - -import manualActionsJSON from "../../../../../../../schemas/json/manual_actions.json"; - -import { CodeBlock } from "../../../CodeBlock.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 - } - - render() { - const { conversion } = this.info.globalState; - - if (!conversion) - return html`

    Your conversion failed. Please try again.

    `; - - // Show a snippet for how to open the NWB file - 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. `)} -
    -

    But what about my other data?

    -

    - The GUIDE still can't do everything. You may need to manually adjust the NWB file to ensure it contains - all the necessary data. -

    - ${new CodeBlock({ - text: `from pynwb import NWBHDF5IO, NWBFile, TimeSeries - -filename = "${this.#sharedPath()}" - -# Open the file -with NWBHDF5IO(filename, "r+") as io: - nwbfile = io.read() - - # Adjust the file as needed - # ... - - # Write the modified file - io.write(nwbfile) -`, - })} -
    Related Documentation
    -
    - ${manualActionsJSON.map( - ({ name, description, url }) => html` -
    -

    - ${name} -

    - ${description} -
    - ` - )} -
    -

    - For more information, please refer to the - PyNWB and - MatNWB documentation. -

    - `; - } -} - -customElements.get("nwbguide-guided-results-page") || - customElements.define("nwbguide-guided-results-page", GuidedResultsPage); +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 "../../../../../utils/electron.js"; + +import manualActionsJSON from "../../../../../../../schemas/json/manual_actions.json"; + +import { CodeBlock } from "../../../CodeBlock.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 + } + + render() { + const { conversion } = this.info.globalState; + + if (!conversion) + return html`

    Your conversion failed. Please try again.

    `; + + // Show a snippet for how to open the NWB file + 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. `)} +
    +

    But what about my other data?

    +

    + The GUIDE still can't do everything. You may need to manually adjust the NWB file to ensure it contains + all the necessary data. +

    + ${new CodeBlock({ + text: `from pynwb import NWBHDF5IO, NWBFile, TimeSeries + +filename = "${this.#sharedPath()}" + +# Open the file +with NWBHDF5IO(filename, "r+") as io: + nwbfile = io.read() + + # Adjust the file as needed + # ... + + # Write the modified file + io.write(nwbfile) +`, + })} +
    Related Documentation
    +
    + ${manualActionsJSON.map( + ({ name, description, url }) => html` +
    +

    + ${name} +

    + ${description} +
    + ` + )} +
    +

    + For more information, please refer to the + PyNWB and + MatNWB documentation. +

    + `; + } +} + +customElements.get("nwbguide-guided-results-page") || + customElements.define("nwbguide-guided-results-page", GuidedResultsPage); From 823db03fe872b6ff46686e051c9069aab9e98199 Mon Sep 17 00:00:00 2001 From: Cody Baker Date: Wed, 29 May 2024 15:53:35 -0400 Subject: [PATCH 08/16] fix one relative import --- .../core/components/pages/guided-mode/results/GuidedResults.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js b/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js index abb4bbd5e5..1768a7fc6c 100644 --- a/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js +++ b/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js @@ -1,6 +1,6 @@ import { html } from "lit"; import { unsafeSVG } from "lit/directives/unsafe-svg.js"; -import folderOpenSVG from "../../../assets/folder_open.svg?raw"; +import folderOpenSVG from "../../../../../assets/icons/folder_open.svg?raw"; import { Page } from "../../Page.js"; import { getStubArray } from "../options/GuidedStubPreview.js"; From dad8a59e47971050ca3af6945d3e44b5bef467c6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 19:57:34 +0000 Subject: [PATCH 09/16] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../guided-mode/results/GuidedResults.js | 212 +++++++++--------- 1 file changed, 106 insertions(+), 106 deletions(-) diff --git a/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js b/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js index 1768a7fc6c..ff3ab9668e 100644 --- a/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js +++ b/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js @@ -1,106 +1,106 @@ -import { html } from "lit"; -import { unsafeSVG } from "lit/directives/unsafe-svg.js"; -import folderOpenSVG from "../../../../../assets/icons/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 "../../../../../utils/electron.js"; - -import manualActionsJSON from "../../../../../../../schemas/json/manual_actions.json"; - -import { CodeBlock } from "../../../CodeBlock.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 - } - - render() { - const { conversion } = this.info.globalState; - - if (!conversion) - return html`

    Your conversion failed. Please try again.

    `; - - // Show a snippet for how to open the NWB file - 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. `)} -
    -

    But what about my other data?

    -

    - The GUIDE still can't do everything. You may need to manually adjust the NWB file to ensure it contains - all the necessary data. -

    - ${new CodeBlock({ - text: `from pynwb import NWBHDF5IO, NWBFile, TimeSeries - -filename = "${this.#sharedPath()}" - -# Open the file -with NWBHDF5IO(filename, "r+") as io: - nwbfile = io.read() - - # Adjust the file as needed - # ... - - # Write the modified file - io.write(nwbfile) -`, - })} -
    Related Documentation
    -
    - ${manualActionsJSON.map( - ({ name, description, url }) => html` -
    -

    - ${name} -

    - ${description} -
    - ` - )} -
    -

    - For more information, please refer to the - PyNWB and - MatNWB documentation. -

    - `; - } -} - -customElements.get("nwbguide-guided-results-page") || - customElements.define("nwbguide-guided-results-page", GuidedResultsPage); +import { html } from "lit"; +import { unsafeSVG } from "lit/directives/unsafe-svg.js"; +import folderOpenSVG from "../../../../../assets/icons/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 "../../../../../utils/electron.js"; + +import manualActionsJSON from "../../../../../../../schemas/json/manual_actions.json"; + +import { CodeBlock } from "../../../CodeBlock.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 + } + + render() { + const { conversion } = this.info.globalState; + + if (!conversion) + return html`

    Your conversion failed. Please try again.

    `; + + // Show a snippet for how to open the NWB file + 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. `)} +
    +

    But what about my other data?

    +

    + The GUIDE still can't do everything. You may need to manually adjust the NWB file to ensure it contains + all the necessary data. +

    + ${new CodeBlock({ + text: `from pynwb import NWBHDF5IO, NWBFile, TimeSeries + +filename = "${this.#sharedPath()}" + +# Open the file +with NWBHDF5IO(filename, "r+") as io: + nwbfile = io.read() + + # Adjust the file as needed + # ... + + # Write the modified file + io.write(nwbfile) +`, + })} +
    Related Documentation
    +
    + ${manualActionsJSON.map( + ({ name, description, url }) => html` +
    +

    + ${name} +

    + ${description} +
    + ` + )} +
    +

    + For more information, please refer to the + PyNWB and + MatNWB documentation. +

    + `; + } +} + +customElements.get("nwbguide-guided-results-page") || + customElements.define("nwbguide-guided-results-page", GuidedResultsPage); From 7769de9afe84ae1445747f5a8126113b73281ddb Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Wed, 29 May 2024 16:18:14 -0400 Subject: [PATCH 10/16] Update src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js --- .../core/components/pages/guided-mode/results/GuidedResults.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js b/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js index ff3ab9668e..61f2a57de7 100644 --- a/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js +++ b/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js @@ -74,8 +74,6 @@ with NWBHDF5IO(filename, "r+") as io: # Adjust the file as needed # ... - # Write the modified file - io.write(nwbfile) `, })}
    Related Documentation
    From 0f85e0a82467a774b3efa5b565ef2bd528813e9a Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Wed, 29 May 2024 16:19:19 -0400 Subject: [PATCH 11/16] Update src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js --- .../components/pages/guided-mode/results/GuidedResults.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js b/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js index 61f2a57de7..88d8b86ad9 100644 --- a/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js +++ b/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js @@ -63,17 +63,16 @@ export class GuidedResultsPage extends Page { all the necessary data.

    ${new CodeBlock({ - text: `from pynwb import NWBHDF5IO, NWBFile, TimeSeries + text: `from pynwb import NWBHDF5IO, NWBFile -filename = "${this.#sharedPath()}" +nwbfile_path= "${this.#sharedPath()}" # Open the file -with NWBHDF5IO(filename, "r+") as io: +with NWBHDF5IO(path=nwbfile_path, mode="r+") as io: nwbfile = io.read() # Adjust the file as needed # ... - `, })}
    Related Documentation
    From 39c110d7ac35de5d672b427aaf1495762657483e Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Wed, 29 May 2024 16:21:06 -0400 Subject: [PATCH 12/16] Apply suggestions from code review --- .../components/pages/guided-mode/results/GuidedResults.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js b/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js index 88d8b86ad9..34874bdcfd 100644 --- a/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js +++ b/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js @@ -61,6 +61,9 @@ export class GuidedResultsPage extends Page {

    The GUIDE still can't do everything. You may need to manually adjust the NWB file to ensure it contains all the necessary data. + + For example, to append to the file using PyNWB you would start with: +

    ${new CodeBlock({ text: `from pynwb import NWBHDF5IO, NWBFile @@ -71,7 +74,8 @@ nwbfile_path= "${this.#sharedPath()}" with NWBHDF5IO(path=nwbfile_path, mode="r+") as io: nwbfile = io.read() - # Adjust the file as needed + # Then adjust the file as needed + # ... `, })} From d83c9a4ef710eae3683c78260154a156ad42d49d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 20:21:21 +0000 Subject: [PATCH 13/16] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../components/pages/guided-mode/results/GuidedResults.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js b/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js index 34874bdcfd..d01709cba7 100644 --- a/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js +++ b/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js @@ -60,10 +60,7 @@ export class GuidedResultsPage extends Page {

    But what about my other data?

    The GUIDE still can't do everything. You may need to manually adjust the NWB file to ensure it contains - all the necessary data. - - For example, to append to the file using PyNWB you would start with: - + all the necessary data. For example, to append to the file using PyNWB you would start with:

    ${new CodeBlock({ text: `from pynwb import NWBHDF5IO, NWBFile From cbf774808f1252a0c1fad1bf3276cac96f6cae3b Mon Sep 17 00:00:00 2001 From: Cody Baker Date: Wed, 29 May 2024 16:22:45 -0400 Subject: [PATCH 14/16] add newlines to breakup page text --- .../core/components/pages/guided-mode/results/GuidedResults.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js b/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js index 34874bdcfd..2f8bd22756 100644 --- a/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js +++ b/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js @@ -60,7 +60,7 @@ export class GuidedResultsPage extends Page {

    But what about my other data?

    The GUIDE still can't do everything. You may need to manually adjust the NWB file to ensure it contains - all the necessary data. + all the necessary data.

    For example, to append to the file using PyNWB you would start with: From d1d1d5eb7316ab5b37e0c38bfc3329bb7a71c592 Mon Sep 17 00:00:00 2001 From: Cody Baker Date: Wed, 29 May 2024 16:24:23 -0400 Subject: [PATCH 15/16] fix conflict --- .../components/pages/guided-mode/results/GuidedResults.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js b/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js index 19812ea95d..13c9084ec3 100644 --- a/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js +++ b/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js @@ -60,14 +60,9 @@ export class GuidedResultsPage extends Page {

    But what about my other data?

    The GUIDE still can't do everything. You may need to manually adjust the NWB file to ensure it contains -<<<<<<< HEAD all the necessary data.

    For example, to append to the file using PyNWB you would start with: - -======= - all the necessary data. For example, to append to the file using PyNWB you would start with: ->>>>>>> origin/flag-manual-interactions

    ${new CodeBlock({ text: `from pynwb import NWBHDF5IO, NWBFile From 35748888cfe0a414ad716e0c9dc27f15023d3d9b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 29 May 2024 20:25:27 +0000 Subject: [PATCH 16/16] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../components/pages/guided-mode/results/GuidedResults.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js b/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js index 13c9084ec3..af1be09d66 100644 --- a/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js +++ b/src/electron/frontend/core/components/pages/guided-mode/results/GuidedResults.js @@ -60,8 +60,8 @@ export class GuidedResultsPage extends Page {

    But what about my other data?

    The GUIDE still can't do everything. You may need to manually adjust the NWB file to ensure it contains - all the necessary data.

    - + all the necessary data.

    + For example, to append to the file using PyNWB you would start with:

    ${new CodeBlock({