2018-02-26 00:11:31 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
|
2018-05-18 23:29:14 +01:00
|
|
|
import { withStyles } from '@material-ui/core/styles';
|
|
|
|
import Drawer from '@material-ui/core/Drawer';
|
|
|
|
import AppBar from '@material-ui/core/AppBar';
|
|
|
|
import Toolbar from '@material-ui/core/Toolbar';
|
|
|
|
import Typography from '@material-ui/core/Typography';
|
|
|
|
import IconButton from '@material-ui/core/IconButton';
|
|
|
|
import Hidden from '@material-ui/core/Hidden';
|
|
|
|
import Divider from '@material-ui/core/Divider';
|
2018-02-26 00:11:31 +00:00
|
|
|
|
2018-05-18 23:29:14 +01:00
|
|
|
import List from '@material-ui/core/List';
|
|
|
|
import ListItem from '@material-ui/core/ListItem';
|
|
|
|
import ListItemIcon from '@material-ui/core/ListItemIcon';
|
|
|
|
import ListItemText from '@material-ui/core/ListItemText';
|
|
|
|
|
|
|
|
import MenuIcon from '@material-ui/icons/Menu';
|
|
|
|
import WifiIcon from '@material-ui/icons/Wifi';
|
|
|
|
import SystemUpdateIcon from '@material-ui/icons/SystemUpdate';
|
|
|
|
import AccessTimeIcon from '@material-ui/icons/AccessTime';
|
2019-05-19 18:56:57 +01:00
|
|
|
import AccountCircleIcon from '@material-ui/icons/AccountCircle';
|
2018-05-18 23:29:14 +01:00
|
|
|
import SettingsInputAntennaIcon from '@material-ui/icons/SettingsInputAntenna';
|
2019-05-21 23:34:48 +01:00
|
|
|
import PeopleIcon from '@material-ui/icons/People';
|
2018-05-18 23:29:14 +01:00
|
|
|
|
2019-05-14 22:20:08 +01:00
|
|
|
import { APP_NAME } from '../constants/App';
|
2019-05-19 18:56:57 +01:00
|
|
|
import { withAuthenticationContext } from '../authentication/Context.js';
|
2019-05-14 22:20:08 +01:00
|
|
|
|
2018-05-18 23:29:14 +01:00
|
|
|
const drawerWidth = 290;
|
2018-02-26 00:11:31 +00:00
|
|
|
|
|
|
|
const styles = theme => ({
|
|
|
|
root: {
|
|
|
|
zIndex: 1,
|
|
|
|
width: '100%',
|
|
|
|
height: '100%',
|
|
|
|
},
|
|
|
|
toolbar: {
|
|
|
|
paddingLeft: theme.spacing.unit,
|
|
|
|
paddingRight: theme.spacing.unit,
|
|
|
|
[theme.breakpoints.up('md')]: {
|
|
|
|
paddingLeft: theme.spacing.unit * 3,
|
|
|
|
paddingRight: theme.spacing.unit * 3,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
appFrame: {
|
|
|
|
position: 'relative',
|
|
|
|
display: 'flex',
|
|
|
|
width: '100%',
|
|
|
|
height: '100%',
|
|
|
|
},
|
|
|
|
appBar: {
|
|
|
|
position: 'absolute',
|
|
|
|
marginLeft: drawerWidth,
|
|
|
|
[theme.breakpoints.up('md')]: {
|
|
|
|
width: `calc(100% - ${drawerWidth}px)`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
navIconHide: {
|
|
|
|
[theme.breakpoints.up('md')]: {
|
|
|
|
display: 'none',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
drawerPaper: {
|
|
|
|
width: drawerWidth,
|
|
|
|
height: '100%',
|
|
|
|
[theme.breakpoints.up('md')]: {
|
|
|
|
width: drawerWidth,
|
|
|
|
position:'fixed',
|
|
|
|
left:0,
|
|
|
|
top:0,
|
|
|
|
overflow:'auto'
|
|
|
|
},
|
|
|
|
},
|
|
|
|
content: {
|
|
|
|
backgroundColor: theme.palette.background.default,
|
|
|
|
width:"100%",
|
|
|
|
marginTop: 56,
|
|
|
|
[theme.breakpoints.up('md')]: {
|
|
|
|
paddingLeft: drawerWidth
|
|
|
|
},
|
|
|
|
[theme.breakpoints.up('sm')]: {
|
|
|
|
height: 'calc(100% - 64px)',
|
|
|
|
marginTop: 64,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
class MenuAppBar extends React.Component {
|
|
|
|
state = {
|
|
|
|
mobileOpen: false,
|
|
|
|
};
|
|
|
|
|
|
|
|
handleDrawerToggle = () => {
|
|
|
|
this.setState({ mobileOpen: !this.state.mobileOpen });
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
2019-05-19 18:56:57 +01:00
|
|
|
const { classes, theme, children, sectionTitle, authenticationContext } = this.props;
|
2018-02-26 00:11:31 +00:00
|
|
|
|
|
|
|
const drawer = (
|
|
|
|
<div>
|
|
|
|
<Toolbar>
|
2019-05-14 23:18:24 +01:00
|
|
|
<Typography variant="h6" color="primary">
|
2019-05-14 22:20:08 +01:00
|
|
|
{APP_NAME}
|
2018-02-26 00:11:31 +00:00
|
|
|
</Typography>
|
|
|
|
<Divider absolute />
|
|
|
|
</Toolbar>
|
|
|
|
<Divider />
|
|
|
|
<List>
|
|
|
|
<ListItem button component={Link} to='/wifi-configuration'>
|
|
|
|
<ListItemIcon>
|
|
|
|
<WifiIcon />
|
|
|
|
</ListItemIcon>
|
|
|
|
<ListItemText primary="WiFi Configuration" />
|
|
|
|
</ListItem>
|
|
|
|
<ListItem button component={Link} to='/ap-configuration'>
|
|
|
|
<ListItemIcon>
|
|
|
|
<SettingsInputAntennaIcon />
|
|
|
|
</ListItemIcon>
|
|
|
|
<ListItemText primary="AP Configuration" />
|
|
|
|
</ListItem>
|
|
|
|
<ListItem button component={Link} to='/ntp-configuration'>
|
|
|
|
<ListItemIcon>
|
|
|
|
<AccessTimeIcon />
|
|
|
|
</ListItemIcon>
|
|
|
|
<ListItemText primary="NTP Configuration" />
|
|
|
|
</ListItem>
|
|
|
|
<ListItem button component={Link} to='/ota-configuration'>
|
|
|
|
<ListItemIcon>
|
|
|
|
<SystemUpdateIcon />
|
|
|
|
</ListItemIcon>
|
|
|
|
<ListItemText primary="OTA Configuration" />
|
|
|
|
</ListItem>
|
2019-05-21 23:34:48 +01:00
|
|
|
<ListItem button component={Link} to='/user-configuration'>
|
|
|
|
<ListItemIcon>
|
|
|
|
<PeopleIcon />
|
|
|
|
</ListItemIcon>
|
|
|
|
<ListItemText primary="User Configuration" />
|
|
|
|
</ListItem>
|
2019-05-19 18:56:57 +01:00
|
|
|
<Divider />
|
|
|
|
<ListItem button onClick={authenticationContext.signOut}>
|
|
|
|
<ListItemIcon>
|
|
|
|
<AccountCircleIcon />
|
|
|
|
</ListItemIcon>
|
|
|
|
<ListItemText primary="Sign Out" secondary={"Signed in as: "+ authenticationContext.jwt.username} />
|
|
|
|
</ListItem>
|
2018-02-26 00:11:31 +00:00
|
|
|
</List>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={classes.root}>
|
|
|
|
<div className={classes.appFrame}>
|
|
|
|
<AppBar className={classes.appBar}>
|
|
|
|
<Toolbar className={classes.toolbar} disableGutters={true}>
|
|
|
|
<IconButton
|
|
|
|
color="inherit"
|
|
|
|
aria-label="open drawer"
|
|
|
|
onClick={this.handleDrawerToggle}
|
|
|
|
className={classes.navIconHide}
|
|
|
|
>
|
|
|
|
<MenuIcon />
|
|
|
|
</IconButton>
|
2019-05-14 23:18:24 +01:00
|
|
|
<Typography variant="h6" color="inherit" noWrap>
|
2018-02-26 00:11:31 +00:00
|
|
|
{sectionTitle}
|
|
|
|
</Typography>
|
|
|
|
</Toolbar>
|
|
|
|
</AppBar>
|
|
|
|
<Hidden mdUp>
|
|
|
|
<Drawer
|
|
|
|
variant="temporary"
|
|
|
|
anchor={theme.direction === 'rtl' ? 'right' : 'left'}
|
|
|
|
open={this.state.mobileOpen}
|
|
|
|
classes={{
|
|
|
|
paper: classes.drawerPaper,
|
|
|
|
}}
|
|
|
|
onClose={this.handleDrawerToggle}
|
|
|
|
ModalProps={{
|
|
|
|
keepMounted: true, // Better open performance on mobile.
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{drawer}
|
|
|
|
</Drawer>
|
|
|
|
</Hidden>
|
|
|
|
<Hidden smDown implementation="css">
|
|
|
|
<Drawer
|
|
|
|
variant="permanent"
|
|
|
|
open
|
|
|
|
classes={{
|
|
|
|
paper: classes.drawerPaper,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{drawer}
|
|
|
|
</Drawer>
|
|
|
|
</Hidden>
|
|
|
|
<main className={classes.content}>
|
|
|
|
{children}
|
|
|
|
</main>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MenuAppBar.propTypes = {
|
|
|
|
classes: PropTypes.object.isRequired,
|
|
|
|
theme: PropTypes.object.isRequired,
|
|
|
|
sectionTitle: PropTypes.string.isRequired,
|
|
|
|
};
|
|
|
|
|
2019-05-19 18:56:57 +01:00
|
|
|
export default withAuthenticationContext(withStyles(styles, { withTheme: true })(MenuAppBar));
|