@dexteel/mesf-core 4.8.4 → 4.8.6

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.6
3
+ - Trending: Get IH DB Path from backend
4
+ ## 4.8.5
5
+ - Trending: Fix bugs on Add Tag modal, SaveDefaultToTag, Remove Tag, Save View, Edit viewTags, and performance (#204)
2
6
  ## 4.8.4
3
7
  - Trending: In Add Tag modal, fix unnecessary calls to /children bug. Now only makes calls when the tag has childrens (#203)
4
8
  ## 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
  }
@@ -10241,6 +10251,7 @@ var ButtonWithLoading = function (_a) {
10241
10251
  children));
10242
10252
  };
10243
10253
 
10254
+ var ihPath = localStorage.getItem('ihPath') || "[mssql2022].[IH_100020].[ih]";
10244
10255
  var saveTagDefaults = function (TagId, Alias, Color, MinScale, MaxScale, Unit) { return __awaiter(void 0, void 0, void 0, function () {
10245
10256
  var apiService, parameters, resp;
10246
10257
  return __generator(this, function (_a) {
@@ -10254,7 +10265,7 @@ var saveTagDefaults = function (TagId, Alias, Color, MinScale, MaxScale, Unit) {
10254
10265
  parameters.push({ name: "MinScale", value: MinScale });
10255
10266
  parameters.push({ name: "MaxScale", value: MaxScale });
10256
10267
  parameters.push({ name: "Unit", value: Unit });
10257
- return [4 /*yield*/, apiService.callV2("[mssql2022].[IH_100020].[ih].[SaveTagDefaults]", parameters)];
10268
+ return [4 /*yield*/, apiService.callV2(ihPath + ".[SaveTagDefaults]", parameters)];
10258
10269
  case 1:
10259
10270
  resp = _a.sent();
10260
10271
  return [2 /*return*/, resp];
@@ -10270,7 +10281,7 @@ var getViews = function (Search) { return __awaiter(void 0, void 0, void 0, func
10270
10281
  apiService = new MESApiService();
10271
10282
  parameters = [];
10272
10283
  parameters.push({ name: "Search", value: Search });
10273
- return [4 /*yield*/, apiService.callV2("[mssql2022].[IH_100020].[ih].[GetViews]", parameters)];
10284
+ return [4 /*yield*/, apiService.callV2(ihPath + ".[GetViews]", parameters)];
10274
10285
  case 1:
10275
10286
  resp = _a.sent();
10276
10287
  return [2 /*return*/, resp];
@@ -10287,7 +10298,7 @@ var upsertView = function (ViewId, ViewName, isPublic) { return __awaiter(void 0
10287
10298
  parameters.push({ name: "ViewId", value: ViewId });
10288
10299
  parameters.push({ name: "ViewName", value: ViewName });
10289
10300
  parameters.push({ name: "isPublic", value: isPublic });
10290
- return [4 /*yield*/, apiService.callV2("[mssql2022].[IH_100020].[ih].[UpsertView]", parameters)];
10301
+ return [4 /*yield*/, apiService.callV2(ihPath + ".[UpsertView]", parameters)];
10291
10302
  case 1:
10292
10303
  resp = _a.sent();
10293
10304
  return [2 /*return*/, resp];
@@ -10302,7 +10313,7 @@ var deleteView = function (ViewId) { return __awaiter(void 0, void 0, void 0, fu
10302
10313
  apiService = new MESApiService();
10303
10314
  parameters = [];
10304
10315
  parameters.push({ name: "ViewId", value: ViewId });
10305
- return [4 /*yield*/, apiService.callV2("[mssql2022].[IH_100020].[ih].[DeleteView]", parameters)];
10316
+ return [4 /*yield*/, apiService.callV2(ihPath + ".[DeleteView]", parameters)];
10306
10317
  case 1:
10307
10318
  resp = _a.sent();
10308
10319
  return [2 /*return*/, resp];
@@ -10318,14 +10329,14 @@ var getViewTags = function (ViewId) { return __awaiter(void 0, void 0, void 0, f
10318
10329
  apiService = new MESApiService();
10319
10330
  parameters = [];
10320
10331
  parameters.push({ name: "ViewId", value: ViewId });
10321
- return [4 /*yield*/, apiService.callV2("[mssql2022].[IH_100020].[ih].[GetViewTags]", parameters)];
10332
+ return [4 /*yield*/, apiService.callV2(ihPath + ".[GetViewTags]", parameters)];
10322
10333
  case 1:
10323
10334
  resp = _a.sent();
10324
10335
  return [2 /*return*/, resp];
10325
10336
  }
10326
10337
  });
10327
10338
  }); };
10328
- var upsertViewTag = function (ViewId, TagId, Color, MinScale, MaxScale, IsVisible, IsAutoScale) { return __awaiter(void 0, void 0, void 0, function () {
10339
+ var upsertViewTag = function (ViewId, TagId, Color, MinScale, MaxScale, IsVisible, IsAutoScale, Unit) { return __awaiter(void 0, void 0, void 0, function () {
10329
10340
  var apiService, parameters, resp;
10330
10341
  return __generator(this, function (_a) {
10331
10342
  switch (_a.label) {
@@ -10339,7 +10350,8 @@ var upsertViewTag = function (ViewId, TagId, Color, MinScale, MaxScale, IsVisibl
10339
10350
  parameters.push({ name: "MaxScale", value: MaxScale });
10340
10351
  parameters.push({ name: "IsVisible", value: IsVisible });
10341
10352
  parameters.push({ name: "IsAutoScale", value: IsAutoScale });
10342
- return [4 /*yield*/, apiService.callV2("[mssql2022].[IH_100020].[ih].[UpsertViewTag]", parameters)];
10353
+ parameters.push({ name: "Unit", value: Unit });
10354
+ return [4 /*yield*/, apiService.callV2(ihPath + ".[UpsertViewTag]", parameters)];
10343
10355
  case 1:
10344
10356
  resp = _a.sent();
10345
10357
  return [2 /*return*/, resp];
@@ -10354,7 +10366,7 @@ var deleteAllViewTagsFromView = function (ViewId) { return __awaiter(void 0, voi
10354
10366
  apiService = new MESApiService();
10355
10367
  parameters = [];
10356
10368
  parameters.push({ name: "ViewId", value: ViewId });
10357
- return [4 /*yield*/, apiService.callV2("[mssql2022].[IH_100020].[ih].[DeleteAllViewTagsFromView]", parameters)];
10369
+ return [4 /*yield*/, apiService.callV2(ihPath + ".[DeleteAllViewTagsFromView]", parameters)];
10358
10370
  case 1:
10359
10371
  resp = _a.sent();
10360
10372
  return [2 /*return*/, resp];
@@ -10698,8 +10710,8 @@ var SaveAsViewModal = function (_a) {
10698
10710
  if (!resp.ok) return [3 /*break*/, 3];
10699
10711
  ViewId_1 = resp.data.returnValue;
10700
10712
  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)
10713
+ var TagId = _a.TagId, Color = _a.Color, MinScale = _a.MinScale, MaxScale = _a.MaxScale, IsAutoScale = _a.IsAutoScale, IsVisible = _a.IsVisible, Unit = _a.Unit;
10714
+ upsertViewTag(ViewId_1, TagId, Color, MinScale, MaxScale, IsVisible, IsAutoScale, Unit)
10703
10715
  .then(function (r) {
10704
10716
  if (!r.ok) {
10705
10717
  setError(r.message);
@@ -10858,7 +10870,7 @@ var formatTimeDiffWithMs = function (start, end) {
10858
10870
  var TableComponent = function (_a) {
10859
10871
  var chartData = _a.chartData, cursorData = _a.cursorData, getTagsFromAPI = _a.getTagsFromAPI;
10860
10872
  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;
10873
+ var _b = useTrendingContext(), _c = _b.state, viewTags = _c.viewTags, viewSelected = _c.viewSelected, _d = _b.actions, setViewTags = _d.setViewTags, setViewTagsAndRefetch = _d.setViewTagsAndRefetch;
10862
10874
  var _e = useState({}); _e[0]; _e[1];
10863
10875
  var _f = useState(''), error = _f[0], setError = _f[1];
10864
10876
  var _g = useState(false); _g[0]; var setIsLoading = _g[1];
@@ -10875,10 +10887,9 @@ var TableComponent = function (_a) {
10875
10887
  return tag.TagId === tagId ? __assign(__assign({}, tag), (_a = {}, _a[property] = value, _a.IsAutoScale = false, _a)) : tag;
10876
10888
  });
10877
10889
  setViewTags(newTags);
10878
- setGraphShouldUpdate();
10879
10890
  };
10880
10891
  var handleChangeAlias = function (tagId, newName) {
10881
- var newTags = viewTags.map(function (tag) { return (tag.TagId === tagId ? __assign(__assign({}, tag), { Alias: newName }) : tag); });
10892
+ var newTags = viewTags.map(function (tag) { return tag.TagId === tagId ? __assign(__assign({}, tag), { Alias: newName }) : tag; });
10882
10893
  setViewTags(newTags);
10883
10894
  };
10884
10895
  var handleVisibilityChange = function (tagId, value) {
@@ -10899,13 +10910,13 @@ var TableComponent = function (_a) {
10899
10910
  };
10900
10911
  var handleDeleteTag = function (tagId) {
10901
10912
  var newTags = viewTags.filter(function (tag) { return tag.TagId !== tagId; });
10902
- setViewTags(newTags);
10913
+ setViewTagsAndRefetch(newTags);
10903
10914
  };
10904
10915
  var handleAddTag = function (newTag) {
10905
10916
  var newArr = __spreadArray([], viewTags, true);
10906
10917
  if (newTag) {
10907
10918
  newArr.push(newTag);
10908
- setViewTags(newArr);
10919
+ setViewTagsAndRefetch(newArr);
10909
10920
  }
10910
10921
  };
10911
10922
  var handleAbleScales = function (tagId, checked) {
@@ -10965,8 +10976,8 @@ var TableComponent = function (_a) {
10965
10976
  setError(deleteResp.message);
10966
10977
  }
10967
10978
  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)
10979
+ var TagId = _a.TagId, Color = _a.Color, MinScale = _a.MinScale, MaxScale = _a.MaxScale, IsAutoScale = _a.IsAutoScale, IsVisible = _a.IsVisible, Unit = _a.Unit;
10980
+ upsertViewTag(viewSelected === null || viewSelected === void 0 ? void 0 : viewSelected.ViewId, TagId, Color, MinScale, MaxScale, IsVisible, IsAutoScale, Unit)
10970
10981
  .then(function (r) {
10971
10982
  if (!r.ok) {
10972
10983
  setError(r.message);
@@ -11037,7 +11048,7 @@ var TableComponent = function (_a) {
11037
11048
  return [4 /*yield*/, saveTagDefaults(TagId, Alias, Color, MinScale, MaxScale, Unit)];
11038
11049
  case 1:
11039
11050
  saveTagDefaultsResp = _b.sent();
11040
- return [4 /*yield*/, upsertViewTag(viewSelected === null || viewSelected === void 0 ? void 0 : viewSelected.ViewId, TagId, Color, MinScale, MaxScale, IsVisible, IsAutoScale)];
11051
+ return [4 /*yield*/, upsertViewTag(viewSelected === null || viewSelected === void 0 ? void 0 : viewSelected.ViewId, TagId, Color, MinScale, MaxScale, IsVisible, IsAutoScale, Unit)];
11041
11052
  case 2:
11042
11053
  upsertViewTagResp = _b.sent();
11043
11054
  if (!saveTagDefaultsResp.ok) {
@@ -11152,7 +11163,7 @@ var TableComponent = function (_a) {
11152
11163
  React__default.createElement("td", { className: classes.aliasCol },
11153
11164
  React__default.createElement(Tooltip, { title: tag.TagName, placement: "top", arrow: true, interactive: true, enterDelay: 500 },
11154
11165
  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"),
11166
+ 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
11167
  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
11168
  var newAlias = e.target.value;
11158
11169
  handleChangeAlias(tag.TagId, newAlias);
@@ -11184,14 +11195,14 @@ var TableComponent = function (_a) {
11184
11195
  }
11185
11196
  } })),
11186
11197
  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); } })),
11198
+ React__default.createElement("input", { type: "checkbox", checked: !!tag.IsAutoScale, onChange: function (e) { return handleAutoScaleChange(tag.TagId, tag.IsAutoScale); } })),
11188
11199
  React__default.createElement("td", { className: "".concat(classes.autoScale, " ").concat(classes.checkbox) },
11189
11200
  React__default.createElement("input", { type: "text", style: {
11190
11201
  width: '100%'
11191
11202
  }, onClick: function () { return handleAbleScales(tag.TagId, tag.IsAutoScale); }, onChange: function (e) {
11192
11203
  var value = e.target.value;
11193
11204
  handleUnitChange(tag.TagId, value);
11194
- }, value: tag.Unit, onFocus: function (e) { return e.target.select(); } })),
11205
+ }, value: tag.Unit === "-" ? '' : tag.Unit, onFocus: function (e) { return e.target.select(); } })),
11195
11206
  React__default.createElement("td", null, round((_a = dataTable[tag.TagName]) === null || _a === void 0 ? void 0 : _a.y1, 3)),
11196
11207
  React__default.createElement("td", { className: classes.doubleInput }, round((_b = dataTable[tag.TagName]) === null || _b === void 0 ? void 0 : _b.y2, 3)),
11197
11208
  React__default.createElement("td", null, round((_c = dataTable[tag.TagName]) === null || _c === void 0 ? void 0 : _c.y2y1, 3)),
@@ -11777,16 +11788,16 @@ var TrendingChart = function (_a) {
11777
11788
  Chart.register(CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip$1, Legend, TimeScale, zoomPlugin);
11778
11789
  var Trending = function (_a) {
11779
11790
  _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({
11791
+ var _b = useTrendingContext(), state = _b.state, _c = _b.state, viewTags = _c.viewTags, shouldRefetchSeries = _c.shouldRefetchSeries;
11792
+ var _d = useState(''), error = _d[0], setError = _d[1];
11793
+ var _e = useState(true), loading = _e[0], setLoading = _e[1];
11794
+ var _f = useState([]), series = _f[0], setSeries = _f[1];
11795
+ var _g = useChartOptions(), chartOptions = _g[0], setChartOptions = _g[1];
11796
+ var _h = useState({
11786
11797
  labels: [],
11787
11798
  datasets: []
11788
- }), chartData = _g[0], setChartData = _g[1];
11789
- var _h = useState(null), cursorData = _h[0], setCursorData = _h[1];
11799
+ }), chartData = _h[0], setChartData = _h[1];
11800
+ var _j = useState(null), cursorData = _j[0], setCursorData = _j[1];
11790
11801
  var debounceForFetchingData = useRef(null);
11791
11802
  useEffect(function () {
11792
11803
  if (debounceForFetchingData.current) {
@@ -11826,7 +11837,7 @@ var Trending = function (_a) {
11826
11837
  }); };
11827
11838
  fetchData();
11828
11839
  }, 800);
11829
- }, [state.graphShouldUpdate, viewTags]);
11840
+ }, [shouldRefetchSeries]);
11830
11841
  return (React__default.createElement(React__default.Fragment, null,
11831
11842
  React__default.createElement(Grid$1, { container: true, style: { width: "95svw", height: "81svh", margin: 0 } },
11832
11843
  React__default.createElement(Header, { setChartOptions: setChartOptions }),
@@ -11841,7 +11852,7 @@ var Trending = function (_a) {
11841
11852
 
11842
11853
  var TrendingsPage = function (props) {
11843
11854
  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;
11855
+ var _b = useTrendingContext(), viewSelected = _b.state.viewSelected, _c = _b.actions, setViews = _c.setViews, setViewTagsAndRefetch = _c.setViewTagsAndRefetch, setViewSelected = _c.setViewSelected;
11845
11856
  var getTagsFromAPI = function (forceReload) {
11846
11857
  if (forceReload === void 0) { forceReload = false; }
11847
11858
  return __awaiter(void 0, void 0, void 0, function () {
@@ -11866,7 +11877,7 @@ var TrendingsPage = function (props) {
11866
11877
  case 2:
11867
11878
  viewTagsResp = _a.sent();
11868
11879
  if (viewTagsResp.ok) {
11869
- setViewTags(viewTagsResp.data.tables[0].rows);
11880
+ setViewTagsAndRefetch(viewTagsResp.data.tables[0].rows);
11870
11881
  }
11871
11882
  else {
11872
11883
  setError(viewTagsResp.message);
@@ -11893,6 +11904,28 @@ var TrendingsPage = function (props) {
11893
11904
  };
11894
11905
 
11895
11906
  var index = function () {
11907
+ var _a = useState(false), ihPathLoaded = _a[0], setIhPathLoaded = _a[1];
11908
+ useEffect(function () {
11909
+ var getIhPath = function () { return __awaiter(void 0, void 0, void 0, function () {
11910
+ var resp;
11911
+ return __generator(this, function (_a) {
11912
+ switch (_a.label) {
11913
+ case 0: return [4 /*yield*/, axiosInstance.get('/backend/ih-path')];
11914
+ case 1:
11915
+ resp = _a.sent();
11916
+ localStorage.setItem('ihPath', resp.data);
11917
+ setIhPathLoaded(true);
11918
+ return [2 /*return*/];
11919
+ }
11920
+ });
11921
+ }); };
11922
+ getIhPath().then(function () {
11923
+ console.log('ih path loaded');
11924
+ });
11925
+ }, []);
11926
+ if (!ihPathLoaded) {
11927
+ return (React__default.createElement("div", { className: 'd-flex justify-content-center align-items-center' }, "Loading..."));
11928
+ }
11896
11929
  return (React__default.createElement(TrendingProvider, null,
11897
11930
  React__default.createElement(TrendingsPage, null)));
11898
11931
  };