-
Notifications
You must be signed in to change notification settings - Fork 9
/
App.js
181 lines (159 loc) · 6.06 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
import React, {Component} from 'react';
import { ConnectedRouter } from 'connected-react-router';
import { Switch } from 'react-router'
import { connect } from 'react-redux';
import { isNil } from 'lodash-es';
import MoleculeContainer from './containers/molecule';
import CalculationContainer from './containers/calculation';
import {VibrationalModesChartContainer, FreeEnergyChartContainer} from './containers/charts';
import { selectors } from '@openchemistry/redux';
import { auth as authUI, route } from '@openchemistry/girder-ui';
// @material-ui components
import { withStyles } from '@material-ui/core/styles'; // v1.x
import Drawer from '@material-ui/core/Drawer';
import Hidden from '@material-ui/core/Hidden';
import NotebookContainer from './containers/notebook';
import NotebooksContainer from './containers/notebooks';
import SideBar from './containers/sidebar';
import Footer from './containers/footer';
import Home from './containers/home';
import Molecules from './containers/molecules';
import Calculations from './containers/calculations';
import Header from './containers/header';
import JupyterIntegration from './containers/jupyterlab-integration/instructions';
import ImageManager from './containers/image-manager/image-manager';
import Groups from './containers/administrator/group-manager';
import Members from './containers/administrator/member-manager';
import User from './containers/user/user-profile';
import Creator from './containers/user/creator-profile';
import { history } from './store';
const appStyles = theme => ({
root: {
width: '100%',
minHeight: '100%',
display: 'flex',
flexDirection: 'column'
},
drawerPaper: {
position: 'relative',
width: theme.drawer.width,
backgroundColor: theme.drawer.backgroundColor,
},
body: {
display: 'flex',
flexGrow: 1
},
contentContainer: {
flexGrow: 1,
display: 'flex',
flexDirection: 'column'
},
content: {
flexGrow:1
},
footer: {
}
})
class App extends Component {
constructor(props) {
super(props);
this.state = {
openSideBar: false
}
}
toggleSideBar = () => {
this.setState({...this.state, openSideBar: !this.state.openSideBar});
}
render() {
const {site, classes} = this.props;
let development = false;
if (!process.env.NODE_ENV || process.env.NODE_ENV === 'development' ||
site === 'development') {
development = true;
}
const nersc = site === 'nersc';
return (
<ConnectedRouter history={history}>
<div className={classes.root}>
<Header onToggleMenu={this.toggleSideBar}/>
<div className={classes.body}>
{/* Desktop side menu */}
<Hidden smDown>
<Drawer
variant='persistent'
open
classes={{
paper: classes.drawerPaper,
}}
>
<SideBar />
</Drawer>
</Hidden>
{/* Mobile side menu */}
<Hidden mdUp>
<Drawer
variant='temporary'
anchor={'left'}
open={this.state.openSideBar}
onClose={this.toggleSideBar}
classes={{
paper: classes.drawerPaper,
}}
ModalProps={{
keepMounted: true, // Better open performance on mobile.
}}
>
<SideBar onLinkClick={this.toggleSideBar} />
</Drawer>
</Hidden>
<div className={classes.contentContainer}>
<div className={classes.content}>
<Switch>
<route.Public exact path='/' component={Home}/>
<route.Public exact path='/molecules/:id' component={MoleculeContainer}/>
<route.Public exact path='/molecules/:id/creator' component={Creator}/>
<route.Public exact path='/molecules/inchikey/:inchikey' component={MoleculeContainer}/>
<route.Public exact path='/molecules' component={Molecules}/>
<route.Public exact path='/chart' component={VibrationalModesChartContainer}/>
<route.Public exact path='/freechart' component={FreeEnergyChartContainer}/>
<route.Public exact path='/calculations/:id/creator' component={Creator}/>
<route.Public path='/calculations/:id/orbital/:iOrbital' component={CalculationContainer}/>
<route.Public path='/calculations/:id' component={CalculationContainer}/>
<route.Public path='/calculations' component={Calculations}/>
<route.Public path='/notebooks/:id' component={NotebookContainer}/>
<route.Public path='/notebooks' component={NotebooksContainer} />
<route.Private path='/groups/:id/members' component={Members} />
<route.Private path='/images' component={ImageManager} />
<route.Private path='/groups' component={Groups} />
<route.Private exact path='/user' component={User} />
<route.Private path='/user/:id/calculations' component={Calculations} />
<route.Private path='/user/:id/molecules' component={Molecules} />
</Switch>
<authUI.LoginOptions girder={development} nersc={nersc}/>
{development && <authUI.GirderLogin/>}
{nersc && <authUI.NerscLogin/>}
<authUI.OauthRedirect/>
<JupyterIntegration/>
</div>
<div className={classes.footer}>
<Footer />
</div>
</div>
</div>
</div>
</ConnectedRouter>
);
}
}
function mapStateToProps(state, _ownProps) {
const props = {
site: ''
};
const config = selectors.configuration.getConfiguration(state);
if (!isNil(config) && !isNil(config.deployment)) {
props.site = config.deployment.site;
}
return props;
}
App = connect(mapStateToProps)(App)
export default withStyles(appStyles)(App);