saveEntity && minor fixes

This commit is contained in:
Artem Halushko 2020-04-28 13:31:47 +03:00
parent 77ec391185
commit d56a3abaca
7 changed files with 31 additions and 25 deletions

View File

@ -39,7 +39,6 @@
"@ngx-share/core": "^7.1.4", "@ngx-share/core": "^7.1.4",
"@ngx-translate/core": "^12.1.2", "@ngx-translate/core": "^12.1.2",
"@ngx-translate/http-loader": "^4.0.0", "@ngx-translate/http-loader": "^4.0.0",
"@types/leaflet-markercluster": "^1.0.3",
"ace-builds": "^1.4.11", "ace-builds": "^1.4.11",
"angular-gridster2": "^9.1.0", "angular-gridster2": "^9.1.0",
"angular2-hotkeys": "^2.2.0", "angular2-hotkeys": "^2.2.0",
@ -48,7 +47,6 @@
"compass-sass-mixins": "^0.12.7", "compass-sass-mixins": "^0.12.7",
"core-js": "^3.6.5", "core-js": "^3.6.5",
"date-fns": "^2.12.0", "date-fns": "^2.12.0",
"es6-promise": "^4.2.8",
"flot": "git://github.com/thingsboard/flot.git#0.9-work", "flot": "git://github.com/thingsboard/flot.git#0.9-work",
"flot.curvedlines": "git://github.com/MichaelZinsmaier/CurvedLines.git#master", "flot.curvedlines": "git://github.com/MichaelZinsmaier/CurvedLines.git#master",
"font-awesome": "^4.7.0", "font-awesome": "^4.7.0",
@ -75,7 +73,6 @@
"ngx-hm-carousel": "^2.0.0-rc.1", "ngx-hm-carousel": "^2.0.0-rc.1",
"ngx-translate-messageformat-compiler": "^4.6.0", "ngx-translate-messageformat-compiler": "^4.6.0",
"objectpath": "^2.0.0", "objectpath": "^2.0.0",
"promise-polyfill": "8.1.3",
"prop-types": "^15.7.2", "prop-types": "^15.7.2",
"raphael": "^2.3.0", "raphael": "^2.3.0",
"rc-select": "^10.2.4", "rc-select": "^10.2.4",
@ -111,8 +108,8 @@
"@types/jstree": "^3.3.39", "@types/jstree": "^3.3.39",
"@types/jszip": "^3.1.7", "@types/jszip": "^3.1.7",
"@types/leaflet": "^1.5.12", "@types/leaflet": "^1.5.12",
"@types/leaflet.markercluster": "^1.4.2",
"@types/leaflet-polylinedecorator": "^1.6.0", "@types/leaflet-polylinedecorator": "^1.6.0",
"@types/leaflet-markercluster": "^1.0.3",
"@types/lodash": "^4.14.150", "@types/lodash": "^4.14.150",
"@types/raphael": "^2.3.0", "@types/raphael": "^2.3.0",
"@types/react": "^16.9.34", "@types/react": "^16.9.34",

View File

@ -23,7 +23,7 @@ export type MapSettings = {
polygonKeyName: any; polygonKeyName: any;
draggableMarker: boolean; draggableMarker: boolean;
initCallback?: () => any; initCallback?: () => any;
posFunction: (rigXPos, origYPos) => { x, y }; posFunction: (origXPos, origYPos) => { x, y };
defaultZoomLevel?: number; defaultZoomLevel?: number;
disableScrollZooming?: boolean; disableScrollZooming?: boolean;
minZoomLevel?: number; minZoomLevel?: number;

View File

@ -166,16 +166,30 @@ export class MapWidgetController implements MapWidgetInterface {
entityType: e.$datasource.entityType, entityType: e.$datasource.entityType,
id: e.$datasource.entityId id: e.$datasource.entityId
}; };
const keys = e.$datasource.dataKeys.map(key => { const attributes = [];
return { const timeseries = [];
e.$datasource.dataKeys.forEach(key => {
const value = {
key: key.name, key: key.name,
value: e[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, entityId,
AttributeScope.SHARED_SCOPE, AttributeScope.SHARED_SCOPE,
keys timeseries
).subscribe(() => {
});
attributeService.saveEntityAttributes(
entityId,
AttributeScope.SERVER_SCOPE,
attributes
).subscribe(() => { ).subscribe(() => {
}); });
} }
@ -260,7 +274,7 @@ export class MapWidgetController implements MapWidgetInterface {
type: widgetType.latest, type: widgetType.latest,
callbacks: { callbacks: {
onDataUpdated: (subscription) => { onDataUpdated: (subscription) => {
result.next(subscription.data[0].data[0]); result.next(subscription?.data[0]?.data[0]);
} }
} }
}; };

View File

@ -19,7 +19,7 @@ import LeafletMap from '../leaflet-map';
import { UnitedMapSettings } from '../map-models'; import { UnitedMapSettings } from '../map-models';
import { aspectCache, parseFunction } from '@app/core/utils'; import { aspectCache, parseFunction } from '@app/core/utils';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { map, filter } from 'rxjs/operators'; import { map, filter, switchMap } from 'rxjs/operators';
const maxZoom = 4;// ? const maxZoom = 4;// ?
@ -33,7 +33,7 @@ export class ImageMap extends LeafletMap {
constructor($container: HTMLElement, options: UnitedMapSettings) { constructor($container: HTMLElement, options: UnitedMapSettings) {
super($container, options); 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; this.imageUrl = options.mapUrl;
aspectCache(this.imageUrl).subscribe(aspect => { aspectCache(this.imageUrl).subscribe(aspect => {
this.aspect = aspect; this.aspect = aspect;
@ -44,14 +44,13 @@ export class ImageMap extends LeafletMap {
} }
setImageAlias(alias: Observable<any>) { setImageAlias(alias: Observable<any>) {
alias.pipe(filter(result => result), alias.pipe(filter(result => result), map(el => el[1]), switchMap(res => {
filter(result => result), map(el => el[1])).subscribe(res => { this.imageUrl = res;
this.imageUrl = res; return aspectCache(res);
aspectCache(res).subscribe(aspect => { })).subscribe(aspect => {
this.aspect = aspect; this.aspect = aspect;
this.onResize(true); this.onResize(true);
}) });
})
} }
updateBounds(updateImage?, lastCenterPos?) { updateBounds(updateImage?, lastCenterPos?) {

View File

@ -52,7 +52,7 @@
margin: 2px; margin: 2px;
line-height: 24px; line-height: 24px;
ng-mat-icon { mat-icon {
width: 24px; width: 24px;
height: 24px; height: 24px;

View File

@ -75,7 +75,6 @@
import './zone-flags'; import './zone-flags';
import 'zone.js/dist/zone'; // Included with Angular CLI. import 'zone.js/dist/zone'; // Included with Angular CLI.
import 'core-js/es/array'; import 'core-js/es/array';
import { polyfill } from 'es6-promise'; polyfill();
import moment from 'moment'; import moment from 'moment';
/*************************************************************************************************** /***************************************************************************************************

View File

@ -2,9 +2,6 @@
"extends": "../tsconfig.json", "extends": "../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"outDir": "../out-tsc/app", "outDir": "../out-tsc/app",
"typeRoots": [
"node_modules/@types"
],
"types": ["node", "jquery", "flot", "tooltipster", "tinycolor2", "js-beautify", "types": ["node", "jquery", "flot", "tooltipster", "tinycolor2", "js-beautify",
"react", "react-dom", "jstree", "raphael", "canvas-gauges", "leaflet", "leaflet-markercluster"] "react", "react-dom", "jstree", "raphael", "canvas-gauges", "leaflet", "leaflet-markercluster"]
}, },