Skip to content

Commit 87b63d1

Browse files
committed
#netpyne-130 just minor fixes
1 parent a6cd3a8 commit 87b63d1

1 file changed

Lines changed: 46 additions & 45 deletions

File tree

webapp/components/NetPyNE.js

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,120 @@
1-
import React from 'react'
1+
import React from 'react';
22

3-
import { Box, Grid } from '@material-ui/core'
4-
import { withStyles } from '@material-ui/core/styles'
3+
import { Box, Grid } from '@material-ui/core';
4+
import { withStyles } from '@material-ui/core/styles';
55
import {
66
ErrorDialog,
77
Topbar,
88
LayoutManager,
99
Drawer,
1010
Dialog,
1111
ConfirmationDialog,
12-
LaunchDialog
13-
} from 'netpyne/components'
14-
import { loadModel } from '../redux/actions/general'
12+
LaunchDialog,
13+
} from 'netpyne/components';
14+
import { loadModel } from '../redux/actions/general';
1515

1616
const styles = ({ zIndex }) => ({
1717
root: {
1818
height: '100%',
1919
overflow: 'hidden',
2020
display: 'flex',
21-
flex: 1
21+
flex: 1,
2222
},
2323
container: {
2424
display: 'flex',
2525
flex: 1,
2626
alignItems: 'stretch',
27-
flexDirection: 'column'
27+
flexDirection: 'column',
2828
},
2929
topbar: {
3030
position: 'relative',
31-
zIndex: zIndex.drawer
31+
zIndex: zIndex.drawer,
3232
},
3333
content: {
3434
flexGrow: 1,
3535
display: 'flex',
3636
flexDirection: 'row',
37-
position: 'relative'
37+
position: 'relative',
3838
},
39-
noGrow: { flexGrow: 0 }
40-
})
39+
noGrow: { flexGrow: 0 },
40+
});
4141

4242
class NetPyNE extends React.Component {
4343
constructor (props) {
44-
super(props)
45-
this.openPythonCallDialog = this.openPythonCallDialog.bind(this)
46-
this.loaded = false
44+
super(props);
45+
this.openPythonCallDialog = this.openPythonCallDialog.bind(this);
46+
this.loaded = false;
4747
}
4848

4949
componentDidMount () {
50-
GEPPETTO.on(GEPPETTO.Events.Error_while_exec_python_command, this.openPythonCallDialog, this)
50+
GEPPETTO.on(GEPPETTO.Events.Error_while_exec_python_command, this.openPythonCallDialog, this);
5151

5252
const {
53-
setDefaultWidgets
54-
} = this.props
53+
setDefaultWidgets,
54+
} = this.props;
5555

56-
setDefaultWidgets()
56+
setDefaultWidgets();
5757

5858
// Listen messages
59-
const loadFromEvent = event => {
60-
console.log('Parent frame message received:', event)
61-
59+
const loadFromEvent = (event) => {
6260
// Here we would expect some cross-origin check, but we don't do anything more than load a model here
6361
switch (event.data.type) {
6462
case 'INIT_INSTANCE':
6563
if (this.loaded) {
66-
return
64+
return;
6765
}
68-
this.loaded = true
69-
console.log('Netpyne is ready')
66+
this.loaded = true;
67+
console.log('Netpyne is ready');
7068
if (window !== window.parent) {
7169
window.parent.postMessage({
72-
type: 'APP_READY'
73-
}, '*')
70+
type: 'APP_READY',
71+
}, '*');
7472
}
75-
break
76-
case 'LOAD_RESOURCE': {
77-
const resource = event.data.payload
78-
this.props.dispatchAction(loadModel(resource))
79-
}
73+
break;
74+
case 'LOAD_RESOURCE':
75+
// eslint-disable-next-line no-case-declarations
76+
const resource = event.data.payload;
77+
this.props.dispatchAction(loadModel(resource));
78+
break;
79+
default:
80+
break;
8081
}
81-
}
82+
};
8283
// A message from the parent frame can specify the file to load
83-
window.addEventListener('message', loadFromEvent)
84+
window.addEventListener('message', loadFromEvent);
8485
// window.load = loadFromEvent
8586
}
8687

8788
componentWillUnmount () {
88-
GEPPETTO.off(GEPPETTO.Events.Error_while_exec_python_command, this.openPythonCallDialog, this)
89+
GEPPETTO.off(GEPPETTO.Events.Error_while_exec_python_command, this.openPythonCallDialog, this);
8990
}
9091

9192
openPythonCallDialog (event) {
9293
if (event?.evalue && event?.traceback) {
9394
this.props.pythonCallErrorDialogBox({
9495
errorMessage: event.evalue,
95-
errorDetails: event.traceback.join('\n')
96-
})
96+
errorDetails: event.traceback.join('\n'),
97+
});
9798
} else {
9899
this.props.pythonCallErrorDialogBox({
99100
errorMessage: event.data.response.evalue,
100-
errorDetails: event.data.response.traceback.join('\n')
101-
})
101+
errorDetails: event.data.response.traceback.join('\n'),
102+
});
102103
}
103104
}
104105

105106
render () {
106-
const { classes } = this.props
107+
const { classes } = this.props;
107108

108-
const Layout = LayoutManager()
109+
const Layout = LayoutManager();
109110
return (
110111
<div className={classes.root}>
111112
<div className={classes.container}>
112113
<div className={classes.topbar}>
113114
<Topbar />
114115
</div>
115-
<Box p={1} flex={1} display='flex' alignItems='stretch'>
116-
<Grid container spacing={1} className={classes.content} alignItems='stretch'>
116+
<Box p={1} flex={1} display="flex" alignItems="stretch">
117+
<Grid container spacing={1} className={classes.content} alignItems="stretch">
117118
<Grid item className={classes.noGrow}>
118119
<Drawer />
119120
</Grid>
@@ -128,8 +129,8 @@ class NetPyNE extends React.Component {
128129
<ErrorDialog />
129130
<LaunchDialog />
130131
</div>
131-
)
132+
);
132133
}
133134
}
134135

135-
export default withStyles(styles)(NetPyNE)
136+
export default withStyles(styles)(NetPyNE);

0 commit comments

Comments
 (0)