From b0e3a32b65d7485b43befb1feec173f2a575fcd0 Mon Sep 17 00:00:00 2001 From: Ashutosh Bishnoi Date: Mon, 9 Nov 2020 12:30:41 +0530 Subject: Minor Report Layout Modifications --- modern/src/reports/EventReportPage.js | 100 ++++++++++++++++----------------- modern/src/reports/ReportLayoutPage.js | 46 +++++++++++++++ modern/src/reports/ReportView.js | 47 ---------------- modern/src/reports/RouteReportPage.js | 41 +++++++------- 4 files changed, 114 insertions(+), 120 deletions(-) create mode 100644 modern/src/reports/ReportLayoutPage.js delete mode 100644 modern/src/reports/ReportView.js (limited to 'modern/src') diff --git a/modern/src/reports/EventReportPage.js b/modern/src/reports/EventReportPage.js index cb3a06aa..e9bca4ef 100644 --- a/modern/src/reports/EventReportPage.js +++ b/modern/src/reports/EventReportPage.js @@ -4,57 +4,57 @@ import { FormControl, InputLabel, Select, MenuItem } from '@material-ui/core'; import t from '../common/localization'; import { formatPosition } from '../common/formatter'; import ReportFilter from './ReportFilter'; -import ReportView from './ReportView'; +import ReportLayoutPage from './ReportLayoutPage'; -const EventReportPage = () => { +const ReportFilterForm = ({ onResult }) => { + const [eventType, setEventType] = useState(['allEvents']); - const ReportFilterForm = ({ onResult }) => { - const [eventType, setEventType] = useState(['allEvents']); + const handleSubmit = async (deviceId, from, to) => { + const query = new URLSearchParams({ + deviceId, + from: from.toISOString(), + to: to.toISOString(), + }); + eventType.map(t=>query.append('type',t)); + const response = await fetch(`/api/reports/events?${query.toString()}`, { headers: { Accept: 'application/json' } }); + if(response.ok) { + onResult(await response.json()); + } + } + return ( + + + {t('reportEventTypes')} + + + + ); +} - const handleSubmit = async (deviceId, from, to) => { - const query = new URLSearchParams({ - deviceId, - from: from.toISOString(), - to: to.toISOString(), - }); - eventType.map(t=>query.append('type',t)); - const response = await fetch(`/api/reports/events?${query.toString()}`, { headers: { Accept: 'application/json' } }); - if(response.ok) { - onResult(await response.json()); - } - } - return ( - - - {t('reportEventTypes')} - - - - ); - } +const EventReportPage = () => { + const [items, setItems] = useState([]); - const ReportListView = ({items}) => { - - return ( + return ( + @@ -79,10 +79,8 @@ const EventReportPage = () => {
- ); - } - - return ; +
+ ); } export default EventReportPage; diff --git a/modern/src/reports/ReportLayoutPage.js b/modern/src/reports/ReportLayoutPage.js new file mode 100644 index 00000000..57a2cefd --- /dev/null +++ b/modern/src/reports/ReportLayoutPage.js @@ -0,0 +1,46 @@ +import React, { useState } from 'react'; +import { Grid, Paper, makeStyles } from '@material-ui/core'; +import MainToolbar from '../MainToolbar'; + +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), + }, +})); + +const ReportLayoutPage = ({ reportFilterForm:ReportFilterForm, setItems, ...rest }) => { + const classes = useStyles(); + + const onResult = (data) => { + setItems(data); + } + return ( +
+ +
+ + + + + + + + {rest.children} + + +
+
+ ); +} + +export default ReportLayoutPage; diff --git a/modern/src/reports/ReportView.js b/modern/src/reports/ReportView.js deleted file mode 100644 index 249ef724..00000000 --- a/modern/src/reports/ReportView.js +++ /dev/null @@ -1,47 +0,0 @@ -import React, { useState } from 'react'; -import { Grid, Paper, makeStyles } from '@material-ui/core'; -import MainToolbar from '../MainToolbar'; - -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), - }, -})); - -const ReportView= ({ reportFilterForm:ReportFilterForm, reportListView:ReportListView }) => { - const classes = useStyles(); - const [data, setData] = useState([]); - - const onResult = (data) => { - setData(data); - } - return ( -
- -
- - - - - - - - - - -
-
- ); -} - -export default ReportView; diff --git a/modern/src/reports/RouteReportPage.js b/modern/src/reports/RouteReportPage.js index 30272c49..0f8d98ab 100644 --- a/modern/src/reports/RouteReportPage.js +++ b/modern/src/reports/RouteReportPage.js @@ -3,29 +3,28 @@ import { TableContainer, Table, TableRow, TableCell, TableHead, TableBody, Paper import t from '../common/localization'; import { formatPosition } from '../common/formatter'; import ReportFilter from './ReportFilter'; -import ReportView from './ReportView'; +import ReportLayoutPage from './ReportLayoutPage'; -const RouteReportPage = () => { - - const ReportFilterForm = ({ onResult }) => { +const ReportFilterForm = ({ onResult }) => { - 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()); - } + 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 ; } + return ; +} - const ReportListView = ({items}) => { - - return ( +const RouteReportPage = () => { + const [items, setItems] = useState([]); + return ( + @@ -50,10 +49,8 @@ const RouteReportPage = () => {
- ); - } - - return ; +
+ ); } export default RouteReportPage; -- cgit v1.2.3