UI: Improvement image-map when image attr empty set default image

This commit is contained in:
Vladyslav_Prykhodko 2022-06-16 15:18:25 +03:00
parent c4bdee92db
commit 66cc42644e
2 changed files with 6 additions and 4 deletions

View File

@ -96,7 +96,7 @@ export function isEmptyStr(value: any): boolean {
} }
export function isNotEmptyStr(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 { export function isFunction(value: any): boolean {

View File

@ -27,7 +27,7 @@ import { WidgetContext } from '@home/models/widget-component.models';
import { DataSet, DatasourceType, widgetType } from '@shared/models/widget.models'; import { DataSet, DatasourceType, widgetType } from '@shared/models/widget.models';
import { DataKeyType } from '@shared/models/telemetry/telemetry.models'; import { DataKeyType } from '@shared/models/telemetry/telemetry.models';
import { WidgetSubscriptionOptions } from '@core/api/widget-api.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'; import { EntityDataPageLink } from '@shared/models/query/query.models';
const maxZoom = 4; // ? const maxZoom = 4; // ?
@ -93,10 +93,12 @@ export class ImageMap extends LeafletMap {
type: widgetType.latest, type: widgetType.latest,
callbacks: { callbacks: {
onDataUpdated: (subscription) => { 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]); result.next([subscription.data[0].data, isUpdate]);
isUpdate = true; } else {
result.next([[[0, options.mapImageUrl]], isUpdate]);
} }
isUpdate = true;
} }
} }
}; };