Merge pull request #52 from stephb9959/feature/32-statistics

Feature/32 statistics
This commit is contained in:
Charles
2021-05-31 19:40:32 -04:00
committed by GitHub
3 changed files with 25 additions and 24 deletions

View File

@@ -3,7 +3,7 @@ import { CFooter } from '@coreui/react';
const TheFooter = () => ( const TheFooter = () => (
<CFooter fixed={false}> <CFooter fixed={false}>
<div>Version 0.0.6</div> <div>Version 0.0.7</div>
<div className="mfs-auto"> <div className="mfs-auto">
<span className="mr-1">Powered by</span> <span className="mr-1">Powered by</span>
<a href="https://coreui.io/react" target="_blank" rel="noopener noreferrer"> <a href="https://coreui.io/react" target="_blank" rel="noopener noreferrer">

View File

@@ -3,12 +3,12 @@ import PropTypes from 'prop-types';
import Chart from 'react-apexcharts' import Chart from 'react-apexcharts'
const DeviceStatisticsChart = ({ data, options }) => ( const DeviceStatisticsChart = ({ data, options }) => (
<div> <div style={{height: '360px'}}>
<Chart <Chart
series={data} series={data}
options={options} options={options}
type='line' type='line'
height={360} height='100%'
/> />
</div> </div>
); );

View File

@@ -97,28 +97,29 @@ const StatisticsChartList = ({ selectedDeviceId, lastRefresh }) => {
} }
const getStatistics = () => { const getStatistics = () => {
if (loading) return; if (!loading){
setLoading(true); setLoading(true);
const options = { const options = {
headers: { headers: {
Accept: 'application/json', Accept: 'application/json',
Authorization: `Bearer ${getToken()}`, Authorization: `Bearer ${getToken()}`,
}, },
params: { params: {
serialNumber: "24f5a207a130" serialNumber: "24f5a207a130"
} }
}; };
axiosInstance axiosInstance
.get(`/device/${selectedDeviceId}/statistics?newest=true&limit=50`, options) .get(`/device/${selectedDeviceId}/statistics?newest=true&limit=50`, options)
.then((response) => { .then((response) => {
transformIntoDataset(response.data.data); transformIntoDataset(response.data.data);
}) })
.catch(() => {}) .catch(() => {})
.finally(() => { .finally(() => {
setLoading(false); setLoading(false);
}); });
}
}; };
useEffect(() => { useEffect(() => {