diff --git a/modern/src/reports/RouteReportPage.js b/modern/src/reports/RouteReportPage.js index 5003ff3117..27b4db1848 100644 --- a/modern/src/reports/RouteReportPage.js +++ b/modern/src/reports/RouteReportPage.js @@ -2,10 +2,14 @@ import React, { Fragment, useCallback, useState } from 'react'; import { useSelector } from 'react-redux'; import { useNavigate } from 'react-router-dom'; import { - IconButton, Table, TableBody, TableCell, TableHead, TableRow, + IconButton, Skeleton, } from '@mui/material'; import GpsFixedIcon from '@mui/icons-material/GpsFixed'; import LocationSearchingIcon from '@mui/icons-material/LocationSearching'; +import useMediaQuery from '@mui/material/useMediaQuery'; +import { useTheme } from '@mui/material/styles'; +import AutoSizer from 'react-virtualized-auto-sizer'; +import { FixedSizeGrid } from 'react-window'; import ReportFilter from './components/ReportFilter'; import { useTranslation } from '../common/components/LocalizationProvider'; import PageLayout from '../common/components/PageLayout'; @@ -19,7 +23,6 @@ import MapRoutePath from '../map/MapRoutePath'; import MapRoutePoints from '../map/MapRoutePoints'; import MapPositions from '../map/MapPositions'; import useReportStyles from './common/useReportStyles'; -import TableShimmer from '../common/components/TableShimmer'; import MapCamera from '../map/MapCamera'; import MapGeofence from '../map/MapGeofence'; import scheduleReport from './common/scheduleReport'; @@ -28,6 +31,10 @@ const RouteReportPage = () => { const navigate = useNavigate(); const classes = useReportStyles(); const t = useTranslation(); + const theme = useTheme(); + + const phone = useMediaQuery(theme.breakpoints.down('md')); + const desktop = useMediaQuery(theme.breakpoints.up('lg')); const positionAttributes = usePositionAttributes(t); @@ -116,7 +123,7 @@ const RouteReportPage = () => { )} -
+
{ />
- - - - - {t('sharedDevice')} - {columns.map((key) => ({positionAttributes[key]?.name || key}))} - - - - {!loading ? items.slice(0, 4000).map((item) => ( - - - {selectedItem === item ? ( - setSelectedItem(null)}> - - - ) : ( - setSelectedItem(item)}> - - - )} - - {devices[item.deviceId].name} - {columns.map((key) => ( - - - - ))} - - )) : ()} - -
+
+ + {({ height, width }) => ( + = width ? + width * (phone ? 0.26 : desktop ? 0.1 : 0.18) : width / (columns.length + 2)} + rowCount={items.length > 0 ? items.length : 5} + rowHeight={52} + overscanRowCount={20} + > + {({ columnIndex, rowIndex, style }) => { + const item = items[rowIndex]; + const columnKey = columns[columnIndex - 2]; + return ( + rowIndex === 0 ? + columnIndex === 0 ? + ( +
+ ) + : + columnIndex === 1 ? + ( +
+ {t('sharedDevice')} +
+ ) : + columnIndex < columns.length + 2 ? + ( +
+ {positionAttributes[columnKey]?.name || columnKey} +
+ ) + : + null + : + !loading ? + item ? + columnIndex === 0 ? + ( +
+ {selectedItem === item ? + ( + setSelectedItem(null)}> + + + ) + : + ( + setSelectedItem(item)}> + + + )} +
+ ) + : + columnIndex === 1 ? + ( +
+ {devices[item.deviceId].name} +
+ ) + : + ( +
+ +
+ ) + : + null + : + ( +
+ +
+ ) + ); + }} + + )} + +
diff --git a/modern/src/reports/common/useReportStyles.js b/modern/src/reports/common/useReportStyles.js index e09c86959b..255d2b8bb0 100644 --- a/modern/src/reports/common/useReportStyles.js +++ b/modern/src/reports/common/useReportStyles.js @@ -46,4 +46,10 @@ export default makeStyles((theme) => ({ flexGrow: 1, overflow: 'hidden', }, + cellStyle: { + display: 'flex', + alignItems: 'center', + padding: '5px', + borderBottom: '1px solid lightgrey', + }, }));