From df01e1d751980843506946a194fa9f67489182b1 Mon Sep 17 00:00:00 2001 From: Ashutosh Bishnoi Date: Fri, 20 Nov 2020 13:56:14 +0530 Subject: Implementing chart report initial structure --- modern/src/reports/ChartReportPage.js | 74 +++++++++++++++++++++++++++++++++++ modern/src/reports/ChartType.js | 53 +++++++++++++++++++++++++ 2 files changed, 127 insertions(+) create mode 100644 modern/src/reports/ChartReportPage.js create mode 100644 modern/src/reports/ChartType.js (limited to 'modern/src/reports') diff --git a/modern/src/reports/ChartReportPage.js b/modern/src/reports/ChartReportPage.js new file mode 100644 index 00000000..68989331 --- /dev/null +++ b/modern/src/reports/ChartReportPage.js @@ -0,0 +1,74 @@ +import React, { useState } from 'react'; +import { Card, CardHeader, CardContent } from '@material-ui/core'; +import { Box, Divider } from '@material-ui/core'; +import { makeStyles } from '@material-ui/core/styles'; +import ReportFilter from './ReportFilter'; +import ReportLayoutPage from './ReportLayoutPage'; +import ChartType from './ChartType'; + +import {LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts'; + +const useStyles = makeStyles((theme) => ({ + formControl: { + minWidth: 160, + }, +})); + +const ReportFilterForm = ({ setItems }) => { + + const handleSubmit = async (deviceId, from, to, mail, headers) => { + const query = new URLSearchParams({ deviceId, from, to, mail }); + const response = await fetch(`/api/reports/route?${query.toString()}`, { headers }); + if (response.ok) { + const contentType = response.headers.get('content-type'); + if (contentType) { + if (contentType === 'application/json') { + setItems(await response.json()); + } else { + window.location.assign(window.URL.createObjectURL(await response.blob())); + } + } + } + }; + + return ; +}; + +const CustomizedAxisTick = ({ x, y, stroke, payload }) =>{ + return ( + + {payload.value} + + ); +} + +const ChartReportPage = () => { + + const [items, setItems] = useState([]); + const [type, setType] = useState('speed'); + + return ( + + + } /> + + + + + + } /> + + + + + + + + + + + + ); +} + +export default ChartReportPage; diff --git a/modern/src/reports/ChartType.js b/modern/src/reports/ChartType.js new file mode 100644 index 00000000..586ea88a --- /dev/null +++ b/modern/src/reports/ChartType.js @@ -0,0 +1,53 @@ +import React from 'react'; +import { FormControl, Select, MenuItem } from '@material-ui/core'; +import { makeStyles } from '@material-ui/core/styles'; +import t from '../common/localization'; + +const useStyles = makeStyles((theme) => ({ + formControl: { + minWidth: 160, + }, +})); + +const ChartType = ({ type, setType }) => { + const classes = useStyles(); + + return ( + + + + ); +} + +export default ChartType; -- cgit v1.2.3