Skip to content

Commit e310b48

Browse files
committed
#142 Layout refactor half working
1 parent 6b5497d commit e310b48

22 files changed

Lines changed: 754 additions & 874 deletions

webapp/components/NetPyNE.js

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from "netpyne/components";
88

99
import { withStyles } from '@material-ui/core/styles'
10-
10+
import Utils from '../Utils';
1111
const styles = ({ zIndex, palette, spacing }) => ({
1212
root: { height: '100%', overflow: 'hidden' },
1313
container: {
@@ -18,7 +18,12 @@ const styles = ({ zIndex, palette, spacing }) => ({
1818
},
1919
topbar: { position: "relative", zIndex: zIndex.drawer + 1 },
2020
content: { flexGrow:1, display: 'flex', flexDirection: 'row', position: 'relative' }
21-
})
21+
});
22+
23+
import {
24+
DEFAULT_HLS_WIDGETS, getPythonDefaultConsoleWidget,
25+
DEFAULT_MORPHOLOGY_WIDGET,DEFAULT_PLOTS_WIDGETS
26+
} from '../constants'
2227

2328

2429
class NetPyNE extends React.Component {
@@ -28,8 +33,32 @@ class NetPyNE extends React.Component {
2833
this.props.pythonCallErrorDialogBox(payload)
2934
}
3035

36+
addMetadataToWindow (data) {
37+
console.log("Initialising NetPyNE Tabs");
38+
window.metadata = data.metadata;
39+
window.currentFolder = data.currentFolder;
40+
window.isDocker = data.isDocker;
41+
window.pythonConsoleLoaded = true
42+
}
43+
3144
componentDidMount () {
32-
GEPPETTO.on(GEPPETTO.Events.Error_while_exec_python_command, this.openPythonCallDialog, this)
45+
GEPPETTO.on(GEPPETTO.Events.Error_while_exec_python_command, this.openPythonCallDialog, this);
46+
this.props.addWidgets([getPythonDefaultConsoleWidget(true) ]);
47+
GEPPETTO.on('jupyter_geppetto_extension_ready', data => {
48+
let project = { id: 1, name: 'Project', experiments: [{ "id": 1, "name": 'Experiment', "status": 'DESIGN' }] }
49+
GEPPETTO.Manager.loadProject(project, false);
50+
GEPPETTO.Manager.loadExperiment(1, [], []);
51+
Utils.execPythonMessage('from netpyne_ui.netpyne_geppetto import netpyne_geppetto');
52+
Utils.evalPythonMessage('netpyne_geppetto.getData',[]).then(response => {
53+
const data = Utils.convertToJSON(response);
54+
this.addMetadataToWindow(data);
55+
this.props.modelLoaded();
56+
this.props.addWidgets(Object.values(DEFAULT_HLS_WIDGETS));
57+
GEPPETTO.trigger("spinner:hide");
58+
})
59+
60+
});
61+
3362
}
3463

3564
componentWillUnmount () {
@@ -38,6 +67,7 @@ class NetPyNE extends React.Component {
3867

3968
render () {
4069
const { classes } = this.props
70+
const Layout = LayoutManager();
4171
return (
4272
<div className={classes.root}>
4373
<div className={classes.container}>
@@ -46,7 +76,7 @@ class NetPyNE extends React.Component {
4676
</div>
4777
<div className={classes.content}>
4878
<Drawer/>
49-
<LayoutManager/>
79+
<Layout />
5080
</div>
5181
</div>
5282
</div>

webapp/components/general/NetPyNEPythonConsole.js

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,19 @@
11
import React, { Component } from 'react'
2-
import Utils from '../../Utils'
32

43
import PythonConsole from '@geppettoengine/geppetto-client/js/components/interface/pythonConsole/PythonConsole';
54

65
export default class NetPyNEPythonConsole extends Component {
76

8-
addMetadataToWindow (data) {
9-
console.log("Initialising NetPyNE Tabs");
10-
window.metadata = data.metadata;
11-
window.currentFolder = data.currentFolder;
12-
window.isDocker = data.isDocker;
13-
window.pythonConsoleLoaded = true
14-
}
7+
158

169
componentWillUnmount () {
1710
console.log("unmounting python console")
1811
}
1912

2013
componentDidMount () {
21-
if (!window.pythonConsoleLoaded) {
22-
GEPPETTO.on('jupyter_geppetto_extension_ready', data => {
23-
let project = { id: 1, name: 'Project', experiments: [{ "id": 1, "name": 'Experiment', "status": 'DESIGN' }] }
24-
GEPPETTO.Manager.loadProject(project, false);
25-
GEPPETTO.Manager.loadExperiment(1, [], []);
26-
Utils.execPythonMessage('from netpyne_ui.netpyne_geppetto import netpyne_geppetto');
27-
Utils.evalPythonMessage('netpyne_geppetto.getData',[]).then(response => {
28-
const data = Utils.convertToJSON(response);
29-
this.addMetadataToWindow(data)
30-
this.props.modelLoaded();
31-
GEPPETTO.trigger("spinner:hide");
32-
})
33-
});
34-
}
14+
15+
16+
3517

3618
}
3719
render () {

webapp/components/index.js

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import PythonControlledCapability from "geppetto-client/js/communication/geppett
44

55
import {
66
activateWidget,
7-
destroyWidget,
7+
addWidgets,
88
minimizeWidget,
99
maximizeWidget,
1010
updateWidget,
@@ -80,7 +80,13 @@ export const Dimensions = connect(
8080
import _NetPyNE from "./NetPyNE";
8181
export const NetPyNE = connect(
8282
state => ({ editMode: state.general.editMode }),
83-
pythonCallErrorDispatch
83+
dispatch => ({
84+
pythonCallErrorDialogBox: payload => dispatch(openBackendErrorDialog(payload)),
85+
addWidgets: payload => dispatch(addWidgets(payload)),
86+
modelLoaded: () => dispatch(modelLoaded),
87+
newWidget: widget => dispatch(newWidget(widget)),
88+
activateWidget: widgetId => dispatch(activateWidget(widgetId))
89+
})
8490
)(_NetPyNE);
8591

8692
import _NetPyNECellRule from "./definition/cellRules/NetPyNECellRule";
@@ -90,17 +96,10 @@ export const NetPyNECellRule = connect((state, ownProps) => ({
9096
}))(_NetPyNECellRule);
9197

9298

93-
import _LayoutManager from "./layout/LayoutManager";
94-
export const LayoutManager = connect(
95-
state => ({ ...state.layout, editMode: state.general.editMode }),
96-
dispatch => ({
97-
updateWidget: widget => dispatch(updateWidget(widget)),
98-
minimizeWidget: id => dispatch(minimizeWidget(id)),
99-
destroyWidget: id => dispatch(destroyWidget(id)),
100-
maximizeWidget: id => dispatch(maximizeWidget(id)),
101-
activateWidget: id => dispatch(activateWidget(id))
102-
})
103-
)(_LayoutManager);
99+
import { getInstance as getLayoutManagerInstance } from "./layout/LayoutManager";
100+
export const LayoutManager = () => connect(state => ({
101+
layout: state.layout,
102+
}))(getLayoutManagerInstance().getComponent());
104103

105104

106105
import _NetPyNEPopulation from "./definition/populations/NetPyNEPopulation";
@@ -196,22 +195,16 @@ export const ActionDialog = connect(
196195
})
197196
)(_ActionDialog)
198197

199-
import _NetPyNEPythonConsole from './general/NetPyNEPythonConsole'
198+
import _NetPyNEPythonConsole from './general/NetPyNEPythonConsole';
200199
export const NetPyNEPythonConsole = connect(
201200
null,
202-
dispatch => ({
203-
modelLoaded: () => dispatch(modelLoaded),
204-
newWidget: widget => dispatch(newWidget(widget)),
205-
activateWidget: widgetId => dispatch(activateWidget(widgetId))
206-
})
201+
null
207202
)(_NetPyNEPythonConsole)
208203

204+
209205
import _Drawer from './settings/Drawer'
210206
export const Drawer = connect(
211-
state => ({
212-
widgets: state.flexlayout.widgets,
213-
editMode: state.general.editMode
214-
}),
207+
state => ({ editMode: state.general.editMode, layout: state.layout }),
215208
dispatch => ({
216209
updateWidget: newConf => dispatch(updateWidget(newConf)),
217210
newWidget: widget => dispatch(newWidget(widget)),

0 commit comments

Comments
 (0)