From 449e5e3190d22704a2cb4d7c5ce3e90eaaf16153 Mon Sep 17 00:00:00 2001 From: Ashutosh Bishnoi Date: Sun, 8 Nov 2020 12:15:17 +0530 Subject: Report Layout Unification with seperate report layout component --- modern/src/reports/RouteReportPage.js | 116 +++++++++++++--------------------- 1 file changed, 45 insertions(+), 71 deletions(-) (limited to 'modern/src/reports/RouteReportPage.js') diff --git a/modern/src/reports/RouteReportPage.js b/modern/src/reports/RouteReportPage.js index 7d34c177..30272c49 100644 --- a/modern/src/reports/RouteReportPage.js +++ b/modern/src/reports/RouteReportPage.js @@ -1,85 +1,59 @@ import React, { useState } from 'react'; -import MainToolbar from '../MainToolbar'; -import { Grid, TableContainer, Table, TableRow, TableCell, TableHead, TableBody, Paper, makeStyles, FormControl, InputLabel, Select, MenuItem, Button, TextField } from '@material-ui/core'; +import { TableContainer, Table, TableRow, TableCell, TableHead, TableBody, Paper } from '@material-ui/core'; import t from '../common/localization'; import { formatPosition } from '../common/formatter'; import ReportFilter from './ReportFilter'; - -const useStyles = makeStyles(theme => ({ - root: { - height: '100%', - display: 'flex', - flexDirection: 'column', - }, - content: { - flex: 1, - overflow: 'auto', - padding: theme.spacing(2), - }, - form: { - padding: theme.spacing(1, 2, 2), - }, -})); +import ReportView from './ReportView'; const RouteReportPage = () => { - const classes = useStyles(); - const [data, setData] = useState([]); - const handleSubmit = async (deviceId, from, to) => { - const query = new URLSearchParams({ - deviceId, - from: from.toISOString(), - to: to.toISOString(), - }); + const ReportFilterForm = ({ onResult }) => { - const response = await fetch(`/api/reports/route?${query.toString()}`, { headers: { Accept: 'application/json' } }) - - if(response.ok) { - const data = await response.json(); - setData(data); + const handleSubmit = async (deviceId, from, to) => { + const query = new URLSearchParams({ + deviceId, + from: from.toISOString(), + to: to.toISOString(), + }); + const response = await fetch(`/api/reports/route?${query.toString()}`, { headers: { Accept: 'application/json' } }); + if(response.ok) { + onResult(await response.json()); + } } + return ; + } + + const ReportListView = ({items}) => { + + 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')} + + ))} + +
+
+ ); } - return ( -
- -
- - - - - - - - - - - - {t('positionFixTime')} - {t('positionLatitude')} - {t('positionLongitude')} - {t('positionSpeed')} - {t('positionAddress')} - - - - {data.map((item) => ( - - {formatPosition(item, 'fixTime')} - {formatPosition(item, 'latitude')} - {formatPosition(item, 'longitude')} - {formatPosition(item, 'speed')} - {formatPosition(item, 'address')} - - ))} - -
-
-
-
-
-
- ); + return ; } export default RouteReportPage; -- cgit v1.2.3