diff --git a/.storybook/main.ts b/.storybook/main.ts index 80af1da82..4325b84cf 100644 --- a/.storybook/main.ts +++ b/.storybook/main.ts @@ -3,7 +3,7 @@ import type { StorybookConfig } from '@storybook/web-components-vite'; import ViteYaml from "@modyfi/vite-plugin-yaml"; const config: StorybookConfig = { - stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"], + stories: ["../stories/**/*.mdx", "../stories/**/*.stories.@(js|jsx|ts|tsx)"], addons: ["@storybook/addon-links", "@storybook/addon-essentials"], framework: { name: "@storybook/web-components-vite", diff --git a/generateInterfaceSchema.py b/generateInterfaceSchema.py index 279c450b7..b3e712f8a 100644 --- a/generateInterfaceSchema.py +++ b/generateInterfaceSchema.py @@ -4,7 +4,7 @@ from neuroconv import NWBConverter, converters, datainterfaces filepath = Path("src") / "supported_interfaces.json" -generatedJSONSchemaPath = Path("schemas", "json", "generated") +generatedJSONSchemaPath = Path("stories") / "inputs" / "interface_schemas" generatedJSONSchemaPath.mkdir(exist_ok=True, parents=True) f = filepath.open() @@ -29,9 +29,11 @@ class CustomNWBConverter(NWBConverter): outfile.write(json.dumps(schema, indent=4)) -sourceDataStoryPath = Path("src/electron/renderer/src/stories/pages/guided-mode/SourceData.stories.js") +sourceDataStoryPath = Path("stories/pages/SourceData.stories.js") -importCode = "\n".join(map(lambda arr: f"import {arr[0]}Schema from '../../../../../../{arr[1]}'", paths.items())) +importCode = "\n".join( + map(lambda arr: f"import {arr[0]}Schema from '../inputs/interface_schemas/{arr[1]}'", paths.items()) +) storyCode = "\n".join( map( lambda arr: f"""export const {arr[0]} = PageTemplate.bind({{}}); diff --git a/src/electron/renderer/src/stories/assets/dandi.svg b/src/electron/renderer/assets/icons/dandi.svg similarity index 100% rename from src/electron/renderer/src/stories/assets/dandi.svg rename to src/electron/renderer/assets/icons/dandi.svg diff --git a/src/electron/renderer/src/stories/assets/delete.svg b/src/electron/renderer/assets/icons/delete.svg similarity index 100% rename from src/electron/renderer/src/stories/assets/delete.svg rename to src/electron/renderer/assets/icons/delete.svg diff --git a/src/electron/renderer/src/stories/assets/exploration.svg b/src/electron/renderer/assets/icons/exploration.svg similarity index 100% rename from src/electron/renderer/src/stories/assets/exploration.svg rename to src/electron/renderer/assets/icons/exploration.svg diff --git a/src/electron/renderer/src/stories/assets/folder_open.svg b/src/electron/renderer/assets/icons/folder_open.svg similarity index 100% rename from src/electron/renderer/src/stories/assets/folder_open.svg rename to src/electron/renderer/assets/icons/folder_open.svg diff --git a/src/electron/renderer/src/stories/assets/fullscreen.svg b/src/electron/renderer/assets/icons/fullscreen.svg similarity index 100% rename from src/electron/renderer/src/stories/assets/fullscreen.svg rename to src/electron/renderer/assets/icons/fullscreen.svg diff --git a/src/electron/renderer/src/stories/assets/fullscreen_exit.svg b/src/electron/renderer/assets/icons/fullscreen_exit.svg similarity index 100% rename from src/electron/renderer/src/stories/assets/fullscreen_exit.svg rename to src/electron/renderer/assets/icons/fullscreen_exit.svg diff --git a/src/electron/renderer/src/stories/assets/global.svg b/src/electron/renderer/assets/icons/global.svg similarity index 100% rename from src/electron/renderer/src/stories/assets/global.svg rename to src/electron/renderer/assets/icons/global.svg diff --git a/src/electron/renderer/src/stories/assets/inspect.svg b/src/electron/renderer/assets/icons/inspect.svg similarity index 100% rename from src/electron/renderer/src/stories/assets/inspect.svg rename to src/electron/renderer/assets/icons/inspect.svg diff --git a/src/electron/renderer/src/stories/assets/key.svg b/src/electron/renderer/assets/icons/key.svg similarity index 100% rename from src/electron/renderer/src/stories/assets/key.svg rename to src/electron/renderer/assets/icons/key.svg diff --git a/src/electron/renderer/src/stories/assets/neurosift-logo.svg b/src/electron/renderer/assets/icons/neurosift-logo.svg similarity index 100% rename from src/electron/renderer/src/stories/assets/neurosift-logo.svg rename to src/electron/renderer/assets/icons/neurosift-logo.svg diff --git a/src/electron/renderer/src/stories/assets/preview.svg b/src/electron/renderer/assets/icons/preview.svg similarity index 100% rename from src/electron/renderer/src/stories/assets/preview.svg rename to src/electron/renderer/assets/icons/preview.svg diff --git a/src/electron/renderer/src/stories/assets/python.svg b/src/electron/renderer/assets/icons/python.svg similarity index 100% rename from src/electron/renderer/src/stories/assets/python.svg rename to src/electron/renderer/assets/icons/python.svg diff --git a/src/electron/renderer/src/stories/assets/restart.svg b/src/electron/renderer/assets/icons/restart.svg similarity index 100% rename from src/electron/renderer/src/stories/assets/restart.svg rename to src/electron/renderer/assets/icons/restart.svg diff --git a/src/electron/renderer/src/stories/assets/save.svg b/src/electron/renderer/assets/icons/save.svg similarity index 100% rename from src/electron/renderer/src/stories/assets/save.svg rename to src/electron/renderer/assets/icons/save.svg diff --git a/src/electron/renderer/src/stories/assets/search.svg b/src/electron/renderer/assets/icons/search.svg similarity index 100% rename from src/electron/renderer/src/stories/assets/search.svg rename to src/electron/renderer/assets/icons/search.svg diff --git a/src/electron/renderer/src/stories/assets/server.svg b/src/electron/renderer/assets/icons/server.svg similarity index 100% rename from src/electron/renderer/src/stories/assets/server.svg rename to src/electron/renderer/assets/icons/server.svg diff --git a/src/electron/renderer/src/stories/assets/settings.svg b/src/electron/renderer/assets/icons/settings.svg similarity index 100% rename from src/electron/renderer/src/stories/assets/settings.svg rename to src/electron/renderer/assets/icons/settings.svg diff --git a/src/electron/renderer/src/stories/assets/web_asset.svg b/src/electron/renderer/assets/icons/web_asset.svg similarity index 100% rename from src/electron/renderer/src/stories/assets/web_asset.svg rename to src/electron/renderer/assets/icons/web_asset.svg diff --git a/src/electron/renderer/src/stories/assets/wifi.svg b/src/electron/renderer/assets/icons/wifi.svg similarity index 100% rename from src/electron/renderer/src/stories/assets/wifi.svg rename to src/electron/renderer/assets/icons/wifi.svg diff --git a/src/electron/renderer/src/pages.js b/src/electron/renderer/src/pages.js index 12c34f0ef..7dbd400e7 100644 --- a/src/electron/renderer/src/pages.js +++ b/src/electron/renderer/src/pages.js @@ -16,11 +16,11 @@ import { GuidedInspectorPage } from "./stories/pages/guided-mode/options/GuidedI import logo from "../assets/img/logo-guide-draft-transparent-tight.png"; import { GuidedPathExpansionPage } from "./stories/pages/guided-mode/data/GuidedPathExpansion"; -import uploadIcon from "./stories/assets/dandi.svg?raw"; -import inspectIcon from "./stories/assets/inspect.svg?raw"; -import neurosiftIcon from "./stories/assets/neurosift-logo.svg?raw"; +import uploadIcon from "../assets/icons/dandi.svg?raw"; +import inspectIcon from "../assets/icons/inspect.svg?raw"; +import neurosiftIcon from "../assets/icons/neurosift-logo.svg?raw"; -import settingsIcon from "./stories/assets/settings.svg?raw"; +import settingsIcon from "../assets/icons/settings.svg?raw"; import { UploadsPage } from "./stories/pages/uploads/UploadsPage"; import { SettingsPage } from "./stories/pages/settings/SettingsPage"; diff --git a/src/electron/renderer/src/server/globals.ts b/src/electron/renderer/src/server/globals.ts index 698243dc9..5ad456472 100644 --- a/src/electron/renderer/src/server/globals.ts +++ b/src/electron/renderer/src/server/globals.ts @@ -1,8 +1,8 @@ import { isElectron, app, port } from '../electron/index.js' -import serverSVG from "../stories/assets/server.svg?raw"; -import webAssetSVG from "../stories/assets/web_asset.svg?raw"; -import wifiSVG from "../stories/assets/wifi.svg?raw"; +import serverSVG from "../../assets/icons/server.svg?raw"; +import webAssetSVG from "../../assets/icons/web_asset.svg?raw"; +import wifiSVG from "../../assets/icons/wifi.svg?raw"; // Base Request URL for Python Server export const baseUrl = `http://127.0.0.1:${port}`; @@ -56,7 +56,7 @@ export const activateServer = () => { export const serverGlobals = { species: new Promise((res, rej) => { onServerOpen(() => { - fetch(new URL("get-recommended-species", baseUrl)) + fetch(new URL("/dandi/get-recommended-species", baseUrl)) .then((res) => res.json()) .then((species) => { res(species) @@ -67,7 +67,7 @@ export const serverGlobals = { }), cpus: new Promise((res, rej) => { onServerOpen(() => { - fetch(new URL("cpus", baseUrl)) + fetch(new URL("/system/cpus", baseUrl)) .then((res) => res.json()) .then((cpus) => { res(cpus) diff --git a/src/electron/renderer/src/stories/FileSystemSelector.js b/src/electron/renderer/src/stories/FileSystemSelector.js index 036c70581..3bef33378 100644 --- a/src/electron/renderer/src/stories/FileSystemSelector.js +++ b/src/electron/renderer/src/stories/FileSystemSelector.js @@ -4,7 +4,7 @@ import { fs, remote } from "../electron/index"; import { List } from "./List"; const { dialog } = remote; -import restartSVG from "./assets/restart.svg?raw"; +import restartSVG from "../../assets/icons/restart.svg?raw"; import { unsafeSVG } from "lit/directives/unsafe-svg.js"; function getObjectTypeReferenceString(type, multiple, { nested, native } = {}) { diff --git a/src/electron/renderer/src/stories/FullScreenToggle.ts b/src/electron/renderer/src/stories/FullScreenToggle.ts index ff1e1557f..fb01e32d9 100644 --- a/src/electron/renderer/src/stories/FullScreenToggle.ts +++ b/src/electron/renderer/src/stories/FullScreenToggle.ts @@ -1,7 +1,7 @@ import { LitElement, css, html } from "lit"; -import fullScreenIcon from './assets/fullscreen.svg?raw' -import fullScreenExitIcon from './assets/fullscreen_exit.svg?raw' +import fullScreenIcon from '../../assets/icons/fullscreen.svg?raw' +import fullScreenExitIcon from '../../assets/icons/fullscreen_exit.svg?raw' import { unsafeHTML } from "lit/directives/unsafe-html.js"; diff --git a/src/electron/renderer/src/stories/Search.js b/src/electron/renderer/src/stories/Search.js index 5cefbe4dd..5b133e2f0 100644 --- a/src/electron/renderer/src/stories/Search.js +++ b/src/electron/renderer/src/stories/Search.js @@ -1,7 +1,7 @@ import { LitElement, html, css } from "lit"; import { styleMap } from "lit/directives/style-map.js"; -import searchSVG from "./assets/search.svg?raw"; +import searchSVG from "../../assets/icons/search.svg?raw"; import tippy from "tippy.js"; import { unsafeHTML } from "lit/directives/unsafe-html.js"; diff --git a/src/electron/renderer/src/stories/pages/guided-mode/data/GuidedMetadata.js b/src/electron/renderer/src/stories/pages/guided-mode/data/GuidedMetadata.js index c1b1592dc..0efe5162a 100644 --- a/src/electron/renderer/src/stories/pages/guided-mode/data/GuidedMetadata.js +++ b/src/electron/renderer/src/stories/pages/guided-mode/data/GuidedMetadata.js @@ -23,7 +23,7 @@ import { header, tempPropertyKey } from "../../../forms/utils"; import { createGlobalFormModal } from "../../../forms/GlobalFormModal"; import { Button } from "../../../Button.js"; -import globalIcon from "../../../assets/global.svg?raw"; +import globalIcon from "../../../../../assets/icons/global.svg?raw"; const parentTableRenderConfig = { Electrodes: (metadata) => { diff --git a/src/electron/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js b/src/electron/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js index d3a6946d9..4fa48857a 100644 --- a/src/electron/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js +++ b/src/electron/renderer/src/stories/pages/guided-mode/data/GuidedPathExpansion.js @@ -14,7 +14,7 @@ import { Button } from "../../../Button.js"; import { Modal } from "../../../Modal"; import { header } from "../../../forms/utils"; -import autocompleteIcon from "../../../assets/inspect.svg?raw"; +import autocompleteIcon from "../../../../../assets/icons/inspect.svg?raw"; const propOrder = ["path", "subject_id", "session_id"]; diff --git a/src/electron/renderer/src/stories/pages/guided-mode/data/GuidedSourceData.js b/src/electron/renderer/src/stories/pages/guided-mode/data/GuidedSourceData.js index 2a2f787ae..f3876100a 100644 --- a/src/electron/renderer/src/stories/pages/guided-mode/data/GuidedSourceData.js +++ b/src/electron/renderer/src/stories/pages/guided-mode/data/GuidedSourceData.js @@ -11,7 +11,7 @@ import { createGlobalFormModal } from "../../../forms/GlobalFormModal"; import { header } from "../../../forms/utils"; import { Button } from "../../../Button.js"; -import globalIcon from "../../../assets/global.svg?raw"; +import globalIcon from "../../../../../assets/icons/global.svg?raw"; import { baseUrl } from "../../../../server/globals"; diff --git a/src/electron/renderer/src/stories/pages/guided-mode/options/GuidedInspectorPage.js b/src/electron/renderer/src/stories/pages/guided-mode/options/GuidedInspectorPage.js index 56c73a217..ae262f389 100644 --- a/src/electron/renderer/src/stories/pages/guided-mode/options/GuidedInspectorPage.js +++ b/src/electron/renderer/src/stories/pages/guided-mode/options/GuidedInspectorPage.js @@ -2,7 +2,7 @@ import { html } from "lit"; import { Page } from "../../Page.js"; 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 { electron } from "../../../../electron/index.js"; import { getSharedPath, removeFilePaths, truncateFilePaths } from "../../../preview/NWBFilePreview.js"; diff --git a/src/electron/renderer/src/stories/pages/guided-mode/options/GuidedStubPreview.js b/src/electron/renderer/src/stories/pages/guided-mode/options/GuidedStubPreview.js index 4f3a2b861..d1b022155 100644 --- a/src/electron/renderer/src/stories/pages/guided-mode/options/GuidedStubPreview.js +++ b/src/electron/renderer/src/stories/pages/guided-mode/options/GuidedStubPreview.js @@ -2,7 +2,7 @@ import { html } from "lit"; import { Page } from "../../Page.js"; 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 { electron } from "../../../../electron/index.js"; import { NWBFilePreview, getSharedPath } from "../../../preview/NWBFilePreview.js"; diff --git a/src/electron/renderer/src/stories/pages/guided-mode/options/GuidedUpload.js b/src/electron/renderer/src/stories/pages/guided-mode/options/GuidedUpload.js index 70e35bfc0..075b1be03 100644 --- a/src/electron/renderer/src/stories/pages/guided-mode/options/GuidedUpload.js +++ b/src/electron/renderer/src/stories/pages/guided-mode/options/GuidedUpload.js @@ -10,7 +10,7 @@ import { until } from "lit/directives/until.js"; import { Button } from "../../../Button.js"; -import keyIcon from "../../../assets/key.svg?raw"; +import keyIcon from "../../../../../assets/icons/key.svg?raw"; import { validate } from "../../uploads/utils"; import { global } from "../../../../progress/index.js"; diff --git a/src/electron/renderer/src/stories/pages/guided-mode/results/GuidedResults.js b/src/electron/renderer/src/stories/pages/guided-mode/results/GuidedResults.js index ace243461..1cc68fa86 100644 --- a/src/electron/renderer/src/stories/pages/guided-mode/results/GuidedResults.js +++ b/src/electron/renderer/src/stories/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"; diff --git a/src/electron/renderer/src/stories/pages/guided-mode/setup/GuidedSubjects.js b/src/electron/renderer/src/stories/pages/guided-mode/setup/GuidedSubjects.js index 5c887e246..7d1d51677 100644 --- a/src/electron/renderer/src/stories/pages/guided-mode/setup/GuidedSubjects.js +++ b/src/electron/renderer/src/stories/pages/guided-mode/setup/GuidedSubjects.js @@ -10,7 +10,7 @@ import { Button } from "../../../Button.js"; import { createGlobalFormModal } from "../../../forms/GlobalFormModal"; import { header } from "../../../forms/utils"; -import globalIcon from "../../../assets/global.svg?raw"; +import globalIcon from "../../../../../assets/icons/global.svg?raw"; export class GuidedSubjectsPage extends Page { constructor(...args) { diff --git a/src/electron/renderer/src/stories/pages/preview/PreviewPage.js b/src/electron/renderer/src/stories/pages/preview/PreviewPage.js index 4436038cd..e6de3b95a 100644 --- a/src/electron/renderer/src/stories/pages/preview/PreviewPage.js +++ b/src/electron/renderer/src/stories/pages/preview/PreviewPage.js @@ -18,7 +18,12 @@ export class PreviewPage extends Page { updatePath = async (path) => { if (path) { - const result = await fetch(`${baseUrl}/files/${path}`, { method: "POST" }).then((res) => res.text()); + // Enable access to the explicit file path + const result = await fetch(`${baseUrl}/files/${path}`, { + method: "POST", + }).then((res) => res.text()); + + // Set Neurosift to access the returned URL if (result) this.neurosift.url = result; } else this.neurosift.url = undefined; }; diff --git a/src/electron/renderer/src/stories/pages/settings/SettingsPage.js b/src/electron/renderer/src/stories/pages/settings/SettingsPage.js index 149a182a0..e314a9a41 100644 --- a/src/electron/renderer/src/stories/pages/settings/SettingsPage.js +++ b/src/electron/renderer/src/stories/pages/settings/SettingsPage.js @@ -15,10 +15,10 @@ import { merge, setUndefinedIfNotDeclared } from "../utils"; import { homeDirectory, notyf, testDataFolderPath } from "../../../dependencies/globals"; import { SERVER_FILE_PATH, electron, path, port, fs } from "../../../electron/index.js"; -import saveSVG from "../../assets/save.svg?raw"; -import folderSVG from "../../assets/folder_open.svg?raw"; -import deleteSVG from "../../assets/delete.svg?raw"; -import generateSVG from "../../assets/restart.svg?raw"; +import saveSVG from "../../../../assets/icons/save.svg?raw"; +import folderSVG from "../../../../assets/icons/folder_open.svg?raw"; +import deleteSVG from "../../../../assets/icons/delete.svg?raw"; +import generateSVG from "../../../../assets/icons/restart.svg?raw"; import { header } from "../../forms/utils"; diff --git a/src/electron/renderer/src/stories/pages/uploads/UploadsPage.js b/src/electron/renderer/src/stories/pages/uploads/UploadsPage.js index ff1099e78..434f830c3 100644 --- a/src/electron/renderer/src/stories/pages/uploads/UploadsPage.js +++ b/src/electron/renderer/src/stories/pages/uploads/UploadsPage.js @@ -32,7 +32,7 @@ import { validateDANDIApiKey } from "../../../validation/dandi"; import * as dandi from "dandi"; -import keyIcon from "../../assets/key.svg?raw"; +import keyIcon from "../../../../assets/icons/key.svg?raw"; import { AWARD_VALIDATION_FAIL_MESSAGE, awardNumberValidator, isStaging, validate } from "./utils"; import { createFormModal } from "../../forms/GlobalFormModal"; diff --git a/src/electron/renderer/src/stories/preview/NWBFilePreview.js b/src/electron/renderer/src/stories/preview/NWBFilePreview.js index cb496d591..cd268a90e 100644 --- a/src/electron/renderer/src/stories/preview/NWBFilePreview.js +++ b/src/electron/renderer/src/stories/preview/NWBFilePreview.js @@ -56,7 +56,10 @@ class NWBPreviewInstance extends LitElement { const isOnline = navigator.onLine; return isOnline - ? new Neurosift({ url: getURLFromFilePath(this.file, this.project), fullscreen: false }) + ? new Neurosift({ + url: getURLFromFilePath(this.file, this.project), + fullscreen: false, + }) : until( (async () => { const htmlRep = await run("html", { nwbfile_path: this.file }, { swal: false }); diff --git a/src/electron/renderer/src/stories/preview/Neurosift.js b/src/electron/renderer/src/stories/preview/Neurosift.js index c70c9d5fc..3f85327d8 100644 --- a/src/electron/renderer/src/stories/preview/Neurosift.js +++ b/src/electron/renderer/src/stories/preview/Neurosift.js @@ -80,7 +80,9 @@ export class Neurosift extends LitElement { render() { return this.url ? html`
- ${new Loader({ message: `Loading Neurosift view...
${this.url}` })} + ${new Loader({ + message: `Loading Neurosift view...
${this.url}`, + })}
${this.fullscreen ? new FullScreenToggle({ target: this }) : ""}