Commit 766594a7aa039c1433a4b0524d6d0fdb0e2a0c0d
1 parent
5bb252b4
UI: Fixed switch control widget, didn't update state after get value in call rpc
Showing
1 changed file
with
8 additions
and
7 deletions
... | ... | @@ -121,7 +121,7 @@ export class SwitchComponent extends PageComponent implements OnInit, OnDestroy |
121 | 121 | |
122 | 122 | this.switchResize$ = new ResizeObserver(() => { |
123 | 123 | this.resize(); |
124 | - }) | |
124 | + }); | |
125 | 125 | this.switchResize$.observe(this.switchContainerRef.nativeElement); |
126 | 126 | this.init(); |
127 | 127 | } |
... | ... | @@ -202,13 +202,13 @@ export class SwitchComponent extends PageComponent implements OnInit, OnDestroy |
202 | 202 | let width = this.switchContainer.width(); |
203 | 203 | let height = this.switchContainer.height(); |
204 | 204 | if (this.showOnOffLabels) { |
205 | - height = height*2/3; | |
205 | + height = height * 2 / 3; | |
206 | 206 | } |
207 | - const ratio = width/height; | |
207 | + const ratio = width / height; | |
208 | 208 | if (ratio > switchAspectRation) { |
209 | - width = height*switchAspectRation; | |
209 | + width = height * switchAspectRation; | |
210 | 210 | } else { |
211 | - height = width/switchAspectRation; | |
211 | + height = width / switchAspectRation; | |
212 | 212 | } |
213 | 213 | this.switchElement.css({width, height}); |
214 | 214 | this.matSlideToggle.css({width, height, minWidth: width}); |
... | ... | @@ -232,11 +232,11 @@ export class SwitchComponent extends PageComponent implements OnInit, OnDestroy |
232 | 232 | fontSize--; |
233 | 233 | textWidth = this.measureTextWidth(text, fontSize); |
234 | 234 | } |
235 | - element.css({fontSize: fontSize+'px', lineHeight: fontSize+'px'}); | |
235 | + element.css({fontSize: fontSize + 'px', lineHeight: fontSize + 'px'}); | |
236 | 236 | } |
237 | 237 | |
238 | 238 | private measureTextWidth(text: string, fontSize: number): number { |
239 | - this.textMeasure.css({fontSize: fontSize+'px', lineHeight: fontSize+'px'}); | |
239 | + this.textMeasure.css({fontSize: fontSize + 'px', lineHeight: fontSize + 'px'}); | |
240 | 240 | this.textMeasure.text(text); |
241 | 241 | return this.textMeasure.width(); |
242 | 242 | } |
... | ... | @@ -260,6 +260,7 @@ export class SwitchComponent extends PageComponent implements OnInit, OnDestroy |
260 | 260 | this.ctx.controlApi.sendTwoWayCommand(this.getValueMethod, null, this.requestTimeout).subscribe( |
261 | 261 | (responseBody) => { |
262 | 262 | this.setValue(this.parseValueFunction(responseBody)); |
263 | + this.ctx.detectChanges(); | |
263 | 264 | }, |
264 | 265 | () => { |
265 | 266 | const errorText = this.ctx.defaultSubscription.rpcErrorText; | ... | ... |