Added decimals by default
This commit is contained in:
parent
1a4ebd9513
commit
c7c22c69ec
@ -153,26 +153,35 @@
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@if (fieldFormGroup.get('type').value === CalculatedFieldType.SIMPLE) {
|
@if (fieldFormGroup.get('type').value === CalculatedFieldType.SIMPLE) {
|
||||||
<mat-form-field class="flex-1" appearance="outline" subscriptSizing="dynamic">
|
<div class="flex items-center gap-3">
|
||||||
<mat-label>
|
<mat-form-field class="flex-1" appearance="outline">
|
||||||
{{ (outputFormGroup.get('type').value === OutputType.Timeseries
|
<mat-label>
|
||||||
? 'calculated-fields.timeseries-key'
|
{{ (outputFormGroup.get('type').value === OutputType.Timeseries
|
||||||
: 'calculated-fields.attribute-key')
|
? 'calculated-fields.timeseries-key'
|
||||||
| translate }}
|
: 'calculated-fields.attribute-key')
|
||||||
</mat-label>
|
| translate }}
|
||||||
<input matInput formControlName="name" required>
|
</mat-label>
|
||||||
@if (outputFormGroup.get('name').errors && outputFormGroup.get('name').touched) {
|
<input matInput formControlName="name" required>
|
||||||
<mat-error>
|
@if (outputFormGroup.get('name').errors && outputFormGroup.get('name').touched) {
|
||||||
@if (outputFormGroup.get('name').hasError('required')) {
|
<mat-error>
|
||||||
{{ 'common.hint.key-required' | translate }}
|
@if (outputFormGroup.get('name').hasError('required')) {
|
||||||
} @else if (outputFormGroup.get('name').hasError('pattern')) {
|
{{ 'common.hint.key-required' | translate }}
|
||||||
{{ 'common.hint.key-pattern' | translate }}
|
} @else if (outputFormGroup.get('name').hasError('pattern')) {
|
||||||
} @else if (outputFormGroup.get('name').hasError('maxlength')) {
|
{{ 'common.hint.key-pattern' | translate }}
|
||||||
{{ 'common.hint.key-max-length' | translate }}
|
} @else if (outputFormGroup.get('name').hasError('maxlength')) {
|
||||||
}
|
{{ 'common.hint.key-max-length' | translate }}
|
||||||
</mat-error>
|
}
|
||||||
}
|
</mat-error>
|
||||||
</mat-form-field>
|
}
|
||||||
|
</mat-form-field>
|
||||||
|
<mat-form-field class="flex-1" appearance="outline">
|
||||||
|
<mat-label>{{ 'calculated-fields.decimals-by-default' | translate }}</mat-label>
|
||||||
|
<input matInput type="number" formControlName="decimalsByDefault">
|
||||||
|
@if (outputFormGroup.get('decimalsByDefault').errors && outputFormGroup.get('decimalsByDefault').touched) {
|
||||||
|
<mat-error>{{ 'calculated-fields.hint.decimals-range' | translate }}</mat-error>
|
||||||
|
}
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|||||||
@ -33,7 +33,7 @@ import {
|
|||||||
OutputType,
|
OutputType,
|
||||||
OutputTypeTranslations
|
OutputTypeTranslations
|
||||||
} from '@shared/models/calculated-field.models';
|
} from '@shared/models/calculated-field.models';
|
||||||
import { oneSpaceInsideRegex } from '@shared/models/regex.constants';
|
import { digitsRegex, oneSpaceInsideRegex } from '@shared/models/regex.constants';
|
||||||
import { AttributeScope } from '@shared/models/telemetry/telemetry.models';
|
import { AttributeScope } from '@shared/models/telemetry/telemetry.models';
|
||||||
import { EntityType } from '@shared/models/entity-type.models';
|
import { EntityType } from '@shared/models/entity-type.models';
|
||||||
import { map, startWith, switchMap } from 'rxjs/operators';
|
import { map, startWith, switchMap } from 'rxjs/operators';
|
||||||
@ -61,7 +61,8 @@ export class CalculatedFieldDialogComponent extends DialogComponent<CalculatedFi
|
|||||||
output: this.fb.group({
|
output: this.fb.group({
|
||||||
name: ['', [Validators.required, Validators.pattern(oneSpaceInsideRegex), Validators.maxLength(255)]],
|
name: ['', [Validators.required, Validators.pattern(oneSpaceInsideRegex), Validators.maxLength(255)]],
|
||||||
scope: [{ value: AttributeScope.SERVER_SCOPE, disabled: true }],
|
scope: [{ value: AttributeScope.SERVER_SCOPE, disabled: true }],
|
||||||
type: [OutputType.Timeseries]
|
type: [OutputType.Timeseries],
|
||||||
|
decimalsByDefault: [null as number, [Validators.min(0), Validators.max(15), Validators.pattern(digitsRegex)]],
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -64,6 +64,7 @@ export interface CalculatedFieldOutput {
|
|||||||
type: OutputType;
|
type: OutputType;
|
||||||
name: string;
|
name: string;
|
||||||
scope?: AttributeScope;
|
scope?: AttributeScope;
|
||||||
|
decimalsByDefault?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ArgumentEntityType {
|
export enum ArgumentEntityType {
|
||||||
|
|||||||
@ -17,3 +17,5 @@
|
|||||||
export const oneSpaceInsideRegex = /^\s*\S+(?:\s\S+)*\s*$/;
|
export const oneSpaceInsideRegex = /^\s*\S+(?:\s\S+)*\s*$/;
|
||||||
|
|
||||||
export const charsWithNumRegex = /^[a-zA-Z]+[a-zA-Z0-9]*$/;
|
export const charsWithNumRegex = /^[a-zA-Z]+[a-zA-Z0-9]*$/;
|
||||||
|
|
||||||
|
export const digitsRegex = /^\d*$/;
|
||||||
|
|||||||
@ -1015,6 +1015,7 @@
|
|||||||
"script": "Script"
|
"script": "Script"
|
||||||
},
|
},
|
||||||
"arguments": "Arguments",
|
"arguments": "Arguments",
|
||||||
|
"decimals-by-default": "Decimals by default",
|
||||||
"debugging": "Calculated field debugging",
|
"debugging": "Calculated field debugging",
|
||||||
"argument-name": "Argument name",
|
"argument-name": "Argument name",
|
||||||
"datasource": "Datasource",
|
"datasource": "Datasource",
|
||||||
@ -1071,6 +1072,7 @@
|
|||||||
"argument-name-max-length": "Argument name should be less than 256 characters.",
|
"argument-name-max-length": "Argument name should be less than 256 characters.",
|
||||||
"argument-type-required": "Argument type is required.",
|
"argument-type-required": "Argument type is required.",
|
||||||
"max-args": "Maximum number of arguments reached.",
|
"max-args": "Maximum number of arguments reached.",
|
||||||
|
"decimals-range": "Decimals by default should be a number between 0 and 15.",
|
||||||
"expression": "Default expression demonstrates how to transform a temperature from Fahrenheit to Celsius."
|
"expression": "Default expression demonstrates how to transform a temperature from Fahrenheit to Celsius."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user