Commit ec7ea7042a46e5cbbf460ae25fd9c65b5585bb7b

Authored by Vladyslav Prykhodko
1 parent 9b92f67b

Fixed loading of data used by post-processing function in key settings for map widgets

... ... @@ -2127,9 +2127,9 @@
2127 2127 }
2128 2128 },
2129 2129 "@types/leaflet": {
2130   - "version": "1.5.12",
2131   - "resolved": "https://registry.npmjs.org/@types/leaflet/-/leaflet-1.5.12.tgz",
2132   - "integrity": "sha512-61HRMIng+bWvnnAIqUWLBlrd/TQZc4gU+gN1JL4K47EDtwIrcMEhWgi7PdcpbG1YmpH4F0EfOimkvV82gJIl9w==",
  2130 + "version": "1.5.17",
  2131 + "resolved": "https://registry.npmjs.org/@types/leaflet/-/leaflet-1.5.17.tgz",
  2132 + "integrity": "sha512-2XYq9k6kNjhNI7PaTz8Rdxcc8Vzwu97OaS9CtcrTxnTSxFUGwjlGjTDvhTLJU+JRSfZ4lBwGcl0SjZHALdVr6g==",
2133 2133 "dev": true,
2134 2134 "requires": {
2135 2135 "@types/geojson": "*"
... ... @@ -3100,6 +3100,16 @@
3100 3100 "integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==",
3101 3101 "dev": true
3102 3102 },
  3103 + "bindings": {
  3104 + "version": "1.5.0",
  3105 + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
  3106 + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
  3107 + "dev": true,
  3108 + "optional": true,
  3109 + "requires": {
  3110 + "file-uri-to-path": "1.0.0"
  3111 + }
  3112 + },
3103 3113 "blob": {
3104 3114 "version": "0.0.5",
3105 3115 "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz",
... ... @@ -5843,6 +5853,13 @@
5843 5853 "tslib": "^1.9.0"
5844 5854 }
5845 5855 },
  5856 + "file-uri-to-path": {
  5857 + "version": "1.0.0",
  5858 + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
  5859 + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==",
  5860 + "dev": true,
  5861 + "optional": true
  5862 + },
5846 5863 "fileset": {
5847 5864 "version": "2.0.3",
5848 5865 "resolved": "https://registry.npmjs.org/fileset/-/fileset-2.0.3.tgz",
... ... @@ -8938,6 +8955,13 @@
8938 8955 "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==",
8939 8956 "dev": true
8940 8957 },
  8958 + "nan": {
  8959 + "version": "2.14.1",
  8960 + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz",
  8961 + "integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==",
  8962 + "dev": true,
  8963 + "optional": true
  8964 + },
8941 8965 "nanomatch": {
8942 8966 "version": "1.2.13",
8943 8967 "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz",
... ... @@ -8997,10 +9021,10 @@
8997 9021 "integrity": "sha512-4O3GWAYJaauMCILm07weko2rHA8a4kjn7+8Lg4s1d7SxwS/3IpkVD/GljbRrIJ1c1W/XGJ3GbuK7RyYZEJChhw=="
8998 9022 },
8999 9023 "ngx-flowchart": {
9000   - "version": "git://github.com/thingsboard/ngx-flowchart.git#7a02f4748b5e7821a883c903107af5f20415d026",
  9024 + "version": "git://github.com/thingsboard/ngx-flowchart.git#97a77477ca8579becf0e3a07866046b4536fe30a",
9001 9025 "from": "git://github.com/thingsboard/ngx-flowchart.git#master",
9002 9026 "requires": {
9003   - "tslib": "^1.13.0"
  9027 + "tslib": "^1.10.0"
9004 9028 },
9005 9029 "dependencies": {
9006 9030 "tslib": {
... ... @@ -14065,7 +14089,11 @@
14065 14089 "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz",
14066 14090 "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==",
14067 14091 "dev": true,
14068   - "optional": true
  14092 + "optional": true,
  14093 + "requires": {
  14094 + "bindings": "^1.5.0",
  14095 + "nan": "^2.12.1"
  14096 + }
14069 14097 },
14070 14098 "is-binary-path": {
14071 14099 "version": "1.0.1",
... ... @@ -14500,7 +14528,11 @@
14500 14528 "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz",
14501 14529 "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==",
14502 14530 "dev": true,
14503   - "optional": true
  14531 + "optional": true,
  14532 + "requires": {
  14533 + "bindings": "^1.5.0",
  14534 + "nan": "^2.12.1"
  14535 + }
14504 14536 },
14505 14537 "is-absolute-url": {
14506 14538 "version": "3.0.3",
... ...
... ... @@ -106,7 +106,7 @@
106 106 "@types/js-beautify": "^1.8.2",
107 107 "@types/jstree": "^3.3.40",
108 108 "@types/jszip": "^3.4.1",
109   - "@types/leaflet": "^1.5.12",
  109 + "@types/leaflet": "^1.5.17",
110 110 "@types/leaflet-markercluster": "^1.0.3",
111 111 "@types/leaflet-polylinedecorator": "^1.6.0",
112 112 "@types/lodash": "^4.14.151",
... ...
... ... @@ -89,6 +89,10 @@ export function isDefinedAndNotNull(value: any): boolean {
89 89 return typeof value !== 'undefined' && value !== null;
90 90 }
91 91
  92 +export function isDefinedAndNotEmptyStr(value: any): boolean {
  93 + return typeof value !== 'undefined' && value !== '';
  94 +}
  95 +
92 96 export function isFunction(value: any): boolean {
93 97 return typeof value === 'function';
94 98 }
... ...
... ... @@ -44,7 +44,7 @@ import { Polygon } from './polygon';
44 44 import { createLoadingDiv, createTooltip, parseArray, safeExecute } from '@home/components/widget/lib/maps/maps-utils';
45 45 import { WidgetContext } from '@home/models/widget-component.models';
46 46 import { DatasourceData } from '@shared/models/widget.models';
47   -import { deepClone, isDefinedAndNotNull } from '@core/utils';
  47 +import { deepClone, isDefinedAndNotEmptyStr } from '@core/utils';
48 48
49 49 export default abstract class LeafletMap {
50 50
... ... @@ -276,7 +276,7 @@ export default abstract class LeafletMap {
276 276 if (!expression) return null;
277 277 const lat = expression[this.options.latKeyName];
278 278 const lng = expression[this.options.lngKeyName];
279   - if (!isDefinedAndNotNull(lat) || isNaN(lat) || !isDefinedAndNotNull(lng) || isNaN(lng)) {
  279 + if (!isDefinedAndNotEmptyStr(lat) || isNaN(lat) || !isDefinedAndNotEmptyStr(lng) || isNaN(lng)) {
280 280 return null;
281 281 }
282 282 return L.latLng(lat, lng) as L.LatLng;
... ... @@ -524,7 +524,7 @@ export default abstract class LeafletMap {
524 524 const keys: string[] = [];
525 525 this.polygonsData = deepClone(polyData);
526 526 polyData.forEach((data: FormattedData) => {
527   - if (data && data.hasOwnProperty(this.options.polygonKeyName) && data[this.options.polygonKeyName] !== null) {
  527 + if (data && isDefinedAndNotEmptyStr(data[this.options.polygonKeyName])) {
528 528 if (typeof (data[this.options.polygonKeyName]) === 'string') {
529 529 data[this.options.polygonKeyName] = JSON.parse(data[this.options.polygonKeyName]);
530 530 }
... ...
... ... @@ -341,8 +341,8 @@ export function parseData(input: DatasourceData[]): FormattedData[] {
341 341 };
342 342 entityArray.filter(el => el.data.length).forEach(el => {
343 343 const indexDate = el?.data?.length ? el.data.length - 1 : 0;
344   - obj[el?.dataKey?.label] = el?.data[indexDate][0] ? el?.data[indexDate][1] : null;
345   - obj[el?.dataKey?.label + '|ts'] = el?.data[indexDate][0] || null;
  344 + obj[el?.dataKey?.label] = el?.data[indexDate][1];
  345 + obj[el?.dataKey?.label + '|ts'] = el?.data[indexDate][0];
346 346 if (el?.dataKey?.label === 'type') {
347 347 obj.deviceType = el?.data[indexDate][1];
348 348 }
... ...
... ... @@ -24,7 +24,7 @@ import { WidgetContext } from '@home/models/widget-component.models';
24 24 import { DataSet, DatasourceType, widgetType } from '@shared/models/widget.models';
25 25 import { DataKeyType } from '@shared/models/telemetry/telemetry.models';
26 26 import { WidgetSubscriptionOptions } from '@core/api/widget-api.models';
27   -import { isDefinedAndNotNull } from '@core/utils';
  27 +import { isDefinedAndNotEmptyStr } from '@core/utils';
28 28
29 29 const maxZoom = 4;// ?
30 30
... ... @@ -212,7 +212,7 @@ export class ImageMap extends LeafletMap {
212 212 convertPosition(expression): L.LatLng {
213 213 const xPos = expression[this.options.xPosKeyName];
214 214 const yPos = expression[this.options.yPosKeyName];
215   - if (!isDefinedAndNotNull(xPos) || isNaN(xPos) || !isDefinedAndNotNull(yPos) || isNaN(yPos)) {
  215 + if (!isDefinedAndNotEmptyStr(xPos) || isNaN(xPos) || !isDefinedAndNotEmptyStr(yPos) || isNaN(yPos)) {
216 216 return null;
217 217 }
218 218 Object.assign(expression, this.posFunction(xPos, yPos));
... ...