@dexteel/mesf-core 4.8.4 → 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,6 @@
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)
2
4
  ## 4.8.4
3
5
  - Trending: In Add Tag modal, fix unnecessary calls to /children bug. Now only makes calls when the tag has childrens (#203)
4
6
  ## 4.8.3
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;
@@ -10144,11 +10152,13 @@ var TagSelectionModal = function (_a) {
10144
10152
  TagId: dbTag.tagId,
10145
10153
  TagName: dbTag.tagName,
10146
10154
  Color: dbTag.color || getColor(),
10147
- IsAutoScale: true,
10148
- MinScale: dbTag.minScale,
10149
- MaxScale: dbTag.maxScale,
10155
+ IsAutoScale: (dbTag.minValue || dbTag.maxValue) ? false : true,
10156
+ MinScale: dbTag.minValue,
10157
+ MaxScale: dbTag.maxValue,
10150
10158
  IsVisible: true,
10151
- TagType: dbTag.tagType
10159
+ TagType: dbTag.tagType,
10160
+ Alias: dbTag.alias,
10161
+ Unit: dbTag.unit
10152
10162
  }
10153
10163
  }];
10154
10164
  }
@@ -10325,7 +10335,7 @@ var getViewTags = function (ViewId) { return __awaiter(void 0, void 0, void 0, f
10325
10335
  }
10326
10336
  });
10327
10337
  }); };
10328
- 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 () {
10329
10339
  var apiService, parameters, resp;
10330
10340
  return __generator(this, function (_a) {
10331
10341
  switch (_a.label) {
@@ -10339,6 +10349,7 @@ var upsertViewTag = function (ViewId, TagId, Color, MinScale, MaxScale, IsVisibl
10339
10349
  parameters.push({ name: "MaxScale", value: MaxScale });
10340
10350
  parameters.push({ name: "IsVisible", value: IsVisible });
10341
10351
  parameters.push({ name: "IsAutoScale", value: IsAutoScale });
10352
+ parameters.push({ name: "Unit", value: Unit });
10342
10353
  return [4 /*yield*/, apiService.callV2("[mssql2022].[IH_100020].[ih].[UpsertViewTag]", parameters)];
10343
10354
  case 1:
10344
10355
  resp = _a.sent();
@@ -10698,8 +10709,8 @@ var SaveAsViewModal = function (_a) {
10698
10709
  if (!resp.ok) return [3 /*break*/, 3];
10699
10710
  ViewId_1 = resp.data.returnValue;
10700
10711
  return [4 /*yield*/, Promise.allSettled(viewTags.map(function (_a) {
10701
- var TagId = _a.TagId, Color = _a.Color, MinScale = _a.MinScale, MaxScale = _a.MaxScale, IsAutoScale = _a.IsAutoScale, IsVisible = _a.IsVisible;
10702
- 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)
10703
10714
  .then(function (r) {
10704
10715
  if (!r.ok) {
10705
10716
  setError(r.message);
@@ -10858,7 +10869,7 @@ var formatTimeDiffWithMs = function (start, end) {
10858
10869
  var TableComponent = function (_a) {
10859
10870
  var chartData = _a.chartData, cursorData = _a.cursorData, getTagsFromAPI = _a.getTagsFromAPI;
10860
10871
  var classes = useTagsTableStyles();
10861
- 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;
10862
10873
  var _e = useState({}); _e[0]; _e[1];
10863
10874
  var _f = useState(''), error = _f[0], setError = _f[1];
10864
10875
  var _g = useState(false); _g[0]; var setIsLoading = _g[1];
@@ -10875,10 +10886,9 @@ var TableComponent = function (_a) {
10875
10886
  return tag.TagId === tagId ? __assign(__assign({}, tag), (_a = {}, _a[property] = value, _a.IsAutoScale = false, _a)) : tag;
10876
10887
  });
10877
10888
  setViewTags(newTags);
10878
- setGraphShouldUpdate();
10879
10889
  };
10880
10890
  var handleChangeAlias = function (tagId, newName) {
10881
- 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; });
10882
10892
  setViewTags(newTags);
10883
10893
  };
10884
10894
  var handleVisibilityChange = function (tagId, value) {
@@ -10899,13 +10909,13 @@ var TableComponent = function (_a) {
10899
10909
  };
10900
10910
  var handleDeleteTag = function (tagId) {
10901
10911
  var newTags = viewTags.filter(function (tag) { return tag.TagId !== tagId; });
10902
- setViewTags(newTags);
10912
+ setViewTagsAndRefetch(newTags);
10903
10913
  };
10904
10914
  var handleAddTag = function (newTag) {
10905
10915
  var newArr = __spreadArray([], viewTags, true);
10906
10916
  if (newTag) {
10907
10917
  newArr.push(newTag);
10908
- setViewTags(newArr);
10918
+ setViewTagsAndRefetch(newArr);
10909
10919
  }
10910
10920
  };
10911
10921
  var handleAbleScales = function (tagId, checked) {
@@ -10965,8 +10975,8 @@ var TableComponent = function (_a) {
10965
10975
  setError(deleteResp.message);
10966
10976
  }
10967
10977
  return [4 /*yield*/, Promise.allSettled(viewTags.map(function (_a) {
10968
- var TagId = _a.TagId, Color = _a.Color, MinScale = _a.MinScale, MaxScale = _a.MaxScale, IsAutoScale = _a.IsAutoScale, IsVisible = _a.IsVisible;
10969
- 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)
10970
10980
  .then(function (r) {
10971
10981
  if (!r.ok) {
10972
10982
  setError(r.message);
@@ -11037,7 +11047,7 @@ var TableComponent = function (_a) {
11037
11047
  return [4 /*yield*/, saveTagDefaults(TagId, Alias, Color, MinScale, MaxScale, Unit)];
11038
11048
  case 1:
11039
11049
  saveTagDefaultsResp = _b.sent();
11040
- 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)];
11041
11051
  case 2:
11042
11052
  upsertViewTagResp = _b.sent();
11043
11053
  if (!saveTagDefaultsResp.ok) {
@@ -11152,7 +11162,7 @@ var TableComponent = function (_a) {
11152
11162
  React__default.createElement("td", { className: classes.aliasCol },
11153
11163
  React__default.createElement(Tooltip, { title: tag.TagName, placement: "top", arrow: true, interactive: true, enterDelay: 500 },
11154
11164
  React__default.createElement("div", { style: { display: 'flex', alignItems: 'center' } },
11155
- 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"),
11156
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) {
11157
11167
  var newAlias = e.target.value;
11158
11168
  handleChangeAlias(tag.TagId, newAlias);
@@ -11184,14 +11194,14 @@ var TableComponent = function (_a) {
11184
11194
  }
11185
11195
  } })),
11186
11196
  React__default.createElement("td", { className: "".concat(classes.autoScale, " ").concat(classes.checkbox) },
11187
- 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); } })),
11188
11198
  React__default.createElement("td", { className: "".concat(classes.autoScale, " ").concat(classes.checkbox) },
11189
11199
  React__default.createElement("input", { type: "text", style: {
11190
11200
  width: '100%'
11191
11201
  }, onClick: function () { return handleAbleScales(tag.TagId, tag.IsAutoScale); }, onChange: function (e) {
11192
11202
  var value = e.target.value;
11193
11203
  handleUnitChange(tag.TagId, value);
11194
- }, value: tag.Unit, onFocus: function (e) { return e.target.select(); } })),
11204
+ }, value: tag.Unit === "-" ? '' : tag.Unit, onFocus: function (e) { return e.target.select(); } })),
11195
11205
  React__default.createElement("td", null, round((_a = dataTable[tag.TagName]) === null || _a === void 0 ? void 0 : _a.y1, 3)),
11196
11206
  React__default.createElement("td", { className: classes.doubleInput }, round((_b = dataTable[tag.TagName]) === null || _b === void 0 ? void 0 : _b.y2, 3)),
11197
11207
  React__default.createElement("td", null, round((_c = dataTable[tag.TagName]) === null || _c === void 0 ? void 0 : _c.y2y1, 3)),
@@ -11777,16 +11787,16 @@ var TrendingChart = function (_a) {
11777
11787
  Chart.register(CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip$1, Legend, TimeScale, zoomPlugin);
11778
11788
  var Trending = function (_a) {
11779
11789
  _a.title; var getTagsFromAPI = _a.getTagsFromAPI;
11780
- var _b = useTrendingContext(), state = _b.state, viewTags = _b.state.viewTags;
11781
- var _c = useState(''), error = _c[0], setError = _c[1];
11782
- var _d = useState(true), loading = _d[0], setLoading = _d[1];
11783
- var _e = useState([]), series = _e[0], setSeries = _e[1];
11784
- var _f = useChartOptions(), chartOptions = _f[0], setChartOptions = _f[1];
11785
- 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({
11786
11796
  labels: [],
11787
11797
  datasets: []
11788
- }), chartData = _g[0], setChartData = _g[1];
11789
- 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];
11790
11800
  var debounceForFetchingData = useRef(null);
11791
11801
  useEffect(function () {
11792
11802
  if (debounceForFetchingData.current) {
@@ -11826,7 +11836,7 @@ var Trending = function (_a) {
11826
11836
  }); };
11827
11837
  fetchData();
11828
11838
  }, 800);
11829
- }, [state.graphShouldUpdate, viewTags]);
11839
+ }, [shouldRefetchSeries]);
11830
11840
  return (React__default.createElement(React__default.Fragment, null,
11831
11841
  React__default.createElement(Grid$1, { container: true, style: { width: "95svw", height: "81svh", margin: 0 } },
11832
11842
  React__default.createElement(Header, { setChartOptions: setChartOptions }),
@@ -11841,7 +11851,7 @@ var Trending = function (_a) {
11841
11851
 
11842
11852
  var TrendingsPage = function (props) {
11843
11853
  var _a = useState(''), error = _a[0], setError = _a[1];
11844
- 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;
11845
11855
  var getTagsFromAPI = function (forceReload) {
11846
11856
  if (forceReload === void 0) { forceReload = false; }
11847
11857
  return __awaiter(void 0, void 0, void 0, function () {
@@ -11866,7 +11876,7 @@ var TrendingsPage = function (props) {
11866
11876
  case 2:
11867
11877
  viewTagsResp = _a.sent();
11868
11878
  if (viewTagsResp.ok) {
11869
- setViewTags(viewTagsResp.data.tables[0].rows);
11879
+ setViewTagsAndRefetch(viewTagsResp.data.tables[0].rows);
11870
11880
  }
11871
11881
  else {
11872
11882
  setError(viewTagsResp.message);