@dexteel/mesf-core 4.5.8 → 4.5.9

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.5.9
3
+ - Add date to X Axis when day changes
2
4
  ## 4.5.8
3
5
  - Fix table data in Trendings
4
6
  - Fix cursors
package/dist/index.esm.js CHANGED
@@ -6966,7 +6966,7 @@ var MESApiService = /** @class */ (function () {
6966
6966
  return [2 /*return*/, { ok: true, data: resp }];
6967
6967
  case 4:
6968
6968
  err_1 = _a.sent();
6969
- console.log("fromCatch", err_1);
6969
+ // console.log("fromCatch", err);
6970
6970
  this.hasErrors = true;
6971
6971
  this.error = err_1;
6972
6972
  return [2 /*return*/, { ok: false, message: err_1.toString() }];
@@ -8524,7 +8524,7 @@ var TagSelectionModal = function (_a) {
8524
8524
  /* I have to get the grandchildren because the toggle action would not be triggered if no children */
8525
8525
  var handleNodeToggle = function (event, nodeIds) { return __awaiter(void 0, void 0, void 0, function () {
8526
8526
  return __generator(this, function (_a) {
8527
- console.log("Toggle:", nodeIds);
8527
+ // console.log("Toggle:", nodeIds);
8528
8528
  setExpanded(nodeIds);
8529
8529
  return [2 /*return*/];
8530
8530
  });
@@ -8532,8 +8532,6 @@ var TagSelectionModal = function (_a) {
8532
8532
  var handleNodeSelect = function (event, nodeId) { return __awaiter(void 0, void 0, void 0, function () {
8533
8533
  var node;
8534
8534
  return __generator(this, function (_a) {
8535
- // console.log('Selected Node ID:', nodeId);
8536
- console.log("treeData", treeData);
8537
8535
  node = findNode(treeData, nodeId);
8538
8536
  if (node === null || node === void 0 ? void 0 : node.tagId) {
8539
8537
  onTagSelect(node.tag);
@@ -8696,7 +8694,6 @@ var useTagsTableStyles = makeStyles$1(function (theme) { return ({
8696
8694
  }); });
8697
8695
 
8698
8696
  var timeDifference = function (start, end) {
8699
- console.log(start, end);
8700
8697
  var differenceMilliseconds = start - end;
8701
8698
  var seconds = Math.floor(differenceMilliseconds / 1000);
8702
8699
  var minutes = Math.floor(seconds / 60);
@@ -9241,7 +9238,7 @@ var CustomOptionsComponent = function (_a) {
9241
9238
  };
9242
9239
 
9243
9240
  var useGetVerticalLinePlugin = function (setChartArea, setCoords) {
9244
- return {
9241
+ var chartPlugin = {
9245
9242
  id: "verticalLinePlugin",
9246
9243
  afterUpdate: function (chart) {
9247
9244
  if (chart.chartArea) {
@@ -9267,6 +9264,7 @@ var useGetVerticalLinePlugin = function (setChartArea, setCoords) {
9267
9264
  setCoords({ x1: x1, x2: x2 });
9268
9265
  }
9269
9266
  };
9267
+ return chartPlugin;
9270
9268
  };
9271
9269
 
9272
9270
  var getValuesAtCursor = function (chart, timeAtCursor) {
@@ -9302,6 +9300,52 @@ var updateCursorData = function (chart, setCursorData) {
9302
9300
  });
9303
9301
  };
9304
9302
 
9303
+ var formatDateTimeToString = function (date) {
9304
+ var hour = date.getHours().toString().padStart(2, '0');
9305
+ var minute = date.getMinutes().toString().padStart(2, '0');
9306
+ var second = date.getSeconds().toString().padStart(2, '0');
9307
+ if (hour === '24') {
9308
+ hour = '00';
9309
+ }
9310
+ var formattedDate = date.toLocaleDateString("en-US", {
9311
+ month: "short",
9312
+ day: "numeric"
9313
+ });
9314
+ var formattedTime = "".concat(hour, ":").concat(minute, ":").concat(second);
9315
+ return { formattedDate: formattedDate, formattedTime: formattedTime };
9316
+ };
9317
+
9318
+ var useXAxisDatePlugin = function () {
9319
+ var chartPlugin = {
9320
+ id: 'xAxisDatePlugin',
9321
+ afterBuildTicks: function (chart) {
9322
+ var oldTicks = chart.scales.x.ticks;
9323
+ var newTicks = [];
9324
+ newTicks.push(oldTicks[0]);
9325
+ for (var i = 1; i < oldTicks.length; i++) {
9326
+ var current = new Date(oldTicks[i].value);
9327
+ var previous = new Date(oldTicks[i - 1].value);
9328
+ var time = formatDateTimeToString(current).formattedTime;
9329
+ var date = formatDateTimeToString(current).formattedDate;
9330
+ var newLabel = void 0;
9331
+ if (current.getDate() !== previous.getDate()) {
9332
+ newLabel = [time, date];
9333
+ }
9334
+ else {
9335
+ newLabel = time;
9336
+ }
9337
+ newTicks.push({
9338
+ value: oldTicks[i].value,
9339
+ major: oldTicks[i].major,
9340
+ label: newLabel
9341
+ });
9342
+ }
9343
+ chart.scales.x.ticks = newTicks;
9344
+ }
9345
+ };
9346
+ return chartPlugin;
9347
+ };
9348
+
9305
9349
  var areRangesSimilar = function (tag1, tag2) {
9306
9350
  var range1 = tag1.maxScale - tag1.minScale; // Rango de la primera etiqueta
9307
9351
  var range2 = tag2.maxScale - tag2.minScale; // Rango de la segunda etiqueta
@@ -9363,6 +9407,7 @@ var Trending = function (_a) {
9363
9407
  datasets: []
9364
9408
  }), chartData = _k[0], setChartData = _k[1];
9365
9409
  var verticalLinePlugin = useGetVerticalLinePlugin(setChartArea, setLineTabCoords);
9410
+ var xAxisDatePlugin = useXAxisDatePlugin();
9366
9411
  var _l = useState({
9367
9412
  showGrid: true,
9368
9413
  stepped: false
@@ -9448,36 +9493,18 @@ var Trending = function (_a) {
9448
9493
  x: {
9449
9494
  type: "time",
9450
9495
  ticks: {
9451
- // Customize tick behavior if needed
9452
9496
  autoSkip: true,
9453
9497
  maxTicksLimit: 20,
9454
- callback: function (value, index, values) {
9455
- // Extract the time and date from the current value
9498
+ callback: function (value, index, ticks) {
9456
9499
  var currentDate = new Date(value);
9457
- var time = currentDate.toLocaleTimeString("en-US", {
9458
- hour12: false,
9459
- hour: "2-digit",
9460
- minute: "2-digit",
9461
- second: "2-digit"
9462
- });
9463
- var date = currentDate.toLocaleDateString("en-US", {
9464
- month: "short",
9465
- day: "numeric"
9466
- });
9467
- // For the first tick, return both date and time
9500
+ var time = formatDateTimeToString(currentDate).formattedTime;
9501
+ var date = formatDateTimeToString(currentDate).formattedDate;
9502
+ // Si es el primer tick, siempre muestra la fecha y hora
9468
9503
  if (index === 0) {
9469
9504
  return [time, date];
9470
9505
  }
9471
- // For subsequent ticks, compare the date with the previous tick
9472
- var previousDate = new Date(values[index - 1].value);
9473
- if (currentDate.getDate() !== previousDate.getDate() ||
9474
- currentDate.getMonth() !== previousDate.getMonth() ||
9475
- currentDate.getFullYear() !== previousDate.getFullYear()) {
9476
- // If the date has changed, return both time and date
9477
- return [time, date];
9478
- }
9479
- // If the date hasn't changed, return only the time
9480
- return [time, ""];
9506
+ // De lo contrario, solo muestra la hora
9507
+ return time;
9481
9508
  }
9482
9509
  },
9483
9510
  grid: {
@@ -9677,45 +9704,15 @@ var Trending = function (_a) {
9677
9704
  chartRef.current.secondLineX = newLeft;
9678
9705
  debouncedUpdateChart();
9679
9706
  } })) : null,
9680
- React__default.createElement(Line, { ref: chartRef, data: chartData, options: chartOptions, plugins: [verticalLinePlugin] }))),
9707
+ React__default.createElement(Line, { ref: chartRef, data: chartData, options: chartOptions, plugins: [verticalLinePlugin, xAxisDatePlugin] }))),
9681
9708
  React__default.createElement(Grid$1, { item: true, xs: 12, style: { height: '40%', minWidth: "100%", paddingTop: "3rem" } },
9682
9709
  React__default.createElement(TableComponent, { tagList: tagList, chartData: chartData, setTagList: setTagList, cursorData: cursorData, onDeleteTag: handleDeleteTag, onAddTag: handleAddTag })),
9683
9710
  loading && (React__default.createElement(Grid$1, { item: true, xs: 12, style: { textAlign: 'center' } },
9684
9711
  React__default.createElement("p", null, "Loading...")))));
9685
9712
  };
9686
9713
 
9687
- //tags
9688
- var getTags = function (NodeName) { return __awaiter(void 0, void 0, void 0, function () {
9689
- var apiService, parameters, resp;
9690
- return __generator(this, function (_a) {
9691
- switch (_a.label) {
9692
- case 0:
9693
- apiService = new MESApiService();
9694
- parameters = [];
9695
- parameters.push({ name: "NodeName", value: NodeName });
9696
- return [4 /*yield*/, apiService.callV2("[mssql2022].[IH_100020].[dbo].[GetTagDirectChildren]", parameters)];
9697
- case 1:
9698
- resp = _a.sent();
9699
- return [2 /*return*/, resp];
9700
- }
9701
- });
9702
- }); };
9703
-
9714
+ // @flow
9704
9715
  var TrendingsIndex = function (props) {
9705
- React.useEffect(function () {
9706
- (function () { return __awaiter(void 0, void 0, void 0, function () {
9707
- var tags;
9708
- return __generator(this, function (_a) {
9709
- switch (_a.label) {
9710
- case 0: return [4 /*yield*/, getTags(null)];
9711
- case 1:
9712
- tags = _a.sent();
9713
- console.log(tags);
9714
- return [2 /*return*/];
9715
- }
9716
- });
9717
- }); })();
9718
- }, []);
9719
9716
  return (React.createElement(TrendingProvider, null,
9720
9717
  React.createElement(Box, { p: 3, style: { maxWidth: "100%" } },
9721
9718
  React.createElement(Paper, null,
@@ -0,0 +1,2 @@
1
+ import { Plugin } from 'chart.js';
2
+ export declare const useXAxisDatePlugin: () => Plugin;
@@ -0,0 +1,4 @@
1
+ export declare const formatDateTimeToString: (date: Date) => {
2
+ formattedDate: string;
3
+ formattedTime: string;
4
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dexteel/mesf-core",
3
- "version": "4.5.8",
3
+ "version": "4.5.9",
4
4
  "author": "Dexteel Team",
5
5
  "module": "dist/index.esm.js",
6
6
  "typings": "dist/index.d.ts",
@@ -99,6 +99,7 @@
99
99
  "chart.js": "^4.4.1",
100
100
  "chartjs-adapter-moment": "^1.0.1",
101
101
  "chartjs-plugin-zoom": "^2.0.1",
102
+ "cross-env": "^7.0.3",
102
103
  "lodash-es": "^4.17.21",
103
104
  "react-chartjs-2": "^5.2.0",
104
105
  "react-dnd": "^16.0.1",