diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-11-01 21:57:47 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-11-01 21:57:47 -0800 |
commit | 162000dc250b1be24fd7e6dd4e9c3883ca6581c5 (patch) | |
tree | b3c683dd896b6ee0b2695217e7251e959a5fa2a9 /modern/src | |
parent | 1a06115aa27a0c1545b8eb9bfb38930fcb8b56bf (diff) | |
download | trackermap-web-162000dc250b1be24fd7e6dd4e9c3883ca6581c5.tar.gz trackermap-web-162000dc250b1be24fd7e6dd4e9c3883ca6581c5.tar.bz2 trackermap-web-162000dc250b1be24fd7e6dd4e9c3883ca6581c5.zip |
Improve session handing
Diffstat (limited to 'modern/src')
-rw-r--r-- | modern/src/App.js | 34 | ||||
-rw-r--r-- | modern/src/MainPage.js | 5 |
2 files changed, 23 insertions, 16 deletions
diff --git a/modern/src/App.js b/modern/src/App.js index 6fd5c007..243489ee 100644 --- a/modern/src/App.js +++ b/modern/src/App.js @@ -15,26 +15,36 @@ import GroupsPage from './settings/GroupsPage'; import GroupPage from './settings/GroupPage'; import PositionPage from './PositionPage'; import ReplayPage from './reports/ReplayPage'; +import { useSelector } from 'react-redux'; +import { LinearProgress } from '@material-ui/core'; const App = () => { + const initialized = useSelector(state => !!state.session.server && !!state.session.user); + return ( <> <CssBaseline /> <SocketController /> <Switch> - <Route exact path='/' component={MainPage} /> <Route exact path='/login' component={LoginPage} /> - <Route exact path='/replay' component={ReplayPage} /> - <Route exact path='/position/:id?' component={PositionPage} /> - <Route exact path='/user/:id?' component={UserPage} /> - <Route exact path='/device/:id?' component={DevicePage} /> - <Route exact path='/reports/route' component={RouteReportPage} /> - <Route exact path='/settings/notifications' component={NotificationsPage} /> - <Route exact path='/settings/notification/:id?' component={NotificationPage} /> - <Route exact path='/settings/groups' component={GroupsPage} /> - <Route exact path='/settings/group/:id?' component={GroupPage} /> - <Route exact path='/admin/server' component={ServerPage} /> - <Route exact path='/admin/users' component={UsersPage} /> + <Route> + {!initialized ? (<LinearProgress />) : ( + <Switch> + <Route exact path='/' component={MainPage} /> + <Route exact path='/replay' component={ReplayPage} /> + <Route exact path='/position/:id?' component={PositionPage} /> + <Route exact path='/user/:id?' component={UserPage} /> + <Route exact path='/device/:id?' component={DevicePage} /> + <Route exact path='/reports/route' component={RouteReportPage} /> + <Route exact path='/settings/notifications' component={NotificationsPage} /> + <Route exact path='/settings/notification/:id?' component={NotificationPage} /> + <Route exact path='/settings/groups' component={GroupsPage} /> + <Route exact path='/settings/group/:id?' component={GroupPage} /> + <Route exact path='/admin/server' component={ServerPage} /> + <Route exact path='/admin/users' component={UsersPage} /> + </Switch> + )} + </Route> </Switch> </> ); diff --git a/modern/src/MainPage.js b/modern/src/MainPage.js index d277f28a..58bf83aa 100644 --- a/modern/src/MainPage.js +++ b/modern/src/MainPage.js @@ -1,9 +1,7 @@ import React from 'react'; -import { useSelector } from 'react-redux'; import { isWidthUp, makeStyles, withWidth } from '@material-ui/core'; import Drawer from '@material-ui/core/Drawer'; import ContainerDimensions from 'react-container-dimensions'; -import LinearProgress from '@material-ui/core/LinearProgress'; import DevicesList from './DevicesList'; import MainToolbar from './MainToolbar'; import Map from './map/Map'; @@ -42,10 +40,9 @@ const useStyles = makeStyles(theme => ({ })); const MainPage = ({ width }) => { - const initialized = useSelector(state => !!state.session.server && !!state.session.user); const classes = useStyles(); - return !initialized ? (<LinearProgress />) : ( + return ( <div className={classes.root}> <MainToolbar /> <div className={classes.content}> |