From 37ff59bbdc540bf2293a96ecbedcf210f6b4548a Mon Sep 17 00:00:00 2001 From: Ashutosh Bishnoi Date: Sat, 14 Nov 2020 09:02:34 +0530 Subject: Adding DailySummary param to summary report and minor code improvements --- modern/src/App.js | 2 -- modern/src/MainToolbar.js | 6 ------ modern/src/common/formatter.js | 2 -- modern/src/reports/SummaryReportPage.js | 13 +++++++++++-- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/modern/src/App.js b/modern/src/App.js index c54e6485..8a308c17 100644 --- a/modern/src/App.js +++ b/modern/src/App.js @@ -21,7 +21,6 @@ import { LinearProgress } from '@material-ui/core'; import TripReportPage from './reports/TripReportPage'; import StopReportPage from './reports/StopReportPage'; import SummaryReportPage from './reports/SummaryReportPage'; -import DailySummaryReportPage from './reports/DailySummaryReportPage'; const App = () => { const initialized = useSelector(state => !!state.session.server && !!state.session.user); @@ -51,7 +50,6 @@ const App = () => { - )} diff --git a/modern/src/MainToolbar.js b/modern/src/MainToolbar.js index a2a9c9fb..a8999500 100644 --- a/modern/src/MainToolbar.js +++ b/modern/src/MainToolbar.js @@ -140,12 +140,6 @@ const MainToolbar = () => { - - history.push('/reports/daily-summary')}> - - - - diff --git a/modern/src/common/formatter.js b/modern/src/common/formatter.js index 72216186..e41e591e 100644 --- a/modern/src/common/formatter.js +++ b/modern/src/common/formatter.js @@ -9,8 +9,6 @@ export const formatPosition = (value, key) => { case 'fixTime': case 'deviceTime': case 'serverTime': - case 'startTime': - case 'endTime': return moment(value).format('LLL'); case 'latitude': case 'longitude': diff --git a/modern/src/reports/SummaryReportPage.js b/modern/src/reports/SummaryReportPage.js index e482d0fa..c90ddb4a 100644 --- a/modern/src/reports/SummaryReportPage.js +++ b/modern/src/reports/SummaryReportPage.js @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { TableContainer, Table, TableRow, TableCell, TableHead, TableBody, Paper } from '@material-ui/core'; +import { TableContainer, Table, TableRow, TableCell, TableHead, TableBody, Paper, FormControlLabel, Checkbox } from '@material-ui/core'; import t from '../common/localization'; import { formatDistance, formatHours, formatDate, formatSpeed, formatVolume } from '../common/formatter'; import ReportFilter from './ReportFilter'; @@ -8,18 +8,27 @@ import { useAttributePreference } from '../common/preferences'; const ReportFilterForm = ({ onResult }) => { + const [daily, setDaily] = useState(false); + const handleSubmit = async (deviceId, from, to) => { const query = new URLSearchParams({ deviceId, from: from.toISOString(), to: to.toISOString(), + daily }); const response = await fetch(`/api/reports/summary?${query.toString()}`, { headers: { Accept: 'application/json' } }); if (response.ok) { onResult(await response.json()); } } - return ; + return ( + + setDaily(event.target.checked)} />} + label={t('reportDaily')} /> + + ); } const SummaryReportPage = () => { -- cgit v1.2.3