@dexteel/mesf-core 4.5.9 → 4.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +446 -397
- package/dist/index.esm.js.map +1 -0
- package/dist/pages/trendings/components/chart/TableComponent.d.ts +0 -2
- package/dist/pages/trendings/components/chart/hooks/useYAxisPlugin.d.ts +2 -0
- package/dist/pages/trendings/components/chart/sections/chart/hooks/useChartOptions.d.ts +106 -0
- package/dist/pages/trendings/components/chart/sections/header.d.ts +6 -0
- package/dist/pages/trendings/components/chart/sections/trending-chart.d.ts +13 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Typography, TextField, makeStyles as makeStyles$1, Button as Button$1, Grid as Grid$1, Dialog as Dialog$1, DialogTitle as DialogTitle$2, DialogContent as DialogContent$2, DialogContentText, DialogActions as DialogActions$2, FormHelperText, CircularProgress as CircularProgress$1, Badge, FormControlLabel, Checkbox, Snackbar as Snackbar$1, Paper as Paper$1, MenuItem as MenuItem$1, useTheme as useTheme$1, Box, Tooltip, IconButton as IconButton$1, FormControl as FormControl$1, Select as Select$1, createStyles as createStyles$1, List, ListItem, ListItemText } from '@material-ui/core';
|
|
2
|
-
import { values, get, isNil as isNil$1, isEmpty, isNaN
|
|
1
|
+
import { Typography, TextField, makeStyles as makeStyles$1, Button as Button$1, Grid as Grid$1, Dialog as Dialog$1, DialogTitle as DialogTitle$2, DialogContent as DialogContent$2, DialogContentText, DialogActions as DialogActions$2, FormHelperText, CircularProgress as CircularProgress$1, Badge, FormControlLabel, Checkbox, Snackbar as Snackbar$1, Paper as Paper$1, MenuItem as MenuItem$1, useTheme as useTheme$1, Box, Tooltip, IconButton as IconButton$1, FormControl as FormControl$1, Select as Select$1, debounce, createStyles as createStyles$1, List, ListItem, ListItemText } from '@material-ui/core';
|
|
2
|
+
import { values, get, isNil as isNil$1, isEmpty, isNaN } from 'lodash-es';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import React__default, { useState, useRef, useEffect, Component, createContext, useContext, useMemo, useCallback, lazy, Suspense } from 'react';
|
|
5
5
|
import { Alert as Alert$1, Modal as Modal$1, Navbar, Container, Nav, NavDropdown } from 'react-bootstrap';
|
|
@@ -20,17 +20,17 @@ import Grid from '@material-ui/core/Grid';
|
|
|
20
20
|
import { isNil, get as get$1 } from 'lodash';
|
|
21
21
|
import { DndProvider } from 'react-dnd';
|
|
22
22
|
import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
23
|
-
import { ArrowRight, ChevronLeft, ChevronRight } from '@material-ui/icons';
|
|
24
23
|
import axios from 'axios';
|
|
25
24
|
import { _adapters, Chart, CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip as Tooltip$1, Legend, TimeScale } from 'chart.js';
|
|
26
25
|
import moment from 'moment';
|
|
27
26
|
import zoomPlugin from 'chartjs-plugin-zoom';
|
|
28
|
-
import { Line } from 'react-chartjs-2';
|
|
29
27
|
import Popover from '@material-ui/core/Popover';
|
|
30
28
|
import ArrowDropDownIcon from '@material-ui/icons/ArrowDropDown';
|
|
31
29
|
import FolderIcon from '@material-ui/icons/Folder';
|
|
32
30
|
import InsertDriveFileIcon from '@material-ui/icons/InsertDriveFile';
|
|
33
31
|
import { Alert as Alert$3, TreeView as TreeView$1, TreeItem as TreeItem$1 } from '@material-ui/lab';
|
|
32
|
+
import { ArrowRight, ChevronLeft, ChevronRight } from '@material-ui/icons';
|
|
33
|
+
import { Line } from 'react-chartjs-2';
|
|
34
34
|
import PersonPinCircleIcon from '@material-ui/icons/PersonPinCircle';
|
|
35
35
|
import PropTypes from 'prop-types';
|
|
36
36
|
import { ResponsiveBar } from '@nivo/bar';
|
|
@@ -8155,7 +8155,7 @@ var AreaSelector$1 = lazy(function () {
|
|
|
8155
8155
|
"default": mod.AreaSelector
|
|
8156
8156
|
}); });
|
|
8157
8157
|
});
|
|
8158
|
-
function Header(_a) {
|
|
8158
|
+
function Header$1(_a) {
|
|
8159
8159
|
var _b = _a.showAreaSelector, showAreaSelector = _b === void 0 ? false : _b, _c = _a.navbarTitle, navbarTitle = _c === void 0 ? "MESF" : _c;
|
|
8160
8160
|
var getUserName = useToken().getUserName;
|
|
8161
8161
|
var _d = useState(""), error = _d[0], setError = _d[1];
|
|
@@ -8704,7 +8704,7 @@ var timeDifference = function (start, end) {
|
|
|
8704
8704
|
};
|
|
8705
8705
|
|
|
8706
8706
|
var TableComponent = function (_a) {
|
|
8707
|
-
var tagList = _a.tagList, setTagList = _a.setTagList, chartData = _a.chartData, cursorData = _a.cursorData
|
|
8707
|
+
var tagList = _a.tagList, setTagList = _a.setTagList, chartData = _a.chartData, cursorData = _a.cursorData;
|
|
8708
8708
|
var classes = useTagsTableStyles();
|
|
8709
8709
|
var _b = useState(""); _b[0]; _b[1];
|
|
8710
8710
|
var dataTable = useTagsDataTable({ tagList: tagList, chartData: chartData, cursorData: cursorData });
|
|
@@ -8729,6 +8729,22 @@ var TableComponent = function (_a) {
|
|
|
8729
8729
|
var handleColorChange = function (tagId, value) {
|
|
8730
8730
|
setTagList(function (prev) { return prev.map(function (tag) { return tag.tagId === tagId ? __assign(__assign({}, tag), { color: value }) : tag; }); });
|
|
8731
8731
|
};
|
|
8732
|
+
var handleDeleteTag = function (tagId) {
|
|
8733
|
+
setTagList(function (prevTagList) {
|
|
8734
|
+
return prevTagList.filter(function (tag) { return tag.tagId !== tagId; });
|
|
8735
|
+
});
|
|
8736
|
+
};
|
|
8737
|
+
var handleAddTag = function (newTag) {
|
|
8738
|
+
if (newTag) {
|
|
8739
|
+
setTagList(function (prevTagList) {
|
|
8740
|
+
// Check if the tag is already in the list to avoid duplicates
|
|
8741
|
+
if (prevTagList.some(function (tag) { return tag.tagId === newTag.tagId; })) {
|
|
8742
|
+
return prevTagList; // Return the existing list if the tag is already there
|
|
8743
|
+
}
|
|
8744
|
+
return __spreadArray(__spreadArray([], prevTagList, true), [newTag], false); // Add the new tag to the list
|
|
8745
|
+
});
|
|
8746
|
+
}
|
|
8747
|
+
};
|
|
8732
8748
|
var _d = useState(null), selectedRowIndex = _d[0], setSelectedRowIndex = _d[1];
|
|
8733
8749
|
var _e = useState(false), addTagModalOpen = _e[0], setAddTagModalOpen = _e[1];
|
|
8734
8750
|
var handleClose = function () { return setAddTagModalOpen(false); };
|
|
@@ -8748,48 +8764,15 @@ var TableComponent = function (_a) {
|
|
|
8748
8764
|
{ id: 'saveDefault', label: 'Save Default To Tag', onClick: function () { } },
|
|
8749
8765
|
{ id: 'saveAsView', label: 'Save as View', onClick: function () { } },
|
|
8750
8766
|
{ id: 'loadView', label: 'Load View', onClick: function () { } },
|
|
8751
|
-
// ... other options
|
|
8752
8767
|
];
|
|
8753
|
-
// const binarySearch = (arr: any, searchDate: Date): number | null => {
|
|
8754
|
-
// let left = 0;
|
|
8755
|
-
// let right = arr.length - 1;
|
|
8756
|
-
// let closest: number | null = null;
|
|
8757
|
-
// if (!arr.length) return null;
|
|
8758
|
-
// while (left <= right) {
|
|
8759
|
-
// const mid = Math.floor((left + right) / 2);
|
|
8760
|
-
// const midDate = arr[mid].x; // Asegúrate de que esto es una instancia de Date
|
|
8761
|
-
// const midTimestamp = midDate.getTime(); // Esto es un number
|
|
8762
|
-
// const searchTimestamp = searchDate.getTime(); // Esto también es un number
|
|
8763
|
-
// console.log(midTimestamp, searchTimestamp);
|
|
8764
|
-
// if (midTimestamp === searchTimestamp) {
|
|
8765
|
-
// return arr[mid].y;
|
|
8766
|
-
// } else if (midTimestamp < searchTimestamp) {
|
|
8767
|
-
// left = mid + 1;
|
|
8768
|
-
// } else {
|
|
8769
|
-
// right = mid - 1;
|
|
8770
|
-
// }
|
|
8771
|
-
// // Revisa si midDate está más cerca que el 'closest' actual
|
|
8772
|
-
// if (closest === null || Math.abs(midTimestamp - searchTimestamp) < Math.abs(arr[closest].x.getTime() - searchTimestamp)) {
|
|
8773
|
-
// closest = mid;
|
|
8774
|
-
// }
|
|
8775
|
-
// }
|
|
8776
|
-
// return closest !== null ? arr[closest].y : null;
|
|
8777
|
-
// };
|
|
8778
|
-
// useEffect(() => {
|
|
8779
|
-
// if (cursorData) {
|
|
8780
|
-
// const yValue = binarySearch(chartData.datasets[0]?.data, new Date(cursorData.x1));
|
|
8781
|
-
// if(yValue)console.log(yValue,"retorna binary")
|
|
8782
|
-
// }
|
|
8783
|
-
// else console.log("NULL")
|
|
8784
|
-
// }, [cursorData,chartData.datasets[1]?.data])
|
|
8785
8768
|
var handleTagSelect = function (selectedTag) {
|
|
8786
|
-
|
|
8769
|
+
handleAddTag(selectedTag);
|
|
8787
8770
|
handleClose();
|
|
8788
8771
|
};
|
|
8789
8772
|
var handleDelete = function (index) {
|
|
8790
8773
|
if (selectedRowIndex !== null) {
|
|
8791
8774
|
var tagToDelete = tagList[selectedRowIndex];
|
|
8792
|
-
|
|
8775
|
+
handleDeleteTag(tagToDelete.tagId);
|
|
8793
8776
|
setSelectedRowIndex(null); // Reset the selected row index
|
|
8794
8777
|
}
|
|
8795
8778
|
};
|
|
@@ -8840,7 +8823,6 @@ var TableComponent = function (_a) {
|
|
|
8840
8823
|
React__default.createElement("th", { colSpan: 4, className: "".concat(classes.topTitles, " ").concat(classes.scale) }, "Scale"),
|
|
8841
8824
|
React__default.createElement("th", { className: "".concat(classes.topTitles, " ").concat(classes.xStats) }, cursorData ? (function () {
|
|
8842
8825
|
var date = new Date(cursorData.x1);
|
|
8843
|
-
// console.log(cursorData, "cursor data")
|
|
8844
8826
|
var formattedDate = date.toLocaleString('en-US', {
|
|
8845
8827
|
hour12: false,
|
|
8846
8828
|
month: 'short',
|
|
@@ -8864,7 +8846,6 @@ var TableComponent = function (_a) {
|
|
|
8864
8846
|
})() : null),
|
|
8865
8847
|
React__default.createElement("th", { className: "".concat(classes.topTitles, " ").concat(classes.xStats) }, cursorData ? (function () {
|
|
8866
8848
|
var date = new Date(cursorData.x2);
|
|
8867
|
-
// console.log(cursorData, "cursor data")
|
|
8868
8849
|
var formattedDate = date.toLocaleString('en-US', {
|
|
8869
8850
|
hour12: false,
|
|
8870
8851
|
month: 'short',
|
|
@@ -8957,44 +8938,6 @@ var TableComponent = function (_a) {
|
|
|
8957
8938
|
React__default.createElement(AddTagModal, { open: addTagModalOpen, handleClose: handleClose, onTagSelect: handleTagSelect })));
|
|
8958
8939
|
};
|
|
8959
8940
|
|
|
8960
|
-
var DraggableLineControl = function (_a) {
|
|
8961
|
-
var initialLeft = _a.initialLeft, onUpdate = _a.onUpdate, color = _a.color, chartArea = _a.chartArea;
|
|
8962
|
-
var _b = useState(false), isDragging = _b[0], setIsDragging = _b[1];
|
|
8963
|
-
var _c = useState(initialLeft), left = _c[0], setLeft = _c[1];
|
|
8964
|
-
var ref = useRef(null);
|
|
8965
|
-
var handleMouseDown = function (e) {
|
|
8966
|
-
setIsDragging(true);
|
|
8967
|
-
e.stopPropagation();
|
|
8968
|
-
e.preventDefault();
|
|
8969
|
-
};
|
|
8970
|
-
var handleMouseMove = function (e) {
|
|
8971
|
-
if (!isDragging || !ref.current)
|
|
8972
|
-
return;
|
|
8973
|
-
chartArea.width - chartArea.right;
|
|
8974
|
-
chartArea.left;
|
|
8975
|
-
var newLeft = Math.min(Math.max(e.clientX - ref.current.offsetParent.getBoundingClientRect().left, chartArea.left), chartArea.right);
|
|
8976
|
-
setLeft(newLeft);
|
|
8977
|
-
onUpdate(newLeft); // Actualiza la posición de la línea en el gráfico
|
|
8978
|
-
};
|
|
8979
|
-
var handleMouseUp = function () {
|
|
8980
|
-
setIsDragging(false);
|
|
8981
|
-
};
|
|
8982
|
-
useEffect(function () {
|
|
8983
|
-
var mouseMoveHandler = function (e) { return handleMouseMove(e); };
|
|
8984
|
-
var mouseUpHandler = function () { return handleMouseUp(); };
|
|
8985
|
-
if (isDragging) {
|
|
8986
|
-
window.addEventListener('mousemove', mouseMoveHandler);
|
|
8987
|
-
window.addEventListener('mouseup', mouseUpHandler);
|
|
8988
|
-
}
|
|
8989
|
-
return function () {
|
|
8990
|
-
window.removeEventListener('mousemove', mouseMoveHandler);
|
|
8991
|
-
window.removeEventListener('mouseup', mouseUpHandler);
|
|
8992
|
-
};
|
|
8993
|
-
}, [isDragging]);
|
|
8994
|
-
return (React__default.createElement("div", { ref: ref, style: { height: 20, width: 20, background: color, position: 'absolute', top: -10, left: left - 10 }, onMouseDown: handleMouseDown },
|
|
8995
|
-
React__default.createElement("div", { style: { height: chartArea.height, width: 2, background: color, position: 'relative', top: 20, left: 0, right: 0, margin: 'auto' } })));
|
|
8996
|
-
};
|
|
8997
|
-
|
|
8998
8941
|
var TrendingsInitialState = {
|
|
8999
8942
|
timeScopeStart: moment(new Date()).subtract(1, "days").toDate(),
|
|
9000
8943
|
timeScopeEnd: new Date(),
|
|
@@ -9159,6 +9102,129 @@ var TrendingProvider = function (_a) {
|
|
|
9159
9102
|
return (React__default.createElement(TrendingContext.Provider, { value: { state: state, actions: actions } }, children));
|
|
9160
9103
|
};
|
|
9161
9104
|
|
|
9105
|
+
var formatDateTimeToString = function (date) {
|
|
9106
|
+
var hour = date.getHours().toString().padStart(2, '0');
|
|
9107
|
+
var minute = date.getMinutes().toString().padStart(2, '0');
|
|
9108
|
+
var second = date.getSeconds().toString().padStart(2, '0');
|
|
9109
|
+
if (hour === '24') {
|
|
9110
|
+
hour = '00';
|
|
9111
|
+
}
|
|
9112
|
+
var formattedDate = date.toLocaleDateString("en-US", {
|
|
9113
|
+
month: "short",
|
|
9114
|
+
day: "numeric"
|
|
9115
|
+
});
|
|
9116
|
+
var formattedTime = "".concat(hour, ":").concat(minute, ":").concat(second);
|
|
9117
|
+
return { formattedDate: formattedDate, formattedTime: formattedTime };
|
|
9118
|
+
};
|
|
9119
|
+
|
|
9120
|
+
var useChartOptions = function () {
|
|
9121
|
+
var _a = useTrendingContext(); _a.state; var actions = _a.actions;
|
|
9122
|
+
var debounceTimerRef = useRef(null);
|
|
9123
|
+
var handleZoom = function (_a) {
|
|
9124
|
+
var chart = _a.chart;
|
|
9125
|
+
if (debounceTimerRef.current) {
|
|
9126
|
+
clearTimeout(debounceTimerRef.current);
|
|
9127
|
+
}
|
|
9128
|
+
debounceTimerRef.current = setTimeout(function () {
|
|
9129
|
+
// Handle zoom event and execute fetch
|
|
9130
|
+
var newStart = new Date(chart.scales.x.min);
|
|
9131
|
+
var newEnd = new Date(chart.scales.x.max);
|
|
9132
|
+
actions.setTotalScope({
|
|
9133
|
+
start: newStart,
|
|
9134
|
+
end: newEnd
|
|
9135
|
+
});
|
|
9136
|
+
}, 1000);
|
|
9137
|
+
};
|
|
9138
|
+
var handlePan = function (_a) {
|
|
9139
|
+
var chart = _a.chart;
|
|
9140
|
+
if (debounceTimerRef.current) {
|
|
9141
|
+
clearTimeout(debounceTimerRef.current);
|
|
9142
|
+
}
|
|
9143
|
+
debounceTimerRef.current = setTimeout(function () {
|
|
9144
|
+
// Handle pan event and execute fetch
|
|
9145
|
+
var newStart = new Date(chart.scales.x.min);
|
|
9146
|
+
var newEnd = new Date(chart.scales.x.max);
|
|
9147
|
+
actions.setTotalScope({
|
|
9148
|
+
start: newStart,
|
|
9149
|
+
end: newEnd,
|
|
9150
|
+
graphPan: true
|
|
9151
|
+
});
|
|
9152
|
+
}, 1000);
|
|
9153
|
+
};
|
|
9154
|
+
return useState({
|
|
9155
|
+
animation: {
|
|
9156
|
+
duration: 0
|
|
9157
|
+
},
|
|
9158
|
+
responsive: true,
|
|
9159
|
+
maintainAspectRatio: false,
|
|
9160
|
+
scales: {
|
|
9161
|
+
x: {
|
|
9162
|
+
type: "time",
|
|
9163
|
+
ticks: {
|
|
9164
|
+
autoSkip: true,
|
|
9165
|
+
maxTicksLimit: 20,
|
|
9166
|
+
callback: function (value, index, ticks) {
|
|
9167
|
+
var currentDate = new Date(value);
|
|
9168
|
+
var time = formatDateTimeToString(currentDate).formattedTime;
|
|
9169
|
+
var date = formatDateTimeToString(currentDate).formattedDate;
|
|
9170
|
+
// Si es el primer tick, siempre muestra la fecha y hora
|
|
9171
|
+
if (index === 0) {
|
|
9172
|
+
return [time, date];
|
|
9173
|
+
}
|
|
9174
|
+
// De lo contrario, solo muestra la hora
|
|
9175
|
+
return time;
|
|
9176
|
+
}
|
|
9177
|
+
},
|
|
9178
|
+
grid: {
|
|
9179
|
+
display: true
|
|
9180
|
+
}
|
|
9181
|
+
},
|
|
9182
|
+
y: {
|
|
9183
|
+
grid: {
|
|
9184
|
+
display: true
|
|
9185
|
+
},
|
|
9186
|
+
afterUpdate: function (axis) {
|
|
9187
|
+
var chart = axis.chart;
|
|
9188
|
+
var keys = Object.keys(chart.scales).filter(function (sc) { return sc !== 'x'; });
|
|
9189
|
+
if (keys.length > 1) {
|
|
9190
|
+
for (var scaleKey in chart.scales) {
|
|
9191
|
+
var scale = chart.scales[scaleKey];
|
|
9192
|
+
if (scale.max === 1 && scale.min === 0) {
|
|
9193
|
+
chart.scales[scaleKey].display = false;
|
|
9194
|
+
chart.scales[scaleKey].options.display = false;
|
|
9195
|
+
}
|
|
9196
|
+
else {
|
|
9197
|
+
chart.scales[scaleKey].display = true;
|
|
9198
|
+
chart.scales[scaleKey].options.display = true;
|
|
9199
|
+
}
|
|
9200
|
+
}
|
|
9201
|
+
}
|
|
9202
|
+
else {
|
|
9203
|
+
console.log('sin y', keys);
|
|
9204
|
+
}
|
|
9205
|
+
}
|
|
9206
|
+
}
|
|
9207
|
+
},
|
|
9208
|
+
plugins: {
|
|
9209
|
+
tooltip: { enabled: false },
|
|
9210
|
+
legend: { display: false },
|
|
9211
|
+
zoom: {
|
|
9212
|
+
zoom: {
|
|
9213
|
+
wheel: { enabled: true, mode: "x" },
|
|
9214
|
+
pinch: { enabled: true, mode: "x" },
|
|
9215
|
+
onZoom: handleZoom,
|
|
9216
|
+
mode: "x"
|
|
9217
|
+
},
|
|
9218
|
+
pan: {
|
|
9219
|
+
enabled: true,
|
|
9220
|
+
mode: "x",
|
|
9221
|
+
onPan: handlePan
|
|
9222
|
+
}
|
|
9223
|
+
}
|
|
9224
|
+
}
|
|
9225
|
+
});
|
|
9226
|
+
};
|
|
9227
|
+
|
|
9162
9228
|
var useTrendingStyles = makeStyles$1(function (theme) { return ({
|
|
9163
9229
|
datetimePicker: {
|
|
9164
9230
|
alignItems: "center",
|
|
@@ -9237,6 +9303,129 @@ var CustomOptionsComponent = function (_a) {
|
|
|
9237
9303
|
"Stepped"))));
|
|
9238
9304
|
};
|
|
9239
9305
|
|
|
9306
|
+
var dateNavigator = function (startDate, endDate, scope, operator) {
|
|
9307
|
+
if (scope === "custom")
|
|
9308
|
+
return;
|
|
9309
|
+
else {
|
|
9310
|
+
var _a = scope.split(" "), quantity = _a[0], duration = _a[1];
|
|
9311
|
+
var newStartDate = moment(startDate)[operator](quantity, duration[0]).toDate();
|
|
9312
|
+
var newEndDate = moment(endDate)[operator](quantity, duration[0]).toDate();
|
|
9313
|
+
return { newStartDate: newStartDate, newEndDate: newEndDate };
|
|
9314
|
+
}
|
|
9315
|
+
};
|
|
9316
|
+
|
|
9317
|
+
var Header = function (_a) {
|
|
9318
|
+
var setChartOptions = _a.setChartOptions;
|
|
9319
|
+
var classes = useTrendingStyles();
|
|
9320
|
+
var _b = useTrendingContext(), state = _b.state, actions = _b.actions;
|
|
9321
|
+
var _c = useState({
|
|
9322
|
+
showGrid: true,
|
|
9323
|
+
stepped: false
|
|
9324
|
+
}), customOptions = _c[0], setCustomOptions = _c[1];
|
|
9325
|
+
var handleDateNavigator = function (operator) {
|
|
9326
|
+
var newDates = dateNavigator(state.timeScopeStart, state.timeScopeEnd, state.scope, operator);
|
|
9327
|
+
if (newDates) {
|
|
9328
|
+
actions.setTotalScope({ start: newDates.newStartDate, end: newDates.newEndDate, scope: state.scope });
|
|
9329
|
+
}
|
|
9330
|
+
};
|
|
9331
|
+
var handleDateChange = function (newValue, key) {
|
|
9332
|
+
var _a;
|
|
9333
|
+
//@ts-ignore
|
|
9334
|
+
actions.setTotalScope((_a = {}, _a[key] = moment(newValue).toDate(), _a));
|
|
9335
|
+
};
|
|
9336
|
+
var handleChangeScope = function (e) {
|
|
9337
|
+
var newScope = e.target.value;
|
|
9338
|
+
actions.setTotalScope({
|
|
9339
|
+
scope: newScope
|
|
9340
|
+
});
|
|
9341
|
+
};
|
|
9342
|
+
useEffect(function () {
|
|
9343
|
+
var changeOptions = function () {
|
|
9344
|
+
// console.log("change options");
|
|
9345
|
+
setChartOptions(function (prevOptions) { return (__assign(__assign({}, prevOptions), { elements: {
|
|
9346
|
+
line: {
|
|
9347
|
+
stepped: customOptions.stepped,
|
|
9348
|
+
lineTension: 0.1
|
|
9349
|
+
}
|
|
9350
|
+
}, scales: __assign(__assign({}, prevOptions.scales), { x: __assign(__assign({}, prevOptions.scales.x), { grid: __assign(__assign({}, prevOptions.scales.x.grid), { display: customOptions.showGrid }) }), y: __assign(__assign({}, prevOptions.scales.y), { grid: __assign(__assign({}, prevOptions.scales.y.grid), { display: customOptions.showGrid }) }) }) })); });
|
|
9351
|
+
};
|
|
9352
|
+
changeOptions();
|
|
9353
|
+
}, [customOptions]);
|
|
9354
|
+
useEffect(function () {
|
|
9355
|
+
setChartOptions(function (prevOptions) { return (__assign(__assign({}, prevOptions), { scales: __assign(__assign({}, prevOptions.scales), { x: __assign(__assign({}, prevOptions.scales.x), { min: state.timeScopeStart.getTime(), max: state.timeScopeEnd.getTime() }) }) })); });
|
|
9356
|
+
}, [state.timeScopeStart, state.timeScopeEnd]);
|
|
9357
|
+
return (React__default.createElement(Grid$1, { item: true, xs: 12, container: true, justifyContent: "space-between", alignItems: "center", style: { height: "15%" } },
|
|
9358
|
+
React__default.createElement(Grid$1, { md: 5, item: true, container: true, justifyContent: "flex-start", alignItems: "center", spacing: 1, wrap: "wrap" },
|
|
9359
|
+
React__default.createElement(IconButton$1, { color: "primary", onClick: function () { return handleDateNavigator("subtract"); }, className: classes.navigatorButton },
|
|
9360
|
+
React__default.createElement(ChevronLeft, { fontSize: "large" })),
|
|
9361
|
+
React__default.createElement(Grid$1, { item: true },
|
|
9362
|
+
React__default.createElement(TextField, { type: "datetime-local", className: classes.datetimePicker, label: "Start", variant: "outlined", value: moment(state.timeScopeStart).format("YYYY-MM-DDTHH:mm:ss"), onChange: function (e) { return handleDateChange(e.target.value, "start"); }, InputLabelProps: {
|
|
9363
|
+
shrink: true,
|
|
9364
|
+
style: { marginLeft: "10px" }
|
|
9365
|
+
}, InputProps: {
|
|
9366
|
+
max: state.timeScopeEnd
|
|
9367
|
+
} })),
|
|
9368
|
+
React__default.createElement(Grid$1, { item: true, className: classes.select },
|
|
9369
|
+
React__default.createElement(FormControl$1, { variant: "outlined" },
|
|
9370
|
+
React__default.createElement(Select$1, { value: state.scope, onChange: handleChangeScope, displayEmpty: true },
|
|
9371
|
+
React__default.createElement(MenuItem$1, { value: "10 min" }, "10 min"),
|
|
9372
|
+
React__default.createElement(MenuItem$1, { value: "1 hour" }, "1 hour"),
|
|
9373
|
+
React__default.createElement(MenuItem$1, { value: "4 hours" }, "4 hours"),
|
|
9374
|
+
React__default.createElement(MenuItem$1, { value: "12 hours" }, "12 hours"),
|
|
9375
|
+
React__default.createElement(MenuItem$1, { value: "1 day" }, "1 day"),
|
|
9376
|
+
React__default.createElement(MenuItem$1, { value: "10 days" }, "10 days"),
|
|
9377
|
+
React__default.createElement(MenuItem$1, { value: "custom" }, "Custom")))),
|
|
9378
|
+
React__default.createElement(Grid$1, { item: true },
|
|
9379
|
+
React__default.createElement(TextField, { label: "End", variant: "outlined", className: classes.datetimePicker, type: "datetime-local", value: moment(state.timeScopeEnd).format("YYYY-MM-DDTHH:mm:ss"), onChange: function (e) { return handleDateChange(e.target.value, "end"); }, InputLabelProps: {
|
|
9380
|
+
shrink: true,
|
|
9381
|
+
style: { marginLeft: "10px" }
|
|
9382
|
+
} })),
|
|
9383
|
+
React__default.createElement(IconButton$1, { color: "primary", onClick: function () { return handleDateNavigator("add"); }, className: classes.navigatorButton },
|
|
9384
|
+
React__default.createElement(ChevronRight, { fontSize: "large" }))),
|
|
9385
|
+
React__default.createElement(Grid$1, { md: 7, item: true, container: true, justifyContent: "space-between" },
|
|
9386
|
+
React__default.createElement(Grid$1, { item: true, container: true, wrap: "nowrap", spacing: 1 },
|
|
9387
|
+
React__default.createElement(Grid$1, { item: true, container: true },
|
|
9388
|
+
React__default.createElement(CustomOptionsComponent, { customOptions: customOptions, setCustomOptions: setCustomOptions }))))));
|
|
9389
|
+
};
|
|
9390
|
+
|
|
9391
|
+
var DraggableLineControl = function (_a) {
|
|
9392
|
+
var initialLeft = _a.initialLeft, onUpdate = _a.onUpdate, color = _a.color, chartArea = _a.chartArea;
|
|
9393
|
+
var _b = useState(false), isDragging = _b[0], setIsDragging = _b[1];
|
|
9394
|
+
var _c = useState(initialLeft), left = _c[0], setLeft = _c[1];
|
|
9395
|
+
var ref = useRef(null);
|
|
9396
|
+
var handleMouseDown = function (e) {
|
|
9397
|
+
setIsDragging(true);
|
|
9398
|
+
e.stopPropagation();
|
|
9399
|
+
e.preventDefault();
|
|
9400
|
+
};
|
|
9401
|
+
var handleMouseMove = function (e) {
|
|
9402
|
+
if (!isDragging || !ref.current)
|
|
9403
|
+
return;
|
|
9404
|
+
chartArea.width - chartArea.right;
|
|
9405
|
+
chartArea.left;
|
|
9406
|
+
var newLeft = Math.min(Math.max(e.clientX - ref.current.offsetParent.getBoundingClientRect().left, chartArea.left), chartArea.right);
|
|
9407
|
+
setLeft(newLeft);
|
|
9408
|
+
onUpdate(newLeft); // Actualiza la posición de la línea en el gráfico
|
|
9409
|
+
};
|
|
9410
|
+
var handleMouseUp = function () {
|
|
9411
|
+
setIsDragging(false);
|
|
9412
|
+
};
|
|
9413
|
+
useEffect(function () {
|
|
9414
|
+
var mouseMoveHandler = function (e) { return handleMouseMove(e); };
|
|
9415
|
+
var mouseUpHandler = function () { return handleMouseUp(); };
|
|
9416
|
+
if (isDragging) {
|
|
9417
|
+
window.addEventListener('mousemove', mouseMoveHandler);
|
|
9418
|
+
window.addEventListener('mouseup', mouseUpHandler);
|
|
9419
|
+
}
|
|
9420
|
+
return function () {
|
|
9421
|
+
window.removeEventListener('mousemove', mouseMoveHandler);
|
|
9422
|
+
window.removeEventListener('mouseup', mouseUpHandler);
|
|
9423
|
+
};
|
|
9424
|
+
}, [isDragging]);
|
|
9425
|
+
return (React__default.createElement("div", { ref: ref, style: { height: 20, width: 20, background: color, position: 'absolute', top: -10, left: left - 10 }, onMouseDown: handleMouseDown },
|
|
9426
|
+
React__default.createElement("div", { style: { height: chartArea.height, width: 2, background: color, position: 'relative', top: 20, left: 0, right: 0, margin: 'auto' } })));
|
|
9427
|
+
};
|
|
9428
|
+
|
|
9240
9429
|
var useGetVerticalLinePlugin = function (setChartArea, setCoords) {
|
|
9241
9430
|
var chartPlugin = {
|
|
9242
9431
|
id: "verticalLinePlugin",
|
|
@@ -9300,21 +9489,6 @@ var updateCursorData = function (chart, setCursorData) {
|
|
|
9300
9489
|
});
|
|
9301
9490
|
};
|
|
9302
9491
|
|
|
9303
|
-
var formatDateTimeToString = function (date) {
|
|
9304
|
-
var hour = date.getHours().toString().padStart(2, '0');
|
|
9305
|
-
var minute = date.getMinutes().toString().padStart(2, '0');
|
|
9306
|
-
var second = date.getSeconds().toString().padStart(2, '0');
|
|
9307
|
-
if (hour === '24') {
|
|
9308
|
-
hour = '00';
|
|
9309
|
-
}
|
|
9310
|
-
var formattedDate = date.toLocaleDateString("en-US", {
|
|
9311
|
-
month: "short",
|
|
9312
|
-
day: "numeric"
|
|
9313
|
-
});
|
|
9314
|
-
var formattedTime = "".concat(hour, ":").concat(minute, ":").concat(second);
|
|
9315
|
-
return { formattedDate: formattedDate, formattedTime: formattedTime };
|
|
9316
|
-
};
|
|
9317
|
-
|
|
9318
9492
|
var useXAxisDatePlugin = function () {
|
|
9319
9493
|
var chartPlugin = {
|
|
9320
9494
|
id: 'xAxisDatePlugin',
|
|
@@ -9346,6 +9520,13 @@ var useXAxisDatePlugin = function () {
|
|
|
9346
9520
|
return chartPlugin;
|
|
9347
9521
|
};
|
|
9348
9522
|
|
|
9523
|
+
var useYAxisPlugin = function () {
|
|
9524
|
+
var chartPlugin = {
|
|
9525
|
+
id: 'yAxisPlugin'
|
|
9526
|
+
};
|
|
9527
|
+
return chartPlugin;
|
|
9528
|
+
};
|
|
9529
|
+
|
|
9349
9530
|
var areRangesSimilar = function (tag1, tag2) {
|
|
9350
9531
|
var range1 = tag1.maxScale - tag1.minScale; // Rango de la primera etiqueta
|
|
9351
9532
|
var range2 = tag2.maxScale - tag2.minScale; // Rango de la segunda etiqueta
|
|
@@ -9378,271 +9559,109 @@ var calculateScales = function (min, max, sigDigits) {
|
|
|
9378
9559
|
return { minScale: minScale, maxScale: maxScale };
|
|
9379
9560
|
};
|
|
9380
9561
|
|
|
9381
|
-
var
|
|
9382
|
-
|
|
9383
|
-
|
|
9384
|
-
|
|
9385
|
-
|
|
9386
|
-
var newStartDate = moment(startDate)[operator](quantity, duration[0]).toDate();
|
|
9387
|
-
var newEndDate = moment(endDate)[operator](quantity, duration[0]).toDate();
|
|
9388
|
-
return { newStartDate: newStartDate, newEndDate: newEndDate };
|
|
9389
|
-
}
|
|
9390
|
-
};
|
|
9391
|
-
|
|
9392
|
-
Chart.register(CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip$1, Legend, TimeScale, zoomPlugin);
|
|
9393
|
-
var Trending = function (_a) {
|
|
9394
|
-
_a.title; var tags = _a.tags;
|
|
9395
|
-
var classes = useTrendingStyles();
|
|
9396
|
-
var _b = useTrendingContext(), state = _b.state, actions = _b.actions;
|
|
9397
|
-
var _c = useState(true), loading = _c[0], setLoading = _c[1];
|
|
9398
|
-
var _d = useState(""), error = _d[0], setError = _d[1];
|
|
9399
|
-
var _e = useState(tags), tagList = _e[0], setTagList = _e[1];
|
|
9400
|
-
var _f = useState(null), cursorData = _f[0], setCursorData = _f[1];
|
|
9401
|
-
var _g = useState(null), lineTabCoords = _g[0], setLineTabCoords = _g[1];
|
|
9402
|
-
var _h = useState(null), chartArea = _h[0], setChartArea = _h[1];
|
|
9403
|
-
var _j = useState(false), chartShouldInitCursors = _j[0], setChartShouldInitCursors = _j[1];
|
|
9562
|
+
var TrendingChart = function (_a) {
|
|
9563
|
+
var tagList = _a.tagList, series = _a.series, chartOptions = _a.chartOptions, setChartOptions = _a.setChartOptions, chartData = _a.chartData, setCursorData = _a.setCursorData, setChartData = _a.setChartData;
|
|
9564
|
+
var _b = useTrendingContext(), state = _b.state; _b.actions;
|
|
9565
|
+
var _c = useState(null), lineTabCoords = _c[0], setLineTabCoords = _c[1];
|
|
9566
|
+
var _d = useState(null), chartArea = _d[0], setChartArea = _d[1];
|
|
9404
9567
|
var chartRef = useRef(null);
|
|
9405
|
-
var _k = useState({
|
|
9406
|
-
labels: [],
|
|
9407
|
-
datasets: []
|
|
9408
|
-
}), chartData = _k[0], setChartData = _k[1];
|
|
9409
|
-
var verticalLinePlugin = useGetVerticalLinePlugin(setChartArea, setLineTabCoords);
|
|
9410
|
-
var xAxisDatePlugin = useXAxisDatePlugin();
|
|
9411
|
-
var _l = useState({
|
|
9412
|
-
showGrid: true,
|
|
9413
|
-
stepped: false
|
|
9414
|
-
}), customOptions = _l[0], setCustomOptions = _l[1];
|
|
9415
|
-
var debounceTimerRef = useRef(null);
|
|
9416
9568
|
var debouncedUpdateChart = useRef(debounce(function () {
|
|
9417
9569
|
if (chartRef.current) {
|
|
9418
9570
|
updateCursorData(chartRef.current, setCursorData);
|
|
9419
9571
|
chartRef.current.update();
|
|
9420
9572
|
}
|
|
9421
9573
|
}, 250)).current;
|
|
9422
|
-
var
|
|
9423
|
-
|
|
9424
|
-
|
|
9425
|
-
|
|
9426
|
-
|
|
9427
|
-
|
|
9428
|
-
|
|
9429
|
-
|
|
9430
|
-
scope: newScope
|
|
9431
|
-
});
|
|
9432
|
-
};
|
|
9433
|
-
var handleZoom = function (_a) {
|
|
9434
|
-
var chart = _a.chart;
|
|
9435
|
-
if (debounceTimerRef.current) {
|
|
9436
|
-
clearTimeout(debounceTimerRef.current);
|
|
9437
|
-
}
|
|
9438
|
-
debounceTimerRef.current = setTimeout(function () {
|
|
9439
|
-
// Handle zoom event and execute fetch
|
|
9440
|
-
var newStart = new Date(chart.scales.x.min);
|
|
9441
|
-
var newEnd = new Date(chart.scales.x.max);
|
|
9442
|
-
actions.setTotalScope({
|
|
9443
|
-
start: newStart,
|
|
9444
|
-
end: newEnd
|
|
9445
|
-
});
|
|
9446
|
-
}, 1000);
|
|
9447
|
-
};
|
|
9448
|
-
var handlePan = function (_a) {
|
|
9449
|
-
var chart = _a.chart;
|
|
9450
|
-
if (debounceTimerRef.current) {
|
|
9451
|
-
clearTimeout(debounceTimerRef.current);
|
|
9574
|
+
var _e = useState(false), chartShouldInitCursors = _e[0], setChartShouldInitCursors = _e[1];
|
|
9575
|
+
var verticalLinePlugin = useGetVerticalLinePlugin(setChartArea, setLineTabCoords);
|
|
9576
|
+
var xAxisDatePlugin = useXAxisDatePlugin();
|
|
9577
|
+
var yAxisPlugin = useYAxisPlugin();
|
|
9578
|
+
useEffect(function () {
|
|
9579
|
+
var axes = [];
|
|
9580
|
+
if (!series.length) {
|
|
9581
|
+
return;
|
|
9452
9582
|
}
|
|
9453
|
-
|
|
9454
|
-
|
|
9455
|
-
|
|
9456
|
-
|
|
9457
|
-
|
|
9458
|
-
|
|
9459
|
-
|
|
9460
|
-
graphPan: true
|
|
9461
|
-
});
|
|
9462
|
-
}, 1000);
|
|
9463
|
-
};
|
|
9464
|
-
var handleDeleteTag = function (tagId) {
|
|
9465
|
-
setTagList(function (prevTagList) {
|
|
9466
|
-
return prevTagList.filter(function (tag) { return tag.tagId !== tagId; });
|
|
9467
|
-
});
|
|
9468
|
-
};
|
|
9469
|
-
var handleAddTag = function (newTag) {
|
|
9470
|
-
if (newTag) {
|
|
9471
|
-
setTagList(function (prevTagList) {
|
|
9472
|
-
// Check if the tag is already in the list to avoid duplicates
|
|
9473
|
-
if (prevTagList.some(function (tag) { return tag.tagId === newTag.tagId; })) {
|
|
9474
|
-
return prevTagList; // Return the existing list if the tag is already there
|
|
9583
|
+
tagList.forEach(function (tag, index) {
|
|
9584
|
+
if (series[index].length) {
|
|
9585
|
+
if (tag.autoScale && series[index]) {
|
|
9586
|
+
var serieSamples = series[index].map(function (sample) { return sample.value; });
|
|
9587
|
+
var _a = calculateScales(Math.min.apply(Math, serieSamples), Math.max.apply(Math, serieSamples), 3), minScale = _a.minScale, maxScale = _a.maxScale;
|
|
9588
|
+
tag.minScale = minScale;
|
|
9589
|
+
tag.maxScale = maxScale;
|
|
9475
9590
|
}
|
|
9476
|
-
|
|
9477
|
-
|
|
9478
|
-
|
|
9479
|
-
|
|
9480
|
-
|
|
9481
|
-
|
|
9482
|
-
|
|
9483
|
-
|
|
9484
|
-
|
|
9485
|
-
|
|
9486
|
-
|
|
9487
|
-
|
|
9488
|
-
|
|
9489
|
-
|
|
9490
|
-
|
|
9491
|
-
|
|
9492
|
-
|
|
9493
|
-
|
|
9494
|
-
type: "time",
|
|
9591
|
+
var existingAxis = axes.find(function (existingTag) {
|
|
9592
|
+
return areRangesSimilar(existingTag, tag);
|
|
9593
|
+
});
|
|
9594
|
+
if (!existingAxis) {
|
|
9595
|
+
axes.push(tag); // Add new axis if no similar one exists
|
|
9596
|
+
}
|
|
9597
|
+
}
|
|
9598
|
+
});
|
|
9599
|
+
// Configure yAxes based on grouped axes
|
|
9600
|
+
var yAxesConfig = axes.map(function (axis, index) {
|
|
9601
|
+
return {
|
|
9602
|
+
id: "y-axis-".concat(index),
|
|
9603
|
+
type: "linear",
|
|
9604
|
+
display: axis.visible,
|
|
9605
|
+
scaleLabel: {
|
|
9606
|
+
display: true,
|
|
9607
|
+
labelString: axis.tagName
|
|
9608
|
+
},
|
|
9495
9609
|
ticks: {
|
|
9496
|
-
|
|
9497
|
-
|
|
9498
|
-
callback: function (value, index, ticks) {
|
|
9499
|
-
var currentDate = new Date(value);
|
|
9500
|
-
var time = formatDateTimeToString(currentDate).formattedTime;
|
|
9501
|
-
var date = formatDateTimeToString(currentDate).formattedDate;
|
|
9502
|
-
// Si es el primer tick, siempre muestra la fecha y hora
|
|
9503
|
-
if (index === 0) {
|
|
9504
|
-
return [time, date];
|
|
9505
|
-
}
|
|
9506
|
-
// De lo contrario, solo muestra la hora
|
|
9507
|
-
return time;
|
|
9508
|
-
}
|
|
9610
|
+
min: axis.autoScale ? undefined : axis.minScale,
|
|
9611
|
+
max: axis.autoScale ? undefined : axis.maxScale
|
|
9509
9612
|
},
|
|
9510
9613
|
grid: {
|
|
9511
9614
|
display: true
|
|
9512
|
-
}
|
|
9513
|
-
},
|
|
9514
|
-
y: {
|
|
9515
|
-
grid: {
|
|
9516
|
-
display: true
|
|
9517
|
-
}
|
|
9518
|
-
}
|
|
9519
|
-
},
|
|
9520
|
-
plugins: {
|
|
9521
|
-
tooltip: { enabled: false },
|
|
9522
|
-
legend: { display: false },
|
|
9523
|
-
zoom: {
|
|
9524
|
-
zoom: {
|
|
9525
|
-
wheel: { enabled: true, mode: "x" },
|
|
9526
|
-
pinch: { enabled: true, mode: "x" },
|
|
9527
|
-
onZoom: handleZoom,
|
|
9528
|
-
mode: "x"
|
|
9529
9615
|
},
|
|
9530
|
-
|
|
9531
|
-
|
|
9532
|
-
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
|
|
9539
|
-
var fetchData = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
9540
|
-
var tagIds, response, series_1, axes_1, updatedSeries, error_1;
|
|
9541
|
-
return __generator(this, function (_a) {
|
|
9542
|
-
switch (_a.label) {
|
|
9543
|
-
case 0:
|
|
9544
|
-
_a.trys.push([0, 2, , 3]);
|
|
9545
|
-
console.log("fetching data");
|
|
9546
|
-
setLoading(true);
|
|
9547
|
-
tagIds = tagList.map(function (tag) { return tag.tagId; });
|
|
9548
|
-
return [4 /*yield*/, axios.post("/series?nodeName=null", {
|
|
9549
|
-
start: state.timeScopeStart.getTime(),
|
|
9550
|
-
end: state.timeScopeEnd.getTime(),
|
|
9551
|
-
tagIds: tagIds,
|
|
9552
|
-
sampleCount: 1000
|
|
9553
|
-
})];
|
|
9554
|
-
case 1:
|
|
9555
|
-
response = _a.sent();
|
|
9556
|
-
series_1 = response.data;
|
|
9557
|
-
axes_1 = [];
|
|
9558
|
-
tagList.forEach(function (tag, index) {
|
|
9559
|
-
if (tag.autoScale && series_1[index]) {
|
|
9560
|
-
var serieSamples = series_1[index].map(function (sample) { return sample.value; });
|
|
9561
|
-
var _a = calculateScales(Math.min.apply(Math, serieSamples), Math.max.apply(Math, serieSamples), 3), minScale = _a.minScale, maxScale = _a.maxScale;
|
|
9562
|
-
tag.minScale = minScale;
|
|
9563
|
-
tag.maxScale = maxScale;
|
|
9616
|
+
afterUpdate: function (axis) {
|
|
9617
|
+
var chart = axis.chart;
|
|
9618
|
+
var keys = Object.keys(chart.scales).filter(function (sc) { return sc !== 'x'; });
|
|
9619
|
+
if (keys.length > 1) {
|
|
9620
|
+
for (var scaleKey in chart.scales) {
|
|
9621
|
+
var scale = chart.scales[scaleKey];
|
|
9622
|
+
if (scale.max === 1 && scale.min === 0) {
|
|
9623
|
+
chart.scales[scaleKey].display = false;
|
|
9624
|
+
chart.scales[scaleKey].options.display = false;
|
|
9564
9625
|
}
|
|
9565
|
-
|
|
9566
|
-
|
|
9567
|
-
|
|
9568
|
-
if (!existingAxis) {
|
|
9569
|
-
axes_1.push(tag); // Add new axis if no similar one exists
|
|
9626
|
+
else {
|
|
9627
|
+
chart.scales[scaleKey].display = true;
|
|
9628
|
+
chart.scales[scaleKey].options.display = true;
|
|
9570
9629
|
}
|
|
9571
|
-
}
|
|
9572
|
-
|
|
9573
|
-
return {
|
|
9574
|
-
id: "y-axis-".concat(index),
|
|
9575
|
-
type: "linear",
|
|
9576
|
-
display: axis.visible,
|
|
9577
|
-
scaleLabel: {
|
|
9578
|
-
display: true,
|
|
9579
|
-
labelString: axis.tagName
|
|
9580
|
-
},
|
|
9581
|
-
ticks: {
|
|
9582
|
-
min: axis.autoScale ? undefined : axis.minScale,
|
|
9583
|
-
max: axis.autoScale ? undefined : axis.maxScale
|
|
9584
|
-
},
|
|
9585
|
-
grid: {
|
|
9586
|
-
display: true
|
|
9587
|
-
}
|
|
9588
|
-
};
|
|
9589
|
-
});
|
|
9590
|
-
setChartOptions(function (prevOptions) { return (__assign(__assign({}, prevOptions), { scales: __assign(__assign({}, prevOptions.scales), { y: { grid: { display: true } } }) })); });
|
|
9591
|
-
updatedSeries = series_1.map(function (serie, index) {
|
|
9592
|
-
var tag = tagList[index];
|
|
9593
|
-
var axisIndex = axes_1.findIndex(function (existingTag) {
|
|
9594
|
-
return areRangesSimilar(existingTag, tag);
|
|
9595
|
-
});
|
|
9596
|
-
return {
|
|
9597
|
-
yAxisID: "y-axis-".concat(axisIndex),
|
|
9598
|
-
data: serie.map(function (sample) { return ({
|
|
9599
|
-
x: new Date(sample.timestamp),
|
|
9600
|
-
y: sample.value
|
|
9601
|
-
}); }),
|
|
9602
|
-
tagId: tag.tagId,
|
|
9603
|
-
borderColor: tag.color,
|
|
9604
|
-
hidden: !tag.visible,
|
|
9605
|
-
pointRadius: serie.length <= 50 ? 3 : 0
|
|
9606
|
-
};
|
|
9607
|
-
});
|
|
9608
|
-
setChartShouldInitCursors(true);
|
|
9609
|
-
setChartData({
|
|
9610
|
-
labels: [],
|
|
9611
|
-
datasets: updatedSeries
|
|
9612
|
-
});
|
|
9613
|
-
setLoading(false);
|
|
9614
|
-
return [3 /*break*/, 3];
|
|
9615
|
-
case 2:
|
|
9616
|
-
error_1 = _a.sent();
|
|
9617
|
-
console.error("Error fetching data:", error_1);
|
|
9618
|
-
setError("Failed to fetch data");
|
|
9619
|
-
setLoading(false);
|
|
9620
|
-
return [3 /*break*/, 3];
|
|
9621
|
-
case 3: return [2 /*return*/];
|
|
9630
|
+
}
|
|
9631
|
+
}
|
|
9622
9632
|
}
|
|
9633
|
+
};
|
|
9634
|
+
});
|
|
9635
|
+
setChartOptions(function (prevOptions) {
|
|
9636
|
+
var newResp = (__assign(__assign({}, prevOptions), { scales: __assign({ x: __assign({}, prevOptions.scales.x) }, yAxesConfig.reduce(function (acc, cur) {
|
|
9637
|
+
var _a;
|
|
9638
|
+
return (__assign(__assign({}, acc), (_a = {}, _a[cur.id] = cur, _a)));
|
|
9639
|
+
}, {})) }));
|
|
9640
|
+
return newResp;
|
|
9641
|
+
});
|
|
9642
|
+
var updatedSeries = series.map(function (serie, index) {
|
|
9643
|
+
var tag = tagList[index];
|
|
9644
|
+
var axisIndex = axes.findIndex(function (existingTag) {
|
|
9645
|
+
return areRangesSimilar(existingTag, tag);
|
|
9623
9646
|
});
|
|
9624
|
-
|
|
9625
|
-
|
|
9626
|
-
|
|
9627
|
-
|
|
9628
|
-
|
|
9629
|
-
|
|
9630
|
-
|
|
9631
|
-
|
|
9632
|
-
|
|
9633
|
-
|
|
9634
|
-
|
|
9635
|
-
|
|
9636
|
-
|
|
9637
|
-
|
|
9638
|
-
|
|
9639
|
-
|
|
9640
|
-
|
|
9641
|
-
|
|
9642
|
-
error);
|
|
9643
|
-
useEffect(function () {
|
|
9644
|
-
setChartOptions(function (prevOptions) { return (__assign(__assign({}, prevOptions), { scales: __assign(__assign({}, prevOptions.scales), { x: __assign(__assign({}, prevOptions.scales.x), { min: state.timeScopeStart.getTime(), max: state.timeScopeEnd.getTime() }) }) })); });
|
|
9645
|
-
}, [state.timeScopeStart, state.timeScopeEnd]);
|
|
9647
|
+
return {
|
|
9648
|
+
yAxisID: axisIndex >= 0 ? "y-axis-".concat(axisIndex) : undefined,
|
|
9649
|
+
data: serie.map(function (sample) { return ({
|
|
9650
|
+
x: new Date(sample.timestamp),
|
|
9651
|
+
y: sample.value
|
|
9652
|
+
}); }),
|
|
9653
|
+
tagId: tag.tagId,
|
|
9654
|
+
borderColor: tag.color,
|
|
9655
|
+
hidden: !tag.visible,
|
|
9656
|
+
pointRadius: serie.length <= 50 ? 3 : 0
|
|
9657
|
+
};
|
|
9658
|
+
});
|
|
9659
|
+
setChartShouldInitCursors(true);
|
|
9660
|
+
setChartData({
|
|
9661
|
+
labels: [],
|
|
9662
|
+
datasets: updatedSeries
|
|
9663
|
+
});
|
|
9664
|
+
}, [JSON.stringify(state), tagList, series]);
|
|
9646
9665
|
useEffect(function () {
|
|
9647
9666
|
if (chartShouldInitCursors) {
|
|
9648
9667
|
if (chartRef.current) {
|
|
@@ -9651,62 +9670,91 @@ var Trending = function (_a) {
|
|
|
9651
9670
|
}
|
|
9652
9671
|
}
|
|
9653
9672
|
}, [chartShouldInitCursors, state]);
|
|
9673
|
+
return (React__default.createElement(Paper$1, { style: { height: '100%', position: 'relative' } },
|
|
9674
|
+
lineTabCoords && chartArea ? (React__default.createElement(DraggableLineControl, { color: 'red', chartArea: chartArea, initialLeft: lineTabCoords === null || lineTabCoords === void 0 ? void 0 : lineTabCoords.x1, onUpdate: function (newLeft) {
|
|
9675
|
+
setLineTabCoords(function (prevCoords) {
|
|
9676
|
+
prevCoords.x1 = newLeft;
|
|
9677
|
+
return prevCoords;
|
|
9678
|
+
});
|
|
9679
|
+
// @ts-ignore
|
|
9680
|
+
chartRef.current.mouseX = newLeft;
|
|
9681
|
+
debouncedUpdateChart();
|
|
9682
|
+
} })) : null,
|
|
9683
|
+
lineTabCoords && chartArea ? (React__default.createElement(DraggableLineControl, { color: 'blue', initialLeft: lineTabCoords === null || lineTabCoords === void 0 ? void 0 : lineTabCoords.x2, chartArea: chartArea, onUpdate: function (newLeft) {
|
|
9684
|
+
setLineTabCoords(function (prevCoords) {
|
|
9685
|
+
prevCoords.x2 = newLeft;
|
|
9686
|
+
return prevCoords;
|
|
9687
|
+
});
|
|
9688
|
+
// @ts-ignore
|
|
9689
|
+
chartRef.current.secondLineX = newLeft;
|
|
9690
|
+
debouncedUpdateChart();
|
|
9691
|
+
} })) : null,
|
|
9692
|
+
React__default.createElement(Line, { ref: chartRef, data: chartData, options: chartOptions, plugins: [verticalLinePlugin, xAxisDatePlugin, yAxisPlugin] })));
|
|
9693
|
+
};
|
|
9694
|
+
|
|
9695
|
+
Chart.register(CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip$1, Legend, TimeScale, zoomPlugin);
|
|
9696
|
+
var Trending = function (_a) {
|
|
9697
|
+
_a.title; var tags = _a.tags;
|
|
9698
|
+
var _b = useTrendingContext(), state = _b.state; _b.actions;
|
|
9699
|
+
var _c = useState(true), loading = _c[0], setLoading = _c[1];
|
|
9700
|
+
var _d = useState(""), error = _d[0], setError = _d[1];
|
|
9701
|
+
var _e = useState(tags), tagList = _e[0], setTagList = _e[1];
|
|
9702
|
+
var _f = useState([]), series = _f[0], setSeries = _f[1];
|
|
9703
|
+
var _g = useChartOptions(), chartOptions = _g[0], setChartOptions = _g[1];
|
|
9704
|
+
var _h = useState({
|
|
9705
|
+
labels: [],
|
|
9706
|
+
datasets: []
|
|
9707
|
+
}), chartData = _h[0], setChartData = _h[1];
|
|
9708
|
+
var _j = useState(null), cursorData = _j[0], setCursorData = _j[1];
|
|
9709
|
+
var debounceForFetchingData = useRef(null);
|
|
9710
|
+
useEffect(function () {
|
|
9711
|
+
if (debounceForFetchingData.current) {
|
|
9712
|
+
clearTimeout(debounceForFetchingData.current);
|
|
9713
|
+
}
|
|
9714
|
+
debounceForFetchingData.current = setTimeout(function () {
|
|
9715
|
+
var fetchData = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
9716
|
+
var tagIds, response, error_1;
|
|
9717
|
+
return __generator(this, function (_a) {
|
|
9718
|
+
switch (_a.label) {
|
|
9719
|
+
case 0:
|
|
9720
|
+
_a.trys.push([0, 2, , 3]);
|
|
9721
|
+
console.log("fetching data");
|
|
9722
|
+
setLoading(true);
|
|
9723
|
+
tagIds = tagList.map(function (tag) { return tag.tagId; });
|
|
9724
|
+
return [4 /*yield*/, axios.post("/series?nodeName=null", {
|
|
9725
|
+
start: state.timeScopeStart.getTime(),
|
|
9726
|
+
end: state.timeScopeEnd.getTime(),
|
|
9727
|
+
tagIds: tagIds,
|
|
9728
|
+
sampleCount: 1000
|
|
9729
|
+
})];
|
|
9730
|
+
case 1:
|
|
9731
|
+
response = _a.sent();
|
|
9732
|
+
setSeries(response.data || []);
|
|
9733
|
+
setLoading(false);
|
|
9734
|
+
return [3 /*break*/, 3];
|
|
9735
|
+
case 2:
|
|
9736
|
+
error_1 = _a.sent();
|
|
9737
|
+
console.error("Error fetching data:", error_1);
|
|
9738
|
+
setError("Failed to fetch data");
|
|
9739
|
+
setLoading(false);
|
|
9740
|
+
return [3 /*break*/, 3];
|
|
9741
|
+
case 3: return [2 /*return*/];
|
|
9742
|
+
}
|
|
9743
|
+
});
|
|
9744
|
+
}); };
|
|
9745
|
+
fetchData();
|
|
9746
|
+
}, 800);
|
|
9747
|
+
}, [JSON.stringify(state), tagList]);
|
|
9748
|
+
if (error)
|
|
9749
|
+
return React__default.createElement("p", null,
|
|
9750
|
+
"Error: ",
|
|
9751
|
+
error);
|
|
9654
9752
|
return (React__default.createElement(Grid$1, { container: true, style: { width: "95svw", height: "81svh", margin: 0 } },
|
|
9655
|
-
React__default.createElement(
|
|
9656
|
-
React__default.createElement(Grid$1, { md: 5, item: true, container: true, justifyContent: "flex-start", alignItems: "center", spacing: 1, wrap: "wrap" },
|
|
9657
|
-
React__default.createElement(IconButton$1, { color: "primary", onClick: function () { return handleDateNavigator("subtract"); }, className: classes.navigatorButton },
|
|
9658
|
-
React__default.createElement(ChevronLeft, { fontSize: "large" })),
|
|
9659
|
-
React__default.createElement(Grid$1, { item: true },
|
|
9660
|
-
React__default.createElement(TextField, { type: "datetime-local", className: classes.datetimePicker, label: "Start", variant: "outlined", value: moment(state.timeScopeStart).format("YYYY-MM-DDTHH:mm:ss"), onChange: function (e) { return handleDateChange(e.target.value, "start"); }, InputLabelProps: {
|
|
9661
|
-
shrink: true,
|
|
9662
|
-
style: { marginLeft: "10px" }
|
|
9663
|
-
}, InputProps: {
|
|
9664
|
-
max: state.timeScopeEnd
|
|
9665
|
-
} })),
|
|
9666
|
-
React__default.createElement(Grid$1, { item: true, className: classes.select },
|
|
9667
|
-
React__default.createElement(FormControl$1, { variant: "outlined" },
|
|
9668
|
-
React__default.createElement(Select$1, { value: state.scope, onChange: handleChangeScope, displayEmpty: true },
|
|
9669
|
-
React__default.createElement(MenuItem$1, { value: "10 min" }, "10 min"),
|
|
9670
|
-
React__default.createElement(MenuItem$1, { value: "1 hour" }, "1 hour"),
|
|
9671
|
-
React__default.createElement(MenuItem$1, { value: "4 hours" }, "4 hours"),
|
|
9672
|
-
React__default.createElement(MenuItem$1, { value: "12 hours" }, "12 hours"),
|
|
9673
|
-
React__default.createElement(MenuItem$1, { value: "1 day" }, "1 day"),
|
|
9674
|
-
React__default.createElement(MenuItem$1, { value: "10 days" }, "10 days"),
|
|
9675
|
-
React__default.createElement(MenuItem$1, { value: "custom" }, "Custom")))),
|
|
9676
|
-
React__default.createElement(Grid$1, { item: true },
|
|
9677
|
-
React__default.createElement(TextField, { label: "End", variant: "outlined", className: classes.datetimePicker, type: "datetime-local", value: moment(state.timeScopeEnd).format("YYYY-MM-DDTHH:mm:ss"), onChange: function (e) { return handleDateChange(e.target.value, "end"); }, InputLabelProps: {
|
|
9678
|
-
shrink: true,
|
|
9679
|
-
style: { marginLeft: "10px" }
|
|
9680
|
-
} })),
|
|
9681
|
-
React__default.createElement(IconButton$1, { color: "primary", onClick: function () { return handleDateNavigator("add"); }, className: classes.navigatorButton },
|
|
9682
|
-
React__default.createElement(ChevronRight, { fontSize: "large" }))),
|
|
9683
|
-
React__default.createElement(Grid$1, { md: 7, item: true, container: true, justifyContent: "space-between" },
|
|
9684
|
-
React__default.createElement(Grid$1, { item: true, container: true, wrap: "nowrap", spacing: 1 },
|
|
9685
|
-
React__default.createElement(Grid$1, { item: true, container: true },
|
|
9686
|
-
React__default.createElement(CustomOptionsComponent, { customOptions: customOptions, setCustomOptions: setCustomOptions }))))),
|
|
9753
|
+
React__default.createElement(Header, { setChartOptions: setChartOptions }),
|
|
9687
9754
|
React__default.createElement(Grid$1, { item: true, xs: 12, style: { height: '45%' } },
|
|
9688
|
-
React__default.createElement(
|
|
9689
|
-
lineTabCoords && chartArea ? (React__default.createElement(DraggableLineControl, { color: 'red', chartArea: chartArea, initialLeft: lineTabCoords === null || lineTabCoords === void 0 ? void 0 : lineTabCoords.x1, onUpdate: function (newLeft) {
|
|
9690
|
-
setLineTabCoords(function (prevCoords) {
|
|
9691
|
-
prevCoords.x1 = newLeft;
|
|
9692
|
-
return prevCoords;
|
|
9693
|
-
});
|
|
9694
|
-
// @ts-ignore
|
|
9695
|
-
chartRef.current.mouseX = newLeft;
|
|
9696
|
-
debouncedUpdateChart();
|
|
9697
|
-
} })) : null,
|
|
9698
|
-
lineTabCoords && chartArea ? (React__default.createElement(DraggableLineControl, { color: 'blue', initialLeft: lineTabCoords === null || lineTabCoords === void 0 ? void 0 : lineTabCoords.x2, chartArea: chartArea, onUpdate: function (newLeft) {
|
|
9699
|
-
setLineTabCoords(function (prevCoords) {
|
|
9700
|
-
prevCoords.x2 = newLeft;
|
|
9701
|
-
return prevCoords;
|
|
9702
|
-
});
|
|
9703
|
-
// @ts-ignore
|
|
9704
|
-
chartRef.current.secondLineX = newLeft;
|
|
9705
|
-
debouncedUpdateChart();
|
|
9706
|
-
} })) : null,
|
|
9707
|
-
React__default.createElement(Line, { ref: chartRef, data: chartData, options: chartOptions, plugins: [verticalLinePlugin, xAxisDatePlugin] }))),
|
|
9755
|
+
React__default.createElement(TrendingChart, { setChartData: setChartData, series: series, tagList: tagList, chartOptions: chartOptions, setChartOptions: setChartOptions, chartData: chartData, setCursorData: setCursorData })),
|
|
9708
9756
|
React__default.createElement(Grid$1, { item: true, xs: 12, style: { height: '40%', minWidth: "100%", paddingTop: "3rem" } },
|
|
9709
|
-
React__default.createElement(TableComponent, { tagList: tagList, chartData: chartData, setTagList: setTagList, cursorData: cursorData
|
|
9757
|
+
React__default.createElement(TableComponent, { tagList: tagList, chartData: chartData, setTagList: setTagList, cursorData: cursorData })),
|
|
9710
9758
|
loading && (React__default.createElement(Grid$1, { item: true, xs: 12, style: { textAlign: 'center' } },
|
|
9711
9759
|
React__default.createElement("p", null, "Loading...")))));
|
|
9712
9760
|
};
|
|
@@ -9794,7 +9842,7 @@ var Navigation = function (_a) {
|
|
|
9794
9842
|
};
|
|
9795
9843
|
}, [params.toString()]);
|
|
9796
9844
|
return (React__default.createElement("div", { className: "wrapper" },
|
|
9797
|
-
React__default.createElement(Header, { showAreaSelector: showAreaSelector, navbarTitle: navbarTitle }),
|
|
9845
|
+
React__default.createElement(Header$1, { showAreaSelector: showAreaSelector, navbarTitle: navbarTitle }),
|
|
9798
9846
|
React__default.createElement(MESFMainContainer, null)));
|
|
9799
9847
|
};
|
|
9800
9848
|
|
|
@@ -9957,3 +10005,4 @@ var areaSelector = /*#__PURE__*/Object.freeze({
|
|
|
9957
10005
|
});
|
|
9958
10006
|
|
|
9959
10007
|
export { Account, AssetProvider, AuthContext, AuthProvider, BarChartControl, ChangePassword, CheckBoxControl, Configuration$1 as Configuration, CurrencyFormatter, DataGridControl, DateFormatter, DateTimeFormatter, ErrorModal, FetchError, FilterPanel, GenericPanel, GenericTable, GetCrewColor, GetShiftColor, HorizontalTextControl, IntegerFormatter, Login, Logout, LongFilterPanel, MESApiService, MESFMain, MESSAGE_API, MESSAGE_ERRORS, MasterDetailPanel, MesfModal, ModalTreeFilterControl, MultipleSelectorControl, NumberFormatter, NumericTextControl, SimplePasswordControl, SimpleSelectorControl, SimpleTextAreaControl, SimpleTextControl, TimeFormatter, TreePickerControl, TrendingsIndex, USER_LABELS, UTLSettingsProvider, UploadFileControl, UserProvider, axiosInstance, formatNumber, getCrewStyle, getError, getShiftStyle, getTokenFromLS, renewToken, useAssetContext, useToken, useUTLSettingsContext, useUserContext };
|
|
10008
|
+
//# sourceMappingURL=index.esm.js.map
|