Skip to content

Commit 00c0905

Browse files
author
rodriguez-facundo
committed
#139 Flexlayout, redux, topbar and drawer changes as per new mockups
1 parent 6be3a1d commit 00c0905

16 files changed

Lines changed: 649 additions & 290 deletions

File tree

webapp/Theme.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11

22
import createMuiTheme from '@material-ui/core/styles/createMuiTheme';
3-
import purple from '@material-ui/core/colors/purple';
4-
import orange from '@material-ui/core/colors/orange';
53

64
// orange
75
const primaryColor = '#37ABC8'
8-
const secondaryColor = '#37ABC8'
96

107
export const bgLight = '#4A4A4A';
118
export const bgRegular = '#434343';
@@ -63,7 +60,8 @@ export default createMuiTheme({
6360
MuiMenuItem: { root: { color: 'white' } },
6461

6562
MuiListItemText: { root: { color: 'white' } },
66-
MuiDialogTitle: { root: { color: 'white' } }
63+
MuiDialogTitle: { root: { color: 'white' } },
64+
MuiTypography: { root: { color: 'white' } }
6765

6866
}
6967
});

webapp/components/NetPyNE.js

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

99
import { withStyles } from '@material-ui/core/styles'
10+
import { NetPyNEPythonConsole } from 'netpyne/components'
1011

1112
const styles = ({ zIndex, palette, spacing }) => ({
13+
root: { height: '100%', overflow: 'hidden' },
1214
container: {
1315
height: "100%",
1416
width: "100%",
1517
display: "flex",
1618
flexDirection: "column"
1719
},
18-
toolbar: {
19-
backgroundColor: palette.primary.main,
20-
width: "100%",
21-
boxShadow: "0 0px 4px 0 rgba(0, 0, 0, 0.2), 0 0px 8px 0 rgba(0, 0, 0, 0.19)",
22-
position: "relative",
23-
top: 0,
24-
left: 0,
25-
zIndex: zIndex.appBar
26-
},
20+
console: { marginTop: 12, width: 0, height: 0 },
2721
views: {
2822
display: "flex",
2923
flexFlow: "rows",
3024
width: "100%",
3125
marginRight: spacing(-1)
3226
},
3327
drawer: { marginLeft: spacing(-1) },
34-
content: { position: "relative", zIndex: zIndex.drawer + 1 }
28+
topbar: { position: "relative", zIndex: zIndex.drawer + 1 },
29+
content: { flexGrow:1, display: 'flex', flexDirection: 'row', position: 'relative' }
3530
})
3631

3732

@@ -54,14 +49,26 @@ class NetPyNE extends React.Component {
5449
const { classes } = this.props
5550

5651
return (
57-
<div className={classes.container}>
58-
<div className={classes.content}>
59-
<Topbar/>
52+
<div className={classes.root}>
53+
<div className={classes.container}>
54+
<div className={classes.topbar}>
55+
<Topbar/>
56+
</div>
57+
<div className={classes.content}>
58+
<Drawer/>
59+
<LayoutManager/>
60+
</div>
6061
</div>
61-
<div style={{ flexGrow:1, display: 'flex', flexDirection: 'row', position: 'relative' }}>
62-
<Drawer/>
63-
<LayoutManager/>
62+
63+
64+
<div className={classes.console}>
65+
{/* Flexlayout bottom panel gives weird layout so can't send the console there
66+
when the widget is closed and the python console must remain open somewhere for the app to sync
67+
*/}
68+
{!this.props.pythonConsoleWidget ? <NetPyNEPythonConsole /> : null}
6469
</div>
70+
71+
6572
</div>
6673
);
6774
}

webapp/components/general/NetPyNEField.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export default class NetPyNEField extends Component {
7272
onClick={() => this.handleOpenHelp(help)}
7373
/>
7474
<Dialog
75+
style={{ zIndex: 5000 }}
7576
open={this.state.openHelp}
7677
onClose={() => this.setState({ openHelp: false })}
7778
>

webapp/components/general/NetPyNEIcons.js

Lines changed: 332 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webapp/components/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export const Dimensions = connect(
7878

7979
import _NetPyNE from "./NetPyNE";
8080
export const NetPyNE = connect(
81-
state => ({ editMode: state.general.editMode, }),
81+
state => ({ editMode: state.general.editMode, pythonConsoleWidget: state.flexlayout.widgets['python'] }),
8282
pythonCallErrorDispatch
8383
)(_NetPyNE);
8484

webapp/components/instantiation/NetPyNEInstantiated.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { createRef } from 'react';
22
import ReactDOM from 'react-dom'
33
import Canvas from '@geppettoengine/geppetto-client/js/components/interface/3dCanvas/Canvas';
44
import ControlPanel from 'geppetto-client/js/components/interface/controlPanel/controlpanel';
5-
import IconButton from '@geppettoengine/geppetto-client/js/components/controls/iconButton/IconButton';
5+
66
import { NetWorkControlButtons } from 'netpyne/components'
77

88

webapp/components/layout/LayoutManager.js

Lines changed: 62 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import React, { Component } from 'react';
22
import * as FlexLayout from 'geppetto-client/js/components/interface/flexLayout2/src/index';
3-
import Actions from 'geppetto-client/js/components/interface/flexLayout2/src/model/Actions';
3+
import Actions from '@geppettoengine/geppetto-client/js/components/interface/flexLayout2/src/model/Actions';
44

55

66
import { WidgetStatus } from '../../constants';
77
import { isEqual } from '../../Utils';
88
import WidgetFactory from './WidgetFactory';
99
import TabsetIconFactory from './TabsetIconFactory'
1010
import defaultLayoutConfiguration from './layoutConf.json';
11-
import simulateLayoutConfiguration from './simulateLayoutConf.json';
1211
import Icon from '@material-ui/core/Icon';
1312

1413
import { withStyles } from '@material-ui/core/styles'
@@ -62,7 +61,7 @@ class LayoutManager extends Component {
6261

6362
this.cacheModels = {
6463
edit: FlexLayout.Model.fromJson(layout),
65-
simulate: FlexLayout.Model.fromJson(simulateLayoutConfiguration)
64+
simulate: FlexLayout.Model.fromJson(layout)
6665
}
6766
}
6867

@@ -83,10 +82,6 @@ class LayoutManager extends Component {
8382
if (newWidgets.length > 0) {
8483
this.addWidgets(newWidgets);
8584
}
86-
87-
if (!this.props.editMode && !this.cacheModels.simulate.getNodeById(widgets.python.id)) {
88-
this.addWidgets([widgets.python]);
89-
}
9085

9186
const updatedWidgets = this.findUpdatedWidgets(widgets, oldWidgets);
9287
if (updatedWidgets) {
@@ -136,7 +131,40 @@ class LayoutManager extends Component {
136131
}
137132

138133
addWidget (widgetConfiguration) {
139-
this.refs.layout.addTabToTabSet(widgetConfiguration.panelName, widget2Node(widgetConfiguration));
134+
const model = this.getModel()
135+
let tabset = model.getNodeById(widgetConfiguration.panelName)
136+
if (tabset === undefined) {
137+
this.createTabSet(widgetConfiguration.panelName)
138+
}
139+
this.refs.layout.addTabToTabSet(widgetConfiguration.panelName, widget2Node(widgetConfiguration))
140+
}
141+
142+
createTabSet (tabsetID) {
143+
// In case the tabset doesn't exist
144+
const model = this.getModel()
145+
const rootNode = model.getNodeById("root")
146+
147+
const pyPanel = model.getNodeById('consolePanel')
148+
if (pyPanel) {
149+
pyPanel._setWeight(20)
150+
}
151+
152+
let hrow = new FlexLayout.RowNode(model, {});
153+
hrow._setWeight(100)
154+
155+
const tabset = new FlexLayout.TabSetNode(model, { id: tabsetID });
156+
tabset._setWeight(80)
157+
158+
hrow._addChild(tabset)
159+
160+
rootNode.getChildren().forEach(child => hrow._addChild(child))
161+
rootNode._removeAll()
162+
rootNode._addChild(hrow, 0);
163+
if (!this.props.editMode && tabsetID === 'plotPanel') {
164+
// We need to resize Geppetto 3D canvas to new panel sizes
165+
setTimeout(() => window.dispatchEvent(new Event('resize')), 1000)
166+
167+
}
140168
}
141169

142170
updateWidgets (widgets) {
@@ -214,11 +242,31 @@ class LayoutManager extends Component {
214242
case Actions.MOVE_NODE :
215243
window.dispatchEvent(new Event('resize'));
216244
break;
245+
case Actions.ADD_NODE:{
246+
if (this.props.editMode && action.data.toNode === 'hlsPanel') {
247+
action.data.index = this.findWidgetInsertionIndex(action.data.json.config.pos)
248+
}
249+
break
250+
}
217251
}
218-
219252
model.doAction(action);
220253
}
221254

255+
findWidgetInsertionIndex (position) {
256+
const model = this.getModel()
257+
const tabset = model.getNodeById('hlsPanel')
258+
259+
const positions = tabset.getChildren().map(node => node.getConfig().pos)
260+
var index = -1
261+
for (let i = 0; i < positions.length; i++) {
262+
if (position < positions[i]) {
263+
index = i
264+
break
265+
}
266+
}
267+
return index
268+
}
269+
222270
onActionMaximizeWidget (action) {
223271
const model = this.getModel()
224272
const { widgets } = this.props;
@@ -270,7 +318,11 @@ class LayoutManager extends Component {
270318

271319
clickOnBordersAction (node) {
272320
const model = this.getModel()
273-
model.doAction(FlexLayout.Actions.moveNode(node.getId(), 'bottomPanel', FlexLayout.DockLocation.CENTER, 0));
321+
let tabset = model.getNodeById('consolePanel')
322+
if (tabset === undefined) {
323+
this.createTabSet('consolePanel')
324+
}
325+
model.doAction(FlexLayout.Actions.moveNode(node.getId(), 'consolePanel', FlexLayout.DockLocation.CENTER, 0));
274326
}
275327

276328
onRenderTab (node,renderValues) {

webapp/components/layout/layoutConf.json

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,7 @@
99
"type": "tabset",
1010
"weight": 100,
1111
"id": "root",
12-
"children": [
13-
{
14-
"type": "row",
15-
"weight": 100,
16-
"children": [
17-
{
18-
"type": "row",
19-
"weight": 65,
20-
"children": [
21-
{
22-
"type": "tabset",
23-
"weight": 100,
24-
"id": "hlsPanel",
25-
"enableDeleteWhenEmpty": false,
26-
"children": [
27-
]
28-
}
29-
]
30-
},
31-
{
32-
"type": "row",
33-
"weight": 35,
34-
"children": [
35-
{
36-
"type": "tabset",
37-
"weight": 100,
38-
"id": "consolePanel",
39-
"enableDeleteWhenEmpty": false,
40-
"children": [
41-
]
42-
}
43-
]
44-
}
45-
46-
]
47-
}
48-
]
12+
"children": []
4913
}
5014
}
5115

webapp/components/layout/simulateLayoutConf.json

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)