UI: Add new widhet type parameters supportsUnitConversion
This commit is contained in:
parent
2e65c79184
commit
76237337b2
@ -47,7 +47,9 @@
|
||||
/>
|
||||
</mat-form-field>
|
||||
<div class="tb-units-field">
|
||||
<tb-unit-input formControlName="units">
|
||||
<tb-unit-input
|
||||
[allowConverted]="supportsUnitConversion"
|
||||
formControlName="units">
|
||||
</tb-unit-input>
|
||||
</div>
|
||||
<div class="tb-decimals-field">
|
||||
|
||||
@ -123,6 +123,10 @@ export class AggregatedDataKeyRowComponent implements ControlValueAccessor, OnIn
|
||||
return [DatasourceType.device, DatasourceType.entity].includes(this.datasourceType);
|
||||
}
|
||||
|
||||
get supportsUnitConversion(): boolean {
|
||||
return this.widgetConfigComponent.modelValue?.typeParameters?.supportsUnitConversion ?? false;
|
||||
}
|
||||
|
||||
private propagateChange = (_val: any) => {};
|
||||
|
||||
constructor(private fb: UntypedFormBuilder,
|
||||
@ -222,7 +226,8 @@ export class AggregatedDataKeyRowComponent implements ControlValueAccessor, OnIn
|
||||
callbacks: this.callbacks,
|
||||
hideDataKeyName: true,
|
||||
hideDataKeyLabel: true,
|
||||
hideDataKeyColor: true
|
||||
hideDataKeyColor: true,
|
||||
supportsUnitConversion: this.supportsUnitConversion
|
||||
}
|
||||
}).afterClosed().subscribe((updatedDataKey) => {
|
||||
if (updatedDataKey) {
|
||||
|
||||
@ -69,6 +69,7 @@
|
||||
</div>
|
||||
<div *ngIf="!hideUnits && !hideDataKeyUnits && (!singleRow || displayUnitsOrDigits)" class="tb-units-field">
|
||||
<tb-unit-input *ngIf="displayUnitsOrDigits"
|
||||
[allowConverted]="supportsUnitConversion"
|
||||
formControlName="units">
|
||||
</tb-unit-input>
|
||||
</div>
|
||||
|
||||
@ -225,6 +225,10 @@ export class DataKeyRowComponent implements ControlValueAccessor, OnInit, OnChan
|
||||
return this.hasAdditionalLatestDataKeys && this.keyRowFormGroup.get('latest').value === true;
|
||||
}
|
||||
|
||||
get supportsUnitConversion(): boolean {
|
||||
return this.widgetConfigComponent.modelValue?.typeParameters?.supportsUnitConversion ?? false;
|
||||
}
|
||||
|
||||
private propagateChange = (_val: any) => {};
|
||||
|
||||
constructor(private fb: UntypedFormBuilder,
|
||||
@ -337,7 +341,8 @@ export class DataKeyRowComponent implements ControlValueAccessor, OnInit, OnChan
|
||||
hideDataKeyLabel: this.hideDataKeyLabel,
|
||||
hideDataKeyColor: this.hideDataKeyColor,
|
||||
hideDataKeyUnits: this.hideDataKeyUnits || !this.displayUnitsOrDigits,
|
||||
hideDataKeyDecimals: this.hideDataKeyDecimals || !this.displayUnitsOrDigits
|
||||
hideDataKeyDecimals: this.hideDataKeyDecimals || !this.displayUnitsOrDigits,
|
||||
supportsUnitConversion: this.supportsUnitConversion
|
||||
}
|
||||
}).afterClosed().subscribe((updatedDataKey) => {
|
||||
if (updatedDataKey) {
|
||||
|
||||
@ -71,6 +71,7 @@
|
||||
[hideDataKeyUnits]="hideDataKeyUnits"
|
||||
[hideDataKeyDecimals]="hideDataKeyDecimals"
|
||||
[maxDataKeys]="maxDataKeys"
|
||||
[supportsUnitConversion]="supportsUnitConversion"
|
||||
[optDataKeys]="isDataKeysOptional(datasourceFormGroup.get('type').value)"
|
||||
[simpleDataKeysLabel]="!hasAdditionalLatestDataKeys"
|
||||
[aliasController]="aliasController"
|
||||
|
||||
@ -135,6 +135,10 @@ export class DatasourceComponent implements ControlValueAccessor, OnInit, Valida
|
||||
return this.widgetConfigComponent.modelValue?.dataKeySettingsFunction;
|
||||
}
|
||||
|
||||
public get supportsUnitConversion(): boolean {
|
||||
return this.widgetConfigComponent.modelValue?.typeParameters?.supportsUnitConversion ?? false;
|
||||
}
|
||||
|
||||
public get dashboard(): Dashboard {
|
||||
return this.widgetConfigComponent.dashboard;
|
||||
}
|
||||
|
||||
@ -50,6 +50,7 @@
|
||||
[hideDataKeyColor]="data.hideDataKeyColor"
|
||||
[hideDataKeyUnits]="data.hideDataKeyUnits"
|
||||
[hideDataKeyDecimals]="data.hideDataKeyDecimals"
|
||||
[supportsUnitConversion]="data.supportsUnitConversion"
|
||||
formControlName="dataKey">
|
||||
</tb-data-key-config>
|
||||
</div>
|
||||
|
||||
@ -56,6 +56,7 @@ export interface DataKeyConfigDialogData {
|
||||
hideDataKeyColor?: boolean;
|
||||
hideDataKeyUnits?: boolean;
|
||||
hideDataKeyDecimals?: boolean;
|
||||
supportsUnitConversion?: boolean
|
||||
}
|
||||
|
||||
@Component({
|
||||
|
||||
@ -49,6 +49,7 @@
|
||||
<div class="tb-form-row space-between" *ngIf="!hideDataKeyUnits">
|
||||
<div translate>widget-config.units-short</div>
|
||||
<tb-unit-input
|
||||
[allowConverted]="supportsUnitConversion"
|
||||
formControlName="units">
|
||||
</tb-unit-input>
|
||||
</div>
|
||||
|
||||
@ -153,6 +153,10 @@ export class DataKeyConfigComponent extends PageComponent implements OnInit, Con
|
||||
@coerceBoolean()
|
||||
hideDataKeyDecimals = false;
|
||||
|
||||
@Input()
|
||||
@coerceBoolean()
|
||||
supportsUnitConversion = false;
|
||||
|
||||
@ViewChild('keyInput') keyInput: ElementRef;
|
||||
|
||||
@ViewChild('funcBodyEdit', {static: false}) funcBodyEdit: JsFuncComponent;
|
||||
|
||||
@ -169,6 +169,10 @@ export class DataKeysComponent implements ControlValueAccessor, OnInit, OnChange
|
||||
@coerceBoolean()
|
||||
simpleDataKeysLabel = false;
|
||||
|
||||
@Input()
|
||||
@coerceBoolean()
|
||||
supportsUnitConversion = false;
|
||||
|
||||
@Input()
|
||||
aliasController: IAliasController;
|
||||
|
||||
@ -610,7 +614,8 @@ export class DataKeysComponent implements ControlValueAccessor, OnInit, OnChange
|
||||
hideDataKeyLabel: this.hideDataKeyLabel,
|
||||
hideDataKeyColor: this.hideDataKeyColor,
|
||||
hideDataKeyUnits: this.hideDataKeyUnits,
|
||||
hideDataKeyDecimals: this.hideDataKeyDecimals
|
||||
hideDataKeyDecimals: this.hideDataKeyDecimals,
|
||||
supportsUnitConversion: this.supportsUnitConversion
|
||||
}
|
||||
}).afterClosed().subscribe((updatedDataKey) => {
|
||||
if (updatedDataKey) {
|
||||
|
||||
@ -662,6 +662,9 @@ export class WidgetComponentService {
|
||||
if (isUndefined(result.typeParameters.targetDeviceOptional)) {
|
||||
result.typeParameters.targetDeviceOptional = false;
|
||||
}
|
||||
if (isUndefined(result.typeParameters.supportsUnitConversion)) {
|
||||
result.typeParameters.supportsUnitConversion = false;
|
||||
}
|
||||
if (isDefinedAndNotNull(result.typeParameters.additionalWidgetActionTypes)) {
|
||||
if (Array.isArray(result.typeParameters.additionalWidgetActionTypes)) {
|
||||
result.typeParameters.additionalWidgetActionTypes = result.typeParameters.additionalWidgetActionTypes.filter(type => WidgetActionType[type]);
|
||||
|
||||
@ -291,6 +291,7 @@
|
||||
<div *ngIf="displayUnitsConfig" class="tb-form-row space-between">
|
||||
<div tb-hint-tooltip-icon="{{'widget-config.default-data-key-parameter-hint' | translate}}" translate>widget-config.units-by-default</div>
|
||||
<tb-unit-input
|
||||
[allowConverted]="modelValue.typeParameters.supportsUnitConversion"
|
||||
formControlName="units">
|
||||
</tb-unit-input>
|
||||
</div>
|
||||
|
||||
@ -196,6 +196,7 @@ export interface WidgetTypeParameters {
|
||||
dataKeySettingsFunction?: DataKeySettingsFunction;
|
||||
displayRpcMessageToast?: boolean;
|
||||
targetDeviceOptional?: boolean;
|
||||
supportsUnitConversion?: boolean;
|
||||
additionalWidgetActionTypes?: WidgetActionType[];
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user