From 98f2dd952e35e41045c7c9f925e229000bbe4797 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 8 May 2022 18:11:23 -0700 Subject: Migrate reports to page layout --- modern/src/common/components/BottomMenu.js | 2 +- modern/src/common/components/PageLayout.js | 2 + modern/src/reports/ChartReportPage.js | 9 +- modern/src/reports/EventReportPage.js | 8 +- modern/src/reports/RouteReportPage.js | 23 ++-- modern/src/reports/StatisticsPage.js | 22 ++-- modern/src/reports/StopReportPage.js | 8 +- modern/src/reports/SummaryReportPage.js | 8 +- modern/src/reports/TripReportPage.js | 8 +- modern/src/reports/components/ReportFilter.js | 11 +- modern/src/reports/components/ReportLayout.js | 124 -------------------- modern/src/reports/components/ReportsMenu.js | 88 ++++++++++++++ modern/src/settings/components/OptionsLayout.js | 148 ------------------------ 13 files changed, 150 insertions(+), 311 deletions(-) delete mode 100644 modern/src/reports/components/ReportLayout.js create mode 100644 modern/src/reports/components/ReportsMenu.js delete mode 100644 modern/src/settings/components/OptionsLayout.js diff --git a/modern/src/common/components/BottomMenu.js b/modern/src/common/components/BottomMenu.js index 048cb0d7..30960396 100644 --- a/modern/src/common/components/BottomMenu.js +++ b/modern/src/common/components/BottomMenu.js @@ -27,7 +27,7 @@ const BottomMenu = () => { const [anchorEl, setAnchorEl] = useState(null); const currentSelection = () => { - if (location.pathname.startsWith('/settings/user')) { + if (location.pathname === `/settings/user/${userId}`) { return 3; } if (location.pathname.startsWith('/settings')) { return 2; diff --git a/modern/src/common/components/PageLayout.js b/modern/src/common/components/PageLayout.js index e37ae4dc..a1f117c4 100644 --- a/modern/src/common/components/PageLayout.js +++ b/modern/src/common/components/PageLayout.js @@ -28,6 +28,8 @@ const useStyles = makeStyles((theme) => ({ flexGrow: 1, alignItems: 'stretch', overflow: 'auto', + display: 'flex', + flexDirection: 'column', }, })); diff --git a/modern/src/reports/ChartReportPage.js b/modern/src/reports/ChartReportPage.js index 70429ec5..4ddb5f75 100644 --- a/modern/src/reports/ChartReportPage.js +++ b/modern/src/reports/ChartReportPage.js @@ -2,13 +2,14 @@ import React, { useState } from 'react'; import { Grid, FormControl, InputLabel, Select, MenuItem, } from '@material-ui/core'; -import ReportLayout from './components/ReportLayout'; import ReportFilter from './components/ReportFilter'; import Graph from './components/Graph'; import { useAttributePreference } from '../common/util/preferences'; import { formatDate } from '../common/util/formatter'; import { speedFromKnots } from '../common/util/converter'; import { useTranslation } from '../common/components/LocalizationProvider'; +import PageLayout from '../common/components/PageLayout'; +import ReportsMenu from './components/ReportsMenu'; const Filter = ({ children, setItems }) => { const speedUnit = useAttributePreference('speedUnit'); @@ -61,14 +62,12 @@ const ChartReportPage = () => { const [type, setType] = useState('speed'); return ( - } breadcrumbs={['reportTitle', 'reportChart']}> - )} - > - + ); }; diff --git a/modern/src/reports/EventReportPage.js b/modern/src/reports/EventReportPage.js index bbd92d59..71ca08d9 100644 --- a/modern/src/reports/EventReportPage.js +++ b/modern/src/reports/EventReportPage.js @@ -7,9 +7,10 @@ import { useTheme } from '@material-ui/core/styles'; import { useSelector } from 'react-redux'; import { formatDate } from '../common/util/formatter'; import ReportFilter from './components/ReportFilter'; -import ReportLayout from './components/ReportLayout'; import { prefixString } from '../common/util/stringUtils'; import { useTranslation } from '../common/components/LocalizationProvider'; +import PageLayout from '../common/components/PageLayout'; +import ReportsMenu from './components/ReportsMenu'; const Filter = ({ setItems }) => { const t = useTranslation(); @@ -106,14 +107,15 @@ const EventReportPage = () => { }]; return ( - }> + } breadcrumbs={['reportTitle', 'reportEvents']}> + - + ); }; diff --git a/modern/src/reports/RouteReportPage.js b/modern/src/reports/RouteReportPage.js index 035f6acd..dfce525f 100644 --- a/modern/src/reports/RouteReportPage.js +++ b/modern/src/reports/RouteReportPage.js @@ -1,14 +1,14 @@ import React, { useState } from 'react'; -import { Paper } from '@material-ui/core'; import { DataGrid } from '@material-ui/data-grid'; import { useTheme } from '@material-ui/core/styles'; import { formatDistance, formatSpeed, formatBoolean, formatDate, formatCoordinate, } from '../common/util/formatter'; import ReportFilter from './components/ReportFilter'; -import ReportLayout from './components/ReportLayout'; import { useAttributePreference, usePreference } from '../common/util/preferences'; import { useTranslation } from '../common/components/LocalizationProvider'; +import PageLayout from '../common/components/PageLayout'; +import ReportsMenu from './components/ReportsMenu'; const Filter = ({ setItems }) => { const handleSubmit = async (deviceId, from, to, mail, headers) => { @@ -88,16 +88,15 @@ const RouteReportPage = () => { const [items, setItems] = useState([]); return ( - }> - - - - + } breadcrumbs={['reportTitle', 'reportRoute']}> + + + ); }; diff --git a/modern/src/reports/StatisticsPage.js b/modern/src/reports/StatisticsPage.js index 4b0d9bfe..f04f6e43 100644 --- a/modern/src/reports/StatisticsPage.js +++ b/modern/src/reports/StatisticsPage.js @@ -1,13 +1,21 @@ import React, { useState } from 'react'; import { - FormControl, InputLabel, Select, MenuItem, TextField, Button, TableContainer, Table, TableRow, TableCell, TableHead, TableBody, + FormControl, InputLabel, Select, MenuItem, TextField, Button, TableContainer, Table, TableRow, TableCell, TableHead, TableBody, makeStyles, } from '@material-ui/core'; import moment from 'moment'; import { formatDate } from '../common/util/formatter'; -import OptionsLayout from '../settings/components/OptionsLayout'; import { useTranslation } from '../common/components/LocalizationProvider'; +import PageLayout from '../common/components/PageLayout'; +import ReportsMenu from './components/ReportsMenu'; + +const useStyles = makeStyles((theme) => ({ + filter: { + margin: theme.spacing(1), + }, +})); const Filter = ({ setItems }) => { + const classes = useStyles(); const t = useTranslation(); const [period, setPeriod] = useState('today'); @@ -56,7 +64,7 @@ const Filter = ({ setItems }) => { }; return ( - <> +
{t('reportPeriod')}