From 8de3b938369ea1e9437b4345d83a50e974f8a606 Mon Sep 17 00:00:00 2001 From: Ashutosh Bishnoi Date: Mon, 15 Mar 2021 14:32:28 +0530 Subject: Initial draft of cutome route table --- modern/package.json | 1 + modern/src/reports/RouteReportPage.js | 77 +++++++++++++++++++++++------------ 2 files changed, 52 insertions(+), 26 deletions(-) diff --git a/modern/package.json b/modern/package.json index 2c30c9fd..a2493f3a 100644 --- a/modern/package.json +++ b/modern/package.json @@ -6,6 +6,7 @@ "@craco/craco": "^5.6.4", "@mapbox/mapbox-gl-draw": "^1.2.0", "@material-ui/core": "^4.11.0", + "@material-ui/data-grid": "^4.0.0-alpha.22", "@material-ui/icons": "^4.9.1", "@material-ui/lab": "^4.0.0-alpha.56", "@reduxjs/toolkit": "^1.4.0", diff --git a/modern/src/reports/RouteReportPage.js b/modern/src/reports/RouteReportPage.js index f2b03616..ff4a0033 100644 --- a/modern/src/reports/RouteReportPage.js +++ b/modern/src/reports/RouteReportPage.js @@ -1,9 +1,10 @@ import React, { useState } from 'react'; -import { TableContainer, Table, TableRow, TableCell, TableHead, TableBody, Paper } from '@material-ui/core'; +import { DataGrid } from '@material-ui/data-grid'; import t from '../common/localization'; -import { formatPosition } from '../common/formatter'; +import { formatPosition, formatDistance } from '../common/formatter'; import ReportFilter from './ReportFilter'; import ReportLayoutPage from './ReportLayoutPage'; +import { useAttributePreference } from '../common/preferences'; const Filter = ({ setItems }) => { @@ -26,35 +27,59 @@ const Filter = ({ setItems }) => { }; const RouteReportPage = () => { + const distanceUnit = useAttributePreference('distanceUnit'); + + const columns = [ + { + headerName: t('positionFixTime'), + field: 'fixTime', + width: 200, + valueFormatter: params => formatPosition(params.value, 'fixTime'), + }, + { + headerName: t('positionLatitude'), + field: 'latitude', + width: 130, + valueFormatter: params => formatPosition(params.value, 'latitude'), + }, + { + headerName: t('positionLongitude'), + field: 'longitude', + width: 130, + valueFormatter: params => formatPosition(params.value, 'longitude'), + }, + { + headerName: t('positionSpeed'), + field: 'speed', + width: 130, + valueFormatter: params => formatPosition(params.value, 'speed'), + }, + { + headerName: t('positionAddress'), + field: 'address', + width: 130, + valueFormatter: params => formatPosition(params.value, 'address'), + }, + { + headerName: t('positionIgnition'), + field: 'ignition', + width: 130, + valueFormatter: params => params.getValue('attributes').ignition ? 'Yes' : 'No', + }, + { + headerName: t('deviceTotalDistance'), + hide: true, + field: 'totalDistance', + width: 160, + valueFormatter: params => formatDistance(params.getValue('attributes').totalDistance, distanceUnit), + }, + ] const [items, setItems] = useState([]); return ( }> - - - - - {t('positionFixTime')} - {t('positionLatitude')} - {t('positionLongitude')} - {t('positionSpeed')} - {t('positionAddress')} - - - - {items.map((item) => ( - - {formatPosition(item, 'fixTime')} - {formatPosition(item, 'latitude')} - {formatPosition(item, 'longitude')} - {formatPosition(item, 'speed')} - {formatPosition(item, 'address')} - - ))} - -
-
+
); }; -- cgit v1.2.3