diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/rpc/switch.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/rpc/switch.component.ts index b1b5a3b336..d2cf53265f 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/rpc/switch.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/rpc/switch.component.ts @@ -121,7 +121,7 @@ export class SwitchComponent extends PageComponent implements OnInit, OnDestroy this.switchResize$ = new ResizeObserver(() => { this.resize(); - }) + }); this.switchResize$.observe(this.switchContainerRef.nativeElement); this.init(); } @@ -202,13 +202,13 @@ export class SwitchComponent extends PageComponent implements OnInit, OnDestroy let width = this.switchContainer.width(); let height = this.switchContainer.height(); if (this.showOnOffLabels) { - height = height*2/3; + height = height * 2 / 3; } - const ratio = width/height; + const ratio = width / height; if (ratio > switchAspectRation) { - width = height*switchAspectRation; + width = height * switchAspectRation; } else { - height = width/switchAspectRation; + height = width / switchAspectRation; } this.switchElement.css({width, height}); this.matSlideToggle.css({width, height, minWidth: width}); @@ -232,11 +232,11 @@ export class SwitchComponent extends PageComponent implements OnInit, OnDestroy fontSize--; textWidth = this.measureTextWidth(text, fontSize); } - element.css({fontSize: fontSize+'px', lineHeight: fontSize+'px'}); + element.css({fontSize: fontSize + 'px', lineHeight: fontSize + 'px'}); } private measureTextWidth(text: string, fontSize: number): number { - this.textMeasure.css({fontSize: fontSize+'px', lineHeight: fontSize+'px'}); + this.textMeasure.css({fontSize: fontSize + 'px', lineHeight: fontSize + 'px'}); this.textMeasure.text(text); return this.textMeasure.width(); } @@ -260,6 +260,7 @@ export class SwitchComponent extends PageComponent implements OnInit, OnDestroy this.ctx.controlApi.sendTwoWayCommand(this.getValueMethod, null, this.requestTimeout).subscribe( (responseBody) => { this.setValue(this.parseValueFunction(responseBody)); + this.ctx.detectChanges(); }, () => { const errorText = this.ctx.defaultSubscription.rpcErrorText;