Browse Source

entity save fix #2

pull/2678/head
Artem Halushko 7 years ago
parent
commit
9479b4194f
  1. 49
      ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts
  2. 1
      ui-ngx/src/app/modules/home/components/widget/lib/maps/markers.ts
  3. 34
      ui-ngx/src/app/shared/components/time/history-selector/history-selector.component.scss

49
ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts

@ -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(key.type === DataKeyType.timeseries){
timeseries.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)
}
}
})
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 {

1
ui-ngx/src/app/modules/home/components/widget/lib/maps/markers.ts

@ -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],

34
ui-ngx/src/app/shared/components/time/history-selector/history-selector.component.scss

@ -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 {
width: 28px;
height: 28px;
font-size: 28px;
svg {
width: inherit;
height: inherit;
}
.mat-icon-button {
width: 44px;
min-width: 44px;
height: 48px;
min-height: 48px;
margin: 0;
line-height: 28px;
mat-icon {
width: 24px;
height: 24px;
font-size: 24px;
svg {
width: inherit;
height: inherit;
}
}

Loading…
Cancel
Save