Commit aabf5c792afe9e71f3aecc878339a0236dfe0caf
1 parent
593f95a7
UI: Fixed multiple datasource processing data in map widgets
Showing
1 changed file
with
14 additions
and
11 deletions
@@ -19,7 +19,8 @@ import { | @@ -19,7 +19,8 @@ import { | ||
19 | createLabelFromDatasource, | 19 | createLabelFromDatasource, |
20 | hashCode, | 20 | hashCode, |
21 | isDefined, | 21 | isDefined, |
22 | - isDefinedAndNotNull, isFunction, | 22 | + isDefinedAndNotNull, |
23 | + isFunction, | ||
23 | isNumber, | 24 | isNumber, |
24 | isUndefined, | 25 | isUndefined, |
25 | padValue | 26 | padValue |
@@ -30,7 +31,7 @@ import { Datasource, DatasourceData } from '@shared/models/widget.models'; | @@ -30,7 +31,7 @@ import { Datasource, DatasourceData } from '@shared/models/widget.models'; | ||
30 | import _ from 'lodash'; | 31 | import _ from 'lodash'; |
31 | import { mapProviderSchema, providerSets } from '@home/components/widget/lib/maps/schemes'; | 32 | import { mapProviderSchema, providerSets } from '@home/components/widget/lib/maps/schemes'; |
32 | import { addCondition, mergeSchemes } from '@core/schema-utils'; | 33 | import { addCondition, mergeSchemes } from '@core/schema-utils'; |
33 | -import L, {Projection} from "leaflet"; | 34 | +import L from 'leaflet'; |
34 | 35 | ||
35 | export function getProviderSchema(mapProvider: MapProviders, ignoreImageMap = false) { | 36 | export function getProviderSchema(mapProvider: MapProviders, ignoreImageMap = false) { |
36 | const providerSchema = _.cloneDeep(mapProviderSchema); | 37 | const providerSchema = _.cloneDeep(mapProviderSchema); |
@@ -318,22 +319,24 @@ export const parseWithTranslation = { | @@ -318,22 +319,24 @@ export const parseWithTranslation = { | ||
318 | }; | 319 | }; |
319 | 320 | ||
320 | export function parseData(input: DatasourceData[]): FormattedData[] { | 321 | export function parseData(input: DatasourceData[]): FormattedData[] { |
321 | - return _(input).groupBy(el => el?.datasource?.entityName) | 322 | + return _(input).groupBy(el => el?.datasource.entityId + el?.datasource.entityType) |
322 | .values().value().map((entityArray, i) => { | 323 | .values().value().map((entityArray, i) => { |
323 | const obj: FormattedData = { | 324 | const obj: FormattedData = { |
324 | entityName: entityArray[0]?.datasource?.entityName, | 325 | entityName: entityArray[0]?.datasource?.entityName, |
325 | - entityId: entityArray[0]?.datasource?.entityId, | ||
326 | - entityType: entityArray[0]?.datasource?.entityType, | ||
327 | - $datasource: entityArray[0]?.datasource, | 326 | + entityId: entityArray[0].datasource.entityId, |
327 | + entityType: entityArray[0].datasource.entityType, | ||
328 | + $datasource: entityArray[0].datasource, | ||
328 | dsIndex: i, | 329 | dsIndex: i, |
329 | deviceType: null | 330 | deviceType: null |
330 | }; | 331 | }; |
331 | entityArray.filter(el => el.data.length).forEach(el => { | 332 | entityArray.filter(el => el.data.length).forEach(el => { |
332 | - const indexDate = el?.data?.length ? el.data.length - 1 : 0; | ||
333 | - obj[el?.dataKey?.label] = el?.data[indexDate][1]; | ||
334 | - obj[el?.dataKey?.label + '|ts'] = el?.data[indexDate][0]; | ||
335 | - if (el?.dataKey?.label === 'type') { | ||
336 | - obj.deviceType = el?.data[indexDate][1]; | 333 | + const indexDate = el.data.length ? el.data.length - 1 : 0; |
334 | + if (!obj.hasOwnProperty(el.dataKey.label) || el.data[indexDate][1] !== '') { | ||
335 | + obj[el.dataKey.label] = el.data[indexDate][1]; | ||
336 | + obj[el.dataKey.label + '|ts'] = el.data[indexDate][0]; | ||
337 | + if (el.dataKey.label === 'type') { | ||
338 | + obj.deviceType = el.data[indexDate][1]; | ||
339 | + } | ||
337 | } | 340 | } |
338 | }); | 341 | }); |
339 | return obj; | 342 | return obj; |