diff --git a/ui-ngx/package.json b/ui-ngx/package.json index 8a0d155524..d3813f92b6 100644 --- a/ui-ngx/package.json +++ b/ui-ngx/package.json @@ -39,7 +39,6 @@ "@ngx-share/core": "^7.1.4", "@ngx-translate/core": "^12.1.2", "@ngx-translate/http-loader": "^4.0.0", - "@types/leaflet-markercluster": "^1.0.3", "ace-builds": "^1.4.11", "angular-gridster2": "^9.1.0", "angular2-hotkeys": "^2.2.0", @@ -48,7 +47,6 @@ "compass-sass-mixins": "^0.12.7", "core-js": "^3.6.5", "date-fns": "^2.12.0", - "es6-promise": "^4.2.8", "flot": "git://github.com/thingsboard/flot.git#0.9-work", "flot.curvedlines": "git://github.com/MichaelZinsmaier/CurvedLines.git#master", "font-awesome": "^4.7.0", @@ -75,7 +73,6 @@ "ngx-hm-carousel": "^2.0.0-rc.1", "ngx-translate-messageformat-compiler": "^4.6.0", "objectpath": "^2.0.0", - "promise-polyfill": "8.1.3", "prop-types": "^15.7.2", "raphael": "^2.3.0", "rc-select": "^10.2.4", @@ -111,8 +108,8 @@ "@types/jstree": "^3.3.39", "@types/jszip": "^3.1.7", "@types/leaflet": "^1.5.12", - "@types/leaflet.markercluster": "^1.4.2", "@types/leaflet-polylinedecorator": "^1.6.0", + "@types/leaflet-markercluster": "^1.0.3", "@types/lodash": "^4.14.150", "@types/raphael": "^2.3.0", "@types/react": "^16.9.34", diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-models.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-models.ts index 15b76e34a0..24564d9759 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-models.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-models.ts @@ -23,7 +23,7 @@ export type MapSettings = { polygonKeyName: any; draggableMarker: boolean; initCallback?: () => any; - posFunction: (rigXPos, origYPos) => { x, y }; + posFunction: (origXPos, origYPos) => { x, y }; defaultZoomLevel?: number; disableScrollZooming?: boolean; minZoomLevel?: number; diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts index 3d970a6fb1..23cf1eca2b 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts @@ -166,16 +166,30 @@ export class MapWidgetController implements MapWidgetInterface { entityType: e.$datasource.entityType, id: e.$datasource.entityId }; - const keys = e.$datasource.dataKeys.map(key => { - return { + const attributes = []; + const timeseries = []; + e.$datasource.dataKeys.forEach(key => { + const value = { key: key.name, value: e[key.name] + }; + if(key.type === DataKeyType.attribute){ + attributes.push(value) + } + if(key.type === DataKeyType.timeseries){ + timeseries.push(value) } }) - return attributeService.saveEntityAttributes( + attributeService.saveEntityTimeseries( entityId, AttributeScope.SHARED_SCOPE, - keys + timeseries + ).subscribe(() => { + }); + attributeService.saveEntityAttributes( + entityId, + AttributeScope.SERVER_SCOPE, + attributes ).subscribe(() => { }); } @@ -260,7 +274,7 @@ export class MapWidgetController implements MapWidgetInterface { type: widgetType.latest, callbacks: { onDataUpdated: (subscription) => { - result.next(subscription.data[0].data[0]); + result.next(subscription?.data[0]?.data[0]); } } }; diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/image-map.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/image-map.ts index 00b67f22a7..792fc0c655 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/image-map.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/image-map.ts @@ -19,7 +19,7 @@ import LeafletMap from '../leaflet-map'; import { UnitedMapSettings } from '../map-models'; import { aspectCache, parseFunction } from '@app/core/utils'; import { Observable } from 'rxjs'; -import { map, filter } from 'rxjs/operators'; +import { map, filter, switchMap } from 'rxjs/operators'; const maxZoom = 4;// ? @@ -33,7 +33,7 @@ export class ImageMap extends LeafletMap { constructor($container: HTMLElement, options: UnitedMapSettings) { super($container, options); - options.posFunction = parseFunction(options.posFunction, ['origXPos', 'origYPos']) as ((rigXPos, origYPos) => { x, y }); + options.posFunction = parseFunction(options.posFunction, ['origXPos', 'origYPos']) as ((origXPos, origYPos) => { x, y }); this.imageUrl = options.mapUrl; aspectCache(this.imageUrl).subscribe(aspect => { this.aspect = aspect; @@ -44,14 +44,13 @@ export class ImageMap extends LeafletMap { } setImageAlias(alias: Observable) { - alias.pipe(filter(result => result), - filter(result => result), map(el => el[1])).subscribe(res => { - this.imageUrl = res; - aspectCache(res).subscribe(aspect => { - this.aspect = aspect; - this.onResize(true); - }) - }) + alias.pipe(filter(result => result), map(el => el[1]), switchMap(res => { + this.imageUrl = res; + return aspectCache(res); + })).subscribe(aspect => { + this.aspect = aspect; + this.onResize(true); + }); } updateBounds(updateImage?, lastCenterPos?) { diff --git a/ui-ngx/src/app/shared/components/time/history-selector/history-selector.component.scss b/ui-ngx/src/app/shared/components/time/history-selector/history-selector.component.scss index 0ca2a9e5b8..04a9cd71e7 100644 --- a/ui-ngx/src/app/shared/components/time/history-selector/history-selector.component.scss +++ b/ui-ngx/src/app/shared/components/time/history-selector/history-selector.component.scss @@ -52,7 +52,7 @@ margin: 2px; line-height: 24px; - ng-mat-icon { + mat-icon { width: 24px; height: 24px; diff --git a/ui-ngx/src/polyfills.ts b/ui-ngx/src/polyfills.ts index 0a1fed31cc..68a59ba5c3 100644 --- a/ui-ngx/src/polyfills.ts +++ b/ui-ngx/src/polyfills.ts @@ -75,7 +75,6 @@ import './zone-flags'; import 'zone.js/dist/zone'; // Included with Angular CLI. import 'core-js/es/array'; -import { polyfill } from 'es6-promise'; polyfill(); import moment from 'moment'; /*************************************************************************************************** diff --git a/ui-ngx/src/tsconfig.app.json b/ui-ngx/src/tsconfig.app.json index b4c56f2b40..ebfff793f7 100644 --- a/ui-ngx/src/tsconfig.app.json +++ b/ui-ngx/src/tsconfig.app.json @@ -2,9 +2,6 @@ "extends": "../tsconfig.json", "compilerOptions": { "outDir": "../out-tsc/app", - "typeRoots": [ - "node_modules/@types" - ], "types": ["node", "jquery", "flot", "tooltipster", "tinycolor2", "js-beautify", "react", "react-dom", "jstree", "raphael", "canvas-gauges", "leaflet", "leaflet-markercluster"] },