Commit d56a3abacab691402ec51884fd6eb1e181376a98

Authored by Artem Halushko
1 parent 77ec3911

saveEntity && minor fixes

@@ -39,7 +39,6 @@ @@ -39,7 +39,6 @@
39 "@ngx-share/core": "^7.1.4", 39 "@ngx-share/core": "^7.1.4",
40 "@ngx-translate/core": "^12.1.2", 40 "@ngx-translate/core": "^12.1.2",
41 "@ngx-translate/http-loader": "^4.0.0", 41 "@ngx-translate/http-loader": "^4.0.0",
42 - "@types/leaflet-markercluster": "^1.0.3",  
43 "ace-builds": "^1.4.11", 42 "ace-builds": "^1.4.11",
44 "angular-gridster2": "^9.1.0", 43 "angular-gridster2": "^9.1.0",
45 "angular2-hotkeys": "^2.2.0", 44 "angular2-hotkeys": "^2.2.0",
@@ -48,7 +47,6 @@ @@ -48,7 +47,6 @@
48 "compass-sass-mixins": "^0.12.7", 47 "compass-sass-mixins": "^0.12.7",
49 "core-js": "^3.6.5", 48 "core-js": "^3.6.5",
50 "date-fns": "^2.12.0", 49 "date-fns": "^2.12.0",
51 - "es6-promise": "^4.2.8",  
52 "flot": "git://github.com/thingsboard/flot.git#0.9-work", 50 "flot": "git://github.com/thingsboard/flot.git#0.9-work",
53 "flot.curvedlines": "git://github.com/MichaelZinsmaier/CurvedLines.git#master", 51 "flot.curvedlines": "git://github.com/MichaelZinsmaier/CurvedLines.git#master",
54 "font-awesome": "^4.7.0", 52 "font-awesome": "^4.7.0",
@@ -75,7 +73,6 @@ @@ -75,7 +73,6 @@
75 "ngx-hm-carousel": "^2.0.0-rc.1", 73 "ngx-hm-carousel": "^2.0.0-rc.1",
76 "ngx-translate-messageformat-compiler": "^4.6.0", 74 "ngx-translate-messageformat-compiler": "^4.6.0",
77 "objectpath": "^2.0.0", 75 "objectpath": "^2.0.0",
78 - "promise-polyfill": "8.1.3",  
79 "prop-types": "^15.7.2", 76 "prop-types": "^15.7.2",
80 "raphael": "^2.3.0", 77 "raphael": "^2.3.0",
81 "rc-select": "^10.2.4", 78 "rc-select": "^10.2.4",
@@ -111,8 +108,8 @@ @@ -111,8 +108,8 @@
111 "@types/jstree": "^3.3.39", 108 "@types/jstree": "^3.3.39",
112 "@types/jszip": "^3.1.7", 109 "@types/jszip": "^3.1.7",
113 "@types/leaflet": "^1.5.12", 110 "@types/leaflet": "^1.5.12",
114 - "@types/leaflet.markercluster": "^1.4.2",  
115 "@types/leaflet-polylinedecorator": "^1.6.0", 111 "@types/leaflet-polylinedecorator": "^1.6.0",
  112 + "@types/leaflet-markercluster": "^1.0.3",
116 "@types/lodash": "^4.14.150", 113 "@types/lodash": "^4.14.150",
117 "@types/raphael": "^2.3.0", 114 "@types/raphael": "^2.3.0",
118 "@types/react": "^16.9.34", 115 "@types/react": "^16.9.34",
@@ -23,7 +23,7 @@ export type MapSettings = { @@ -23,7 +23,7 @@ export type MapSettings = {
23 polygonKeyName: any; 23 polygonKeyName: any;
24 draggableMarker: boolean; 24 draggableMarker: boolean;
25 initCallback?: () => any; 25 initCallback?: () => any;
26 - posFunction: (rigXPos, origYPos) => { x, y }; 26 + posFunction: (origXPos, origYPos) => { x, y };
27 defaultZoomLevel?: number; 27 defaultZoomLevel?: number;
28 disableScrollZooming?: boolean; 28 disableScrollZooming?: boolean;
29 minZoomLevel?: number; 29 minZoomLevel?: number;
@@ -166,16 +166,30 @@ export class MapWidgetController implements MapWidgetInterface { @@ -166,16 +166,30 @@ export class MapWidgetController implements MapWidgetInterface {
166 entityType: e.$datasource.entityType, 166 entityType: e.$datasource.entityType,
167 id: e.$datasource.entityId 167 id: e.$datasource.entityId
168 }; 168 };
169 - const keys = e.$datasource.dataKeys.map(key => {  
170 - return { 169 + const attributes = [];
  170 + const timeseries = [];
  171 + e.$datasource.dataKeys.forEach(key => {
  172 + const value = {
171 key: key.name, 173 key: key.name,
172 value: e[key.name] 174 value: e[key.name]
  175 + };
  176 + if(key.type === DataKeyType.attribute){
  177 + attributes.push(value)
  178 + }
  179 + if(key.type === DataKeyType.timeseries){
  180 + timeseries.push(value)
173 } 181 }
174 }) 182 })
175 - return attributeService.saveEntityAttributes( 183 + attributeService.saveEntityTimeseries(
176 entityId, 184 entityId,
177 AttributeScope.SHARED_SCOPE, 185 AttributeScope.SHARED_SCOPE,
178 - keys 186 + timeseries
  187 + ).subscribe(() => {
  188 + });
  189 + attributeService.saveEntityAttributes(
  190 + entityId,
  191 + AttributeScope.SERVER_SCOPE,
  192 + attributes
179 ).subscribe(() => { 193 ).subscribe(() => {
180 }); 194 });
181 } 195 }
@@ -260,7 +274,7 @@ export class MapWidgetController implements MapWidgetInterface { @@ -260,7 +274,7 @@ export class MapWidgetController implements MapWidgetInterface {
260 type: widgetType.latest, 274 type: widgetType.latest,
261 callbacks: { 275 callbacks: {
262 onDataUpdated: (subscription) => { 276 onDataUpdated: (subscription) => {
263 - result.next(subscription.data[0].data[0]); 277 + result.next(subscription?.data[0]?.data[0]);
264 } 278 }
265 } 279 }
266 }; 280 };
@@ -19,7 +19,7 @@ import LeafletMap from '../leaflet-map'; @@ -19,7 +19,7 @@ import LeafletMap from '../leaflet-map';
19 import { UnitedMapSettings } from '../map-models'; 19 import { UnitedMapSettings } from '../map-models';
20 import { aspectCache, parseFunction } from '@app/core/utils'; 20 import { aspectCache, parseFunction } from '@app/core/utils';
21 import { Observable } from 'rxjs'; 21 import { Observable } from 'rxjs';
22 -import { map, filter } from 'rxjs/operators'; 22 +import { map, filter, switchMap } from 'rxjs/operators';
23 23
24 const maxZoom = 4;// ? 24 const maxZoom = 4;// ?
25 25
@@ -33,7 +33,7 @@ export class ImageMap extends LeafletMap { @@ -33,7 +33,7 @@ export class ImageMap extends LeafletMap {
33 33
34 constructor($container: HTMLElement, options: UnitedMapSettings) { 34 constructor($container: HTMLElement, options: UnitedMapSettings) {
35 super($container, options); 35 super($container, options);
36 - options.posFunction = parseFunction(options.posFunction, ['origXPos', 'origYPos']) as ((rigXPos, origYPos) => { x, y }); 36 + options.posFunction = parseFunction(options.posFunction, ['origXPos', 'origYPos']) as ((origXPos, origYPos) => { x, y });
37 this.imageUrl = options.mapUrl; 37 this.imageUrl = options.mapUrl;
38 aspectCache(this.imageUrl).subscribe(aspect => { 38 aspectCache(this.imageUrl).subscribe(aspect => {
39 this.aspect = aspect; 39 this.aspect = aspect;
@@ -44,14 +44,13 @@ export class ImageMap extends LeafletMap { @@ -44,14 +44,13 @@ export class ImageMap extends LeafletMap {
44 } 44 }
45 45
46 setImageAlias(alias: Observable<any>) { 46 setImageAlias(alias: Observable<any>) {
47 - alias.pipe(filter(result => result),  
48 - filter(result => result), map(el => el[1])).subscribe(res => {  
49 - this.imageUrl = res;  
50 - aspectCache(res).subscribe(aspect => {  
51 - this.aspect = aspect;  
52 - this.onResize(true);  
53 - })  
54 - }) 47 + alias.pipe(filter(result => result), map(el => el[1]), switchMap(res => {
  48 + this.imageUrl = res;
  49 + return aspectCache(res);
  50 + })).subscribe(aspect => {
  51 + this.aspect = aspect;
  52 + this.onResize(true);
  53 + });
55 } 54 }
56 55
57 updateBounds(updateImage?, lastCenterPos?) { 56 updateBounds(updateImage?, lastCenterPos?) {
@@ -52,7 +52,7 @@ @@ -52,7 +52,7 @@
52 margin: 2px; 52 margin: 2px;
53 line-height: 24px; 53 line-height: 24px;
54 54
55 - ng-mat-icon { 55 + mat-icon {
56 width: 24px; 56 width: 24px;
57 height: 24px; 57 height: 24px;
58 58
@@ -75,7 +75,6 @@ @@ -75,7 +75,6 @@
75 import './zone-flags'; 75 import './zone-flags';
76 import 'zone.js/dist/zone'; // Included with Angular CLI. 76 import 'zone.js/dist/zone'; // Included with Angular CLI.
77 import 'core-js/es/array'; 77 import 'core-js/es/array';
78 -import { polyfill } from 'es6-promise'; polyfill();  
79 import moment from 'moment'; 78 import moment from 'moment';
80 79
81 /*************************************************************************************************** 80 /***************************************************************************************************
@@ -2,9 +2,6 @@ @@ -2,9 +2,6 @@
2 "extends": "../tsconfig.json", 2 "extends": "../tsconfig.json",
3 "compilerOptions": { 3 "compilerOptions": {
4 "outDir": "../out-tsc/app", 4 "outDir": "../out-tsc/app",
5 - "typeRoots": [  
6 - "node_modules/@types"  
7 - ],  
8 "types": ["node", "jquery", "flot", "tooltipster", "tinycolor2", "js-beautify", 5 "types": ["node", "jquery", "flot", "tooltipster", "tinycolor2", "js-beautify",
9 "react", "react-dom", "jstree", "raphael", "canvas-gauges", "leaflet", "leaflet-markercluster"] 6 "react", "react-dom", "jstree", "raphael", "canvas-gauges", "leaflet", "leaflet-markercluster"]
10 }, 7 },