@dexteel/mesf-core 4.8.0 → 4.8.2

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,5 +1,5 @@
1
1
  # CHANGELOG
2
- ## 4.8.0
2
+ ## 4.8.0-1
3
3
  - Trending: Fix when removing view tag bug (#184)
4
4
  - Trending: Add new button to navigate to current date (#189 and #207)
5
5
  ## 4.7.11
package/dist/index.esm.js CHANGED
@@ -10249,7 +10249,7 @@ var upsertViewTag = function (ViewId, TagId, Color, MinScale, MaxScale, IsVisibl
10249
10249
  }
10250
10250
  });
10251
10251
  }); };
10252
- var deleteViewTag = function (ViewId, TagId) { return __awaiter(void 0, void 0, void 0, function () {
10252
+ var deleteAllViewTagsFromView = function (ViewId) { return __awaiter(void 0, void 0, void 0, function () {
10253
10253
  var apiService, parameters, resp;
10254
10254
  return __generator(this, function (_a) {
10255
10255
  switch (_a.label) {
@@ -10257,8 +10257,7 @@ var deleteViewTag = function (ViewId, TagId) { return __awaiter(void 0, void 0,
10257
10257
  apiService = new MESApiService();
10258
10258
  parameters = [];
10259
10259
  parameters.push({ name: "ViewId", value: ViewId });
10260
- parameters.push({ name: "TagId", value: TagId });
10261
- return [4 /*yield*/, apiService.callV2("[mssql2022].[IH_100020].[ih].[DeleteViewTag]", parameters)];
10260
+ return [4 /*yield*/, apiService.callV2("[mssql2022].[IH_100020].[ih].[DeleteAllViewTagsFromView]", parameters)];
10262
10261
  case 1:
10263
10262
  resp = _a.sent();
10264
10263
  return [2 /*return*/, resp];
@@ -10798,14 +10797,40 @@ var useTagsTableStyles = makeStyles$1(function (theme) { return ({
10798
10797
  }
10799
10798
  }); });
10800
10799
 
10801
- var timeDifference = function (start, end) {
10802
- var differenceMilliseconds = start - end;
10803
- var seconds = Math.floor(differenceMilliseconds / 1000);
10804
- var minutes = Math.floor(seconds / 60);
10805
- var hours = Math.floor(minutes / 60);
10806
- var remainingMinutes = minutes % 60;
10807
- var remainingSeconds = seconds % 60;
10808
- return "".concat(hours, "h ").concat(remainingMinutes, "m ").concat(remainingSeconds, "s");
10800
+ var formatTimeDiffWithMs = function (start, end) {
10801
+ // Calculate total difference in milliseconds
10802
+ var totalMilliseconds = end - start;
10803
+ // Convert milliseconds to seconds, minutes, hours, days, and months for comparison
10804
+ var seconds = totalMilliseconds / 1000;
10805
+ var minutes = seconds / 60;
10806
+ var hours = minutes / 60;
10807
+ var days = hours / 24;
10808
+ var months = days / 30; // Approximation of a month
10809
+ var remainingSeconds = seconds % 60; // Remaining seconds after full minutes
10810
+ if (months > 12) {
10811
+ var years = months / 12;
10812
+ return "".concat(Math.floor(years), " years, ").concat(Math.floor(months % 12), " months");
10813
+ }
10814
+ else if (months > 6) {
10815
+ return "".concat(Math.floor(months), " months, ").concat(Math.floor(days % 30), " days");
10816
+ }
10817
+ else if (days > 10) {
10818
+ return "".concat(Math.floor(days), " days, ").concat(Math.floor(hours % 24), " hours");
10819
+ }
10820
+ else if (days > 1) {
10821
+ return "".concat(Math.floor(days), " days, ").concat(Math.floor(hours % 24), " hours");
10822
+ }
10823
+ else if (hours > 12) {
10824
+ return "".concat(Math.floor(hours), " hours, ").concat(Math.floor(minutes % 60), " minutes, ").concat(remainingSeconds.toFixed(2), " seconds");
10825
+ }
10826
+ else if (hours < 1) {
10827
+ // If there are 0 hours, return just minutes and remaining seconds
10828
+ return "".concat(Math.floor(minutes), " minutes, ").concat(remainingSeconds.toFixed(2), " seconds");
10829
+ }
10830
+ else {
10831
+ // For time intervals less than 12 hours but more than 1 hour, return hours, minutes, and remaining seconds
10832
+ return "".concat(Math.floor(hours), " hours, ").concat(Math.floor(minutes % 60), " minutes, ").concat(remainingSeconds.toFixed(2), " seconds");
10833
+ }
10809
10834
  };
10810
10835
 
10811
10836
  var TableComponent = function (_a) {
@@ -10814,6 +10839,7 @@ var TableComponent = function (_a) {
10814
10839
  var _b = useTrendingContext(), _c = _b.state, viewTags = _c.viewTags, viewSelected = _c.viewSelected, _d = _b.actions, setViewTags = _d.setViewTags, setGraphShouldUpdate = _d.setGraphShouldUpdate; _d.setViewSelected;
10815
10840
  var _e = useState(''), error = _e[0], setError = _e[1];
10816
10841
  var _f = useState(false); _f[0]; var setIsLoading = _f[1];
10842
+ var _g = useState(null), viewTagForDelete = _g[0], setViewTagForDelete = _g[1];
10817
10843
  var dataTable = useTagsDataTable({ viewTags: viewTags, chartData: chartData, cursorData: cursorData });
10818
10844
  var handleChange = function (tagId, value, property) {
10819
10845
  var newTags = viewTags.map(function (tag) {
@@ -10859,11 +10885,11 @@ var TableComponent = function (_a) {
10859
10885
  handleAutoScaleChange(tagId, checked);
10860
10886
  }
10861
10887
  };
10862
- var _g = useState(null), selectedRowIndex = _g[0], setSelectedRowIndex = _g[1];
10863
- var _h = useState(false), addTagModalOpen = _h[0], setAddTagModalOpen = _h[1];
10864
- var _j = useState(false), saveAsViewModalOpen = _j[0], setSaveAsViewModalOpen = _j[1];
10865
- var _k = useState(false), loadViewOpen = _k[0], setLoadViewOpen = _k[1];
10866
- var _l = useState(''), snackbarMessage = _l[0], setSnackbarMessage = _l[1];
10888
+ var _h = useState(null), selectedRowIndex = _h[0], setSelectedRowIndex = _h[1];
10889
+ var _j = useState(false), addTagModalOpen = _j[0], setAddTagModalOpen = _j[1];
10890
+ var _k = useState(false), saveAsViewModalOpen = _k[0], setSaveAsViewModalOpen = _k[1];
10891
+ var _l = useState(false), loadViewOpen = _l[0], setLoadViewOpen = _l[1];
10892
+ var _m = useState(''), snackbarMessage = _m[0], setSnackbarMessage = _m[1];
10867
10893
  var handleClose = function () { return setAddTagModalOpen(false); };
10868
10894
  var ContextMenu = function (_a) {
10869
10895
  var x = _a.x, y = _a.y, options = _a.options;
@@ -10874,7 +10900,7 @@ var TableComponent = function (_a) {
10874
10900
  React__default.createElement("ul", null, options.map(function (option) { return (React__default.createElement("li", { key: option.id, onClick: option.onClick }, option.label)); }))));
10875
10901
  };
10876
10902
  // Position state for the context menu
10877
- var _m = useState({ x: 0, y: 0 }), contextMenuPosition = _m[0], setContextMenuPosition = _m[1];
10903
+ var _o = useState({ x: 0, y: 0 }), contextMenuPosition = _o[0], setContextMenuPosition = _o[1];
10878
10904
  var contextMenuOptions = [
10879
10905
  { id: 'delete', label: 'Remove Tag', onClick: function () { return handleDelete(); } },
10880
10906
  { id: 'add', label: 'Add Tag', onClick: function () { return setAddTagModalOpen(true); } },
@@ -10887,41 +10913,34 @@ var TableComponent = function (_a) {
10887
10913
  handleAddTag(selectedTag);
10888
10914
  };
10889
10915
  var handleDelete = function (index) { return __awaiter(void 0, void 0, void 0, function () {
10890
- var tagToDelete, resp;
10891
10916
  return __generator(this, function (_a) {
10892
- switch (_a.label) {
10893
- case 0:
10894
- if (!(selectedRowIndex !== null)) return [3 /*break*/, 3];
10895
- tagToDelete = viewTags[selectedRowIndex];
10896
- if (!(viewSelected === null || viewSelected === void 0 ? void 0 : viewSelected.ViewId)) return [3 /*break*/, 2];
10897
- return [4 /*yield*/, deleteViewTag(viewSelected === null || viewSelected === void 0 ? void 0 : viewSelected.ViewId, tagToDelete.TagId)];
10898
- case 1:
10899
- resp = _a.sent();
10900
- if (resp.ok) {
10901
- handleDeleteTag(tagToDelete.TagId);
10902
- }
10903
- else {
10904
- setError(resp.message);
10905
- }
10906
- _a.label = 2;
10907
- case 2:
10908
- setSelectedRowIndex(null); // Reset the selected row index
10909
- _a.label = 3;
10910
- case 3: return [2 /*return*/];
10917
+ if (!isNil$1(viewTagForDelete)) {
10918
+ if (viewSelected === null || viewSelected === void 0 ? void 0 : viewSelected.ViewId) {
10919
+ handleDeleteTag(viewTagForDelete.TagId);
10920
+ }
10921
+ setSelectedRowIndex(null); // Reset the selected row index
10922
+ setViewTagForDelete(null);
10911
10923
  }
10924
+ return [2 /*return*/];
10912
10925
  });
10913
10926
  }); };
10914
10927
  var handleSaveView = function () { return __awaiter(void 0, void 0, void 0, function () {
10915
- var resp, results;
10928
+ var resp, deleteResp, results;
10916
10929
  return __generator(this, function (_a) {
10917
10930
  switch (_a.label) {
10918
10931
  case 0:
10919
10932
  setIsLoading(true);
10920
- if (!(viewSelected === null || viewSelected === void 0 ? void 0 : viewSelected.ViewId)) return [3 /*break*/, 4];
10933
+ if (!(viewSelected === null || viewSelected === void 0 ? void 0 : viewSelected.ViewId)) return [3 /*break*/, 5];
10921
10934
  return [4 /*yield*/, upsertView(viewSelected === null || viewSelected === void 0 ? void 0 : viewSelected.ViewId, viewSelected.ViewName, viewSelected.IsPublic)];
10922
10935
  case 1:
10923
10936
  resp = _a.sent();
10924
- if (!resp.ok) return [3 /*break*/, 3];
10937
+ if (!resp.ok) return [3 /*break*/, 4];
10938
+ return [4 /*yield*/, deleteAllViewTagsFromView(viewSelected.ViewId)];
10939
+ case 2:
10940
+ deleteResp = _a.sent();
10941
+ if (!deleteResp.ok) {
10942
+ setError(deleteResp.message);
10943
+ }
10925
10944
  return [4 /*yield*/, Promise.allSettled(viewTags.map(function (_a) {
10926
10945
  var TagId = _a.TagId, Color = _a.Color, MinScale = _a.MinScale, MaxScale = _a.MaxScale, IsAutoScale = _a.IsAutoScale, IsVisible = _a.IsVisible;
10927
10946
  upsertViewTag(viewSelected === null || viewSelected === void 0 ? void 0 : viewSelected.ViewId, TagId, Color, MinScale, MaxScale, IsVisible, IsAutoScale)
@@ -10931,7 +10950,7 @@ var TableComponent = function (_a) {
10931
10950
  }
10932
10951
  });
10933
10952
  }))];
10934
- case 2:
10953
+ case 3:
10935
10954
  results = _a.sent();
10936
10955
  results.forEach(function (result, index) {
10937
10956
  if (result.status === "rejected") {
@@ -10942,11 +10961,11 @@ var TableComponent = function (_a) {
10942
10961
  setSnackbarMessage('View saved successfully');
10943
10962
  }
10944
10963
  });
10945
- return [3 /*break*/, 4];
10946
- case 3:
10947
- setError(resp.message);
10948
- _a.label = 4;
10964
+ return [3 /*break*/, 5];
10949
10965
  case 4:
10966
+ setError(resp.message);
10967
+ _a.label = 5;
10968
+ case 5:
10950
10969
  setIsLoading(false);
10951
10970
  return [2 /*return*/];
10952
10971
  }
@@ -10982,6 +11001,7 @@ var TableComponent = function (_a) {
10982
11001
  event.preventDefault();
10983
11002
  event.stopPropagation(); // Prevent the click event from propagating to the document
10984
11003
  setSelectedRowIndex(index);
11004
+ setViewTagForDelete(viewTags[index]);
10985
11005
  setContextMenuPosition({ x: event.clientX, y: event.clientY });
10986
11006
  };
10987
11007
  var handleSaveDefaultToTag = function () { return __awaiter(void 0, void 0, void 0, function () {
@@ -11021,12 +11041,9 @@ var TableComponent = function (_a) {
11021
11041
  React__default.createElement("th", { className: classes.color }),
11022
11042
  React__default.createElement("th", { colSpan: 4, className: "".concat(classes.topTitles, " ").concat(classes.scale) }, "Scale"),
11023
11043
  React__default.createElement("th", { className: "".concat(classes.topTitles, " ").concat(classes.xStats) }, cursorData ? (function () {
11024
- var date = new Date(cursorData.x1);
11025
- var formattedDate = date.toLocaleString('en-US', {
11026
- hour12: false,
11027
- month: 'short',
11028
- day: 'numeric'
11029
- });
11044
+ var dateX1 = new Date(cursorData.x1);
11045
+ var dateX2 = new Date(cursorData.x2);
11046
+ var formattedDate = dateX1.toLocaleString('en-US', __assign({ hour12: false, month: 'short', day: 'numeric' }, (dateX1.getFullYear() !== dateX2.getFullYear() && { year: 'numeric' })));
11030
11047
  var dateText = "".concat(formattedDate);
11031
11048
  return (React__default.createElement(React__default.Fragment, null,
11032
11049
  React__default.createElement("span", { style: {
@@ -11040,12 +11057,9 @@ var TableComponent = function (_a) {
11040
11057
  dateText));
11041
11058
  })() : null),
11042
11059
  React__default.createElement("th", { className: "".concat(classes.topTitles, " ").concat(classes.xStats) }, cursorData ? (function () {
11043
- var date = new Date(cursorData.x2);
11044
- var formattedDate = date.toLocaleString('en-US', {
11045
- hour12: false,
11046
- month: 'short',
11047
- day: 'numeric'
11048
- });
11060
+ var dateX1 = new Date(cursorData.x1);
11061
+ var dateX2 = new Date(cursorData.x2);
11062
+ var formattedDate = dateX2.toLocaleString('en-US', __assign({ hour12: false, month: 'short', day: 'numeric' }, (dateX1.getFullYear() !== dateX2.getFullYear() && { year: 'numeric' })));
11049
11063
  var dateText = "".concat(formattedDate);
11050
11064
  return (React__default.createElement(React__default.Fragment, null,
11051
11065
  React__default.createElement("span", { style: {
@@ -11058,7 +11072,7 @@ var TableComponent = function (_a) {
11058
11072
  } }),
11059
11073
  dateText));
11060
11074
  })() : null),
11061
- React__default.createElement("th", { colSpan: 3, className: "".concat(classes.topTitles, " ").concat(classes.xStats) }, cursorData ? timeDifference(cursorData.x2, cursorData.x1) : null)))),
11075
+ React__default.createElement("th", { colSpan: 3, className: "".concat(classes.topTitles, " ").concat(classes.xStats) }, cursorData ? formatTimeDiffWithMs(cursorData.x1, cursorData.x2) : null)))),
11062
11076
  React__default.createElement("table", { style: { width: '100%', tableLayout: 'fixed', textAlign: "center" } },
11063
11077
  React__default.createElement("thead", null,
11064
11078
  React__default.createElement("tr", { className: classes.bottomTitlesRow },
@@ -11079,7 +11093,7 @@ var TableComponent = function (_a) {
11079
11093
  minute: '2-digit',
11080
11094
  second: '2-digit'
11081
11095
  });
11082
- var milliseconds = date.getMilliseconds().toString().padStart(2, '0');
11096
+ var milliseconds = (date.getMilliseconds() / 1000).toFixed(2).substring(2);
11083
11097
  var dateText = "".concat(formattedHour, ".").concat(milliseconds, " hs");
11084
11098
  return (React__default.createElement(React__default.Fragment, null, dateText));
11085
11099
  })() : null,
@@ -11094,7 +11108,7 @@ var TableComponent = function (_a) {
11094
11108
  minute: '2-digit',
11095
11109
  second: '2-digit'
11096
11110
  });
11097
- var milliseconds = date.getMilliseconds().toString().padStart(2, '0');
11111
+ var milliseconds = (date.getMilliseconds() / 1000).toFixed(2).substring(2);
11098
11112
  var dateText = "".concat(formattedHour, ".").concat(milliseconds, " hs");
11099
11113
  return (React__default.createElement(React__default.Fragment, null, dateText));
11100
11114
  })() : null,