From 8e0fa926ee03a025ad284b06280132f55be22e28 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 27 May 2022 07:20:07 -0700 Subject: Improve page scrolling --- modern/src/main/StatusCard.js | 37 +++++----- modern/src/reports/EventReportPage.js | 102 ++++++++++++++------------ modern/src/reports/RouteReportPage.js | 74 +++++++++++-------- modern/src/reports/StatisticsPage.js | 58 +++++++++------ modern/src/reports/StopReportPage.js | 58 +++++++++------ modern/src/reports/SummaryReportPage.js | 78 +++++++++++--------- modern/src/reports/TripReportPage.js | 58 +++++++++------ modern/src/settings/CalendarsPage.js | 38 +++++----- modern/src/settings/CommandsPage.js | 46 ++++++------ modern/src/settings/ComputedAttributesPage.js | 54 +++++++------- modern/src/settings/DriversPage.js | 42 +++++------ modern/src/settings/GroupsPage.js | 38 +++++----- modern/src/settings/MaintenancesPage.js | 50 ++++++------- modern/src/settings/NotificationsPage.js | 50 ++++++------- modern/src/settings/UsersPage.js | 50 ++++++------- 15 files changed, 443 insertions(+), 390 deletions(-) (limited to 'modern') diff --git a/modern/src/main/StatusCard.js b/modern/src/main/StatusCard.js index d521749b..d991bd6a 100644 --- a/modern/src/main/StatusCard.js +++ b/modern/src/main/StatusCard.js @@ -13,7 +13,6 @@ import { TableBody, TableRow, TableCell, - TableContainer, } from '@mui/material'; import makeStyles from '@mui/styles/makeStyles'; import CloseIcon from '@mui/icons-material/Close'; @@ -124,25 +123,23 @@ const StatusCard = ({ deviceId, onClose }) => { /> {position && ( - - - - {positionItems.filter((key) => position.hasOwnProperty(key) || position.attributes.hasOwnProperty(key)).map((key) => ( - - )} - /> - ))} - -
-
+ + + {positionItems.filter((key) => position.hasOwnProperty(key) || position.attributes.hasOwnProperty(key)).map((key) => ( + + )} + /> + ))} + +
)} diff --git a/modern/src/reports/EventReportPage.js b/modern/src/reports/EventReportPage.js index bc820c4c..504534a2 100644 --- a/modern/src/reports/EventReportPage.js +++ b/modern/src/reports/EventReportPage.js @@ -1,8 +1,9 @@ import React, { useState } from 'react'; import { - FormControl, InputLabel, Select, MenuItem, TableContainer, Table, TableHead, TableRow, TableCell, TableBody, + FormControl, InputLabel, Select, MenuItem, Table, TableHead, TableRow, TableCell, TableBody, } from '@mui/material'; import { useSelector } from 'react-redux'; +import { makeStyles } from '@mui/styles'; import { formatDate } from '../common/util/formatter'; import ReportFilter, { useFilterStyles } from './components/ReportFilter'; import { prefixString } from '../common/util/stringUtils'; @@ -43,8 +44,19 @@ const columnsArray = [ ]; const columnsMap = new Map(columnsArray); +const useStyles = makeStyles(() => ({ + header: { + position: 'sticky', + left: 0, + display: 'flex', + flexDirection: 'column', + alignItems: 'stretch', + }, +})); + const EventReportPage = () => { - const classes = useFilterStyles(); + const classes = useStyles(); + const filterClasses = useFilterStyles(); const t = useTranslation(); const geofences = useSelector((state) => state.geofences.items); @@ -96,51 +108,51 @@ const EventReportPage = () => { return ( } breadcrumbs={['reportTitle', 'reportEvents']}> - -
- - {t('reportEventTypes')} - { + let values = event.target.value; + const clicked = child.props.value; + if (values.includes('allEvents') && values.length > 1) { + values = [clicked]; + } + setEventTypes(values); + }} + multiple + > + {typesArray.map(([key, string]) => ( + {t(string)} + ))} + + +
+ +
+ + + + + {columns.map((key) => ({t(columnsMap.get(key))}))} + + + + {items.map((item) => ( + + {columns.map((key) => ( + + {formatValue(item, key)} + ))} - - - - - - -
- - - {columns.map((key) => ({t(columnsMap.get(key))}))} - - - {items.map((item) => ( - - {columns.map((key) => ( - - {formatValue(item, key)} - - ))} - - ))} - -
- + ))} + +
); }; diff --git a/modern/src/reports/RouteReportPage.js b/modern/src/reports/RouteReportPage.js index 3f89888f..c88da633 100644 --- a/modern/src/reports/RouteReportPage.js +++ b/modern/src/reports/RouteReportPage.js @@ -1,7 +1,8 @@ import React, { useState } from 'react'; import { - Table, TableBody, TableCell, TableContainer, TableHead, TableRow, + Table, TableBody, TableCell, TableHead, TableRow, } from '@mui/material'; +import { makeStyles } from '@mui/styles'; import ReportFilter from './components/ReportFilter'; import { useTranslation } from '../common/components/LocalizationProvider'; import PageLayout from '../common/components/PageLayout'; @@ -12,7 +13,18 @@ import ColumnSelect from './components/ColumnSelect'; import usePositionAttributes from '../common/attributes/usePositionAttributes'; import { useCatch } from '../reactHelper'; +const useStyles = makeStyles(() => ({ + header: { + position: 'sticky', + left: 0, + display: 'flex', + flexDirection: 'column', + alignItems: 'stretch', + }, +})); + const RouteReportPage = () => { + const classes = useStyles(); const t = useTranslation(); const positionAttributes = usePositionAttributes(t); @@ -41,37 +53,37 @@ const RouteReportPage = () => { return ( } breadcrumbs={['reportTitle', 'reportRoute']}> - - - - - - - - {columns.map((key) => ({positionAttributes[key].name}))} +
+ + + +
+
+ + + {columns.map((key) => ({positionAttributes[key].name}))} + + + + {items.map((item) => ( + + {columns.map((key) => ( + + + + ))} - - - {items.map((item) => ( - - {columns.map((key) => ( - - - - ))} - - ))} - -
-
+ ))} + +
); }; diff --git a/modern/src/reports/StatisticsPage.js b/modern/src/reports/StatisticsPage.js index b9b14902..bb9926f7 100644 --- a/modern/src/reports/StatisticsPage.js +++ b/modern/src/reports/StatisticsPage.js @@ -1,7 +1,8 @@ import React, { useState } from 'react'; import { - TableContainer, Table, TableRow, TableCell, TableHead, TableBody, + Table, TableRow, TableCell, TableHead, TableBody, } from '@mui/material'; +import { makeStyles } from '@mui/styles'; import { formatDate } from '../common/util/formatter'; import { useTranslation } from '../common/components/LocalizationProvider'; import PageLayout from '../common/components/PageLayout'; @@ -25,7 +26,18 @@ const columnsArray = [ ]; const columnsMap = new Map(columnsArray); +const useStyles = makeStyles(() => ({ + header: { + position: 'sticky', + left: 0, + display: 'flex', + flexDirection: 'column', + alignItems: 'stretch', + }, +})); + const StatisticsPage = () => { + const classes = useStyles(); const t = useTranslation(); const [columns, setColumns] = usePersistedState('statisticsColumns', ['captureTime', 'activeUsers', 'activeDevices', 'messagesStored']); @@ -43,29 +55,29 @@ const StatisticsPage = () => { return ( } breadcrumbs={['reportTitle', 'statisticsTitle']}> - - - - - - - - {columns.map((key) => ({t(columnsMap.get(key))}))} +
+ + + +
+
+ + + {columns.map((key) => ({t(columnsMap.get(key))}))} + + + + {items.map((item) => ( + + {columns.map((key) => ( + + {key === 'captureTime' ? formatDate(item[key]) : item[key]} + + ))} - - - {items.map((item) => ( - - {columns.map((key) => ( - - {key === 'captureTime' ? formatDate(item[key]) : item[key]} - - ))} - - ))} - -
-
+ ))} + +
); }; diff --git a/modern/src/reports/StopReportPage.js b/modern/src/reports/StopReportPage.js index 55091292..6cf8be07 100644 --- a/modern/src/reports/StopReportPage.js +++ b/modern/src/reports/StopReportPage.js @@ -1,7 +1,8 @@ import React, { useState } from 'react'; import { - Table, TableBody, TableCell, TableContainer, TableHead, TableRow, + Table, TableBody, TableCell, TableHead, TableRow, } from '@mui/material'; +import { makeStyles } from '@mui/styles'; import { formatDistance, formatHours, formatDate, formatVolume, } from '../common/util/formatter'; @@ -25,7 +26,18 @@ const columnsArray = [ ]; const columnsMap = new Map(columnsArray); +const useStyles = makeStyles(() => ({ + header: { + position: 'sticky', + left: 0, + display: 'flex', + flexDirection: 'column', + alignItems: 'stretch', + }, +})); + const StopReportPage = () => { + const classes = useStyles(); const t = useTranslation(); const distanceUnit = useAttributePreference('distanceUnit'); @@ -73,29 +85,29 @@ const StopReportPage = () => { return ( } breadcrumbs={['reportTitle', 'reportStops']}> - - - - - - - - {columns.map((key) => ({t(columnsMap.get(key))}))} +
+ + + +
+
+ + + {columns.map((key) => ({t(columnsMap.get(key))}))} + + + + {items.map((item) => ( + + {columns.map((key) => ( + + {formatValue(item, key)} + + ))} - - - {items.map((item) => ( - - {columns.map((key) => ( - - {formatValue(item, key)} - - ))} - - ))} - -
-
+ ))} + +
); }; diff --git a/modern/src/reports/SummaryReportPage.js b/modern/src/reports/SummaryReportPage.js index 49fc7bb1..e2f5e009 100644 --- a/modern/src/reports/SummaryReportPage.js +++ b/modern/src/reports/SummaryReportPage.js @@ -1,7 +1,8 @@ import React, { useState } from 'react'; import { - FormControl, InputLabel, Select, MenuItem, TableContainer, Table, TableHead, TableRow, TableBody, TableCell, + FormControl, InputLabel, Select, MenuItem, Table, TableHead, TableRow, TableBody, TableCell, } from '@mui/material'; +import { makeStyles } from '@mui/styles'; import { formatDistance, formatHours, formatDate, formatSpeed, formatVolume, } from '../common/util/formatter'; @@ -26,8 +27,19 @@ const columnsArray = [ ]; const columnsMap = new Map(columnsArray); +const useStyles = makeStyles(() => ({ + header: { + position: 'sticky', + left: 0, + display: 'flex', + flexDirection: 'column', + alignItems: 'stretch', + }, +})); + const SummaryReportPage = () => { - const classes = useFilterStyles(); + const classes = useStyles(); + const filterClasses = useFilterStyles(); const t = useTranslation(); const distanceUnit = useAttributePreference('distanceUnit'); @@ -79,38 +91,38 @@ const SummaryReportPage = () => { return ( } breadcrumbs={['reportTitle', 'reportSummary']}> - -
- - {t('sharedType')} - - -
- -
- - - - - {columns.map((key) => ({t(columnsMap.get(key))}))} +
+ +
+ + {t('sharedType')} + + +
+ +
+
+
+ + + {columns.map((key) => ({t(columnsMap.get(key))}))} + + + + {items.map((item) => ( + + {columns.map((key) => ( + + {formatValue(item, key)} + + ))} - - - {items.map((item) => ( - - {columns.map((key) => ( - - {formatValue(item, key)} - - ))} - - ))} - -
-
+ ))} + +
); }; diff --git a/modern/src/reports/TripReportPage.js b/modern/src/reports/TripReportPage.js index 773e7510..4d627b67 100644 --- a/modern/src/reports/TripReportPage.js +++ b/modern/src/reports/TripReportPage.js @@ -1,7 +1,8 @@ import React, { useState } from 'react'; import { - Table, TableBody, TableCell, TableContainer, TableHead, TableRow, + Table, TableBody, TableCell, TableHead, TableRow, } from '@mui/material'; +import { makeStyles } from '@mui/styles'; import { formatDistance, formatSpeed, formatHours, formatDate, formatVolume, } from '../common/util/formatter'; @@ -30,7 +31,18 @@ const columnsArray = [ ]; const columnsMap = new Map(columnsArray); +const useStyles = makeStyles(() => ({ + header: { + position: 'sticky', + left: 0, + display: 'flex', + flexDirection: 'column', + alignItems: 'stretch', + }, +})); + const TripReportPage = () => { + const classes = useStyles(); const t = useTranslation(); const distanceUnit = useAttributePreference('distanceUnit'); @@ -82,29 +94,29 @@ const TripReportPage = () => { return ( } breadcrumbs={['reportTitle', 'reportTrips']}> - - - - - - - - {columns.map((key) => ({t(columnsMap.get(key))}))} +
+ + + +
+
+ + + {columns.map((key) => ({t(columnsMap.get(key))}))} + + + + {items.map((item) => ( + + {columns.map((key) => ( + + {formatValue(item, key)} + + ))} - - - {items.map((item) => ( - - {columns.map((key) => ( - - {formatValue(item, key)} - - ))} - - ))} - -
-
+ ))} + +
); }; diff --git a/modern/src/settings/CalendarsPage.js b/modern/src/settings/CalendarsPage.js index 3f4aa3d3..ea28967c 100644 --- a/modern/src/settings/CalendarsPage.js +++ b/modern/src/settings/CalendarsPage.js @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import { - TableContainer, Table, TableRow, TableCell, TableHead, TableBody, + Table, TableRow, TableCell, TableHead, TableBody, } from '@mui/material'; import makeStyles from '@mui/styles/makeStyles'; import { useEffectAsync } from '../reactHelper'; @@ -35,26 +35,24 @@ const CalendarsPage = () => { return ( } breadcrumbs={['settingsTitle', 'sharedCalendars']}> - - - - - {t('sharedName')} - +
+ + + {t('sharedName')} + + + + + {items.map((item) => ( + + {item.name} + + + - - - {items.map((item) => ( - - {item.name} - - - - - ))} - -
-
+ ))} + +
); diff --git a/modern/src/settings/CommandsPage.js b/modern/src/settings/CommandsPage.js index 397263d0..5ff194d5 100644 --- a/modern/src/settings/CommandsPage.js +++ b/modern/src/settings/CommandsPage.js @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import { - TableContainer, Table, TableRow, TableCell, TableHead, TableBody, + Table, TableRow, TableCell, TableHead, TableBody, } from '@mui/material'; import makeStyles from '@mui/styles/makeStyles'; import { useEffectAsync } from '../reactHelper'; @@ -37,30 +37,28 @@ const CommandsPage = () => { return ( } breadcrumbs={['settingsTitle', 'sharedSavedCommands']}> - - - - - {t('sharedDescription')} - {t('sharedType')} - {t('commandSendSms')} - +
+ + + {t('sharedDescription')} + {t('sharedType')} + {t('commandSendSms')} + + + + + {items.map((item) => ( + + {item.description} + {t(prefixString('command', item.type))} + {formatBoolean(item.textChannel, t)} + + + - - - {items.map((item) => ( - - {item.description} - {t(prefixString('command', item.type))} - {formatBoolean(item.textChannel, t)} - - - - - ))} - -
-
+ ))} + +
); diff --git a/modern/src/settings/ComputedAttributesPage.js b/modern/src/settings/ComputedAttributesPage.js index c8e07b71..5de79dc0 100644 --- a/modern/src/settings/ComputedAttributesPage.js +++ b/modern/src/settings/ComputedAttributesPage.js @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import { - TableContainer, Table, TableRow, TableCell, TableHead, TableBody, + Table, TableRow, TableCell, TableHead, TableBody, } from '@mui/material'; import makeStyles from '@mui/styles/makeStyles'; import { useEffectAsync } from '../reactHelper'; @@ -37,34 +37,32 @@ const ComputedAttributesPage = () => { return ( } breadcrumbs={['settingsTitle', 'sharedComputedAttributes']}> - - - - - {t('sharedDescription')} - {t('sharedAttribute')} - {t('sharedExpression')} - {t('sharedType')} - {administrator && } +
+ + + {t('sharedDescription')} + {t('sharedAttribute')} + {t('sharedExpression')} + {t('sharedType')} + {administrator && } + + + + {items.map((item) => ( + + {item.description} + {item.attribute} + {item.expression} + {item.type} + {administrator && ( + + + + )} - - - {items.map((item) => ( - - {item.description} - {item.attribute} - {item.expression} - {item.type} - {administrator && ( - - - - )} - - ))} - -
-
+ ))} + +
); diff --git a/modern/src/settings/DriversPage.js b/modern/src/settings/DriversPage.js index b66f9f9a..cdff5488 100644 --- a/modern/src/settings/DriversPage.js +++ b/modern/src/settings/DriversPage.js @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import { - TableContainer, Table, TableRow, TableCell, TableHead, TableBody, + Table, TableRow, TableCell, TableHead, TableBody, } from '@mui/material'; import makeStyles from '@mui/styles/makeStyles'; import { useEffectAsync } from '../reactHelper'; @@ -35,28 +35,26 @@ const DriversPage = () => { return ( } breadcrumbs={['settingsTitle', 'sharedDrivers']}> - - - - - {t('sharedName')} - {t('deviceIdentifier')} - +
+ + + {t('sharedName')} + {t('deviceIdentifier')} + + + + + {items.map((item) => ( + + {item.name} + {item.uniqueId} + + + - - - {items.map((item) => ( - - {item.name} - {item.uniqueId} - - - - - ))} - -
-
+ ))} + +
); diff --git a/modern/src/settings/GroupsPage.js b/modern/src/settings/GroupsPage.js index 1ec63b0c..16a907c2 100644 --- a/modern/src/settings/GroupsPage.js +++ b/modern/src/settings/GroupsPage.js @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import { - TableContainer, Table, TableRow, TableCell, TableHead, TableBody, + Table, TableRow, TableCell, TableHead, TableBody, } from '@mui/material'; import makeStyles from '@mui/styles/makeStyles'; import { useEffectAsync } from '../reactHelper'; @@ -35,26 +35,24 @@ const GroupsPage = () => { return ( } breadcrumbs={['settingsTitle', 'settingsGroups']}> - - - - - {t('sharedName')} - +
+ + + {t('sharedName')} + + + + + {items.map((item) => ( + + {item.name} + + + - - - {items.map((item) => ( - - {item.name} - - - - - ))} - -
-
+ ))} + +
); diff --git a/modern/src/settings/MaintenancesPage.js b/modern/src/settings/MaintenancesPage.js index 6f752b32..7569e7bf 100644 --- a/modern/src/settings/MaintenancesPage.js +++ b/modern/src/settings/MaintenancesPage.js @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import { - TableContainer, Table, TableRow, TableCell, TableHead, TableBody, + Table, TableRow, TableCell, TableHead, TableBody, } from '@mui/material'; import makeStyles from '@mui/styles/makeStyles'; import { useEffectAsync } from '../reactHelper'; @@ -58,32 +58,30 @@ const MaintenacesPage = () => { return ( } breadcrumbs={['settingsTitle', 'sharedMaintenance']}> - - - - - {t('sharedName')} - {t('sharedType')} - {t('maintenanceStart')} - {t('maintenancePeriod')} - +
+ + + {t('sharedName')} + {t('sharedType')} + {t('maintenanceStart')} + {t('maintenancePeriod')} + + + + + {items.map((item) => ( + + {item.name} + {item.type} + {convertAttribute(item.type, item.start)} + {convertAttribute(item.type, item.period)} + + + - - - {items.map((item) => ( - - {item.name} - {item.type} - {convertAttribute(item.type, item.start)} - {convertAttribute(item.type, item.period)} - - - - - ))} - -
-
+ ))} + +
); diff --git a/modern/src/settings/NotificationsPage.js b/modern/src/settings/NotificationsPage.js index 5f8c5512..bdc9857f 100644 --- a/modern/src/settings/NotificationsPage.js +++ b/modern/src/settings/NotificationsPage.js @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import { - TableContainer, Table, TableRow, TableCell, TableHead, TableBody, + Table, TableRow, TableCell, TableHead, TableBody, } from '@mui/material'; import makeStyles from '@mui/styles/makeStyles'; import { useEffectAsync } from '../reactHelper'; @@ -48,32 +48,30 @@ const NotificationsPage = () => { return ( } breadcrumbs={['settingsTitle', 'sharedNotifications']}> - - - - - {t('notificationType')} - {t('notificationAlways')} - {t('sharedAlarms')} - {t('notificationNotificators')} - +
+ + + {t('notificationType')} + {t('notificationAlways')} + {t('sharedAlarms')} + {t('notificationNotificators')} + + + + + {items.map((item) => ( + + {t(prefixString('event', item.type))} + {formatBoolean(item.always, t)} + {formatList('alarm', item.attributes.alarms)} + {formatList('notificator', item.notificators)} + + + - - - {items.map((item) => ( - - {t(prefixString('event', item.type))} - {formatBoolean(item.always, t)} - {formatList('alarm', item.attributes.alarms)} - {formatList('notificator', item.notificators)} - - - - - ))} - -
-
+ ))} + +
); diff --git a/modern/src/settings/UsersPage.js b/modern/src/settings/UsersPage.js index adbbcbda..ad755936 100644 --- a/modern/src/settings/UsersPage.js +++ b/modern/src/settings/UsersPage.js @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import { - TableContainer, Table, TableRow, TableCell, TableHead, TableBody, + Table, TableRow, TableCell, TableHead, TableBody, } from '@mui/material'; import makeStyles from '@mui/styles/makeStyles'; import { useEffectAsync } from '../reactHelper'; @@ -36,32 +36,30 @@ const UsersPage = () => { return ( } breadcrumbs={['settingsTitle', 'settingsUsers']}> - - - - - {t('sharedName')} - {t('userEmail')} - {t('userAdmin')} - {t('sharedDisabled')} - +
+ + + {t('sharedName')} + {t('userEmail')} + {t('userAdmin')} + {t('sharedDisabled')} + + + + + {items.map((item) => ( + + {item.name} + {item.email} + {formatBoolean(item.administrator, t)} + {formatBoolean(item.disabled, t)} + + + - - - {items.map((item) => ( - - {item.name} - {item.email} - {formatBoolean(item.administrator, t)} - {formatBoolean(item.disabled, t)} - - - - - ))} - -
-
+ ))} + +
); -- cgit v1.2.3