|
|
@ -121,7 +121,7 @@ export class SwitchComponent extends PageComponent implements OnInit, OnDestroy |
|
|
|
|
|
|
|
|
this.switchResize$ = new ResizeObserver(() => { |
|
|
this.switchResize$ = new ResizeObserver(() => { |
|
|
this.resize(); |
|
|
this.resize(); |
|
|
}) |
|
|
}); |
|
|
this.switchResize$.observe(this.switchContainerRef.nativeElement); |
|
|
this.switchResize$.observe(this.switchContainerRef.nativeElement); |
|
|
this.init(); |
|
|
this.init(); |
|
|
} |
|
|
} |
|
|
@ -202,13 +202,13 @@ export class SwitchComponent extends PageComponent implements OnInit, OnDestroy |
|
|
let width = this.switchContainer.width(); |
|
|
let width = this.switchContainer.width(); |
|
|
let height = this.switchContainer.height(); |
|
|
let height = this.switchContainer.height(); |
|
|
if (this.showOnOffLabels) { |
|
|
if (this.showOnOffLabels) { |
|
|
height = height*2/3; |
|
|
height = height * 2 / 3; |
|
|
} |
|
|
} |
|
|
const ratio = width/height; |
|
|
const ratio = width / height; |
|
|
if (ratio > switchAspectRation) { |
|
|
if (ratio > switchAspectRation) { |
|
|
width = height*switchAspectRation; |
|
|
width = height * switchAspectRation; |
|
|
} else { |
|
|
} else { |
|
|
height = width/switchAspectRation; |
|
|
height = width / switchAspectRation; |
|
|
} |
|
|
} |
|
|
this.switchElement.css({width, height}); |
|
|
this.switchElement.css({width, height}); |
|
|
this.matSlideToggle.css({width, height, minWidth: width}); |
|
|
this.matSlideToggle.css({width, height, minWidth: width}); |
|
|
@ -232,11 +232,11 @@ export class SwitchComponent extends PageComponent implements OnInit, OnDestroy |
|
|
fontSize--; |
|
|
fontSize--; |
|
|
textWidth = this.measureTextWidth(text, 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 { |
|
|
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); |
|
|
this.textMeasure.text(text); |
|
|
return this.textMeasure.width(); |
|
|
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( |
|
|
this.ctx.controlApi.sendTwoWayCommand(this.getValueMethod, null, this.requestTimeout).subscribe( |
|
|
(responseBody) => { |
|
|
(responseBody) => { |
|
|
this.setValue(this.parseValueFunction(responseBody)); |
|
|
this.setValue(this.parseValueFunction(responseBody)); |
|
|
|
|
|
this.ctx.detectChanges(); |
|
|
}, |
|
|
}, |
|
|
() => { |
|
|
() => { |
|
|
const errorText = this.ctx.defaultSubscription.rpcErrorText; |
|
|
const errorText = this.ctx.defaultSubscription.rpcErrorText; |
|
|
|