This commit is contained in:
Charles
2022-06-01 16:44:07 +01:00
parent ebd2419634
commit c3574d96d7
19 changed files with 674 additions and 129 deletions

View File

@@ -4,7 +4,7 @@ import { CSpinner } from '@coreui/react';
import { useTranslation } from 'react-i18next';
import { v4 as createUuid } from 'uuid';
import axiosInstance from 'utils/axiosInstance';
import { useAuth, useDevice } from 'ucentral-libs';
import { useAuth } from 'ucentral-libs';
import {
capitalizeFirstLetter,
datesSameDay,
@@ -14,11 +14,10 @@ import {
} from 'utils/helper';
import DeviceStatisticsChart from './DeviceStatisticsChart';
const StatisticsChartList = ({ setOptions, section, setStart, setEnd, time }) => {
const StatisticsChartList = ({ deviceSerialNumber, setOptions, section, time }) => {
const { t } = useTranslation();
const [loading, setLoading] = useState(false);
const { currentToken, endpoints } = useAuth();
const { deviceSerialNumber } = useDevice();
const [statOptions, setStatOptions] = useState({
interfaceList: [],
memory: [],
@@ -244,10 +243,6 @@ const StatisticsChartList = ({ setOptions, section, setStart, setEnd, time }) =>
}));
setOptions([...sectionOptions, { value: 'memory', label: t('statistics.memory') }]);
setStatOptions({ ...newOptions });
if (sortedData.length > 0) {
setStart(new Date(sortedData[0].recorded * 1000));
setEnd(new Date(sortedData[sortedData.length - 1].recorded * 1000));
}
}
};
@@ -358,11 +353,10 @@ const StatisticsChartList = ({ setOptions, section, setStart, setEnd, time }) =>
};
StatisticsChartList.propTypes = {
deviceSerialNumber: PropTypes.string.isRequired,
setOptions: PropTypes.func.isRequired,
section: PropTypes.string.isRequired,
time: PropTypes.instanceOf(Object).isRequired,
setStart: PropTypes.func.isRequired,
setEnd: PropTypes.func.isRequired,
};
export default React.memo(StatisticsChartList);