entity save fix #2

This commit is contained in:
Artem Halushko 2020-04-28 15:18:40 +03:00
parent c627e79947
commit 9479b4194f
3 changed files with 42 additions and 38 deletions

View File

@ -38,7 +38,7 @@ import { WidgetContext } from '@app/modules/home/models/widget-component.models'
import { getDefCenterPosition } from './maps-utils';
import { JsonSettingsSchema, WidgetActionDescriptor, DatasourceType, widgetType } from '@shared/models/widget.models';
import { EntityId } from '@shared/models/id/entity-id';
import { AttributeScope, DataKeyType } from '@shared/models/telemetry/telemetry.models';
import { AttributeScope, DataKeyType, LatestTelemetry } from '@shared/models/telemetry/telemetry.models';
import { AttributeService } from '@core/http/attribute.service';
import { Type } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
@ -168,30 +168,35 @@ export class MapWidgetController implements MapWidgetInterface {
};
const attributes = [];
const timeseries = [];
const latLngProperties = [this.settings.latKeyName, this.settings.lngKeyName, this.settings.xPosKeyName, this.settings.yPosKeyName];
e.$datasource.dataKeys.forEach(key => {
const value = {
key: key.name,
value: e[key.name]
};
if(key.type === DataKeyType.attribute){
attributes.push(value)
if (latLngProperties.includes(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)
}
}
if(key.type === DataKeyType.timeseries){
timeseries.push(value)
}
})
attributeService.saveEntityTimeseries(
entityId,
AttributeScope.SHARED_SCOPE,
timeseries
).subscribe(() => {
});
attributeService.saveEntityAttributes(
entityId,
AttributeScope.SERVER_SCOPE,
attributes
).subscribe(() => {
});
if (attributes.length) {
attributeService.saveEntityTimeseries(
entityId,
LatestTelemetry.LATEST_TELEMETRY,
timeseries
).subscribe(() => { });
}
if (timeseries.length) {
attributeService.saveEntityAttributes(
entityId,
AttributeScope.SERVER_SCOPE,
attributes
).subscribe(() => { });
}
}
initSettings(settings: UnitedMapSettings): UnitedMapSettings {

View File

@ -150,7 +150,6 @@ export class Marker {
}
createDefaultMarkerIcon(color, onMarkerIconReady) {
const pinColor = color.substr(1);
const icon = L.icon({
iconUrl: 'https://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|' + color,
iconSize: [21, 34],

View File

@ -90,24 +90,24 @@
mat-slider {
min-width: 80px;
}
}
button.mat-button.mat-icon-button {
width: 44px;
min-width: 44px;
height: 44px;
min-height: 44px;
margin: 0;
line-height: 28px;
.mat-icon-button {
width: 44px;
min-width: 44px;
height: 48px;
min-height: 48px;
margin: 0;
line-height: 28px;
mat-icon {
width: 28px;
height: 28px;
font-size: 28px;
mat-icon {
width: 24px;
height: 24px;
font-size: 24px;
svg {
width: inherit;
height: inherit;
}
svg {
width: inherit;
height: inherit;
}
}