@dexteel/mesf-core 4.5.6 → 4.5.8
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/CHANGELOG.md +3 -0
- package/dist/index.esm.js +607 -254
- package/dist/pages/trendings/components/chart/TableComponent.d.ts +3 -1
- package/dist/pages/trendings/components/chart/Trending.d.ts +1 -24
- package/dist/pages/trendings/components/chart/components/CellComponent.d.ts +11 -0
- package/dist/pages/trendings/components/chart/components/DraggableLineControl.d.ts +10 -0
- package/dist/pages/trendings/components/chart/components/modals/addTagModal/AddTagModal.d.ts +9 -0
- package/dist/pages/trendings/components/chart/{TagSelectionModal.d.ts → components/modals/addTagModal/TagSelectionModal.d.ts} +1 -1
- package/dist/pages/trendings/components/chart/context/TrendingContext.d.ts +7 -1
- package/dist/pages/trendings/components/chart/customOptionsComponent.d.ts +1 -1
- package/dist/pages/trendings/components/chart/hooks/useGetVerticalLinePlugin.d.ts +2 -0
- package/dist/pages/trendings/components/chart/hooks/useTagsDataTable.d.ts +24 -0
- package/dist/pages/trendings/components/chart/hooks/useUpdateCursorData.d.ts +2 -0
- package/dist/pages/trendings/components/chart/models/TrendingModels.d.ts +33 -0
- package/dist/pages/trendings/components/chart/repository/TrendingRepository.d.ts +8 -0
- package/dist/pages/trendings/components/chart/styles/TagsTableStyles.d.ts +1 -1
- package/dist/pages/trendings/components/chart/utils/areRangeSimilar.d.ts +2 -0
- package/dist/pages/trendings/components/chart/utils/calculateScales.d.ts +4 -0
- package/dist/pages/trendings/components/chart/utils/timeDifference.d.ts +1 -0
- package/dist/pages/trendings/reducers/trendings.reducer.d.ts +7 -1
- 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,
|
|
2
|
-
import { values, get, isNil as isNil$1, isEmpty } from 'lodash-es';
|
|
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, debounce } 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';
|
|
@@ -26,11 +26,11 @@ import { _adapters, Chart, CategoryScale, LinearScale, PointElement, LineElement
|
|
|
26
26
|
import moment from 'moment';
|
|
27
27
|
import zoomPlugin from 'chartjs-plugin-zoom';
|
|
28
28
|
import { Line } from 'react-chartjs-2';
|
|
29
|
-
import
|
|
29
|
+
import Popover from '@material-ui/core/Popover';
|
|
30
30
|
import ArrowDropDownIcon from '@material-ui/icons/ArrowDropDown';
|
|
31
31
|
import FolderIcon from '@material-ui/icons/Folder';
|
|
32
32
|
import InsertDriveFileIcon from '@material-ui/icons/InsertDriveFile';
|
|
33
|
-
import
|
|
33
|
+
import { Alert as Alert$3, TreeView as TreeView$1, TreeItem as TreeItem$1 } from '@material-ui/lab';
|
|
34
34
|
import PersonPinCircleIcon from '@material-ui/icons/PersonPinCircle';
|
|
35
35
|
import PropTypes from 'prop-types';
|
|
36
36
|
import { ResponsiveBar } from '@nivo/bar';
|
|
@@ -8348,6 +8348,23 @@ _adapters._date.override(typeof moment === 'function' ? {
|
|
|
8348
8348
|
var css$1 = "/* ContextMenu.css */\n.context-menu {\n position: absolute;\n z-index: 1000;\n background-color: #fff;\n border: 1px solid #ddd;\n box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);\n border-radius: 4px;\n overflow: hidden;\n}\n\n .context-menu ul {\n list-style: none;\n margin: 0;\n padding: 0;\n }\n\n .context-menu li {\n padding: 8px 15px;\n cursor: pointer;\n border-bottom: 1px solid #eee;\n background-color: #fff;\n color: #333;\n font-size: 14px;\n }\n\n .context-menu li:hover {\n background-color: #f5f5f5;\n }\n\n\n";
|
|
8349
8349
|
n(css$1,{});
|
|
8350
8350
|
|
|
8351
|
+
var useTagColorsStyles = makeStyles$1({
|
|
8352
|
+
swatch: {
|
|
8353
|
+
width: '25px',
|
|
8354
|
+
height: '25px',
|
|
8355
|
+
display: 'inline-block',
|
|
8356
|
+
margin: '2px',
|
|
8357
|
+
borderRadius: '4px',
|
|
8358
|
+
cursor: 'pointer'
|
|
8359
|
+
},
|
|
8360
|
+
popover: {
|
|
8361
|
+
display: 'flex',
|
|
8362
|
+
flexWrap: 'wrap',
|
|
8363
|
+
padding: '10px',
|
|
8364
|
+
maxWidth: '165px'
|
|
8365
|
+
}
|
|
8366
|
+
});
|
|
8367
|
+
|
|
8351
8368
|
var tagColors = [
|
|
8352
8369
|
"#5eaf60",
|
|
8353
8370
|
"green",
|
|
@@ -8366,6 +8383,42 @@ var tagColors = [
|
|
|
8366
8383
|
"#bf3b2c", // dark red
|
|
8367
8384
|
];
|
|
8368
8385
|
|
|
8386
|
+
var Swatch = function (_a) {
|
|
8387
|
+
var color = _a.color, onSelect = _a.onSelect;
|
|
8388
|
+
var classes = useTagColorsStyles();
|
|
8389
|
+
return (React__default.createElement("div", { className: classes.swatch, style: { backgroundColor: color }, onClick: function () { return onSelect(color); } }));
|
|
8390
|
+
};
|
|
8391
|
+
var ColorPicker = function (_a) {
|
|
8392
|
+
var onChange = _a.onChange, color = _a.color, elementId = _a.elementId;
|
|
8393
|
+
var classes = useTagColorsStyles();
|
|
8394
|
+
var _b = useState(null), anchorEl = _b[0], setAnchorEl = _b[1];
|
|
8395
|
+
var handleClick = function (event) {
|
|
8396
|
+
setAnchorEl(event.currentTarget);
|
|
8397
|
+
};
|
|
8398
|
+
var handleClose = function () {
|
|
8399
|
+
setAnchorEl(null);
|
|
8400
|
+
};
|
|
8401
|
+
var open = Boolean(anchorEl);
|
|
8402
|
+
var id = open ? 'simple-popover' : undefined;
|
|
8403
|
+
return (React__default.createElement("div", null,
|
|
8404
|
+
React__default.createElement(Button, { "aria-describedby": id, variant: "outlined", onClick: handleClick, style: {
|
|
8405
|
+
backgroundColor: color,
|
|
8406
|
+
width: '20px',
|
|
8407
|
+
height: '20px',
|
|
8408
|
+
minWidth: '20px',
|
|
8409
|
+
padding: 0,
|
|
8410
|
+
margin: '4px'
|
|
8411
|
+
} }),
|
|
8412
|
+
React__default.createElement(Popover, { id: id, open: open, anchorEl: anchorEl, onClose: handleClose, anchorOrigin: {
|
|
8413
|
+
vertical: 'bottom',
|
|
8414
|
+
horizontal: 'left'
|
|
8415
|
+
} },
|
|
8416
|
+
React__default.createElement("div", { className: classes.popover }, tagColors.map(function (color) { return (React__default.createElement(Swatch, { key: color, color: color, onSelect: function (color) {
|
|
8417
|
+
onChange(elementId, color);
|
|
8418
|
+
handleClose();
|
|
8419
|
+
} })); })))));
|
|
8420
|
+
};
|
|
8421
|
+
|
|
8369
8422
|
var TagSelectionModal = function (_a) {
|
|
8370
8423
|
var isOpen = _a.isOpen; _a.onClose; var onTagSelect = _a.onTagSelect;
|
|
8371
8424
|
var _b = useState(true), isLoading = _b[0], setIsLoading = _b[1];
|
|
@@ -8512,57 +8565,74 @@ var TagSelectionModal = function (_a) {
|
|
|
8512
8565
|
React__default.createElement(CircularProgress$1, { size: "2rem" }))) : (React__default.createElement(TreeView$1, { expanded: expanded, onNodeSelect: handleNodeSelect, onNodeToggle: handleNodeToggle }, treeData.map(function (tree) { return renderTree(tree); }))))));
|
|
8513
8566
|
};
|
|
8514
8567
|
|
|
8515
|
-
var
|
|
8516
|
-
|
|
8517
|
-
|
|
8518
|
-
|
|
8519
|
-
|
|
8520
|
-
|
|
8521
|
-
|
|
8522
|
-
|
|
8523
|
-
},
|
|
8524
|
-
popover: {
|
|
8525
|
-
display: 'flex',
|
|
8526
|
-
flexWrap: 'wrap',
|
|
8527
|
-
padding: '10px',
|
|
8528
|
-
maxWidth: '165px'
|
|
8529
|
-
}
|
|
8530
|
-
});
|
|
8568
|
+
var AddTagModal = function (_a) {
|
|
8569
|
+
var open = _a.open, handleClose = _a.handleClose, onTagSelect = _a.onTagSelect;
|
|
8570
|
+
return (React__default.createElement(MesfModal, { open: open, handleClose: handleClose, maxWidth: "lg", "aria-labelledby": "modal-modal-title", "aria-describedby": "modal-modal-description", title: 'Tags' },
|
|
8571
|
+
React__default.createElement(MesfModal.Content, null,
|
|
8572
|
+
React__default.createElement(Box, null,
|
|
8573
|
+
React__default.createElement(Typography, { id: "modal-modal-description" },
|
|
8574
|
+
React__default.createElement(TagSelectionModal, { isOpen: open, onClose: function () { return handleClose; }, onTagSelect: onTagSelect }))))));
|
|
8575
|
+
};
|
|
8531
8576
|
|
|
8532
|
-
var
|
|
8533
|
-
var
|
|
8534
|
-
|
|
8535
|
-
|
|
8536
|
-
|
|
8537
|
-
var
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
|
|
8549
|
-
|
|
8550
|
-
|
|
8551
|
-
|
|
8552
|
-
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
|
|
8556
|
-
|
|
8557
|
-
|
|
8558
|
-
|
|
8559
|
-
|
|
8560
|
-
|
|
8561
|
-
|
|
8562
|
-
|
|
8563
|
-
|
|
8564
|
-
|
|
8565
|
-
|
|
8577
|
+
var useTagsDataTable = function (_a) {
|
|
8578
|
+
var cursorData = _a.cursorData, tagList = _a.tagList, chartData = _a.chartData;
|
|
8579
|
+
return useMemo(function () {
|
|
8580
|
+
// calculo y1,y2,y2y1,ymin,ymax por cada tag
|
|
8581
|
+
var _a;
|
|
8582
|
+
var dataTable = {};
|
|
8583
|
+
if (cursorData) {
|
|
8584
|
+
var _loop_1 = function (idx) {
|
|
8585
|
+
var tag = tagList[idx];
|
|
8586
|
+
var datasetForTag = ((_a = chartData.datasets.find(function (ds) { return ds.tagId === tag.tagId; })) === null || _a === void 0 ? void 0 : _a.data) || [];
|
|
8587
|
+
var p1 = { x: new Date('1900-01-01'), y: 0 };
|
|
8588
|
+
var p2 = { x: new Date('1900-01-01'), y: 0 };
|
|
8589
|
+
var p1Found = false;
|
|
8590
|
+
var pmin = { x: 0, y: Number.POSITIVE_INFINITY };
|
|
8591
|
+
var pmax = { x: 0, y: Number.NEGATIVE_INFINITY };
|
|
8592
|
+
for (var idx_1 = 0; idx_1 < datasetForTag.length; idx_1++) {
|
|
8593
|
+
var curr = datasetForTag[idx_1];
|
|
8594
|
+
var currentVal = curr.x;
|
|
8595
|
+
if (!p1Found) {
|
|
8596
|
+
if (currentVal < cursorData.x1) {
|
|
8597
|
+
p1 = curr;
|
|
8598
|
+
p2 = JSON.parse(JSON.stringify(p1));
|
|
8599
|
+
pmin = JSON.parse(JSON.stringify(p1));
|
|
8600
|
+
pmax = JSON.parse(JSON.stringify(p1));
|
|
8601
|
+
continue;
|
|
8602
|
+
}
|
|
8603
|
+
else {
|
|
8604
|
+
p1Found = true;
|
|
8605
|
+
}
|
|
8606
|
+
}
|
|
8607
|
+
else {
|
|
8608
|
+
if (currentVal < cursorData.x2) {
|
|
8609
|
+
p2 = curr;
|
|
8610
|
+
if (pmin['y'] > curr['y']) {
|
|
8611
|
+
pmin = JSON.parse(JSON.stringify(curr));
|
|
8612
|
+
}
|
|
8613
|
+
if (pmax['y'] < curr['y']) {
|
|
8614
|
+
pmax = JSON.parse(JSON.stringify(curr));
|
|
8615
|
+
}
|
|
8616
|
+
}
|
|
8617
|
+
else {
|
|
8618
|
+
break;
|
|
8619
|
+
}
|
|
8620
|
+
}
|
|
8621
|
+
}
|
|
8622
|
+
dataTable[tag.tagName] = {
|
|
8623
|
+
y1: p1.y,
|
|
8624
|
+
y2: p2.y,
|
|
8625
|
+
y2y1: Number(p2.y) - Number(p1.y),
|
|
8626
|
+
pmin: pmin,
|
|
8627
|
+
pmax: pmax
|
|
8628
|
+
};
|
|
8629
|
+
};
|
|
8630
|
+
for (var idx = 0; idx < tagList.length; idx++) {
|
|
8631
|
+
_loop_1(idx);
|
|
8632
|
+
}
|
|
8633
|
+
}
|
|
8634
|
+
return dataTable;
|
|
8635
|
+
}, [tagList, chartData, cursorData]);
|
|
8566
8636
|
};
|
|
8567
8637
|
|
|
8568
8638
|
var useTagsTableStyles = makeStyles$1(function (theme) { return ({
|
|
@@ -8571,18 +8641,88 @@ var useTagsTableStyles = makeStyles$1(function (theme) { return ({
|
|
|
8571
8641
|
zoom: 1.5
|
|
8572
8642
|
},
|
|
8573
8643
|
textAlign: 'center'
|
|
8644
|
+
},
|
|
8645
|
+
rowHover: {
|
|
8646
|
+
'&:hover': {
|
|
8647
|
+
backgroundColor: "#f2f2f2"
|
|
8648
|
+
}
|
|
8649
|
+
},
|
|
8650
|
+
topTitles: {
|
|
8651
|
+
border: "0.0625rem black solid",
|
|
8652
|
+
borderBottom: "none",
|
|
8653
|
+
backgroundColor: "#e9ecef"
|
|
8654
|
+
},
|
|
8655
|
+
bottomTitlesRow: {
|
|
8656
|
+
'& th': {
|
|
8657
|
+
border: "1px black solid"
|
|
8658
|
+
},
|
|
8659
|
+
backgroundColor: "#e9ecef"
|
|
8660
|
+
},
|
|
8661
|
+
doubleInput: {
|
|
8662
|
+
padding: "0",
|
|
8663
|
+
'& input[type="text"] ': {
|
|
8664
|
+
width: "100%",
|
|
8665
|
+
height: "17px",
|
|
8666
|
+
display: "block",
|
|
8667
|
+
margin: "0",
|
|
8668
|
+
padding: "0"
|
|
8669
|
+
}
|
|
8670
|
+
},
|
|
8671
|
+
inputCol: {
|
|
8672
|
+
width: "11.25rem",
|
|
8673
|
+
overflow: 'hidden',
|
|
8674
|
+
textOverflow: 'ellipsis',
|
|
8675
|
+
whiteSpace: 'nowrap'
|
|
8676
|
+
},
|
|
8677
|
+
autoScale: {
|
|
8678
|
+
width: '7.5rem'
|
|
8679
|
+
},
|
|
8680
|
+
scale: {
|
|
8681
|
+
width: '37.5rem',
|
|
8682
|
+
padding: "0"
|
|
8683
|
+
},
|
|
8684
|
+
visible: {
|
|
8685
|
+
width: '3.75rem'
|
|
8686
|
+
},
|
|
8687
|
+
color: {
|
|
8688
|
+
width: '4.375rem'
|
|
8689
|
+
},
|
|
8690
|
+
unit: {
|
|
8691
|
+
width: '7.5rem'
|
|
8692
|
+
},
|
|
8693
|
+
xStats: {
|
|
8694
|
+
// ...
|
|
8574
8695
|
}
|
|
8575
8696
|
}); });
|
|
8576
8697
|
|
|
8698
|
+
var timeDifference = function (start, end) {
|
|
8699
|
+
console.log(start, end);
|
|
8700
|
+
var differenceMilliseconds = start - end;
|
|
8701
|
+
var seconds = Math.floor(differenceMilliseconds / 1000);
|
|
8702
|
+
var minutes = Math.floor(seconds / 60);
|
|
8703
|
+
var hours = Math.floor(minutes / 60);
|
|
8704
|
+
var remainingMinutes = minutes % 60;
|
|
8705
|
+
var remainingSeconds = seconds % 60;
|
|
8706
|
+
return "".concat(hours, "h ").concat(remainingMinutes, "m ").concat(remainingSeconds, "s");
|
|
8707
|
+
};
|
|
8708
|
+
|
|
8577
8709
|
var TableComponent = function (_a) {
|
|
8578
|
-
var tagList = _a.tagList, setTagList = _a.setTagList, cursorData = _a.cursorData, onDeleteTag = _a.onDeleteTag, onAddTag = _a.onAddTag;
|
|
8710
|
+
var tagList = _a.tagList, setTagList = _a.setTagList, chartData = _a.chartData, cursorData = _a.cursorData, onDeleteTag = _a.onDeleteTag, onAddTag = _a.onAddTag;
|
|
8579
8711
|
var classes = useTagsTableStyles();
|
|
8712
|
+
var _b = useState(""); _b[0]; _b[1];
|
|
8713
|
+
var dataTable = useTagsDataTable({ tagList: tagList, chartData: chartData, cursorData: cursorData });
|
|
8714
|
+
var _c = useState({}), editableTagNames = _c[0], setEditableTagNames = _c[1];
|
|
8580
8715
|
var handleChange = function (index, value, property) {
|
|
8581
8716
|
setTagList(function (prev) { return prev.map(function (tag, currentIndex) {
|
|
8582
8717
|
var _a;
|
|
8583
8718
|
return currentIndex === index ? __assign(__assign({}, tag), (_a = {}, _a[property] = value, _a.autoScale = false, _a)) : tag;
|
|
8584
8719
|
}); });
|
|
8585
8720
|
};
|
|
8721
|
+
var handleChangeAlias = function (tagId, newName) {
|
|
8722
|
+
setTagList(function (prevTagList) {
|
|
8723
|
+
return prevTagList.map(function (tag) { return (tag.tagId === tagId ? __assign(__assign({}, tag), { tagName: newName }) : tag); });
|
|
8724
|
+
});
|
|
8725
|
+
};
|
|
8586
8726
|
var handleVisibilityChange = function (index, value) {
|
|
8587
8727
|
setTagList(function (prev) { return prev.map(function (tag, currentIndex) { return currentIndex === index ? __assign(__assign({}, tag), { visible: value }) : tag; }); });
|
|
8588
8728
|
};
|
|
@@ -8592,10 +8732,9 @@ var TableComponent = function (_a) {
|
|
|
8592
8732
|
var handleColorChange = function (tagId, value) {
|
|
8593
8733
|
setTagList(function (prev) { return prev.map(function (tag) { return tag.tagId === tagId ? __assign(__assign({}, tag), { color: value }) : tag; }); });
|
|
8594
8734
|
};
|
|
8595
|
-
var
|
|
8596
|
-
var
|
|
8597
|
-
var
|
|
8598
|
-
var handleClose = function () { return setModalOpen(false); };
|
|
8735
|
+
var _d = useState(null), selectedRowIndex = _d[0], setSelectedRowIndex = _d[1];
|
|
8736
|
+
var _e = useState(false), addTagModalOpen = _e[0], setAddTagModalOpen = _e[1];
|
|
8737
|
+
var handleClose = function () { return setAddTagModalOpen(false); };
|
|
8599
8738
|
var ContextMenu = function (_a) {
|
|
8600
8739
|
var x = _a.x, y = _a.y, options = _a.options;
|
|
8601
8740
|
var handleContextMenuClick = function (e) {
|
|
@@ -8605,15 +8744,47 @@ var TableComponent = function (_a) {
|
|
|
8605
8744
|
React__default.createElement("ul", null, options.map(function (option) { return (React__default.createElement("li", { key: option.id, onClick: option.onClick }, option.label)); }))));
|
|
8606
8745
|
};
|
|
8607
8746
|
// Position state for the context menu
|
|
8608
|
-
var
|
|
8747
|
+
var _f = useState({ x: 0, y: 0 }), contextMenuPosition = _f[0], setContextMenuPosition = _f[1];
|
|
8609
8748
|
var contextMenuOptions = [
|
|
8610
8749
|
{ id: 'delete', label: 'Remove Tag', onClick: function () { return handleDelete(); } },
|
|
8611
|
-
{ id: 'add', label: 'Add Tag', onClick: function () { return
|
|
8750
|
+
{ id: 'add', label: 'Add Tag', onClick: function () { return setAddTagModalOpen(true); } },
|
|
8751
|
+
{ id: 'saveDefault', label: 'Save Default To Tag', onClick: function () { } },
|
|
8752
|
+
{ id: 'saveAsView', label: 'Save as View', onClick: function () { } },
|
|
8753
|
+
{ id: 'loadView', label: 'Load View', onClick: function () { } },
|
|
8612
8754
|
// ... other options
|
|
8613
8755
|
];
|
|
8614
|
-
|
|
8615
|
-
|
|
8616
|
-
|
|
8756
|
+
// const binarySearch = (arr: any, searchDate: Date): number | null => {
|
|
8757
|
+
// let left = 0;
|
|
8758
|
+
// let right = arr.length - 1;
|
|
8759
|
+
// let closest: number | null = null;
|
|
8760
|
+
// if (!arr.length) return null;
|
|
8761
|
+
// while (left <= right) {
|
|
8762
|
+
// const mid = Math.floor((left + right) / 2);
|
|
8763
|
+
// const midDate = arr[mid].x; // Asegúrate de que esto es una instancia de Date
|
|
8764
|
+
// const midTimestamp = midDate.getTime(); // Esto es un number
|
|
8765
|
+
// const searchTimestamp = searchDate.getTime(); // Esto también es un number
|
|
8766
|
+
// console.log(midTimestamp, searchTimestamp);
|
|
8767
|
+
// if (midTimestamp === searchTimestamp) {
|
|
8768
|
+
// return arr[mid].y;
|
|
8769
|
+
// } else if (midTimestamp < searchTimestamp) {
|
|
8770
|
+
// left = mid + 1;
|
|
8771
|
+
// } else {
|
|
8772
|
+
// right = mid - 1;
|
|
8773
|
+
// }
|
|
8774
|
+
// // Revisa si midDate está más cerca que el 'closest' actual
|
|
8775
|
+
// if (closest === null || Math.abs(midTimestamp - searchTimestamp) < Math.abs(arr[closest].x.getTime() - searchTimestamp)) {
|
|
8776
|
+
// closest = mid;
|
|
8777
|
+
// }
|
|
8778
|
+
// }
|
|
8779
|
+
// return closest !== null ? arr[closest].y : null;
|
|
8780
|
+
// };
|
|
8781
|
+
// useEffect(() => {
|
|
8782
|
+
// if (cursorData) {
|
|
8783
|
+
// const yValue = binarySearch(chartData.datasets[0]?.data, new Date(cursorData.x1));
|
|
8784
|
+
// if(yValue)console.log(yValue,"retorna binary")
|
|
8785
|
+
// }
|
|
8786
|
+
// else console.log("NULL")
|
|
8787
|
+
// }, [cursorData,chartData.datasets[1]?.data])
|
|
8617
8788
|
var handleTagSelect = function (selectedTag) {
|
|
8618
8789
|
onAddTag(selectedTag);
|
|
8619
8790
|
handleClose();
|
|
@@ -8625,6 +8796,12 @@ var TableComponent = function (_a) {
|
|
|
8625
8796
|
setSelectedRowIndex(null); // Reset the selected row index
|
|
8626
8797
|
}
|
|
8627
8798
|
};
|
|
8799
|
+
useEffect(function () {
|
|
8800
|
+
setEditableTagNames(tagList.reduce(function (acc, tag) {
|
|
8801
|
+
acc[tag.tagId] = tag.tagName;
|
|
8802
|
+
return acc;
|
|
8803
|
+
}, {}));
|
|
8804
|
+
}, [tagList]);
|
|
8628
8805
|
useEffect(function () {
|
|
8629
8806
|
var handleGlobalClick = function (e) {
|
|
8630
8807
|
if (selectedRowIndex !== null) {
|
|
@@ -8654,88 +8831,178 @@ var TableComponent = function (_a) {
|
|
|
8654
8831
|
setSelectedRowIndex(index);
|
|
8655
8832
|
setContextMenuPosition({ x: event.clientX, y: event.clientY });
|
|
8656
8833
|
};
|
|
8657
|
-
|
|
8658
|
-
visible: { width: '60px' },
|
|
8659
|
-
color: { width: '70px' },
|
|
8660
|
-
autoScale: { width: '120px' }
|
|
8661
|
-
};
|
|
8662
|
-
var cellStyles = {
|
|
8663
|
-
tagName: {
|
|
8664
|
-
maxWidth: '200px',
|
|
8665
|
-
overflow: 'hidden',
|
|
8666
|
-
textOverflow: 'ellipsis',
|
|
8667
|
-
whiteSpace: 'nowrap'
|
|
8668
|
-
}
|
|
8669
|
-
};
|
|
8670
|
-
return (React__default.createElement(Grid$1, { container: true },
|
|
8834
|
+
return (React__default.createElement(Grid$1, { container: true, spacing: 1 },
|
|
8671
8835
|
React__default.createElement(Grid$1, { item: true, xs: 12 },
|
|
8672
8836
|
React__default.createElement("div", { style: { overflowX: 'auto', width: '100%' } },
|
|
8673
|
-
React__default.createElement("table", { style: { width: '
|
|
8837
|
+
React__default.createElement("table", { style: { width: '100%', tableLayout: 'fixed', textAlign: "center" } },
|
|
8674
8838
|
React__default.createElement("thead", null,
|
|
8675
8839
|
React__default.createElement("tr", null,
|
|
8676
|
-
React__default.createElement("th", {
|
|
8677
|
-
React__default.createElement("th",
|
|
8678
|
-
React__default.createElement("th", {
|
|
8679
|
-
React__default.createElement("th",
|
|
8680
|
-
React__default.createElement("th",
|
|
8681
|
-
|
|
8682
|
-
|
|
8683
|
-
|
|
8840
|
+
React__default.createElement("th", { className: classes.visible }),
|
|
8841
|
+
React__default.createElement("th", { className: classes.inputCol }),
|
|
8842
|
+
React__default.createElement("th", { className: classes.color }),
|
|
8843
|
+
React__default.createElement("th", { colSpan: 4, className: "".concat(classes.topTitles, " ").concat(classes.scale) }, "Scale"),
|
|
8844
|
+
React__default.createElement("th", { className: "".concat(classes.topTitles, " ").concat(classes.xStats) }, cursorData ? (function () {
|
|
8845
|
+
var date = new Date(cursorData.x1);
|
|
8846
|
+
// console.log(cursorData, "cursor data")
|
|
8847
|
+
var formattedDate = date.toLocaleString('en-US', {
|
|
8848
|
+
hour12: false,
|
|
8849
|
+
month: 'short',
|
|
8850
|
+
day: 'numeric',
|
|
8851
|
+
hour: '2-digit',
|
|
8852
|
+
minute: '2-digit',
|
|
8853
|
+
second: '2-digit'
|
|
8854
|
+
});
|
|
8855
|
+
var milliseconds = date.getMilliseconds().toString().padStart(3, '0');
|
|
8856
|
+
var dateText = "".concat(formattedDate, ".").concat(milliseconds);
|
|
8857
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
8858
|
+
React__default.createElement("span", { style: {
|
|
8859
|
+
height: '10px',
|
|
8860
|
+
width: '10px',
|
|
8861
|
+
backgroundColor: "red",
|
|
8862
|
+
borderRadius: '50%',
|
|
8863
|
+
display: 'inline-block',
|
|
8864
|
+
marginRight: '5px'
|
|
8865
|
+
} }),
|
|
8866
|
+
dateText));
|
|
8867
|
+
})() : null),
|
|
8868
|
+
React__default.createElement("th", { className: "".concat(classes.topTitles, " ").concat(classes.xStats) }, cursorData ? (function () {
|
|
8869
|
+
var date = new Date(cursorData.x2);
|
|
8870
|
+
// console.log(cursorData, "cursor data")
|
|
8871
|
+
var formattedDate = date.toLocaleString('en-US', {
|
|
8872
|
+
hour12: false,
|
|
8873
|
+
month: 'short',
|
|
8874
|
+
day: 'numeric',
|
|
8875
|
+
hour: '2-digit',
|
|
8876
|
+
minute: '2-digit',
|
|
8877
|
+
second: '2-digit'
|
|
8878
|
+
});
|
|
8879
|
+
var milliseconds = date.getMilliseconds().toString().padStart(3, '0');
|
|
8880
|
+
var dateText = "".concat(formattedDate, ".").concat(milliseconds);
|
|
8881
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
8882
|
+
React__default.createElement("span", { style: {
|
|
8883
|
+
height: '10px',
|
|
8884
|
+
width: '10px',
|
|
8885
|
+
backgroundColor: "blue",
|
|
8886
|
+
borderRadius: '50%',
|
|
8887
|
+
display: 'inline-block',
|
|
8888
|
+
marginRight: '5px'
|
|
8889
|
+
} }),
|
|
8890
|
+
dateText));
|
|
8891
|
+
})() : null),
|
|
8892
|
+
React__default.createElement("th", { colSpan: 3, className: "".concat(classes.topTitles, " ").concat(classes.xStats) }, cursorData ? timeDifference(cursorData.x2, cursorData.x1) : null)))),
|
|
8893
|
+
React__default.createElement("table", { style: { width: '100%', tableLayout: 'fixed', textAlign: "center" } },
|
|
8894
|
+
React__default.createElement("thead", null,
|
|
8895
|
+
React__default.createElement("tr", { className: classes.bottomTitlesRow },
|
|
8896
|
+
React__default.createElement("th", { className: classes.visible }, "Visible"),
|
|
8897
|
+
React__default.createElement("th", { className: classes.inputCol }, "Alias / Tagname"),
|
|
8898
|
+
React__default.createElement("th", { className: classes.color }, "Color"),
|
|
8899
|
+
React__default.createElement("th", { className: classes.inputCol }, "Min Scale"),
|
|
8900
|
+
React__default.createElement("th", { className: classes.inputCol }, "Max Scale"),
|
|
8901
|
+
React__default.createElement("th", { className: classes.unit }, "Unit"),
|
|
8902
|
+
React__default.createElement("th", { className: classes.autoScale }, "AutoScale"),
|
|
8903
|
+
React__default.createElement("th", null, " "),
|
|
8904
|
+
React__default.createElement("th", null),
|
|
8905
|
+
React__default.createElement("th", null, "Y2-Y1"),
|
|
8906
|
+
React__default.createElement("th", null, "Min"),
|
|
8907
|
+
React__default.createElement("th", null, "Max")))))),
|
|
8684
8908
|
React__default.createElement(Grid$1, { item: true, xs: 12 },
|
|
8685
|
-
React__default.createElement("div", { style: { width: '100%', overflowY: 'auto', maxHeight: '
|
|
8686
|
-
React__default.createElement("table", { cellPadding: '4px', style: { width: '
|
|
8687
|
-
React__default.createElement("tbody", null, tagList.map(function (tag, index) {
|
|
8688
|
-
|
|
8689
|
-
|
|
8690
|
-
|
|
8691
|
-
|
|
8692
|
-
|
|
8693
|
-
|
|
8694
|
-
|
|
8695
|
-
|
|
8696
|
-
|
|
8697
|
-
|
|
8698
|
-
|
|
8699
|
-
|
|
8700
|
-
|
|
8701
|
-
|
|
8702
|
-
|
|
8703
|
-
React__default.createElement("
|
|
8704
|
-
|
|
8705
|
-
|
|
8706
|
-
|
|
8707
|
-
|
|
8708
|
-
|
|
8709
|
-
|
|
8710
|
-
|
|
8711
|
-
|
|
8712
|
-
React__default.createElement("
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
8718
|
-
|
|
8719
|
-
|
|
8720
|
-
|
|
8721
|
-
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
|
|
8909
|
+
React__default.createElement("div", { style: { width: '100%', overflowY: 'auto', maxHeight: ' 20svh' } },
|
|
8910
|
+
React__default.createElement("table", { cellPadding: '4px', style: { width: '100%', tableLayout: 'fixed', textAlign: "center" } },
|
|
8911
|
+
React__default.createElement("tbody", null, tagList.map(function (tag, index) {
|
|
8912
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
8913
|
+
return (React__default.createElement("tr", { key: tag.tagName, onClick: function () { return handleRowClick(index); }, onContextMenu: function (e) { return handleRightClick(e, index); }, className: classes.rowHover },
|
|
8914
|
+
React__default.createElement("td", { className: "".concat(classes.visible, " ").concat(classes.checkbox) },
|
|
8915
|
+
React__default.createElement("input", { type: "checkbox", checked: tag.visible, onChange: function (e) { return handleVisibilityChange(index, e.target.checked); } })),
|
|
8916
|
+
React__default.createElement("td", { className: classes.inputCol },
|
|
8917
|
+
React__default.createElement(Tooltip, { title: tag.tagName, placement: "top", arrow: true, interactive: true, enterDelay: 500 },
|
|
8918
|
+
React__default.createElement("div", null,
|
|
8919
|
+
React__default.createElement("input", { type: "text", style: { width: '100%' }, value: editableTagNames[tag.tagId] || '', onFocus: function (e) { return e.target.select(); }, onChange: function (e) {
|
|
8920
|
+
var _a;
|
|
8921
|
+
setEditableTagNames(__assign(__assign({}, editableTagNames), (_a = {}, _a[tag.tagId] = e.target.value, _a)));
|
|
8922
|
+
}, onKeyDown: function (e) {
|
|
8923
|
+
if (e.key === 'Enter') {
|
|
8924
|
+
handleChangeAlias(tag.tagId, editableTagNames[tag.tagId]);
|
|
8925
|
+
}
|
|
8926
|
+
} })))),
|
|
8927
|
+
React__default.createElement("td", { className: classes.color },
|
|
8928
|
+
React__default.createElement(ColorPicker, { onChange: handleColorChange, color: tag.color, elementId: tag.tagId })),
|
|
8929
|
+
React__default.createElement("td", { className: classes.inputCol },
|
|
8930
|
+
React__default.createElement("input", { type: "text", style: { width: '100%' }, disabled: tag.autoScale, value: tag.minScale, onFocus: function (e) { return e.target.select(); }, onChange: function (e) {
|
|
8931
|
+
var value = e.target.value;
|
|
8932
|
+
var numericValue = Number(value);
|
|
8933
|
+
// Check if the value is a number and not empty
|
|
8934
|
+
handleChange(index, numericValue, 'minScale');
|
|
8935
|
+
} })),
|
|
8936
|
+
React__default.createElement("td", { className: classes.inputCol },
|
|
8937
|
+
React__default.createElement("input", { type: "text", style: { width: '100%' }, disabled: tag.autoScale, value: tag.maxScale, onFocus: function (e) { return e.target.select(); }, onChange: function (e) {
|
|
8938
|
+
var value = e.target.value;
|
|
8939
|
+
var numericValue = Number(value);
|
|
8940
|
+
// Check if the value is a number and not empty
|
|
8941
|
+
if (!isNaN(numericValue) && value.trim() !== '') {
|
|
8942
|
+
handleChange(index, numericValue, 'maxScale');
|
|
8943
|
+
}
|
|
8944
|
+
} })),
|
|
8945
|
+
React__default.createElement("td", { className: "".concat(classes.autoScale, " ").concat(classes.checkbox) },
|
|
8946
|
+
React__default.createElement("input", { type: "text", style: { width: '100%' }, disabled: true, value: /* tag.unit */ "Unit ", onFocus: function (e) { return e.target.select(); } })),
|
|
8947
|
+
React__default.createElement("td", { className: "".concat(classes.autoScale, " ").concat(classes.checkbox) },
|
|
8948
|
+
React__default.createElement("input", { type: "checkbox", checked: tag.autoScale, onChange: function (e) { return handleAutoScaleChange(index, e.target.checked); } })),
|
|
8949
|
+
React__default.createElement("td", null, (_a = dataTable[tag.tagName]) === null || _a === void 0 ? void 0 : _a.y1),
|
|
8950
|
+
React__default.createElement("td", { className: classes.doubleInput }, (_b = dataTable[tag.tagName]) === null || _b === void 0 ? void 0 : _b.y2),
|
|
8951
|
+
React__default.createElement("td", null, (_c = dataTable[tag.tagName]) === null || _c === void 0 ? void 0 : _c.y2y1),
|
|
8952
|
+
React__default.createElement("td", null,
|
|
8953
|
+
!isNaN(((_d = dataTable[tag.tagName]) === null || _d === void 0 ? void 0 : _d.pmin.y) * 0) ? (_e = dataTable[tag.tagName]) === null || _e === void 0 ? void 0 : _e.pmin.y : 0,
|
|
8954
|
+
" "),
|
|
8955
|
+
React__default.createElement("td", null,
|
|
8956
|
+
!isNaN(((_f = dataTable[tag.tagName]) === null || _f === void 0 ? void 0 : _f.pmax.y) * 0) ? (_g = dataTable[tag.tagName]) === null || _g === void 0 ? void 0 : _g.pmax.y : 0,
|
|
8957
|
+
" ")));
|
|
8958
|
+
}))))),
|
|
8727
8959
|
selectedRowIndex !== null && (React__default.createElement(ContextMenu, { x: contextMenuPosition.x, y: contextMenuPosition.y, options: contextMenuOptions })),
|
|
8728
|
-
React__default.createElement(
|
|
8729
|
-
|
|
8730
|
-
|
|
8731
|
-
|
|
8732
|
-
|
|
8960
|
+
React__default.createElement(AddTagModal, { open: addTagModalOpen, handleClose: handleClose, onTagSelect: handleTagSelect })));
|
|
8961
|
+
};
|
|
8962
|
+
|
|
8963
|
+
var DraggableLineControl = function (_a) {
|
|
8964
|
+
var initialLeft = _a.initialLeft, onUpdate = _a.onUpdate, color = _a.color, chartArea = _a.chartArea;
|
|
8965
|
+
var _b = useState(false), isDragging = _b[0], setIsDragging = _b[1];
|
|
8966
|
+
var _c = useState(initialLeft), left = _c[0], setLeft = _c[1];
|
|
8967
|
+
var ref = useRef(null);
|
|
8968
|
+
var handleMouseDown = function (e) {
|
|
8969
|
+
setIsDragging(true);
|
|
8970
|
+
e.stopPropagation();
|
|
8971
|
+
e.preventDefault();
|
|
8972
|
+
};
|
|
8973
|
+
var handleMouseMove = function (e) {
|
|
8974
|
+
if (!isDragging || !ref.current)
|
|
8975
|
+
return;
|
|
8976
|
+
chartArea.width - chartArea.right;
|
|
8977
|
+
chartArea.left;
|
|
8978
|
+
var newLeft = Math.min(Math.max(e.clientX - ref.current.offsetParent.getBoundingClientRect().left, chartArea.left), chartArea.right);
|
|
8979
|
+
setLeft(newLeft);
|
|
8980
|
+
onUpdate(newLeft); // Actualiza la posición de la línea en el gráfico
|
|
8981
|
+
};
|
|
8982
|
+
var handleMouseUp = function () {
|
|
8983
|
+
setIsDragging(false);
|
|
8984
|
+
};
|
|
8985
|
+
useEffect(function () {
|
|
8986
|
+
var mouseMoveHandler = function (e) { return handleMouseMove(e); };
|
|
8987
|
+
var mouseUpHandler = function () { return handleMouseUp(); };
|
|
8988
|
+
if (isDragging) {
|
|
8989
|
+
window.addEventListener('mousemove', mouseMoveHandler);
|
|
8990
|
+
window.addEventListener('mouseup', mouseUpHandler);
|
|
8991
|
+
}
|
|
8992
|
+
return function () {
|
|
8993
|
+
window.removeEventListener('mousemove', mouseMoveHandler);
|
|
8994
|
+
window.removeEventListener('mouseup', mouseUpHandler);
|
|
8995
|
+
};
|
|
8996
|
+
}, [isDragging]);
|
|
8997
|
+
return (React__default.createElement("div", { ref: ref, style: { height: 20, width: 20, background: color, position: 'absolute', top: -10, left: left - 10 }, onMouseDown: handleMouseDown },
|
|
8998
|
+
React__default.createElement("div", { style: { height: chartArea.height, width: 2, background: color, position: 'relative', top: 20, left: 0, right: 0, margin: 'auto' } })));
|
|
8733
8999
|
};
|
|
8734
9000
|
|
|
8735
9001
|
var TrendingsInitialState = {
|
|
8736
9002
|
timeScopeStart: moment(new Date()).subtract(1, "days").toDate(),
|
|
8737
9003
|
timeScopeEnd: new Date(),
|
|
8738
|
-
scope: "1 day"
|
|
9004
|
+
scope: "1 day",
|
|
9005
|
+
graphPan: false
|
|
8739
9006
|
};
|
|
8740
9007
|
var TrendingsReducer = createSlice({
|
|
8741
9008
|
name: "__",
|
|
@@ -8788,13 +9055,19 @@ var TrendingsReducer = createSlice({
|
|
|
8788
9055
|
state.scope = payload.scope;
|
|
8789
9056
|
return;
|
|
8790
9057
|
}
|
|
8791
|
-
if (!isNil$1(payload.start) && !isNil$1(payload.end) && isNil$1(payload.
|
|
8792
|
-
// from
|
|
9058
|
+
if (!isNil$1(payload.start) && !isNil$1(payload.end) && isNil$1(payload.graphPan)) {
|
|
9059
|
+
// from zoom
|
|
8793
9060
|
state.timeScopeStart = payload.start;
|
|
8794
9061
|
state.timeScopeEnd = payload.end;
|
|
8795
9062
|
state.scope = "custom";
|
|
8796
9063
|
return;
|
|
8797
9064
|
}
|
|
9065
|
+
if (!isNil$1(payload.start) && !isNil$1(payload.end) && !isNil$1(payload.graphPan)) {
|
|
9066
|
+
// from pan
|
|
9067
|
+
state.timeScopeStart = payload.start;
|
|
9068
|
+
state.timeScopeEnd = payload.end;
|
|
9069
|
+
return;
|
|
9070
|
+
}
|
|
8798
9071
|
if (!isNil$1(payload.start)) {
|
|
8799
9072
|
state.timeScopeStart = payload.start;
|
|
8800
9073
|
if (state.scope !== "custom") {
|
|
@@ -8967,6 +9240,100 @@ var CustomOptionsComponent = function (_a) {
|
|
|
8967
9240
|
"Stepped"))));
|
|
8968
9241
|
};
|
|
8969
9242
|
|
|
9243
|
+
var useGetVerticalLinePlugin = function (setChartArea, setCoords) {
|
|
9244
|
+
return {
|
|
9245
|
+
id: "verticalLinePlugin",
|
|
9246
|
+
afterUpdate: function (chart) {
|
|
9247
|
+
if (chart.chartArea) {
|
|
9248
|
+
// console.log("after update");
|
|
9249
|
+
if (chart.mouseX === null) {
|
|
9250
|
+
chart.mouseX = chart.chartArea.left + (chart.chartArea.width / 10);
|
|
9251
|
+
// chart.mouseX = chart.chartArea.left + 30.9
|
|
9252
|
+
}
|
|
9253
|
+
if (chart.secondLineX === null) {
|
|
9254
|
+
chart.secondLineX = chart.chartArea.left + (chart.chartArea.width * 0.90);
|
|
9255
|
+
// chart.secondLineX = chart.chartArea.right
|
|
9256
|
+
}
|
|
9257
|
+
}
|
|
9258
|
+
},
|
|
9259
|
+
beforeInit: function (chart) {
|
|
9260
|
+
chart.mouseX = null;
|
|
9261
|
+
chart.secondLineX = null;
|
|
9262
|
+
},
|
|
9263
|
+
afterDatasetsDraw: function (chart) {
|
|
9264
|
+
var x1 = chart.mouseX;
|
|
9265
|
+
var x2 = chart.secondLineX;
|
|
9266
|
+
setChartArea(chart.chartArea);
|
|
9267
|
+
setCoords({ x1: x1, x2: x2 });
|
|
9268
|
+
}
|
|
9269
|
+
};
|
|
9270
|
+
};
|
|
9271
|
+
|
|
9272
|
+
var getValuesAtCursor = function (chart, timeAtCursor) {
|
|
9273
|
+
var valuesAtCursor = [];
|
|
9274
|
+
chart.data.datasets.forEach(function (dataset) {
|
|
9275
|
+
var previousDataPoint = null;
|
|
9276
|
+
for (var i = 0; i < dataset.data.length; i++) {
|
|
9277
|
+
if (dataset.data[i].x.getTime() <= timeAtCursor) {
|
|
9278
|
+
previousDataPoint = dataset.data[i];
|
|
9279
|
+
}
|
|
9280
|
+
else {
|
|
9281
|
+
break;
|
|
9282
|
+
}
|
|
9283
|
+
}
|
|
9284
|
+
if (previousDataPoint) {
|
|
9285
|
+
valuesAtCursor.push(previousDataPoint.y);
|
|
9286
|
+
}
|
|
9287
|
+
});
|
|
9288
|
+
return valuesAtCursor;
|
|
9289
|
+
};
|
|
9290
|
+
var updateCursorData = function (chart, setCursorData) {
|
|
9291
|
+
var xScale = chart.scales.x;
|
|
9292
|
+
// Coordenadas para la primera y segunda línea
|
|
9293
|
+
var timeAtCursor1 = xScale.getValueForPixel(chart.mouseX);
|
|
9294
|
+
var timeAtCursor2 = xScale.getValueForPixel(chart.secondLineX);
|
|
9295
|
+
// Los valores en el punto del cursor pueden ser diferentes
|
|
9296
|
+
var valuesAtCursor1 = getValuesAtCursor(chart, timeAtCursor1);
|
|
9297
|
+
var valuesAtCursor2 = getValuesAtCursor(chart, timeAtCursor2);
|
|
9298
|
+
setCursorData({
|
|
9299
|
+
x1: timeAtCursor1,
|
|
9300
|
+
x2: timeAtCursor2,
|
|
9301
|
+
values: __spreadArray(__spreadArray([], valuesAtCursor1, true), valuesAtCursor2, true)
|
|
9302
|
+
});
|
|
9303
|
+
};
|
|
9304
|
+
|
|
9305
|
+
var areRangesSimilar = function (tag1, tag2) {
|
|
9306
|
+
var range1 = tag1.maxScale - tag1.minScale; // Rango de la primera etiqueta
|
|
9307
|
+
var range2 = tag2.maxScale - tag2.minScale; // Rango de la segunda etiqueta
|
|
9308
|
+
// Determina los límites para la comparación
|
|
9309
|
+
var lowerBound = Math.max(tag1.minScale, tag2.minScale);
|
|
9310
|
+
var upperBound = Math.min(tag1.maxScale, tag2.maxScale);
|
|
9311
|
+
// Calcula el solapamiento entre los dos rangos
|
|
9312
|
+
var overlap = Math.max(0, upperBound - lowerBound);
|
|
9313
|
+
// Determina si el solapamiento es significativo comparado con los rangos individuales
|
|
9314
|
+
var isSignificantOverlap = (overlap / range1 > 0.5) && (overlap / range2 > 0.5);
|
|
9315
|
+
return isSignificantOverlap;
|
|
9316
|
+
};
|
|
9317
|
+
|
|
9318
|
+
var calculateScales = function (min, max, sigDigits) {
|
|
9319
|
+
var roundToSignificantDigits = function (num) {
|
|
9320
|
+
if (num === 0)
|
|
9321
|
+
return 0;
|
|
9322
|
+
var multiplier = Math.pow(10, sigDigits - Math.floor(Math.log10(Math.abs(num))) - 1);
|
|
9323
|
+
return Math.round(num * multiplier) / multiplier;
|
|
9324
|
+
};
|
|
9325
|
+
var minScale = roundToSignificantDigits(min);
|
|
9326
|
+
var maxScale = roundToSignificantDigits(max);
|
|
9327
|
+
// Adjust minScale and maxScale if necessary
|
|
9328
|
+
if (minScale > min) {
|
|
9329
|
+
minScale *= 0.9;
|
|
9330
|
+
}
|
|
9331
|
+
if (maxScale < max) {
|
|
9332
|
+
maxScale *= 1.1;
|
|
9333
|
+
}
|
|
9334
|
+
return { minScale: minScale, maxScale: maxScale };
|
|
9335
|
+
};
|
|
9336
|
+
|
|
8970
9337
|
var dateNavigator = function (startDate, endDate, scope, operator) {
|
|
8971
9338
|
if (scope === "custom")
|
|
8972
9339
|
return;
|
|
@@ -8979,76 +9346,34 @@ var dateNavigator = function (startDate, endDate, scope, operator) {
|
|
|
8979
9346
|
};
|
|
8980
9347
|
|
|
8981
9348
|
Chart.register(CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip$1, Legend, TimeScale, zoomPlugin);
|
|
8982
|
-
function getVerticalLinePlugin(setCursorData) {
|
|
8983
|
-
return {
|
|
8984
|
-
id: "verticalLinePlugin",
|
|
8985
|
-
beforeInit: function (chart) {
|
|
8986
|
-
var canvas = chart.canvas;
|
|
8987
|
-
chart.mouseX = null;
|
|
8988
|
-
canvas.addEventListener("mousemove", function (event) {
|
|
8989
|
-
var rect = canvas.getBoundingClientRect();
|
|
8990
|
-
chart.mouseX = event.clientX - rect.left;
|
|
8991
|
-
var xScale = chart.scales.x;
|
|
8992
|
-
var mouseXPixel = chart.mouseX - xScale.left; // Adjusting for the scale's position
|
|
8993
|
-
var timeAtCursor = xScale.min +
|
|
8994
|
-
(mouseXPixel * (xScale.max - xScale.min)) / xScale.width;
|
|
8995
|
-
var valuesAtCursor = [];
|
|
8996
|
-
// Loop through each dataset to find the previous y-values at the current x-position
|
|
8997
|
-
chart.data.datasets.forEach(function (dataset) {
|
|
8998
|
-
// Find the closest preceding data point
|
|
8999
|
-
var previousDataPoint = null;
|
|
9000
|
-
for (var i = 0; i < dataset.data.length; i++) {
|
|
9001
|
-
if (dataset.data[i].x.getTime() <= timeAtCursor) {
|
|
9002
|
-
previousDataPoint = dataset.data[i];
|
|
9003
|
-
}
|
|
9004
|
-
else {
|
|
9005
|
-
break;
|
|
9006
|
-
}
|
|
9007
|
-
}
|
|
9008
|
-
if (previousDataPoint) {
|
|
9009
|
-
valuesAtCursor.push(previousDataPoint.y);
|
|
9010
|
-
}
|
|
9011
|
-
});
|
|
9012
|
-
setCursorData({ x: timeAtCursor, values: valuesAtCursor });
|
|
9013
|
-
chart.draw();
|
|
9014
|
-
});
|
|
9015
|
-
},
|
|
9016
|
-
afterDatasetsDraw: function (chart, args, options) {
|
|
9017
|
-
if (chart.mouseX) {
|
|
9018
|
-
var ctx = chart.ctx;
|
|
9019
|
-
var x = chart.mouseX;
|
|
9020
|
-
var topY = chart.chartArea.top;
|
|
9021
|
-
var bottomY = chart.chartArea.bottom;
|
|
9022
|
-
ctx.save();
|
|
9023
|
-
ctx.beginPath();
|
|
9024
|
-
ctx.moveTo(x, topY);
|
|
9025
|
-
ctx.lineTo(x, bottomY);
|
|
9026
|
-
ctx.strokeStyle = "#ff0000"; // Customize line color
|
|
9027
|
-
ctx.lineWidth = 1; // Customize line width
|
|
9028
|
-
ctx.stroke();
|
|
9029
|
-
ctx.restore();
|
|
9030
|
-
}
|
|
9031
|
-
}
|
|
9032
|
-
};
|
|
9033
|
-
}
|
|
9034
9349
|
var Trending = function (_a) {
|
|
9035
9350
|
_a.title; var tags = _a.tags;
|
|
9351
|
+
var classes = useTrendingStyles();
|
|
9036
9352
|
var _b = useTrendingContext(), state = _b.state, actions = _b.actions;
|
|
9037
|
-
var _c = useState(
|
|
9353
|
+
var _c = useState(true), loading = _c[0], setLoading = _c[1];
|
|
9354
|
+
var _d = useState(""), error = _d[0], setError = _d[1];
|
|
9355
|
+
var _e = useState(tags), tagList = _e[0], setTagList = _e[1];
|
|
9356
|
+
var _f = useState(null), cursorData = _f[0], setCursorData = _f[1];
|
|
9357
|
+
var _g = useState(null), lineTabCoords = _g[0], setLineTabCoords = _g[1];
|
|
9358
|
+
var _h = useState(null), chartArea = _h[0], setChartArea = _h[1];
|
|
9359
|
+
var _j = useState(false), chartShouldInitCursors = _j[0], setChartShouldInitCursors = _j[1];
|
|
9360
|
+
var chartRef = useRef(null);
|
|
9361
|
+
var _k = useState({
|
|
9038
9362
|
labels: [],
|
|
9039
9363
|
datasets: []
|
|
9040
|
-
}), chartData =
|
|
9041
|
-
var
|
|
9042
|
-
var
|
|
9043
|
-
var verticalLinePlugin = getVerticalLinePlugin(setCursorData);
|
|
9044
|
-
var _f = useState({
|
|
9364
|
+
}), chartData = _k[0], setChartData = _k[1];
|
|
9365
|
+
var verticalLinePlugin = useGetVerticalLinePlugin(setChartArea, setLineTabCoords);
|
|
9366
|
+
var _l = useState({
|
|
9045
9367
|
showGrid: true,
|
|
9046
9368
|
stepped: false
|
|
9047
|
-
}), customOptions =
|
|
9048
|
-
var _g = useState(true), loading = _g[0], setLoading = _g[1];
|
|
9049
|
-
var _h = useState(""), error = _h[0], setError = _h[1];
|
|
9369
|
+
}), customOptions = _l[0], setCustomOptions = _l[1];
|
|
9050
9370
|
var debounceTimerRef = useRef(null);
|
|
9051
|
-
var
|
|
9371
|
+
var debouncedUpdateChart = useRef(debounce(function () {
|
|
9372
|
+
if (chartRef.current) {
|
|
9373
|
+
updateCursorData(chartRef.current, setCursorData);
|
|
9374
|
+
chartRef.current.update();
|
|
9375
|
+
}
|
|
9376
|
+
}, 250)).current;
|
|
9052
9377
|
var handleDateChange = function (newValue, key) {
|
|
9053
9378
|
var _a;
|
|
9054
9379
|
//@ts-ignore
|
|
@@ -9075,6 +9400,22 @@ var Trending = function (_a) {
|
|
|
9075
9400
|
});
|
|
9076
9401
|
}, 1000);
|
|
9077
9402
|
};
|
|
9403
|
+
var handlePan = function (_a) {
|
|
9404
|
+
var chart = _a.chart;
|
|
9405
|
+
if (debounceTimerRef.current) {
|
|
9406
|
+
clearTimeout(debounceTimerRef.current);
|
|
9407
|
+
}
|
|
9408
|
+
debounceTimerRef.current = setTimeout(function () {
|
|
9409
|
+
// Handle pan event and execute fetch
|
|
9410
|
+
var newStart = new Date(chart.scales.x.min);
|
|
9411
|
+
var newEnd = new Date(chart.scales.x.max);
|
|
9412
|
+
actions.setTotalScope({
|
|
9413
|
+
start: newStart,
|
|
9414
|
+
end: newEnd,
|
|
9415
|
+
graphPan: true
|
|
9416
|
+
});
|
|
9417
|
+
}, 1000);
|
|
9418
|
+
};
|
|
9078
9419
|
var handleDeleteTag = function (tagId) {
|
|
9079
9420
|
setTagList(function (prevTagList) {
|
|
9080
9421
|
return prevTagList.filter(function (tag) { return tag.tagId !== tagId; });
|
|
@@ -9097,7 +9438,7 @@ var Trending = function (_a) {
|
|
|
9097
9438
|
actions.setTotalScope({ start: newDates.newStartDate, end: newDates.newEndDate, scope: state.scope });
|
|
9098
9439
|
}
|
|
9099
9440
|
};
|
|
9100
|
-
var
|
|
9441
|
+
var _m = useState({
|
|
9101
9442
|
animation: {
|
|
9102
9443
|
duration: 0
|
|
9103
9444
|
},
|
|
@@ -9162,11 +9503,11 @@ var Trending = function (_a) {
|
|
|
9162
9503
|
pan: {
|
|
9163
9504
|
enabled: true,
|
|
9164
9505
|
mode: "x",
|
|
9165
|
-
onPan:
|
|
9506
|
+
onPan: handlePan
|
|
9166
9507
|
}
|
|
9167
9508
|
}
|
|
9168
9509
|
}
|
|
9169
|
-
}), chartOptions =
|
|
9510
|
+
}), chartOptions = _m[0], setChartOptions = _m[1];
|
|
9170
9511
|
useEffect(function () {
|
|
9171
9512
|
var fetchData = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
9172
9513
|
var tagIds, response, series_1, axes_1, updatedSeries, error_1;
|
|
@@ -9231,11 +9572,13 @@ var Trending = function (_a) {
|
|
|
9231
9572
|
x: new Date(sample.timestamp),
|
|
9232
9573
|
y: sample.value
|
|
9233
9574
|
}); }),
|
|
9575
|
+
tagId: tag.tagId,
|
|
9234
9576
|
borderColor: tag.color,
|
|
9235
9577
|
hidden: !tag.visible,
|
|
9236
9578
|
pointRadius: serie.length <= 50 ? 3 : 0
|
|
9237
9579
|
};
|
|
9238
9580
|
});
|
|
9581
|
+
setChartShouldInitCursors(true);
|
|
9239
9582
|
setChartData({
|
|
9240
9583
|
labels: [],
|
|
9241
9584
|
datasets: updatedSeries
|
|
@@ -9256,7 +9599,7 @@ var Trending = function (_a) {
|
|
|
9256
9599
|
}, [JSON.stringify(state), tagList]);
|
|
9257
9600
|
useEffect(function () {
|
|
9258
9601
|
var changeOptions = function () {
|
|
9259
|
-
console.log("change options");
|
|
9602
|
+
// console.log("change options");
|
|
9260
9603
|
setChartOptions(function (prevOptions) { return (__assign(__assign({}, prevOptions), { elements: {
|
|
9261
9604
|
line: {
|
|
9262
9605
|
stepped: customOptions.stepped,
|
|
@@ -9266,56 +9609,21 @@ var Trending = function (_a) {
|
|
|
9266
9609
|
};
|
|
9267
9610
|
changeOptions();
|
|
9268
9611
|
}, [customOptions]);
|
|
9269
|
-
function areRangesSimilar(tag1, tag2) {
|
|
9270
|
-
var threshold = 1; // Define a threshold for "closeness"
|
|
9271
|
-
// Helper function to safely compute logarithm, avoiding negative and zero values
|
|
9272
|
-
var safeLog = function (value) {
|
|
9273
|
-
if (value <= 0) {
|
|
9274
|
-
return null; // or some safe value depending on your context
|
|
9275
|
-
}
|
|
9276
|
-
return Math.log(value);
|
|
9277
|
-
};
|
|
9278
|
-
var logTag1Min = safeLog(tag1.minScale);
|
|
9279
|
-
var logTag1Max = safeLog(tag1.maxScale);
|
|
9280
|
-
var logTag2Min = safeLog(tag2.minScale);
|
|
9281
|
-
var logTag2Max = safeLog(tag2.maxScale);
|
|
9282
|
-
// Check if any log value is null, which indicates an invalid comparison
|
|
9283
|
-
if (logTag1Min === null ||
|
|
9284
|
-
logTag1Max === null ||
|
|
9285
|
-
logTag2Min === null ||
|
|
9286
|
-
logTag2Max === null) {
|
|
9287
|
-
return false;
|
|
9288
|
-
}
|
|
9289
|
-
var logDiffMin = Math.abs(logTag1Min - logTag2Min);
|
|
9290
|
-
var logDiffMax = Math.abs(logTag1Max - logTag2Max);
|
|
9291
|
-
return logDiffMin < threshold && logDiffMax < threshold;
|
|
9292
|
-
}
|
|
9293
|
-
function calculateScales(min, max, sigDigits) {
|
|
9294
|
-
var roundToSignificantDigits = function (num) {
|
|
9295
|
-
if (num === 0)
|
|
9296
|
-
return 0;
|
|
9297
|
-
var multiplier = Math.pow(10, sigDigits - Math.floor(Math.log10(Math.abs(num))) - 1);
|
|
9298
|
-
return Math.round(num * multiplier) / multiplier;
|
|
9299
|
-
};
|
|
9300
|
-
var minScale = roundToSignificantDigits(min);
|
|
9301
|
-
var maxScale = roundToSignificantDigits(max);
|
|
9302
|
-
// Adjust minScale and maxScale if necessary
|
|
9303
|
-
if (minScale > min) {
|
|
9304
|
-
minScale *= 0.9;
|
|
9305
|
-
}
|
|
9306
|
-
if (maxScale < max) {
|
|
9307
|
-
maxScale *= 1.1;
|
|
9308
|
-
}
|
|
9309
|
-
return { minScale: minScale, maxScale: maxScale };
|
|
9310
|
-
}
|
|
9311
9612
|
if (error)
|
|
9312
9613
|
return React__default.createElement("p", null,
|
|
9313
9614
|
"Error: ",
|
|
9314
9615
|
error);
|
|
9315
|
-
useRef(null);
|
|
9316
9616
|
useEffect(function () {
|
|
9317
9617
|
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() }) }) })); });
|
|
9318
9618
|
}, [state.timeScopeStart, state.timeScopeEnd]);
|
|
9619
|
+
useEffect(function () {
|
|
9620
|
+
if (chartShouldInitCursors) {
|
|
9621
|
+
if (chartRef.current) {
|
|
9622
|
+
updateCursorData(chartRef.current, setCursorData);
|
|
9623
|
+
chartRef.current.update();
|
|
9624
|
+
}
|
|
9625
|
+
}
|
|
9626
|
+
}, [chartShouldInitCursors, state]);
|
|
9319
9627
|
return (React__default.createElement(Grid$1, { container: true, style: { width: "95svw", height: "81svh", margin: 0 } },
|
|
9320
9628
|
React__default.createElement(Grid$1, { item: true, xs: 12, container: true, justifyContent: "space-between", alignItems: "center", style: { height: "15%" } },
|
|
9321
9629
|
React__default.createElement(Grid$1, { md: 5, item: true, container: true, justifyContent: "flex-start", alignItems: "center", spacing: 1, wrap: "wrap" },
|
|
@@ -9348,21 +9656,66 @@ var Trending = function (_a) {
|
|
|
9348
9656
|
React__default.createElement(Grid$1, { md: 7, item: true, container: true, justifyContent: "space-between" },
|
|
9349
9657
|
React__default.createElement(Grid$1, { item: true, container: true, wrap: "nowrap", spacing: 1 },
|
|
9350
9658
|
React__default.createElement(Grid$1, { item: true, container: true },
|
|
9351
|
-
React__default.createElement(CustomOptionsComponent, { customOptions: customOptions, setCustomOptions: setCustomOptions })),
|
|
9352
|
-
React__default.createElement(Grid$1, { item: true, container: true, justifyContent: "flex-end" },
|
|
9353
|
-
React__default.createElement(Button$1, { variant: "contained", color: "primary" }, "Load View"),
|
|
9354
|
-
React__default.createElement(Button$1, { variant: "contained", color: "secondary" }, "Save View"))))),
|
|
9659
|
+
React__default.createElement(CustomOptionsComponent, { customOptions: customOptions, setCustomOptions: setCustomOptions }))))),
|
|
9355
9660
|
React__default.createElement(Grid$1, { item: true, xs: 12, style: { height: '45%' } },
|
|
9356
|
-
React__default.createElement(Paper$1, { style: { height: '100%',
|
|
9357
|
-
React__default.createElement(
|
|
9661
|
+
React__default.createElement(Paper$1, { style: { height: '100%', position: 'relative' } },
|
|
9662
|
+
lineTabCoords && chartArea ? (React__default.createElement(DraggableLineControl, { color: 'red', chartArea: chartArea, initialLeft: lineTabCoords === null || lineTabCoords === void 0 ? void 0 : lineTabCoords.x1, onUpdate: function (newLeft) {
|
|
9663
|
+
setLineTabCoords(function (prevCoords) {
|
|
9664
|
+
prevCoords.x1 = newLeft;
|
|
9665
|
+
return prevCoords;
|
|
9666
|
+
});
|
|
9667
|
+
// @ts-ignore
|
|
9668
|
+
chartRef.current.mouseX = newLeft;
|
|
9669
|
+
debouncedUpdateChart();
|
|
9670
|
+
} })) : null,
|
|
9671
|
+
lineTabCoords && chartArea ? (React__default.createElement(DraggableLineControl, { color: 'blue', initialLeft: lineTabCoords === null || lineTabCoords === void 0 ? void 0 : lineTabCoords.x2, chartArea: chartArea, onUpdate: function (newLeft) {
|
|
9672
|
+
setLineTabCoords(function (prevCoords) {
|
|
9673
|
+
prevCoords.x2 = newLeft;
|
|
9674
|
+
return prevCoords;
|
|
9675
|
+
});
|
|
9676
|
+
// @ts-ignore
|
|
9677
|
+
chartRef.current.secondLineX = newLeft;
|
|
9678
|
+
debouncedUpdateChart();
|
|
9679
|
+
} })) : null,
|
|
9680
|
+
React__default.createElement(Line, { ref: chartRef, data: chartData, options: chartOptions, plugins: [verticalLinePlugin] }))),
|
|
9358
9681
|
React__default.createElement(Grid$1, { item: true, xs: 12, style: { height: '40%', minWidth: "100%", paddingTop: "3rem" } },
|
|
9359
|
-
React__default.createElement(TableComponent, { tagList: tagList, setTagList: setTagList, cursorData: cursorData, onDeleteTag: handleDeleteTag, onAddTag: handleAddTag })),
|
|
9682
|
+
React__default.createElement(TableComponent, { tagList: tagList, chartData: chartData, setTagList: setTagList, cursorData: cursorData, onDeleteTag: handleDeleteTag, onAddTag: handleAddTag })),
|
|
9360
9683
|
loading && (React__default.createElement(Grid$1, { item: true, xs: 12, style: { textAlign: 'center' } },
|
|
9361
9684
|
React__default.createElement("p", null, "Loading...")))));
|
|
9362
9685
|
};
|
|
9363
9686
|
|
|
9364
|
-
//
|
|
9687
|
+
//tags
|
|
9688
|
+
var getTags = function (NodeName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
9689
|
+
var apiService, parameters, resp;
|
|
9690
|
+
return __generator(this, function (_a) {
|
|
9691
|
+
switch (_a.label) {
|
|
9692
|
+
case 0:
|
|
9693
|
+
apiService = new MESApiService();
|
|
9694
|
+
parameters = [];
|
|
9695
|
+
parameters.push({ name: "NodeName", value: NodeName });
|
|
9696
|
+
return [4 /*yield*/, apiService.callV2("[mssql2022].[IH_100020].[dbo].[GetTagDirectChildren]", parameters)];
|
|
9697
|
+
case 1:
|
|
9698
|
+
resp = _a.sent();
|
|
9699
|
+
return [2 /*return*/, resp];
|
|
9700
|
+
}
|
|
9701
|
+
});
|
|
9702
|
+
}); };
|
|
9703
|
+
|
|
9365
9704
|
var TrendingsIndex = function (props) {
|
|
9705
|
+
React.useEffect(function () {
|
|
9706
|
+
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
9707
|
+
var tags;
|
|
9708
|
+
return __generator(this, function (_a) {
|
|
9709
|
+
switch (_a.label) {
|
|
9710
|
+
case 0: return [4 /*yield*/, getTags(null)];
|
|
9711
|
+
case 1:
|
|
9712
|
+
tags = _a.sent();
|
|
9713
|
+
console.log(tags);
|
|
9714
|
+
return [2 /*return*/];
|
|
9715
|
+
}
|
|
9716
|
+
});
|
|
9717
|
+
}); })();
|
|
9718
|
+
}, []);
|
|
9366
9719
|
return (React.createElement(TrendingProvider, null,
|
|
9367
9720
|
React.createElement(Box, { p: 3, style: { maxWidth: "100%" } },
|
|
9368
9721
|
React.createElement(Paper, null,
|