@dexteel/mesf-core 4.8.3 → 4.8.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,8 @@
1
1
  # CHANGELOG
2
+ ## 4.8.5
3
+ - Trending: Fix bugs on Add Tag modal, SaveDefaultToTag, Remove Tag, Save View, Edit viewTags, and performance (#204)
4
+ ## 4.8.4
5
+ - Trending: In Add Tag modal, fix unnecessary calls to /children bug. Now only makes calls when the tag has childrens (#203)
2
6
  ## 4.8.3
3
7
  - Trending: Add new icon to ViewTags table and Add tag modal to know if it is Digital or Real (#205 and #206)
4
8
  ## 4.8.2
package/dist/index.esm.js CHANGED
@@ -9663,7 +9663,8 @@ var TrendingsInitialState = {
9663
9663
  }
9664
9664
  ],
9665
9665
  viewSelected: null,
9666
- viewTags: []
9666
+ viewTags: [],
9667
+ shouldRefetchSeries: 1
9667
9668
  };
9668
9669
  var TrendingsReducer = createSlice({
9669
9670
  name: "__",
@@ -9671,6 +9672,7 @@ var TrendingsReducer = createSlice({
9671
9672
  reducers: {
9672
9673
  setTotalScope: function (state, _a) {
9673
9674
  var payload = _a.payload; _a.type;
9675
+ state.shouldRefetchSeries += 1;
9674
9676
  state.graphShouldUpdate += 1;
9675
9677
  if (!isNil$1(payload.start) && !isNil$1(payload.end) && !isNil$1(payload.scope)) {
9676
9678
  //from arrow navigators
@@ -9818,6 +9820,12 @@ var TrendingsReducer = createSlice({
9818
9820
  setViewTags: function (state, _a) {
9819
9821
  var payload = _a.payload;
9820
9822
  state.viewTags = payload;
9823
+ state.graphShouldUpdate += 1;
9824
+ },
9825
+ setViewTagsAndRefetch: function (state, _a) {
9826
+ var payload = _a.payload;
9827
+ state.viewTags = payload;
9828
+ state.shouldRefetchSeries += 1;
9821
9829
  },
9822
9830
  setGraphShouldUpdate: function (state) {
9823
9831
  state.graphShouldUpdate = +1;
@@ -10123,31 +10131,36 @@ var TagSelectionModal = function (_a) {
10123
10131
  case 2:
10124
10132
  response = _a.sent();
10125
10133
  return [4 /*yield*/, Promise.all(response.data.map(function (dbTag) { return __awaiter(void 0, void 0, void 0, function () {
10126
- var childTagName, children;
10134
+ var children, childTagName;
10127
10135
  return __generator(this, function (_a) {
10128
10136
  switch (_a.label) {
10129
10137
  case 0:
10138
+ children = null;
10130
10139
  childTagName = tagName !== "root" ? tagName + "." + dbTag.tagName : dbTag.tagName;
10140
+ if (!isNil$1(dbTag.tagType)) return [3 /*break*/, 2];
10131
10141
  return [4 /*yield*/, fetchChildren(childTagName, depth + 1, maxDepth)];
10132
10142
  case 1:
10133
10143
  children = _a.sent();
10134
- return [2 /*return*/, {
10144
+ _a.label = 2;
10145
+ case 2: return [2 /*return*/, {
10146
+ TagId: dbTag.tagId,
10147
+ TagName: childTagName,
10148
+ shortName: dbTag.tagName,
10149
+ children: children,
10150
+ isLoaded: true,
10151
+ tag: {
10135
10152
  TagId: dbTag.tagId,
10136
- TagName: childTagName,
10137
- shortName: dbTag.tagName,
10138
- children: children,
10139
- isLoaded: true,
10140
- tag: {
10141
- TagId: dbTag.tagId,
10142
- TagName: dbTag.tagName,
10143
- Color: dbTag.color || getColor(),
10144
- IsAutoScale: true,
10145
- MinScale: dbTag.minScale,
10146
- MaxScale: dbTag.maxScale,
10147
- IsVisible: true,
10148
- TagType: dbTag.tagType
10149
- }
10150
- }];
10153
+ TagName: dbTag.tagName,
10154
+ Color: dbTag.color || getColor(),
10155
+ IsAutoScale: (dbTag.minValue || dbTag.maxValue) ? false : true,
10156
+ MinScale: dbTag.minValue,
10157
+ MaxScale: dbTag.maxValue,
10158
+ IsVisible: true,
10159
+ TagType: dbTag.tagType,
10160
+ Alias: dbTag.alias,
10161
+ Unit: dbTag.unit
10162
+ }
10163
+ }];
10151
10164
  }
10152
10165
  });
10153
10166
  }); }))];
@@ -10322,7 +10335,7 @@ var getViewTags = function (ViewId) { return __awaiter(void 0, void 0, void 0, f
10322
10335
  }
10323
10336
  });
10324
10337
  }); };
10325
- var upsertViewTag = function (ViewId, TagId, Color, MinScale, MaxScale, IsVisible, IsAutoScale) { return __awaiter(void 0, void 0, void 0, function () {
10338
+ var upsertViewTag = function (ViewId, TagId, Color, MinScale, MaxScale, IsVisible, IsAutoScale, Unit) { return __awaiter(void 0, void 0, void 0, function () {
10326
10339
  var apiService, parameters, resp;
10327
10340
  return __generator(this, function (_a) {
10328
10341
  switch (_a.label) {
@@ -10336,6 +10349,7 @@ var upsertViewTag = function (ViewId, TagId, Color, MinScale, MaxScale, IsVisibl
10336
10349
  parameters.push({ name: "MaxScale", value: MaxScale });
10337
10350
  parameters.push({ name: "IsVisible", value: IsVisible });
10338
10351
  parameters.push({ name: "IsAutoScale", value: IsAutoScale });
10352
+ parameters.push({ name: "Unit", value: Unit });
10339
10353
  return [4 /*yield*/, apiService.callV2("[mssql2022].[IH_100020].[ih].[UpsertViewTag]", parameters)];
10340
10354
  case 1:
10341
10355
  resp = _a.sent();
@@ -10695,8 +10709,8 @@ var SaveAsViewModal = function (_a) {
10695
10709
  if (!resp.ok) return [3 /*break*/, 3];
10696
10710
  ViewId_1 = resp.data.returnValue;
10697
10711
  return [4 /*yield*/, Promise.allSettled(viewTags.map(function (_a) {
10698
- var TagId = _a.TagId, Color = _a.Color, MinScale = _a.MinScale, MaxScale = _a.MaxScale, IsAutoScale = _a.IsAutoScale, IsVisible = _a.IsVisible;
10699
- upsertViewTag(ViewId_1, TagId, Color, MinScale, MaxScale, IsVisible, IsAutoScale)
10712
+ var TagId = _a.TagId, Color = _a.Color, MinScale = _a.MinScale, MaxScale = _a.MaxScale, IsAutoScale = _a.IsAutoScale, IsVisible = _a.IsVisible, Unit = _a.Unit;
10713
+ upsertViewTag(ViewId_1, TagId, Color, MinScale, MaxScale, IsVisible, IsAutoScale, Unit)
10700
10714
  .then(function (r) {
10701
10715
  if (!r.ok) {
10702
10716
  setError(r.message);
@@ -10855,7 +10869,7 @@ var formatTimeDiffWithMs = function (start, end) {
10855
10869
  var TableComponent = function (_a) {
10856
10870
  var chartData = _a.chartData, cursorData = _a.cursorData, getTagsFromAPI = _a.getTagsFromAPI;
10857
10871
  var classes = useTagsTableStyles();
10858
- var _b = useTrendingContext(), _c = _b.state, viewTags = _c.viewTags, viewSelected = _c.viewSelected, _d = _b.actions, setViewTags = _d.setViewTags, setGraphShouldUpdate = _d.setGraphShouldUpdate; _d.setViewSelected;
10872
+ var _b = useTrendingContext(), _c = _b.state, viewTags = _c.viewTags, viewSelected = _c.viewSelected, _d = _b.actions, setViewTags = _d.setViewTags, setViewTagsAndRefetch = _d.setViewTagsAndRefetch;
10859
10873
  var _e = useState({}); _e[0]; _e[1];
10860
10874
  var _f = useState(''), error = _f[0], setError = _f[1];
10861
10875
  var _g = useState(false); _g[0]; var setIsLoading = _g[1];
@@ -10872,10 +10886,9 @@ var TableComponent = function (_a) {
10872
10886
  return tag.TagId === tagId ? __assign(__assign({}, tag), (_a = {}, _a[property] = value, _a.IsAutoScale = false, _a)) : tag;
10873
10887
  });
10874
10888
  setViewTags(newTags);
10875
- setGraphShouldUpdate();
10876
10889
  };
10877
10890
  var handleChangeAlias = function (tagId, newName) {
10878
- var newTags = viewTags.map(function (tag) { return (tag.TagId === tagId ? __assign(__assign({}, tag), { Alias: newName }) : tag); });
10891
+ var newTags = viewTags.map(function (tag) { return tag.TagId === tagId ? __assign(__assign({}, tag), { Alias: newName }) : tag; });
10879
10892
  setViewTags(newTags);
10880
10893
  };
10881
10894
  var handleVisibilityChange = function (tagId, value) {
@@ -10896,13 +10909,13 @@ var TableComponent = function (_a) {
10896
10909
  };
10897
10910
  var handleDeleteTag = function (tagId) {
10898
10911
  var newTags = viewTags.filter(function (tag) { return tag.TagId !== tagId; });
10899
- setViewTags(newTags);
10912
+ setViewTagsAndRefetch(newTags);
10900
10913
  };
10901
10914
  var handleAddTag = function (newTag) {
10902
10915
  var newArr = __spreadArray([], viewTags, true);
10903
10916
  if (newTag) {
10904
10917
  newArr.push(newTag);
10905
- setViewTags(newArr);
10918
+ setViewTagsAndRefetch(newArr);
10906
10919
  }
10907
10920
  };
10908
10921
  var handleAbleScales = function (tagId, checked) {
@@ -10962,8 +10975,8 @@ var TableComponent = function (_a) {
10962
10975
  setError(deleteResp.message);
10963
10976
  }
10964
10977
  return [4 /*yield*/, Promise.allSettled(viewTags.map(function (_a) {
10965
- var TagId = _a.TagId, Color = _a.Color, MinScale = _a.MinScale, MaxScale = _a.MaxScale, IsAutoScale = _a.IsAutoScale, IsVisible = _a.IsVisible;
10966
- upsertViewTag(viewSelected === null || viewSelected === void 0 ? void 0 : viewSelected.ViewId, TagId, Color, MinScale, MaxScale, IsVisible, IsAutoScale)
10978
+ var TagId = _a.TagId, Color = _a.Color, MinScale = _a.MinScale, MaxScale = _a.MaxScale, IsAutoScale = _a.IsAutoScale, IsVisible = _a.IsVisible, Unit = _a.Unit;
10979
+ upsertViewTag(viewSelected === null || viewSelected === void 0 ? void 0 : viewSelected.ViewId, TagId, Color, MinScale, MaxScale, IsVisible, IsAutoScale, Unit)
10967
10980
  .then(function (r) {
10968
10981
  if (!r.ok) {
10969
10982
  setError(r.message);
@@ -11034,7 +11047,7 @@ var TableComponent = function (_a) {
11034
11047
  return [4 /*yield*/, saveTagDefaults(TagId, Alias, Color, MinScale, MaxScale, Unit)];
11035
11048
  case 1:
11036
11049
  saveTagDefaultsResp = _b.sent();
11037
- return [4 /*yield*/, upsertViewTag(viewSelected === null || viewSelected === void 0 ? void 0 : viewSelected.ViewId, TagId, Color, MinScale, MaxScale, IsVisible, IsAutoScale)];
11050
+ return [4 /*yield*/, upsertViewTag(viewSelected === null || viewSelected === void 0 ? void 0 : viewSelected.ViewId, TagId, Color, MinScale, MaxScale, IsVisible, IsAutoScale, Unit)];
11038
11051
  case 2:
11039
11052
  upsertViewTagResp = _b.sent();
11040
11053
  if (!saveTagDefaultsResp.ok) {
@@ -11149,7 +11162,7 @@ var TableComponent = function (_a) {
11149
11162
  React__default.createElement("td", { className: classes.aliasCol },
11150
11163
  React__default.createElement(Tooltip, { title: tag.TagName, placement: "top", arrow: true, interactive: true, enterDelay: 500 },
11151
11164
  React__default.createElement("div", { style: { display: 'flex', alignItems: 'center' } },
11152
- React__default.createElement("div", { className: classes.dataType, style: { backgroundColor: tag.TagType === "Real" ? "blue" : "red" } }, tag.TagType === "Real" ? "A" : "D"),
11165
+ React__default.createElement("div", { className: classes.dataType, style: { backgroundColor: tag.TagType === "Real" || tag.TagType === "A" ? "blue" : "red" } }, tag.TagType === "Real" || tag.TagType === "A" ? "A" : "D"),
11153
11166
  React__default.createElement("input", { type: "text", style: { width: '100%' }, value: tag.Alias || tag.TagName, onFocus: function (e) { return e.target.select(); }, onChange: function (e) {
11154
11167
  var newAlias = e.target.value;
11155
11168
  handleChangeAlias(tag.TagId, newAlias);
@@ -11181,14 +11194,14 @@ var TableComponent = function (_a) {
11181
11194
  }
11182
11195
  } })),
11183
11196
  React__default.createElement("td", { className: "".concat(classes.autoScale, " ").concat(classes.checkbox) },
11184
- React__default.createElement("input", { type: "checkbox", checked: tag.IsAutoScale, onChange: function (e) { return handleAutoScaleChange(tag.TagId, tag.IsAutoScale); } })),
11197
+ React__default.createElement("input", { type: "checkbox", checked: !!tag.IsAutoScale, onChange: function (e) { return handleAutoScaleChange(tag.TagId, tag.IsAutoScale); } })),
11185
11198
  React__default.createElement("td", { className: "".concat(classes.autoScale, " ").concat(classes.checkbox) },
11186
11199
  React__default.createElement("input", { type: "text", style: {
11187
11200
  width: '100%'
11188
11201
  }, onClick: function () { return handleAbleScales(tag.TagId, tag.IsAutoScale); }, onChange: function (e) {
11189
11202
  var value = e.target.value;
11190
11203
  handleUnitChange(tag.TagId, value);
11191
- }, value: tag.Unit, onFocus: function (e) { return e.target.select(); } })),
11204
+ }, value: tag.Unit === "-" ? '' : tag.Unit, onFocus: function (e) { return e.target.select(); } })),
11192
11205
  React__default.createElement("td", null, round((_a = dataTable[tag.TagName]) === null || _a === void 0 ? void 0 : _a.y1, 3)),
11193
11206
  React__default.createElement("td", { className: classes.doubleInput }, round((_b = dataTable[tag.TagName]) === null || _b === void 0 ? void 0 : _b.y2, 3)),
11194
11207
  React__default.createElement("td", null, round((_c = dataTable[tag.TagName]) === null || _c === void 0 ? void 0 : _c.y2y1, 3)),
@@ -11774,16 +11787,16 @@ var TrendingChart = function (_a) {
11774
11787
  Chart.register(CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip$1, Legend, TimeScale, zoomPlugin);
11775
11788
  var Trending = function (_a) {
11776
11789
  _a.title; var getTagsFromAPI = _a.getTagsFromAPI;
11777
- var _b = useTrendingContext(), state = _b.state, viewTags = _b.state.viewTags;
11778
- var _c = useState(''), error = _c[0], setError = _c[1];
11779
- var _d = useState(true), loading = _d[0], setLoading = _d[1];
11780
- var _e = useState([]), series = _e[0], setSeries = _e[1];
11781
- var _f = useChartOptions(), chartOptions = _f[0], setChartOptions = _f[1];
11782
- var _g = useState({
11790
+ var _b = useTrendingContext(), state = _b.state, _c = _b.state, viewTags = _c.viewTags, shouldRefetchSeries = _c.shouldRefetchSeries;
11791
+ var _d = useState(''), error = _d[0], setError = _d[1];
11792
+ var _e = useState(true), loading = _e[0], setLoading = _e[1];
11793
+ var _f = useState([]), series = _f[0], setSeries = _f[1];
11794
+ var _g = useChartOptions(), chartOptions = _g[0], setChartOptions = _g[1];
11795
+ var _h = useState({
11783
11796
  labels: [],
11784
11797
  datasets: []
11785
- }), chartData = _g[0], setChartData = _g[1];
11786
- var _h = useState(null), cursorData = _h[0], setCursorData = _h[1];
11798
+ }), chartData = _h[0], setChartData = _h[1];
11799
+ var _j = useState(null), cursorData = _j[0], setCursorData = _j[1];
11787
11800
  var debounceForFetchingData = useRef(null);
11788
11801
  useEffect(function () {
11789
11802
  if (debounceForFetchingData.current) {
@@ -11823,7 +11836,7 @@ var Trending = function (_a) {
11823
11836
  }); };
11824
11837
  fetchData();
11825
11838
  }, 800);
11826
- }, [state.graphShouldUpdate, viewTags]);
11839
+ }, [shouldRefetchSeries]);
11827
11840
  return (React__default.createElement(React__default.Fragment, null,
11828
11841
  React__default.createElement(Grid$1, { container: true, style: { width: "95svw", height: "81svh", margin: 0 } },
11829
11842
  React__default.createElement(Header, { setChartOptions: setChartOptions }),
@@ -11838,7 +11851,7 @@ var Trending = function (_a) {
11838
11851
 
11839
11852
  var TrendingsPage = function (props) {
11840
11853
  var _a = useState(''), error = _a[0], setError = _a[1];
11841
- var _b = useTrendingContext(), viewSelected = _b.state.viewSelected, _c = _b.actions, setViews = _c.setViews, setViewTags = _c.setViewTags, setViewSelected = _c.setViewSelected;
11854
+ var _b = useTrendingContext(), viewSelected = _b.state.viewSelected, _c = _b.actions, setViews = _c.setViews, setViewTagsAndRefetch = _c.setViewTagsAndRefetch, setViewSelected = _c.setViewSelected;
11842
11855
  var getTagsFromAPI = function (forceReload) {
11843
11856
  if (forceReload === void 0) { forceReload = false; }
11844
11857
  return __awaiter(void 0, void 0, void 0, function () {
@@ -11863,7 +11876,7 @@ var TrendingsPage = function (props) {
11863
11876
  case 2:
11864
11877
  viewTagsResp = _a.sent();
11865
11878
  if (viewTagsResp.ok) {
11866
- setViewTags(viewTagsResp.data.tables[0].rows);
11879
+ setViewTagsAndRefetch(viewTagsResp.data.tables[0].rows);
11867
11880
  }
11868
11881
  else {
11869
11882
  setError(viewTagsResp.message);