-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'break_up_endpoints' of https://github.com/neurodatawith…
…outborders/nwb-guide into break_up_endpoints
- Loading branch information
Showing
3 changed files
with
357 additions
and
382 deletions.
There are no files selected for viewing
125 changes: 61 additions & 64 deletions
125
src/electron/renderer/src/stories/pages/preview/PreviewPage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,61 @@ | ||
import { html } from "lit"; | ||
import { Page } from "../Page.js"; | ||
import { onThrow } from "../../../errors"; | ||
import { JSONSchemaInput } from "../../JSONSchemaInput.js"; | ||
import { Neurosift } from "../../preview/Neurosift.js"; | ||
import { baseUrl } from "../../../server/globals"; | ||
|
||
export class PreviewPage extends Page { | ||
header = { | ||
title: "NWB File Exploration", | ||
subtitle: "Visualize your NWB file using Neurosift.", | ||
}; | ||
|
||
constructor(...args) { | ||
super(...args); | ||
this.style.height = "100%"; // Fix main section | ||
} | ||
|
||
updatePath = async (path) => { | ||
if (path) { | ||
// 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; | ||
}; | ||
|
||
neurosift = new Neurosift(); | ||
|
||
input = new JSONSchemaInput({ | ||
path: ["file_path"], | ||
schema: { | ||
type: "string", | ||
format: "file", | ||
description: | ||
"Please provide a file path that you'd like to visualize using Neurosift. The GUIDE will serve this file and access the appropriate URL automatically.", | ||
}, | ||
onUpdate: this.updatePath, | ||
onThrow, | ||
}); | ||
|
||
render() { | ||
const urlFilePath = new URL(document.location).searchParams.get("file"); | ||
|
||
if (urlFilePath) { | ||
this.updatePath(urlFilePath); | ||
this.input.value = urlFilePath; | ||
} | ||
|
||
return html` | ||
<div | ||
style="display: grid; width: 100%; height: 100%; grid-template-rows: min-content 1fr; gap: 10px;" | ||
> | ||
${this.input} ${this.neurosift} | ||
</div> | ||
`; | ||
} | ||
} | ||
|
||
customElements.get("nwbguide-preview-page") || | ||
customElements.define("nwbguide-preview-page", PreviewPage); | ||
import { html } from "lit"; | ||
import { Page } from "../Page.js"; | ||
import { onThrow } from "../../../errors"; | ||
import { JSONSchemaInput } from "../../JSONSchemaInput.js"; | ||
import { Neurosift } from "../../preview/Neurosift.js"; | ||
import { baseUrl } from "../../../server/globals"; | ||
|
||
export class PreviewPage extends Page { | ||
header = { | ||
title: "NWB File Exploration", | ||
subtitle: "Visualize your NWB file using Neurosift.", | ||
}; | ||
|
||
constructor(...args) { | ||
super(...args); | ||
this.style.height = "100%"; // Fix main section | ||
} | ||
|
||
updatePath = async (path) => { | ||
if (path) { | ||
// 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; | ||
}; | ||
|
||
neurosift = new Neurosift(); | ||
|
||
input = new JSONSchemaInput({ | ||
path: ["file_path"], | ||
schema: { | ||
type: "string", | ||
format: "file", | ||
description: | ||
"Please provide a file path that you'd like to visualize using Neurosift. The GUIDE will serve this file and access the appropriate URL automatically.", | ||
}, | ||
onUpdate: this.updatePath, | ||
onThrow, | ||
}); | ||
|
||
render() { | ||
const urlFilePath = new URL(document.location).searchParams.get("file"); | ||
|
||
if (urlFilePath) { | ||
this.updatePath(urlFilePath); | ||
this.input.value = urlFilePath; | ||
} | ||
|
||
return html` | ||
<div style="display: grid; width: 100%; height: 100%; grid-template-rows: min-content 1fr; gap: 10px;"> | ||
${this.input} ${this.neurosift} | ||
</div> | ||
`; | ||
} | ||
} | ||
|
||
customElements.get("nwbguide-preview-page") || customElements.define("nwbguide-preview-page", PreviewPage); |
Oops, something went wrong.