From f75cf89d3b4bdb160b4cc7f0a938fe074aed7192 Mon Sep 17 00:00:00 2001 From: Ashutosh Bishnoi Date: Fri, 30 Oct 2020 14:02:16 +0530 Subject: Added Event report with Report Filter as a seperate component --- modern/src/MainToolbar.js | 176 ++++++++++++++++++++++++---------------------- 1 file changed, 90 insertions(+), 86 deletions(-) (limited to 'modern/src/MainToolbar.js') diff --git a/modern/src/MainToolbar.js b/modern/src/MainToolbar.js index 374c694c..46d46496 100644 --- a/modern/src/MainToolbar.js +++ b/modern/src/MainToolbar.js @@ -1,45 +1,45 @@ -import React, { useState } from 'react'; -import { useHistory } from 'react-router-dom'; -import { makeStyles } from '@material-ui/core/styles'; -import { useDispatch, useSelector } from 'react-redux'; -import { sessionActions } from './store'; -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 ListSubheader from '@material-ui/core/ListSubheader'; -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 MapIcon from '@material-ui/icons/Map'; -import BarChartIcon from '@material-ui/icons/BarChart'; -import PeopleIcon from '@material-ui/icons/People'; -import StorageIcon from '@material-ui/icons/Storage'; -import PersonIcon from '@material-ui/icons/Person'; -import NotificationsIcon from '@material-ui/icons/Notifications'; -import TimelineIcon from '@material-ui/icons/Timeline'; -import PauseCircleFilledIcon from '@material-ui/icons/PauseCircleFilled'; -import PlayCircleFilledIcon from '@material-ui/icons/PlayCircleFilled'; -import NotificationsActiveIcon from '@material-ui/icons/NotificationsActive'; -import FormatListBulletedIcon from '@material-ui/icons/FormatListBulleted'; -import TrendingUpIcon from '@material-ui/icons/TrendingUp'; -import FolderIcon from '@material-ui/icons/Folder'; -import t from './common/localization'; +import React, { useState } from "react"; +import { useHistory } from "react-router-dom"; +import { makeStyles } from "@material-ui/core/styles"; +import { useDispatch, useSelector } from "react-redux"; +import { sessionActions } from "./store"; +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 ListSubheader from "@material-ui/core/ListSubheader"; +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 MapIcon from "@material-ui/icons/Map"; +import BarChartIcon from "@material-ui/icons/BarChart"; +import PeopleIcon from "@material-ui/icons/People"; +import StorageIcon from "@material-ui/icons/Storage"; +import PersonIcon from "@material-ui/icons/Person"; +import NotificationsIcon from "@material-ui/icons/Notifications"; +import TimelineIcon from "@material-ui/icons/Timeline"; +import PauseCircleFilledIcon from "@material-ui/icons/PauseCircleFilled"; +import PlayCircleFilledIcon from "@material-ui/icons/PlayCircleFilled"; +import NotificationsActiveIcon from "@material-ui/icons/NotificationsActive"; +import FormatListBulletedIcon from "@material-ui/icons/FormatListBulleted"; +import TrendingUpIcon from "@material-ui/icons/TrendingUp"; +import FolderIcon from "@material-ui/icons/Folder"; +import t from "./common/localization"; -const useStyles = makeStyles(theme => ({ +const useStyles = makeStyles((theme) => ({ flex: { - flexGrow: 1 + flexGrow: 1, }, appBar: { zIndex: theme.zIndex.drawer + 1, }, list: { - width: 250 + width: 250, }, menuButton: { marginLeft: -12, @@ -52,19 +52,27 @@ const MainToolbar = () => { const [drawer, setDrawer] = useState(false); const classes = useStyles(); const history = useHistory(); - const adminEnabled = useSelector(state => state.session.user && state.session.user.administrator); - const userId = useSelector(state => state.session.user && state.session.user.id); + const adminEnabled = useSelector( + (state) => state.session.user && state.session.user.administrator + ); + const userId = useSelector( + (state) => state.session.user && state.session.user.id + ); - const openDrawer = () => { setDrawer(true) } - const closeDrawer = () => { setDrawer(false) } + const openDrawer = () => { + setDrawer(true); + }; + const closeDrawer = () => { + setDrawer(false); + }; const handleLogout = async () => { - const response = await fetch('/api/session', { method: 'DELETE' }); + const response = await fetch("/api/session", { method: "DELETE" }); if (response.ok) { dispatch(sessionActions.updateUser(null)); - history.push('/login'); + history.push("/login"); } - } + }; return ( <> @@ -73,13 +81,16 @@ const MainToolbar = () => { + onClick={openDrawer} + > Traccar - - + + @@ -88,111 +99,104 @@ const MainToolbar = () => { className={classes.list} role="button" onClick={closeDrawer} - onKeyDown={closeDrawer}> + onKeyDown={closeDrawer} + > - history.push('/')}> + history.push("/")}> - + - - {t('reportTitle')} - - }> - history.push('/reports/route')}> + {t("reportTitle")}}> + history.push("/reports/route")}> - + - + history.push("/reports/event")}> - + - + - + - + - + - - {t('settingsTitle')} - - }> - history.push(`/user/${userId}`)}> + {t("settingsTitle")}}> + history.push(`/user/${userId}`)} + > - + - history.push('/settings/notifications')}> + history.push("/settings/notifications")} + > - + - history.push('/settings/groups')}> + history.push("/settings/groups")}> - + {adminEnabled && ( <> - - {t('userAdmin')} - - }> - history.push('/admin/server')}> + {t("userAdmin")}}> + history.push("/admin/server")}> - + - history.push('/admin/users')}> + history.push("/admin/users")}> - + - + @@ -201,6 +205,6 @@ const MainToolbar = () => { ); -} +}; export default MainToolbar; -- cgit v1.2.3