blob: 9ec89a2fd5920050958d57fbe3dcdcb1f40e046b (
plain)
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
|
import React, { useState } from 'react';
import { useHistory } from 'react-router-dom';
import { makeStyles } from '@material-ui/core/styles';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import Typography from '@material-ui/core/Typography';
import Button from '@material-ui/core/Button';
import IconButton from '@material-ui/core/IconButton';
import MenuIcon from '@material-ui/icons/Menu';
import Drawer from '@material-ui/core/Drawer';
import List from '@material-ui/core/List';
import Divider from '@material-ui/core/Divider';
import ListItem from '@material-ui/core/ListItem';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemText from '@material-ui/core/ListItemText';
import DashboardIcon from '@material-ui/icons/Dashboard';
import BarChartIcon from '@material-ui/icons/BarChart';
import SettingsIcon from '@material-ui/icons/Settings';
const useStyles = makeStyles(theme => ({
flex: {
flexGrow: 1
},
appBar: {
zIndex: theme.zIndex.drawer + 1,
},
list: {
width: 250
},
menuButton: {
marginLeft: -12,
marginRight: 20,
}
}));
const MainToolbar = () => {
const [drawer, setDrawer] = useState(false);
const classes = useStyles();
const history = useHistory();
const openDrawer = () => { setDrawer(true) }
const closeDrawer = () => { setDrawer(false) }
const handleLogout = () => {
fetch('/api/session', { method: 'DELETE' }).then(response => {
if (response.ok) {
history.push('/login');
}
})
}
return (<>
<AppBar position="static" className={classes.appBar}>
<Toolbar>
<IconButton
className={classes.menuButton}
color="inherit"
onClick={openDrawer}>
<MenuIcon />
</IconButton>
<Typography variant="h6" color="inherit" className={classes.flex}>
Traccar
</Typography>
<Button color="inherit" onClick={handleLogout}>Logout</Button>
</Toolbar>
</AppBar>
<Drawer open={drawer} onClose={closeDrawer}>
<div
tabIndex={0}
className={classes.list}
role="button"
onClick={closeDrawer}
onKeyDown={closeDrawer}>
<List>
<ListItem button>
<ListItemIcon>
<DashboardIcon />
</ListItemIcon>
<ListItemText primary="Dashboard" />
</ListItem>
<ListItem button disabled>
<ListItemIcon>
<BarChartIcon />
</ListItemIcon>
<ListItemText primary="Reports" />
</ListItem>
</List>
<Divider />
<List>
<ListItem button disabled>
<ListItemIcon>
<SettingsIcon />
</ListItemIcon>
<ListItemText primary="Settings" />
</ListItem>
</List>
</div>
</Drawer>
</>);
}
export default MainToolbar;
|