Skip to content

Commit

Permalink
Fix model switching
Browse files Browse the repository at this point in the history
  • Loading branch information
filippomc committed Nov 14, 2023
1 parent 1018c5c commit a5b69b0
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
sys.argv.append('--NotebookApp.default_url=/geppetto')
sys.argv.append("--NotebookApp.token=''")
sys.argv.append('--library=nwb_explorer')

app = NotebookApp.instance()
app.initialize(sys.argv)
app.file_to_run = ''
Expand Down
11 changes: 7 additions & 4 deletions utilities/embed/embed_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
<title>NWB explorer embedding example</title>
<script>

function updateFile(){
function updateFile(fileName){
console.log("Update called");
let frame = document.getElementById("nwb-explorer");
let fileName = "https://github.com/OpenSourceBrain/NWBShowcase/raw/master/NWB/time_series_data.nwb";
frame.contentWindow.postMessage(fileName, '*');
frame.contentWindow.postMessage({ type: 'LOAD_RESOURCE', payload: fileName }, '*');
}


</script>
</head>

<body>
<iframe id="nwb-explorer" src="http://localhost:8888/geppetto" style="width:100%; min-height: 800px" onLoad="updateFile();"></iframe>
<button onclick="updateFile('https://github.com/OpenSourceBrain/NWBShowcase/raw/master/FergusonEtAl2015/FergusonEtAl2015.nwb');">Load NWB file</button>
<iframe id="nwb-explorer" src="http://localhost:8081/geppetto" style="width:100%; height: 100vh" onLoad="updateFile('https://github.com/OpenSourceBrain/NWBShowcase/raw/master/NWB/time_series_data.nwb');"></iframe>

</body>
</html>
2 changes: 1 addition & 1 deletion webapp/components/Metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export default class Metadata extends React.Component {
return "Loading...";
}
if (!this.props.instancePath) {
return "No instance is selected"
return ""
}
const instance = Instances.getInstance(this.props.instancePath);
const content = this.getContent(instance);
Expand Down
13 changes: 8 additions & 5 deletions webapp/redux/middleware/nwbMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
UNLOAD_NWB_FILE_IN_NOTEBOOK,
loadedNWBFileInNotebook,
loadNWBFileInNotebook,
nwbFileLoaded
nwbFileLoaded,
CLEAR_MODEL
} from "../actions/nwbfile";

import * as GeppettoActions from "@metacell/geppetto-meta-client/common/actions/actions";
Expand All @@ -32,8 +33,7 @@ import { NOTEBOOK_READY, notebookReady } from "../actions/notebook";
import { WidgetStatus } from "@metacell/geppetto-meta-client/common/layout/model";

import { getNotebookPath } from "../../services/NotebookService";
import { Layout } from "@metacell/geppetto-meta-ui/flex-layout/src";
import { call } from "file-loader";


export const DEFAULT_WIDGETS = {
python: {
Expand All @@ -57,7 +57,7 @@ export const DEFAULT_WIDGETS = {
panelName: "leftPanel",
enableClose: false,
pos: 1,
config: { instancePath: "tmp" }
config: { instancePath: "" }
},

details: {
Expand Down Expand Up @@ -214,6 +214,7 @@ const nwbMiddleware = store => next => action => {

switch (action.type) {
case LOAD_NWB_FILE: {
next(LayoutActions.setWidgets([]));
const fileName = action.data.nwbFileUrl.match(/^http|^\//g)
? action.data.nwbFileUrl
: `workspace/${action.data.nwbFileUrl}`;
Expand Down Expand Up @@ -267,8 +268,10 @@ const nwbMiddleware = store => next => action => {
}), () => next(LayoutActions.deleteWidget(action.data.hostId)));
}
case LayoutActions.layoutActions.RESET_LAYOUT:
case CLEAR_MODEL:
next(LayoutActions.setWidgets(DEFAULT_WIDGETS));
next(action);
next(LayoutActions.setWidgets([]));

break;
case GeppettoActions.backendActions.MODEL_LOADED:
next(action);
Expand Down
4 changes: 4 additions & 0 deletions webapp/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ extended.devServer = {
inline: true,
publicPath: '/geppetto/build',

headers: {
// Set Content-Security-Policy header to allow only self as frame ancestor
"Content-Security-Policy": "frame-ancestors '*' 'wsl.localhost' 'localhost'"
},
proxy: [
{
path: '/',
Expand Down

0 comments on commit a5b69b0

Please sign in to comment.