diff options
Diffstat (limited to 'modern/src/reports')
-rw-r--r-- | modern/src/reports/RouteReportPage.js | 6 | ||||
-rw-r--r-- | modern/src/reports/StopReportPage.js | 80 |
2 files changed, 61 insertions, 25 deletions
diff --git a/modern/src/reports/RouteReportPage.js b/modern/src/reports/RouteReportPage.js index b29fb269..33bc9350 100644 --- a/modern/src/reports/RouteReportPage.js +++ b/modern/src/reports/RouteReportPage.js @@ -13,7 +13,7 @@ import PositionValue from '../common/components/PositionValue'; import ColumnSelect from './components/ColumnSelect'; import usePositionAttributes from '../common/attributes/usePositionAttributes'; import { useCatch } from '../reactHelper'; -import Map from '../map/core/Map'; +import MapView from '../map/core/MapView'; import MapRoutePath from '../map/MapRoutePath'; import MapPositions from '../map/MapPositions'; import useReportStyles from './common/useReportStyles'; @@ -52,10 +52,10 @@ const RouteReportPage = () => { <div className={classes.container}> {selectedItem && ( <div className={classes.containerMap}> - <Map> + <MapView> <MapRoutePath positions={items} /> <MapPositions positions={[selectedItem]} /> - </Map> + </MapView> </div> )} <div className={classes.containerMain}> diff --git a/modern/src/reports/StopReportPage.js b/modern/src/reports/StopReportPage.js index d2823b06..d44e2046 100644 --- a/modern/src/reports/StopReportPage.js +++ b/modern/src/reports/StopReportPage.js @@ -1,7 +1,10 @@ import React, { useState } from 'react'; import { + IconButton, Table, TableBody, TableCell, TableHead, TableRow, } from '@mui/material'; +import GpsFixedIcon from '@mui/icons-material/GpsFixed'; +import LocationSearchingIcon from '@mui/icons-material/LocationSearching'; import { formatDistance, formatHours, formatDate, formatVolume, } from '../common/util/formatter'; @@ -14,6 +17,9 @@ import ColumnSelect from './components/ColumnSelect'; import usePersistedState from '../common/util/usePersistedState'; import { useCatch } from '../reactHelper'; import useReportStyles from './common/useReportStyles'; +import MapPositions from '../map/MapPositions'; +import MapView from '../map/core/MapView'; +import MapCamera from '../map/MapCamera'; const columnsArray = [ ['startTime', 'reportStartTime'], @@ -35,6 +41,7 @@ const StopReportPage = () => { const [columns, setColumns] = usePersistedState('stopColumns', ['startTime', 'endTime', 'startOdometer', 'address']); const [items, setItems] = useState([]); + const [selectedItem, setSelectedItem] = useState(null); const handleSubmit = useCatch(async (deviceId, from, to, mail, headers) => { const query = new URLSearchParams({ @@ -75,29 +82,58 @@ const StopReportPage = () => { return ( <PageLayout menu={<ReportsMenu />} breadcrumbs={['reportTitle', 'reportStops']}> - <div className={classes.header}> - <ReportFilter handleSubmit={handleSubmit}> - <ColumnSelect columns={columns} setColumns={setColumns} columnsArray={columnsArray} /> - </ReportFilter> - </div> - <Table> - <TableHead> - <TableRow> - {columns.map((key) => (<TableCell key={key}>{t(columnsMap.get(key))}</TableCell>))} - </TableRow> - </TableHead> - <TableBody> - {items.map((item) => ( - <TableRow key={item.positionId}> - {columns.map((key) => ( - <TableCell key={key}> - {formatValue(item, key)} - </TableCell> + <div className={classes.container}> + {selectedItem && ( + <div className={classes.containerMap}> + <MapView> + <MapPositions positions={[{ + deviceId: selectedItem.deviceId, + latitude: selectedItem.latitude, + longitude: selectedItem.longitude, + }]} + /> + </MapView> + <MapCamera latitude={selectedItem.latitude} longitude={selectedItem.longitude} /> + </div> + )} + <div className={classes.containerMain}> + <div className={classes.header}> + <ReportFilter handleSubmit={handleSubmit}> + <ColumnSelect columns={columns} setColumns={setColumns} columnsArray={columnsArray} /> + </ReportFilter> + </div> + <Table> + <TableHead> + <TableRow> + <TableCell className={classes.columnAction} /> + {columns.map((key) => (<TableCell key={key}>{t(columnsMap.get(key))}</TableCell>))} + </TableRow> + </TableHead> + <TableBody> + {items.map((item) => ( + <TableRow key={item.positionId}> + <TableCell className={classes.columnAction} padding="none"> + {selectedItem === item ? ( + <IconButton size="small" onClick={() => setSelectedItem(null)}> + <GpsFixedIcon fontSize="small" /> + </IconButton> + ) : ( + <IconButton size="small" onClick={() => setSelectedItem(item)}> + <LocationSearchingIcon fontSize="small" /> + </IconButton> + )} + </TableCell> + {columns.map((key) => ( + <TableCell key={key}> + {formatValue(item, key)} + </TableCell> + ))} + </TableRow> ))} - </TableRow> - ))} - </TableBody> - </Table> + </TableBody> + </Table> + </div> + </div> </PageLayout> ); }; |