mirror of
https://github.com/optim-enterprises-bv/OptimCloud-gw-ui.git
synced 2025-10-30 17:57:46 +00:00
Version 2.5.24
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "ucentral-client",
|
"name": "ucentral-client",
|
||||||
"version": "2.5.23",
|
"version": "2.5.24",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "ucentral-client",
|
"name": "ucentral-client",
|
||||||
"version": "2.5.23",
|
"version": "2.5.24",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@coreui/coreui": "^3.4.0",
|
"@coreui/coreui": "^3.4.0",
|
||||||
"@coreui/icons": "^2.0.1",
|
"@coreui/icons": "^2.0.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ucentral-client",
|
"name": "ucentral-client",
|
||||||
"version": "2.5.23",
|
"version": "2.5.24",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@coreui/coreui": "^3.4.0",
|
"@coreui/coreui": "^3.4.0",
|
||||||
"@coreui/icons": "^2.0.1",
|
"@coreui/icons": "^2.0.1",
|
||||||
|
|||||||
@@ -5,10 +5,16 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { v4 as createUuid } from 'uuid';
|
import { v4 as createUuid } from 'uuid';
|
||||||
import axiosInstance from 'utils/axiosInstance';
|
import axiosInstance from 'utils/axiosInstance';
|
||||||
import { useAuth, useDevice } from 'ucentral-libs';
|
import { useAuth, useDevice } from 'ucentral-libs';
|
||||||
import { capitalizeFirstLetter, dateToUnix, prettyDate } from 'utils/helper';
|
import {
|
||||||
|
capitalizeFirstLetter,
|
||||||
|
datesSameDay,
|
||||||
|
dateToUnix,
|
||||||
|
prettyDate,
|
||||||
|
unixToTime,
|
||||||
|
} from 'utils/helper';
|
||||||
import DeviceStatisticsChart from './DeviceStatisticsChart';
|
import DeviceStatisticsChart from './DeviceStatisticsChart';
|
||||||
|
|
||||||
const StatisticsChartList = ({ setOptions, section, start, end, setStart, setEnd, refreshId }) => {
|
const StatisticsChartList = ({ setOptions, section, setStart, setEnd, time }) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const { currentToken, endpoints } = useAuth();
|
const { currentToken, endpoints } = useAuth();
|
||||||
@@ -25,20 +31,18 @@ const StatisticsChartList = ({ setOptions, section, start, end, setStart, setEnd
|
|||||||
if (b.recorded > a.recorded) return -1;
|
if (b.recorded > a.recorded) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
const dataLength = sortedData.length;
|
const dataLength = sortedData.length;
|
||||||
|
|
||||||
console.log(dataLength);
|
|
||||||
|
|
||||||
if (dataLength > 1000 && dataLength < 3000) {
|
if (dataLength > 1000 && dataLength < 3000) {
|
||||||
sortedData = sortedData.filter((dat, index) => index % 4 === 0);
|
sortedData = sortedData.filter((dat, index) => index % 4 === 0);
|
||||||
} else if (dataLength >= 3000 && dataLength < 5000) {
|
} else if (dataLength >= 3000 && dataLength < 5000) {
|
||||||
sortedData = sortedData.filter((dat, index) => index % 6 === 0);
|
|
||||||
} else if (dataLength >= 5000 && dataLength < 7000) {
|
|
||||||
sortedData = sortedData.filter((dat, index) => index % 8 === 0);
|
sortedData = sortedData.filter((dat, index) => index % 8 === 0);
|
||||||
|
} else if (dataLength >= 5000 && dataLength < 7000) {
|
||||||
|
sortedData = sortedData.filter((dat, index) => index % 12 === 0);
|
||||||
|
} else if (dataLength > 7000) {
|
||||||
|
sortedData = sortedData.filter((dat, index) => index % 20 === 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(sortedData.length);
|
|
||||||
|
|
||||||
// Looping through data to build our memory graph data
|
// Looping through data to build our memory graph data
|
||||||
const memoryUsed = [
|
const memoryUsed = [
|
||||||
{
|
{
|
||||||
@@ -77,10 +81,14 @@ const StatisticsChartList = ({ setOptions, section, start, end, setStart, setEnd
|
|||||||
const interfaceList = [];
|
const interfaceList = [];
|
||||||
const categories = [];
|
const categories = [];
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
const areSameDay = datesSameDay(
|
||||||
|
new Date(sortedData[0].recorded * 1000),
|
||||||
|
new Date(sortedData[sortedData.length - 1].recorded * 1000),
|
||||||
|
);
|
||||||
|
|
||||||
// Just building the array for all the interfaces
|
// Just building the array for all the interfaces
|
||||||
for (const log of sortedData) {
|
for (const log of sortedData) {
|
||||||
categories.push(prettyDate(log.recorded));
|
categories.push(areSameDay ? unixToTime(log.recorded) : prettyDate(log.recorded));
|
||||||
for (const logInterface of log.data.interfaces) {
|
for (const logInterface of log.data.interfaces) {
|
||||||
if (interfaceTypes[logInterface.name] === undefined) {
|
if (interfaceTypes[logInterface.name] === undefined) {
|
||||||
interfaceTypes[logInterface.name] = i;
|
interfaceTypes[logInterface.name] = i;
|
||||||
@@ -133,7 +141,7 @@ const StatisticsChartList = ({ setOptions, section, start, end, setStart, setEnd
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
categories,
|
categories,
|
||||||
tickAmount: 20,
|
tickAmount: areSameDay ? 15 : 10,
|
||||||
},
|
},
|
||||||
yaxis: {
|
yaxis: {
|
||||||
labels: {
|
labels: {
|
||||||
@@ -161,6 +169,7 @@ const StatisticsChartList = ({ setOptions, section, start, end, setStart, setEnd
|
|||||||
curve: 'smooth',
|
curve: 'smooth',
|
||||||
},
|
},
|
||||||
xaxis: {
|
xaxis: {
|
||||||
|
tickAmount: areSameDay ? 15 : 10,
|
||||||
title: {
|
title: {
|
||||||
text: 'Time',
|
text: 'Time',
|
||||||
style: {
|
style: {
|
||||||
@@ -250,9 +259,9 @@ const StatisticsChartList = ({ setOptions, section, start, end, setStart, setEnd
|
|||||||
};
|
};
|
||||||
|
|
||||||
let extraParams = '';
|
let extraParams = '';
|
||||||
if (start !== null && end !== null) {
|
if (time.start !== null && time.end !== null) {
|
||||||
const utcStart = new Date(start).toISOString();
|
const utcStart = new Date(time.start).toISOString();
|
||||||
const utcEnd = new Date(end).toISOString();
|
const utcEnd = new Date(time.end).toISOString();
|
||||||
options.params.startDate = dateToUnix(utcStart);
|
options.params.startDate = dateToUnix(utcStart);
|
||||||
options.params.endDate = dateToUnix(utcEnd);
|
options.params.endDate = dateToUnix(utcEnd);
|
||||||
options.params.limit = 10000;
|
options.params.limit = 10000;
|
||||||
@@ -276,7 +285,7 @@ const StatisticsChartList = ({ setOptions, section, start, end, setStart, setEnd
|
|||||||
if (deviceSerialNumber) {
|
if (deviceSerialNumber) {
|
||||||
getStatistics();
|
getStatistics();
|
||||||
}
|
}
|
||||||
}, [deviceSerialNumber, refreshId]);
|
}, [deviceSerialNumber, time.refreshId]);
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return (
|
return (
|
||||||
@@ -317,15 +326,9 @@ const StatisticsChartList = ({ setOptions, section, start, end, setStart, setEnd
|
|||||||
StatisticsChartList.propTypes = {
|
StatisticsChartList.propTypes = {
|
||||||
setOptions: PropTypes.func.isRequired,
|
setOptions: PropTypes.func.isRequired,
|
||||||
section: PropTypes.string.isRequired,
|
section: PropTypes.string.isRequired,
|
||||||
start: PropTypes.instanceOf(Date),
|
time: PropTypes.instanceOf(Object).isRequired,
|
||||||
end: PropTypes.instanceOf(Date),
|
|
||||||
setStart: PropTypes.func.isRequired,
|
setStart: PropTypes.func.isRequired,
|
||||||
setEnd: PropTypes.func.isRequired,
|
setEnd: PropTypes.func.isRequired,
|
||||||
refreshId: PropTypes.string.isRequired,
|
|
||||||
};
|
|
||||||
StatisticsChartList.defaultProps = {
|
|
||||||
start: null,
|
|
||||||
end: null,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default React.memo(StatisticsChartList);
|
export default React.memo(StatisticsChartList);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ const DeviceStatisticsCard = () => {
|
|||||||
const [startError, setStartError] = useState(false);
|
const [startError, setStartError] = useState(false);
|
||||||
const [end, setEnd] = useState(null);
|
const [end, setEnd] = useState(null);
|
||||||
const [endError, setEndError] = useState(false);
|
const [endError, setEndError] = useState(false);
|
||||||
const [refreshId, setRefreshId] = useState('1');
|
const [time, setTime] = useState({ refreshId: '0', start: null, end: null });
|
||||||
|
|
||||||
const toggleLatestModal = () => {
|
const toggleLatestModal = () => {
|
||||||
setShowLatestModal(!showLatestModal);
|
setShowLatestModal(!showLatestModal);
|
||||||
@@ -60,7 +60,7 @@ const DeviceStatisticsCard = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const refresh = () => {
|
const refresh = () => {
|
||||||
setRefreshId(createUuid());
|
setTime({ refreshId: createUuid(), start, end });
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -131,11 +131,9 @@ const DeviceStatisticsCard = () => {
|
|||||||
<StatisticsChartList
|
<StatisticsChartList
|
||||||
setOptions={setOptions}
|
setOptions={setOptions}
|
||||||
section={section}
|
section={section}
|
||||||
start={start}
|
time={time}
|
||||||
end={end}
|
|
||||||
setStart={setStart}
|
setStart={setStart}
|
||||||
setEnd={setEnd}
|
setEnd={setEnd}
|
||||||
refreshId={refreshId}
|
|
||||||
/>
|
/>
|
||||||
</CCardBody>
|
</CCardBody>
|
||||||
</CCard>
|
</CCard>
|
||||||
|
|||||||
@@ -124,3 +124,5 @@ export const testRegex = (value, regexString) => {
|
|||||||
const regex = new RegExp(regexString);
|
const regex = new RegExp(regexString);
|
||||||
return regex.test(value);
|
return regex.test(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const datesSameDay = (first, second) => first.getDate() === second.getDate();
|
||||||
|
|||||||
Reference in New Issue
Block a user