Commit 9479b4194f2395ed485fb0b0db2598f8ef1d037b

Authored by Artem Halushko
1 parent c627e799

entity save fix #2

@@ -38,7 +38,7 @@ import { WidgetContext } from '@app/modules/home/models/widget-component.models' @@ -38,7 +38,7 @@ import { WidgetContext } from '@app/modules/home/models/widget-component.models'
38 import { getDefCenterPosition } from './maps-utils'; 38 import { getDefCenterPosition } from './maps-utils';
39 import { JsonSettingsSchema, WidgetActionDescriptor, DatasourceType, widgetType } from '@shared/models/widget.models'; 39 import { JsonSettingsSchema, WidgetActionDescriptor, DatasourceType, widgetType } from '@shared/models/widget.models';
40 import { EntityId } from '@shared/models/id/entity-id'; 40 import { EntityId } from '@shared/models/id/entity-id';
41 -import { AttributeScope, DataKeyType } from '@shared/models/telemetry/telemetry.models'; 41 +import { AttributeScope, DataKeyType, LatestTelemetry } from '@shared/models/telemetry/telemetry.models';
42 import { AttributeService } from '@core/http/attribute.service'; 42 import { AttributeService } from '@core/http/attribute.service';
43 import { Type } from '@angular/core'; 43 import { Type } from '@angular/core';
44 import { TranslateService } from '@ngx-translate/core'; 44 import { TranslateService } from '@ngx-translate/core';
@@ -168,30 +168,35 @@ export class MapWidgetController implements MapWidgetInterface { @@ -168,30 +168,35 @@ export class MapWidgetController implements MapWidgetInterface {
168 }; 168 };
169 const attributes = []; 169 const attributes = [];
170 const timeseries = []; 170 const timeseries = [];
  171 + const latLngProperties = [this.settings.latKeyName, this.settings.lngKeyName, this.settings.xPosKeyName, this.settings.yPosKeyName];
171 e.$datasource.dataKeys.forEach(key => { 172 e.$datasource.dataKeys.forEach(key => {
172 - const value = {  
173 - key: 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 + if (latLngProperties.includes(key)) {
  174 + const value = {
  175 + key: key.name,
  176 + value: e[key.name]
  177 + };
  178 + if (key.type === DataKeyType.attribute) {
  179 + attributes.push(value)
  180 + }
  181 + if (key.type === DataKeyType.timeseries) {
  182 + timeseries.push(value)
  183 + }
181 } 184 }
182 - })  
183 - attributeService.saveEntityTimeseries(  
184 - entityId,  
185 - AttributeScope.SHARED_SCOPE,  
186 - timeseries  
187 - ).subscribe(() => {  
188 - });  
189 - attributeService.saveEntityAttributes(  
190 - entityId,  
191 - AttributeScope.SERVER_SCOPE,  
192 - attributes  
193 - ).subscribe(() => {  
194 }); 185 });
  186 + if (attributes.length) {
  187 + attributeService.saveEntityTimeseries(
  188 + entityId,
  189 + LatestTelemetry.LATEST_TELEMETRY,
  190 + timeseries
  191 + ).subscribe(() => { });
  192 + }
  193 + if (timeseries.length) {
  194 + attributeService.saveEntityAttributes(
  195 + entityId,
  196 + AttributeScope.SERVER_SCOPE,
  197 + attributes
  198 + ).subscribe(() => { });
  199 + }
195 } 200 }
196 201
197 initSettings(settings: UnitedMapSettings): UnitedMapSettings { 202 initSettings(settings: UnitedMapSettings): UnitedMapSettings {
@@ -150,7 +150,6 @@ export class Marker { @@ -150,7 +150,6 @@ export class Marker {
150 } 150 }
151 151
152 createDefaultMarkerIcon(color, onMarkerIconReady) { 152 createDefaultMarkerIcon(color, onMarkerIconReady) {
153 - const pinColor = color.substr(1);  
154 const icon = L.icon({ 153 const icon = L.icon({
155 iconUrl: 'https://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|' + color, 154 iconUrl: 'https://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|' + color,
156 iconSize: [21, 34], 155 iconSize: [21, 34],
@@ -90,24 +90,24 @@ @@ -90,24 +90,24 @@
90 mat-slider { 90 mat-slider {
91 min-width: 80px; 91 min-width: 80px;
92 } 92 }
  93 + }
93 94
94 - button.mat-button.mat-icon-button {  
95 - width: 44px;  
96 - min-width: 44px;  
97 - height: 44px;  
98 - min-height: 44px;  
99 - margin: 0;  
100 - line-height: 28px;  
101 -  
102 - mat-icon {  
103 - width: 28px;  
104 - height: 28px;  
105 - font-size: 28px;  
106 -  
107 - svg {  
108 - width: inherit;  
109 - height: inherit;  
110 - } 95 + .mat-icon-button {
  96 + width: 44px;
  97 + min-width: 44px;
  98 + height: 48px;
  99 + min-height: 48px;
  100 + margin: 0;
  101 + line-height: 28px;
  102 +
  103 + mat-icon {
  104 + width: 24px;
  105 + height: 24px;
  106 + font-size: 24px;
  107 +
  108 + svg {
  109 + width: inherit;
  110 + height: inherit;
111 } 111 }
112 } 112 }
113 113