From 66cc42644e78f0b82d11e2919a1fe6ebe92bfaa7 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Thu, 16 Jun 2022 15:18:25 +0300 Subject: [PATCH] UI: Improvement image-map when image attr empty set default image --- ui-ngx/src/app/core/utils.ts | 2 +- .../components/widget/lib/maps/providers/image-map.ts | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ui-ngx/src/app/core/utils.ts b/ui-ngx/src/app/core/utils.ts index 37d2f1f652..96fad967a1 100644 --- a/ui-ngx/src/app/core/utils.ts +++ b/ui-ngx/src/app/core/utils.ts @@ -96,7 +96,7 @@ export function isEmptyStr(value: any): boolean { } export function isNotEmptyStr(value: any): boolean { - return value !== null && typeof value === 'string' && value.trim().length > 0; + return typeof value === 'string' && value.trim().length > 0; } export function isFunction(value: any): boolean { diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/image-map.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/image-map.ts index 783ebd2096..dd03604a9a 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/image-map.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/image-map.ts @@ -27,7 +27,7 @@ import { WidgetContext } from '@home/models/widget-component.models'; import { DataSet, DatasourceType, widgetType } from '@shared/models/widget.models'; import { DataKeyType } from '@shared/models/telemetry/telemetry.models'; import { WidgetSubscriptionOptions } from '@core/api/widget-api.models'; -import { isDefinedAndNotNull, isEmptyStr, parseFunction } from '@core/utils'; +import { isDefinedAndNotNull, isEmptyStr, isNotEmptyStr, parseFunction } from '@core/utils'; import { EntityDataPageLink } from '@shared/models/query/query.models'; const maxZoom = 4; // ? @@ -93,10 +93,12 @@ export class ImageMap extends LeafletMap { type: widgetType.latest, callbacks: { onDataUpdated: (subscription) => { - if (subscription.data[0]?.data[0]?.length > 0) { + if (isNotEmptyStr(subscription.data[0]?.data[0]?.[1])) { result.next([subscription.data[0].data, isUpdate]); - isUpdate = true; + } else { + result.next([[[0, options.mapImageUrl]], isUpdate]); } + isUpdate = true; } } };