@dexteel/mesf-core 4.7.2 → 4.7.4

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 CHANGED
@@ -1,4 +1,12 @@
1
1
  # CHANGELOG
2
+ ## 4.7.4
3
+ - Trending: Change size of the date navigator arrows to improve the responsive behavior
4
+ - Trendings: Fix too many numbers on table bug. Show only the 3 digits after the comma
5
+ - Trending: Set new limits on the draggable line cursors. Now one cursor cannot exceed the position of the other cursor
6
+ - Trending: In add tag modal, when you select a tag, the popup doesn't close
7
+ - Trending: Fix cannot edit unit bug
8
+ ## 4.7.3
9
+ - Trendings: Fix date time navigation when the scope is 'custom'. Navigator takes difference between start date and end date
2
10
  ## 4.7.2
3
11
  - Trending: Fix repeated tags bug. When you select a tag that was already in the view, you get an error message
4
12
  - MESF: Add a button in the navbar to go to /trendings
package/dist/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export { LicenseManager } from 'ag-grid-enterprise';
2
2
  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, Tooltip, createStyles as createStyles$1, FormControl as FormControl$1, Select as Select$1, Box, Divider, IconButton as IconButton$1, debounce, List, ListItem, ListItemText } from '@material-ui/core';
3
- import { values, get, isNil as isNil$1, isEmpty, isNaN } from 'lodash-es';
3
+ import { values, get, isNil as isNil$1, isEmpty, isNaN, round } from 'lodash-es';
4
4
  import * as React from 'react';
5
5
  import React__default, { useState, useRef, useEffect, Component, createContext, useContext, useMemo, useCallback, lazy, Suspense } from 'react';
6
6
  import { Alert as Alert$1, Modal as Modal$1, Navbar, Container, Nav, NavDropdown } from 'react-bootstrap';
@@ -10273,11 +10273,12 @@ var useTrendingStyles = makeStyles$1(function (theme) { return ({
10273
10273
  fontSize: "13px !important",
10274
10274
  height: "15px !important",
10275
10275
  paddingRight: "3px",
10276
- paddingLeft: "5px"
10276
+ paddingLeft: "3px"
10277
10277
  },
10278
10278
  "& .MuiInput-underline:before": {
10279
10279
  borderBottomColor: "rgba(0, 0, 0, 0.42)"
10280
- }
10280
+ },
10281
+ padding: 0
10281
10282
  },
10282
10283
  select: {
10283
10284
  "& .MuiInput-root": {
@@ -10295,7 +10296,8 @@ var useTrendingStyles = makeStyles$1(function (theme) { return ({
10295
10296
  },
10296
10297
  "& .MuiInput-underline:before": {
10297
10298
  borderBottomColor: "rgba(0, 0, 0, 0.42)"
10298
- }
10299
+ },
10300
+ padding: 0
10299
10301
  },
10300
10302
  labelOptions: {
10301
10303
  paddingLeft: "2rem",
@@ -10323,8 +10325,15 @@ var useTrendingStyles = makeStyles$1(function (theme) { return ({
10323
10325
  },
10324
10326
  navigatorButton: {
10325
10327
  "& .MuiSvgIcon-root": {
10326
- cursor: "pointer !important"
10327
- }
10328
+ cursor: "pointer !important",
10329
+ height: '24px',
10330
+ width: '24px',
10331
+ '& svg': {
10332
+ // Adjust the icon size as well
10333
+ fontSize: '1.5rem'
10334
+ }
10335
+ },
10336
+ color: 'black'
10328
10337
  }
10329
10338
  }); });
10330
10339
 
@@ -10619,6 +10628,10 @@ var TableComponent = function (_a) {
10619
10628
  var newTags = viewTags.map(function (tag) { return tag.TagId === tagId ? __assign(__assign({}, tag), { IsVisible: value }) : tag; });
10620
10629
  setViewTags(newTags);
10621
10630
  };
10631
+ var handleUnitChange = function (tagId, newUnit) {
10632
+ var newTags = viewTags.map(function (tag) { return (tag.TagId === tagId ? __assign(__assign({}, tag), { Unit: newUnit }) : tag); });
10633
+ setViewTags(newTags);
10634
+ };
10622
10635
  var handleAutoScaleChange = function (tagId, checked) {
10623
10636
  var newTags = viewTags.map(function (t) { return t.TagId == tagId ? __assign(__assign({}, t), { IsAutoScale: !checked }) : t; });
10624
10637
  setViewTags(newTags);
@@ -10669,7 +10682,6 @@ var TableComponent = function (_a) {
10669
10682
  ];
10670
10683
  var handleTagSelect = function (selectedTag) {
10671
10684
  handleAddTag(selectedTag);
10672
- handleClose();
10673
10685
  };
10674
10686
  var handleDelete = function (index) { return __awaiter(void 0, void 0, void 0, function () {
10675
10687
  var tagToDelete, resp;
@@ -10887,17 +10899,24 @@ var TableComponent = function (_a) {
10887
10899
  }
10888
10900
  } })),
10889
10901
  React__default.createElement("td", { className: "".concat(classes.autoScale, " ").concat(classes.checkbox) },
10890
- React__default.createElement("input", { type: "text", style: { width: '100%' }, disabled: true, value: tag.Unit, onFocus: function (e) { return e.target.select(); } })),
10902
+ React__default.createElement("input", { type: "text", style: __assign({ width: '100%' }, (tag.IsAutoScale ? {
10903
+ backgroundColor: 'rgba(239, 239, 239, 0.3)',
10904
+ color: 'rgba(84, 84, 84, 1)',
10905
+ border: '1px solid rgba(118, 118, 118, 0.3)'
10906
+ } : {})), onClick: function () { return handleAbleScales(tag.TagId, tag.IsAutoScale); }, onChange: function (e) {
10907
+ var value = e.target.value;
10908
+ handleUnitChange(tag.TagId, value);
10909
+ }, value: tag.Unit, onFocus: function (e) { return e.target.select(); } })),
10891
10910
  React__default.createElement("td", { className: "".concat(classes.autoScale, " ").concat(classes.checkbox) },
10892
10911
  React__default.createElement("input", { type: "checkbox", checked: tag.IsAutoScale, onChange: function (e) { return handleAutoScaleChange(tag.TagId, tag.IsAutoScale); } })),
10893
- React__default.createElement("td", null, (_a = dataTable[tag.TagName]) === null || _a === void 0 ? void 0 : _a.y1),
10894
- React__default.createElement("td", { className: classes.doubleInput }, (_b = dataTable[tag.TagName]) === null || _b === void 0 ? void 0 : _b.y2),
10895
- React__default.createElement("td", null, (_c = dataTable[tag.TagName]) === null || _c === void 0 ? void 0 : _c.y2y1),
10912
+ React__default.createElement("td", null, round((_a = dataTable[tag.TagName]) === null || _a === void 0 ? void 0 : _a.y1, 3)),
10913
+ React__default.createElement("td", { className: classes.doubleInput }, round((_b = dataTable[tag.TagName]) === null || _b === void 0 ? void 0 : _b.y2, 3)),
10914
+ React__default.createElement("td", null, round((_c = dataTable[tag.TagName]) === null || _c === void 0 ? void 0 : _c.y2y1, 3)),
10896
10915
  React__default.createElement("td", null,
10897
- !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,
10916
+ !isNaN(((_d = dataTable[tag.TagName]) === null || _d === void 0 ? void 0 : _d.pmin.y) * 0) ? round((_e = dataTable[tag.TagName]) === null || _e === void 0 ? void 0 : _e.pmin.y, 3) : 0,
10898
10917
  " "),
10899
10918
  React__default.createElement("td", null,
10900
- !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,
10919
+ !isNaN(((_f = dataTable[tag.TagName]) === null || _f === void 0 ? void 0 : _f.pmax.y) * 0) ? round((_g = dataTable[tag.TagName]) === null || _g === void 0 ? void 0 : _g.pmax.y) : 0,
10901
10920
  " ")));
10902
10921
  }) : React__default.createElement("div", { style: { padding: '2rem' } },
10903
10922
  React__default.createElement("div", { style: { padding: "1rem" } }, "No tag view detected. "),
@@ -11064,8 +11083,12 @@ var CustomOptionsComponent = function (_a) {
11064
11083
  };
11065
11084
 
11066
11085
  var dateNavigator = function (startDate, endDate, scope, operator) {
11067
- if (scope === "custom")
11068
- return;
11086
+ if (scope === "custom") {
11087
+ var durationInMs = moment(endDate).diff(moment(startDate));
11088
+ var newStartDate = moment(startDate)[operator](durationInMs).toDate();
11089
+ var newEndDate = moment(endDate)[operator](durationInMs).toDate();
11090
+ return { newStartDate: newStartDate, newEndDate: newEndDate };
11091
+ }
11069
11092
  else {
11070
11093
  var _a = scope.split(" "), quantity = _a[0], duration = _a[1];
11071
11094
  var newStartDate = moment(startDate)[operator](quantity, duration[0]).toDate();
@@ -11101,13 +11124,20 @@ var Header = function (_a) {
11101
11124
  };
11102
11125
  useEffect(function () {
11103
11126
  var changeOptions = function () {
11104
- // console.log("change options");
11105
- setChartOptions(function (prevOptions) { return (__assign(__assign({}, prevOptions), { elements: {
11106
- line: {
11107
- stepped: customOptions.stepped,
11108
- lineTension: 0.1
11127
+ setChartOptions(function (prevOptions) {
11128
+ var newScales = __assign({}, prevOptions.scales);
11129
+ Object.keys(newScales).forEach(function (key) {
11130
+ if (key) {
11131
+ newScales[key] = __assign(__assign({}, newScales[key]), { grid: __assign(__assign({}, newScales[key].grid), { display: customOptions.showGrid }) });
11109
11132
  }
11110
- }, 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 }) }) }) })); });
11133
+ });
11134
+ return __assign(__assign({}, prevOptions), { elements: {
11135
+ line: {
11136
+ stepped: customOptions.stepped,
11137
+ lineTension: 0.1
11138
+ }
11139
+ }, scales: newScales });
11140
+ });
11111
11141
  };
11112
11142
  changeOptions();
11113
11143
  }, [customOptions]);
@@ -11115,9 +11145,10 @@ var Header = function (_a) {
11115
11145
  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() }) }) })); });
11116
11146
  }, [state.timeScopeStart, state.timeScopeEnd]);
11117
11147
  return (React__default.createElement(Grid$1, { item: true, xs: 12, container: true, justifyContent: "space-between", alignItems: "center", style: { height: "15%" } },
11118
- React__default.createElement(Grid$1, { md: 5, item: true, container: true, justifyContent: "flex-start", alignItems: "center", spacing: 1, wrap: "wrap" },
11119
- React__default.createElement(IconButton$1, { color: "primary", onClick: function () { return handleDateNavigator("subtract"); }, className: classes.navigatorButton },
11120
- React__default.createElement(ChevronLeft, { fontSize: "large" })),
11148
+ React__default.createElement(Grid$1, { md: 6, item: true, container: true, justifyContent: "flex-start", alignItems: "center", wrap: "wrap" },
11149
+ React__default.createElement(Grid$1, { item: true },
11150
+ React__default.createElement(IconButton$1, { color: "primary", onClick: function () { return handleDateNavigator("subtract"); }, className: classes.navigatorButton },
11151
+ React__default.createElement(ChevronLeft, { fontSize: "large" }))),
11121
11152
  React__default.createElement(Grid$1, { item: true },
11122
11153
  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: {
11123
11154
  shrink: true,
@@ -11140,16 +11171,17 @@ var Header = function (_a) {
11140
11171
  shrink: true,
11141
11172
  style: { marginLeft: "10px" }
11142
11173
  } })),
11143
- React__default.createElement(IconButton$1, { color: "primary", onClick: function () { return handleDateNavigator("add"); }, className: classes.navigatorButton },
11144
- React__default.createElement(ChevronRight, { fontSize: "large" }))),
11145
- React__default.createElement(Grid$1, { md: 7, item: true, container: true, justifyContent: "space-between" },
11174
+ React__default.createElement(Grid$1, { item: true },
11175
+ React__default.createElement(IconButton$1, { onClick: function () { return handleDateNavigator("add"); }, className: "".concat(classes.navigatorButton) },
11176
+ React__default.createElement(ChevronRight, { fontSize: "large" })))),
11177
+ React__default.createElement(Grid$1, { md: 6, item: true, container: true, justifyContent: "space-between" },
11146
11178
  React__default.createElement(Grid$1, { item: true, container: true, wrap: "nowrap", spacing: 1 },
11147
11179
  React__default.createElement(Grid$1, { item: true, container: true },
11148
11180
  React__default.createElement(CustomOptionsComponent, { customOptions: customOptions, setCustomOptions: setCustomOptions }))))));
11149
11181
  };
11150
11182
 
11151
11183
  var DraggableLineControl = function (_a) {
11152
- var initialLeft = _a.initialLeft, onUpdate = _a.onUpdate, color = _a.color, chartArea = _a.chartArea;
11184
+ var initialLeft = _a.initialLeft, otherLineCoord = _a.otherLineCoord, onUpdate = _a.onUpdate, color = _a.color, chartArea = _a.chartArea;
11153
11185
  var _b = useState(false), isDragging = _b[0], setIsDragging = _b[1];
11154
11186
  var _c = useState(initialLeft), left = _c[0], setLeft = _c[1];
11155
11187
  var ref = useRef(null);
@@ -11164,6 +11196,13 @@ var DraggableLineControl = function (_a) {
11164
11196
  chartArea.width - chartArea.right;
11165
11197
  chartArea.left;
11166
11198
  var newLeft = Math.min(Math.max(e.clientX - ref.current.offsetParent.getBoundingClientRect().left, chartArea.left), chartArea.right);
11199
+ // Line limit
11200
+ if (color === 'red' && newLeft > (otherLineCoord - 20)) {
11201
+ newLeft = otherLineCoord - 20;
11202
+ }
11203
+ else if (color === 'blue' && newLeft < (otherLineCoord + 20)) {
11204
+ newLeft = otherLineCoord + 20;
11205
+ }
11167
11206
  setLeft(newLeft);
11168
11207
  onUpdate(newLeft); // Actualiza la posición de la línea en el gráfico
11169
11208
  };
@@ -11416,7 +11455,7 @@ var TrendingChart = function (_a) {
11416
11455
  }
11417
11456
  }, [chartShouldInitCursors, state.graphShouldUpdate]);
11418
11457
  return (React__default.createElement(Paper$1, { style: { height: '100%', position: 'relative' } },
11419
- lineTabCoords && chartArea ? (React__default.createElement(DraggableLineControl, { color: 'red', chartArea: chartArea, initialLeft: lineTabCoords === null || lineTabCoords === void 0 ? void 0 : lineTabCoords.x1, onUpdate: function (newLeft) {
11458
+ lineTabCoords && chartArea ? (React__default.createElement(DraggableLineControl, { color: 'red', chartArea: chartArea, initialLeft: lineTabCoords === null || lineTabCoords === void 0 ? void 0 : lineTabCoords.x1, otherLineCoord: lineTabCoords === null || lineTabCoords === void 0 ? void 0 : lineTabCoords.x2, onUpdate: function (newLeft) {
11420
11459
  setLineTabCoords(function (prevCoords) {
11421
11460
  prevCoords.x1 = newLeft;
11422
11461
  return prevCoords;
@@ -11425,7 +11464,7 @@ var TrendingChart = function (_a) {
11425
11464
  chartRef.current.mouseX = newLeft;
11426
11465
  debouncedUpdateChart();
11427
11466
  } })) : null,
11428
- lineTabCoords && chartArea ? (React__default.createElement(DraggableLineControl, { color: 'blue', initialLeft: lineTabCoords === null || lineTabCoords === void 0 ? void 0 : lineTabCoords.x2, chartArea: chartArea, onUpdate: function (newLeft) {
11467
+ lineTabCoords && chartArea ? (React__default.createElement(DraggableLineControl, { color: 'blue', initialLeft: lineTabCoords === null || lineTabCoords === void 0 ? void 0 : lineTabCoords.x2, otherLineCoord: lineTabCoords === null || lineTabCoords === void 0 ? void 0 : lineTabCoords.x1, chartArea: chartArea, onUpdate: function (newLeft) {
11429
11468
  setLineTabCoords(function (prevCoords) {
11430
11469
  prevCoords.x2 = newLeft;
11431
11470
  return prevCoords;