@dexteel/mesf-core 4.7.3 → 4.7.5

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.5
3
+ - Added function to format AssetFullPath and display a part in the input
4
+ ## 4.7.4
5
+ - Trending: Change size of the date navigator arrows to improve the responsive behavior
6
+ - Trendings: Fix too many numbers on table bug. Show only the 3 digits after the comma
7
+ - Trending: Set new limits on the draggable line cursors. Now one cursor cannot exceed the position of the other cursor
8
+ - Trending: In add tag modal, when you select a tag, the popup doesn't close
9
+ - Trending: Fix cannot edit unit bug
2
10
  ## 4.7.3
3
11
  - Trendings: Fix date time navigation when the scope is 'custom'. Navigator takes difference between start date and end date
4
12
  ## 4.7.2
@@ -1,6 +1,6 @@
1
1
  import React, { Component } from "react";
2
2
  type TreePickerControlProps = {
3
- onSelect: (value: string, description: string, findNode: any) => void;
3
+ onSelect: (value: string, description: string, findNode: any, showPath?: boolean) => void;
4
4
  [key: string]: any;
5
5
  };
6
6
  export declare const TreePickerControl: (props: TreePickerControlProps) => React.JSX.Element;
package/dist/index.esm.js CHANGED
@@ -1,8 +1,8 @@
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
- import React__default, { useState, useRef, useEffect, Component, createContext, useContext, useMemo, useCallback, lazy, Suspense } from 'react';
5
+ import React__default, { useState, useRef, useEffect, useMemo, Component, createContext, useContext, useCallback, lazy, Suspense } from 'react';
6
6
  import { Alert as Alert$1, Modal as Modal$1, Navbar, Container, Nav, NavDropdown } from 'react-bootstrap';
7
7
  import DialogTitle$1 from '@material-ui/core/DialogTitle';
8
8
  import DialogContent$1 from '@material-ui/core/DialogContent';
@@ -450,26 +450,26 @@ ModalTreeFilterControl.propTypes = {
450
450
  data: PropTypes.object.isRequired
451
451
  };
452
452
 
453
- var TreePickerControl = function (props) {
454
- var useStyles = makeStyles(function (theme) { return ({
455
- root: {
456
- width: "100%",
457
- backgroundColor: theme.palette.background.paper,
458
- "& .MuiInputBase-input": {
459
- color: "black",
460
- cursor: "pointer",
461
- paddingRight: 45
462
- }
463
- },
464
- paper: {
465
- width: "100%",
466
- maxWidth: 600,
467
- maxHeight: 600
453
+ var useStyles$A = makeStyles(function (theme) { return ({
454
+ root: {
455
+ width: "100%",
456
+ backgroundColor: theme.palette.background.paper,
457
+ "& .MuiInputBase-input": {
458
+ color: "black",
459
+ cursor: "pointer",
460
+ paddingRight: 45
468
461
  }
469
- }); });
470
- var classes = useStyles();
471
- var onSelect = props.onSelect, value = props.value; props.styleLabel; var dataSource = props.dataSource, _a = props.inputTitle, inputTitle = _a === void 0 ? "Asset" : _a, other = __rest(props, ["onSelect", "value", "styleLabel", "dataSource", "inputTitle"]);
472
- var _b = React__default.useState(false), open = _b[0], setOpen = _b[1];
462
+ },
463
+ paper: {
464
+ width: "100%",
465
+ maxWidth: 600,
466
+ maxHeight: 600
467
+ }
468
+ }); });
469
+ var TreePickerControl = function (props) {
470
+ var classes = useStyles$A();
471
+ var onSelect = props.onSelect, value = props.value; props.styleLabel; var dataSource = props.dataSource, _a = props.inputTitle, inputTitle = _a === void 0 ? "Asset" : _a; props.showPath; var other = __rest(props, ["onSelect", "value", "styleLabel", "dataSource", "inputTitle", "showPath"]);
472
+ var _c = React__default.useState(false), open = _c[0], setOpen = _c[1];
473
473
  var handleClickListItem = function (e) {
474
474
  e.stopPropagation();
475
475
  setOpen(true);
@@ -481,10 +481,40 @@ var TreePickerControl = function (props) {
481
481
  onSelect(newValue, newDescription, findNode);
482
482
  }
483
483
  };
484
+ var formatDescription = function (description) {
485
+ if (props.showPath && (description === null || description === void 0 ? void 0 : description.includes('/')) && description.split('/').length > 3) {
486
+ var parts = description.split('/');
487
+ var formattedDescription = '';
488
+ for (var i = 0; i < parts.length; i++) {
489
+ if (i < parts.length - 2) {
490
+ formattedDescription += '.../';
491
+ }
492
+ else if (i === parts.length - 2) {
493
+ if (parts[i].length > 6) {
494
+ formattedDescription += parts[i].substring(0, 6) + '.../';
495
+ }
496
+ else {
497
+ formattedDescription += parts[i] + '/';
498
+ }
499
+ }
500
+ else {
501
+ formattedDescription += parts[i];
502
+ if (i < parts.length - 1) {
503
+ formattedDescription += '/';
504
+ }
505
+ }
506
+ }
507
+ return formattedDescription;
508
+ }
509
+ else {
510
+ return description;
511
+ }
512
+ };
513
+ var description = useMemo(function () { return formatDescription(props.description); }, [props.description]);
484
514
  return (React__default.createElement(Grid, { container: true, className: classes.root },
485
- React__default.createElement(Grid, { container: true, item: true, md: 12, xs: 12, style: { position: "relative" } },
515
+ React__default.createElement(Grid, { container: true, item: true, md: 12, xs: 12, style: { position: "relative" }, title: props.description },
486
516
  React__default.createElement(Grid, { item: true, style: { position: "relative", width: "100%" } },
487
- React__default.createElement(TextField, { label: inputTitle, variant: "outlined", value: props.description, margin: "dense", autoComplete: "off", fullWidth: true, disabled: true }),
517
+ React__default.createElement(TextField, { id: "treePickerTextField", label: inputTitle, variant: "outlined", value: description, margin: "dense", autoComplete: "off", fullWidth: true, disabled: true }),
488
518
  React__default.createElement(AccountTreeIcon, { style: {
489
519
  position: "absolute",
490
520
  right: 15,
@@ -10273,11 +10303,12 @@ var useTrendingStyles = makeStyles$1(function (theme) { return ({
10273
10303
  fontSize: "13px !important",
10274
10304
  height: "15px !important",
10275
10305
  paddingRight: "3px",
10276
- paddingLeft: "5px"
10306
+ paddingLeft: "3px"
10277
10307
  },
10278
10308
  "& .MuiInput-underline:before": {
10279
10309
  borderBottomColor: "rgba(0, 0, 0, 0.42)"
10280
- }
10310
+ },
10311
+ padding: 0
10281
10312
  },
10282
10313
  select: {
10283
10314
  "& .MuiInput-root": {
@@ -10295,7 +10326,8 @@ var useTrendingStyles = makeStyles$1(function (theme) { return ({
10295
10326
  },
10296
10327
  "& .MuiInput-underline:before": {
10297
10328
  borderBottomColor: "rgba(0, 0, 0, 0.42)"
10298
- }
10329
+ },
10330
+ padding: 0
10299
10331
  },
10300
10332
  labelOptions: {
10301
10333
  paddingLeft: "2rem",
@@ -10323,8 +10355,15 @@ var useTrendingStyles = makeStyles$1(function (theme) { return ({
10323
10355
  },
10324
10356
  navigatorButton: {
10325
10357
  "& .MuiSvgIcon-root": {
10326
- cursor: "pointer !important"
10327
- }
10358
+ cursor: "pointer !important",
10359
+ height: '24px',
10360
+ width: '24px',
10361
+ '& svg': {
10362
+ // Adjust the icon size as well
10363
+ fontSize: '1.5rem'
10364
+ }
10365
+ },
10366
+ color: 'black'
10328
10367
  }
10329
10368
  }); });
10330
10369
 
@@ -10619,6 +10658,10 @@ var TableComponent = function (_a) {
10619
10658
  var newTags = viewTags.map(function (tag) { return tag.TagId === tagId ? __assign(__assign({}, tag), { IsVisible: value }) : tag; });
10620
10659
  setViewTags(newTags);
10621
10660
  };
10661
+ var handleUnitChange = function (tagId, newUnit) {
10662
+ var newTags = viewTags.map(function (tag) { return (tag.TagId === tagId ? __assign(__assign({}, tag), { Unit: newUnit }) : tag); });
10663
+ setViewTags(newTags);
10664
+ };
10622
10665
  var handleAutoScaleChange = function (tagId, checked) {
10623
10666
  var newTags = viewTags.map(function (t) { return t.TagId == tagId ? __assign(__assign({}, t), { IsAutoScale: !checked }) : t; });
10624
10667
  setViewTags(newTags);
@@ -10669,7 +10712,6 @@ var TableComponent = function (_a) {
10669
10712
  ];
10670
10713
  var handleTagSelect = function (selectedTag) {
10671
10714
  handleAddTag(selectedTag);
10672
- handleClose();
10673
10715
  };
10674
10716
  var handleDelete = function (index) { return __awaiter(void 0, void 0, void 0, function () {
10675
10717
  var tagToDelete, resp;
@@ -10887,17 +10929,24 @@ var TableComponent = function (_a) {
10887
10929
  }
10888
10930
  } })),
10889
10931
  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(); } })),
10932
+ React__default.createElement("input", { type: "text", style: __assign({ width: '100%' }, (tag.IsAutoScale ? {
10933
+ backgroundColor: 'rgba(239, 239, 239, 0.3)',
10934
+ color: 'rgba(84, 84, 84, 1)',
10935
+ border: '1px solid rgba(118, 118, 118, 0.3)'
10936
+ } : {})), onClick: function () { return handleAbleScales(tag.TagId, tag.IsAutoScale); }, onChange: function (e) {
10937
+ var value = e.target.value;
10938
+ handleUnitChange(tag.TagId, value);
10939
+ }, value: tag.Unit, onFocus: function (e) { return e.target.select(); } })),
10891
10940
  React__default.createElement("td", { className: "".concat(classes.autoScale, " ").concat(classes.checkbox) },
10892
10941
  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),
10942
+ React__default.createElement("td", null, round((_a = dataTable[tag.TagName]) === null || _a === void 0 ? void 0 : _a.y1, 3)),
10943
+ React__default.createElement("td", { className: classes.doubleInput }, round((_b = dataTable[tag.TagName]) === null || _b === void 0 ? void 0 : _b.y2, 3)),
10944
+ React__default.createElement("td", null, round((_c = dataTable[tag.TagName]) === null || _c === void 0 ? void 0 : _c.y2y1, 3)),
10896
10945
  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,
10946
+ !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
10947
  " "),
10899
10948
  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,
10949
+ !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
10950
  " ")));
10902
10951
  }) : React__default.createElement("div", { style: { padding: '2rem' } },
10903
10952
  React__default.createElement("div", { style: { padding: "1rem" } }, "No tag view detected. "),
@@ -11105,13 +11154,20 @@ var Header = function (_a) {
11105
11154
  };
11106
11155
  useEffect(function () {
11107
11156
  var changeOptions = function () {
11108
- // console.log("change options");
11109
- setChartOptions(function (prevOptions) { return (__assign(__assign({}, prevOptions), { elements: {
11110
- line: {
11111
- stepped: customOptions.stepped,
11112
- lineTension: 0.1
11157
+ setChartOptions(function (prevOptions) {
11158
+ var newScales = __assign({}, prevOptions.scales);
11159
+ Object.keys(newScales).forEach(function (key) {
11160
+ if (key) {
11161
+ newScales[key] = __assign(__assign({}, newScales[key]), { grid: __assign(__assign({}, newScales[key].grid), { display: customOptions.showGrid }) });
11113
11162
  }
11114
- }, 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 }) }) }) })); });
11163
+ });
11164
+ return __assign(__assign({}, prevOptions), { elements: {
11165
+ line: {
11166
+ stepped: customOptions.stepped,
11167
+ lineTension: 0.1
11168
+ }
11169
+ }, scales: newScales });
11170
+ });
11115
11171
  };
11116
11172
  changeOptions();
11117
11173
  }, [customOptions]);
@@ -11119,9 +11175,10 @@ var Header = function (_a) {
11119
11175
  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() }) }) })); });
11120
11176
  }, [state.timeScopeStart, state.timeScopeEnd]);
11121
11177
  return (React__default.createElement(Grid$1, { item: true, xs: 12, container: true, justifyContent: "space-between", alignItems: "center", style: { height: "15%" } },
11122
- React__default.createElement(Grid$1, { md: 5, item: true, container: true, justifyContent: "flex-start", alignItems: "center", spacing: 1, wrap: "wrap" },
11123
- React__default.createElement(IconButton$1, { color: "primary", onClick: function () { return handleDateNavigator("subtract"); }, className: classes.navigatorButton },
11124
- React__default.createElement(ChevronLeft, { fontSize: "large" })),
11178
+ React__default.createElement(Grid$1, { md: 6, item: true, container: true, justifyContent: "flex-start", alignItems: "center", wrap: "wrap" },
11179
+ React__default.createElement(Grid$1, { item: true },
11180
+ React__default.createElement(IconButton$1, { color: "primary", onClick: function () { return handleDateNavigator("subtract"); }, className: classes.navigatorButton },
11181
+ React__default.createElement(ChevronLeft, { fontSize: "large" }))),
11125
11182
  React__default.createElement(Grid$1, { item: true },
11126
11183
  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: {
11127
11184
  shrink: true,
@@ -11144,16 +11201,17 @@ var Header = function (_a) {
11144
11201
  shrink: true,
11145
11202
  style: { marginLeft: "10px" }
11146
11203
  } })),
11147
- React__default.createElement(IconButton$1, { color: "primary", onClick: function () { return handleDateNavigator("add"); }, className: classes.navigatorButton },
11148
- React__default.createElement(ChevronRight, { fontSize: "large" }))),
11149
- React__default.createElement(Grid$1, { md: 7, item: true, container: true, justifyContent: "space-between" },
11204
+ React__default.createElement(Grid$1, { item: true },
11205
+ React__default.createElement(IconButton$1, { onClick: function () { return handleDateNavigator("add"); }, className: "".concat(classes.navigatorButton) },
11206
+ React__default.createElement(ChevronRight, { fontSize: "large" })))),
11207
+ React__default.createElement(Grid$1, { md: 6, item: true, container: true, justifyContent: "space-between" },
11150
11208
  React__default.createElement(Grid$1, { item: true, container: true, wrap: "nowrap", spacing: 1 },
11151
11209
  React__default.createElement(Grid$1, { item: true, container: true },
11152
11210
  React__default.createElement(CustomOptionsComponent, { customOptions: customOptions, setCustomOptions: setCustomOptions }))))));
11153
11211
  };
11154
11212
 
11155
11213
  var DraggableLineControl = function (_a) {
11156
- var initialLeft = _a.initialLeft, onUpdate = _a.onUpdate, color = _a.color, chartArea = _a.chartArea;
11214
+ var initialLeft = _a.initialLeft, otherLineCoord = _a.otherLineCoord, onUpdate = _a.onUpdate, color = _a.color, chartArea = _a.chartArea;
11157
11215
  var _b = useState(false), isDragging = _b[0], setIsDragging = _b[1];
11158
11216
  var _c = useState(initialLeft), left = _c[0], setLeft = _c[1];
11159
11217
  var ref = useRef(null);
@@ -11168,6 +11226,13 @@ var DraggableLineControl = function (_a) {
11168
11226
  chartArea.width - chartArea.right;
11169
11227
  chartArea.left;
11170
11228
  var newLeft = Math.min(Math.max(e.clientX - ref.current.offsetParent.getBoundingClientRect().left, chartArea.left), chartArea.right);
11229
+ // Line limit
11230
+ if (color === 'red' && newLeft > (otherLineCoord - 20)) {
11231
+ newLeft = otherLineCoord - 20;
11232
+ }
11233
+ else if (color === 'blue' && newLeft < (otherLineCoord + 20)) {
11234
+ newLeft = otherLineCoord + 20;
11235
+ }
11171
11236
  setLeft(newLeft);
11172
11237
  onUpdate(newLeft); // Actualiza la posición de la línea en el gráfico
11173
11238
  };
@@ -11420,7 +11485,7 @@ var TrendingChart = function (_a) {
11420
11485
  }
11421
11486
  }, [chartShouldInitCursors, state.graphShouldUpdate]);
11422
11487
  return (React__default.createElement(Paper$1, { style: { height: '100%', position: 'relative' } },
11423
- lineTabCoords && chartArea ? (React__default.createElement(DraggableLineControl, { color: 'red', chartArea: chartArea, initialLeft: lineTabCoords === null || lineTabCoords === void 0 ? void 0 : lineTabCoords.x1, onUpdate: function (newLeft) {
11488
+ 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) {
11424
11489
  setLineTabCoords(function (prevCoords) {
11425
11490
  prevCoords.x1 = newLeft;
11426
11491
  return prevCoords;
@@ -11429,7 +11494,7 @@ var TrendingChart = function (_a) {
11429
11494
  chartRef.current.mouseX = newLeft;
11430
11495
  debouncedUpdateChart();
11431
11496
  } })) : null,
11432
- lineTabCoords && chartArea ? (React__default.createElement(DraggableLineControl, { color: 'blue', initialLeft: lineTabCoords === null || lineTabCoords === void 0 ? void 0 : lineTabCoords.x2, chartArea: chartArea, onUpdate: function (newLeft) {
11497
+ 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) {
11433
11498
  setLineTabCoords(function (prevCoords) {
11434
11499
  prevCoords.x2 = newLeft;
11435
11500
  return prevCoords;