@dexteel/mesf-core 4.11.0 → 4.11.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
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [4.11.2](https://github.com/dexteel/mesf-core-frontend/compare/v4.11.1...v4.11.2) (2024-05-09)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **Assets Tree:** Fix bug when assets have parent assets with IsActive as false ([b27651e](https://github.com/dexteel/mesf-core-frontend/commit/b27651e6b6777b140fd0b0738408bfcc3fc42f14))
11
+
12
+ ### [4.11.1](https://github.com/dexteel/mesf-core-frontend/compare/v4.11.0...v4.11.1) (2024-05-05)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * **TimeService:** Add some try catches and handle utc datetime strings ([b073cd1](https://github.com/dexteel/mesf-core-frontend/commit/b073cd1e1fc3dcceed7a2155ab1a33e21e962805))
18
+
5
19
  ## [4.11.0](https://github.com/dexteel/mesf-core-frontend/compare/v4.10.5...v4.11.0) (2024-05-02)
6
20
 
7
21
 
@@ -4,4 +4,5 @@ export interface AssetCode {
4
4
  name: string;
5
5
  isLeaf: boolean | null;
6
6
  isActive: boolean | null;
7
+ children: AssetCode[];
7
8
  }
package/dist/index.esm.js CHANGED
@@ -77,7 +77,8 @@ import 'ag-grid-community/styles/ag-theme-alpine.css';
77
77
  import ImageIcon from '@material-ui/icons/Image';
78
78
  import ListAltIcon from '@material-ui/icons/ListAlt';
79
79
  import DescriptionIcon from '@material-ui/icons/Description';
80
- import { formatInTimeZone } from 'date-fns-tz';
80
+ import { format, fromZonedTime, formatInTimeZone } from 'date-fns-tz';
81
+ import { findIana } from 'windows-iana';
81
82
  import FormControlLabel$1 from '@material-ui/core/FormControlLabel';
82
83
  import Checkbox$1 from '@material-ui/core/Checkbox';
83
84
  import Input from '@material-ui/core/Input';
@@ -4703,28 +4704,29 @@ var useAssetCodes = function () {
4703
4704
  }
4704
4705
  // Use our mapping to locate the parent element in our data array
4705
4706
  var parentEl = nodes[idMapping[el.parentId]];
4707
+ // Handle the case where the element has no parent
4708
+ if (!parentEl) {
4709
+ console.log(el);
4710
+ return;
4711
+ }
4706
4712
  // Add our current el to its parent's `children` array
4707
- parentEl.children = __spreadArray(__spreadArray([], (parentEl.children || []), true), [el], false);
4713
+ if (!parentEl['children']) {
4714
+ parentEl['children'] = [];
4715
+ }
4716
+ parentEl['children'] = __spreadArray(__spreadArray([], (parentEl['children'] || []), true), [el], false);
4708
4717
  });
4709
4718
  setAssetCodes(root);
4710
4719
  };
4711
4720
  var loadFilterAssets = function () {
4712
- var mydataSource = [];
4713
- allAssets.forEach(function (row) {
4714
- var code = TransformAssetCodeModel(row);
4715
- mydataSource = __spreadArray(__spreadArray([], mydataSource, true), [code], false);
4716
- });
4717
- buildTreeAssets(mydataSource);
4718
- };
4719
- var TransformAssetCodeModel = function (data) {
4720
- var model = {
4721
- id: data.AssetId,
4722
- parentId: data.ParentAssetId,
4723
- name: data.AssetName,
4724
- isLeaf: data.isLeaf,
4725
- isActive: true
4726
- };
4727
- return model;
4721
+ var nodes = allAssets.map(function (el) { return ({
4722
+ id: el.AssetId,
4723
+ parentId: el.ParentAssetId,
4724
+ name: el.AssetName,
4725
+ isLeaf: !!el.IsLeaf,
4726
+ isActive: true,
4727
+ children: []
4728
+ }); });
4729
+ buildTreeAssets(nodes);
4728
4730
  };
4729
4731
  return { loadFilterAssets: loadFilterAssets };
4730
4732
  };
@@ -7309,16 +7311,45 @@ var TimeService = /** @class */ (function () {
7309
7311
  return TimeService.instance;
7310
7312
  };
7311
7313
  TimeService.prototype.setTimeZone = function (timeZone) {
7312
- this.timeZone = timeZone;
7314
+ var ianaTimeZones = findIana(timeZone);
7315
+ if (ianaTimeZones.length) {
7316
+ this.timeZone = ianaTimeZones[0];
7317
+ }
7318
+ else {
7319
+ this.timeZone = timeZone;
7320
+ }
7313
7321
  };
7314
- TimeService.prototype.toUTC = function (datetime) {
7315
- if (datetime instanceof Date) {
7316
- return datetime.toUTCString();
7322
+ TimeService.prototype.toUTC = function (datetime, format$1) {
7323
+ try {
7324
+ if (datetime instanceof Date) {
7325
+ return format(datetime, format$1);
7326
+ }
7327
+ return format(fromZonedTime(datetime, TimeService.instance.timeZone), format$1);
7328
+ }
7329
+ catch (e) {
7330
+ console.log({ datetime: datetime, e: e });
7331
+ return '';
7317
7332
  }
7318
- return new Date(datetime).toUTCString();
7319
7333
  };
7320
7334
  TimeService.prototype.toLocalServerTime = function (datetime, format) {
7321
- return formatInTimeZone(datetime, TimeService.instance.timeZone, format);
7335
+ try {
7336
+ if (isNil$1(datetime) || !datetime) {
7337
+ return '';
7338
+ }
7339
+ if (typeof datetime === 'string') {
7340
+ if (datetime.includes('Z')) {
7341
+ datetime = new Date(datetime);
7342
+ }
7343
+ else {
7344
+ datetime = new Date("".concat(datetime, "Z"));
7345
+ }
7346
+ }
7347
+ return formatInTimeZone(datetime, TimeService.instance.timeZone, format);
7348
+ }
7349
+ catch (e) {
7350
+ console.log({ datetime: datetime, e: e });
7351
+ return '';
7352
+ }
7322
7353
  };
7323
7354
  return TimeService;
7324
7355
  }());