From 0a9b21ce157ae019f224cde8bbf84fb7f6c660f9 Mon Sep 17 00:00:00 2001 From: Dmitriymush Date: Thu, 7 Dec 2023 17:02:23 +0200 Subject: [PATCH 1/2] UI: added additional check for string and empty string in value card widget --- .../widget/lib/cards/value-card-widget.component.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/cards/value-card-widget.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/cards/value-card-widget.component.ts index bce2f0b506..77228677aa 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/cards/value-card-widget.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/cards/value-card-widget.component.ts @@ -27,7 +27,7 @@ import { ViewChild } from '@angular/core'; import { WidgetContext } from '@home/models/widget-component.models'; -import { formatValue, isDefinedAndNotNull } from '@core/utils'; +import { formatValue, isDefinedAndNotNull, isNotEmptyStr, isString } from '@core/utils'; import { backgroundStyle, ColorProcessor, @@ -183,7 +183,10 @@ export class ValueCardWidgetComponent implements OnInit, AfterViewInit, OnDestro const tsValue = getSingleTsValue(this.ctx.data); let ts; let value; - if (tsValue && isDefinedAndNotNull(tsValue[1])) { + if ( + tsValue && isDefinedAndNotNull(tsValue[1]) && + (!isString(tsValue[1]) || isNotEmptyStr(tsValue[1])) + ) { ts = tsValue[0]; value = tsValue[1]; this.valueText = formatValue(value, this.decimals, this.units, false); From c1262bd3a818f2554c991ceb9b6310ce720b7944 Mon Sep 17 00:00:00 2001 From: Dmitriymush Date: Thu, 7 Dec 2023 17:28:29 +0200 Subject: [PATCH 2/2] UI: refactored check for value card widget --- .../widget/lib/cards/value-card-widget.component.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/cards/value-card-widget.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/cards/value-card-widget.component.ts index 77228677aa..27899f6e83 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/cards/value-card-widget.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/cards/value-card-widget.component.ts @@ -27,7 +27,7 @@ import { ViewChild } from '@angular/core'; import { WidgetContext } from '@home/models/widget-component.models'; -import { formatValue, isDefinedAndNotNull, isNotEmptyStr, isString } from '@core/utils'; +import { formatValue, isDefinedAndNotNull } from '@core/utils'; import { backgroundStyle, ColorProcessor, @@ -183,10 +183,7 @@ export class ValueCardWidgetComponent implements OnInit, AfterViewInit, OnDestro const tsValue = getSingleTsValue(this.ctx.data); let ts; let value; - if ( - tsValue && isDefinedAndNotNull(tsValue[1]) && - (!isString(tsValue[1]) || isNotEmptyStr(tsValue[1])) - ) { + if (tsValue && isDefinedAndNotNull(tsValue[1]) && tsValue[0] !== 0) { ts = tsValue[0]; value = tsValue[1]; this.valueText = formatValue(value, this.decimals, this.units, false);