2019-08-29 20:04:59 +03:00
|
|
|
<!--
|
|
|
|
|
|
2024-01-09 10:46:16 +02:00
|
|
|
Copyright © 2016-2024 The Thingsboard Authors
|
2019-08-29 20:04:59 +03:00
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
|
limitations under the License.
|
|
|
|
|
|
|
|
|
|
-->
|
|
|
|
|
<form #inputForm="ngForm">
|
2024-01-23 20:03:14 +02:00
|
|
|
<section [fxLayout]="computedLayout" fxLayoutGap="8px">
|
|
|
|
|
<mat-form-field *ngIf="showValueType" appearance="outline" subscriptSizing="dynamic" class="tb-value-type tb-inline-field" [class]="computedLayout">
|
|
|
|
|
<mat-select [disabled]="disabled" name="valueType" [(ngModel)]="valueType" (ngModelChange)="onValueTypeChanged()">
|
2019-08-29 20:04:59 +03:00
|
|
|
<mat-select-trigger>
|
2024-01-23 20:03:14 +02:00
|
|
|
<div class="tb-value-type-row">
|
|
|
|
|
<mat-icon class="tb-mat-18" svgIcon="{{ valueTypes.get(valueType).icon }}"></mat-icon>
|
|
|
|
|
<span>{{ valueTypes.get(valueType).name | translate }}</span>
|
|
|
|
|
</div>
|
2019-08-29 20:04:59 +03:00
|
|
|
</mat-select-trigger>
|
|
|
|
|
<mat-option *ngFor="let valueType of valueTypeKeys" [value]="valueType">
|
2024-01-23 20:03:14 +02:00
|
|
|
<mat-icon class="tb-mat-20" svgIcon="{{ valueTypes.get(valueTypeEnum[valueType]).icon }}"></mat-icon>
|
2020-02-04 15:14:17 +02:00
|
|
|
<span>{{ valueTypes.get(valueTypeEnum[valueType]).name | translate }}</span>
|
2019-08-29 20:04:59 +03:00
|
|
|
</mat-option>
|
|
|
|
|
</mat-select>
|
|
|
|
|
</mat-form-field>
|
2024-01-23 20:03:14 +02:00
|
|
|
<mat-form-field *ngIf="valueType === valueTypeEnum.STRING" fxFlex appearance="outline" subscriptSizing="dynamic" class="tb-inline-field flex tb-suffix-absolute">
|
|
|
|
|
<input [disabled]="disabled" matInput required name="value" #value="ngModel" [(ngModel)]="modelValue" (ngModelChange)="onValueChanged()"
|
|
|
|
|
placeholder="{{ 'value.string-value' | translate }}*"/>
|
|
|
|
|
<mat-icon matSuffix
|
|
|
|
|
matTooltipPosition="above"
|
|
|
|
|
matTooltipClass="tb-error-tooltip"
|
|
|
|
|
[matTooltip]="(requiredText ? requiredText : 'value.string-value-required') | translate"
|
|
|
|
|
*ngIf="value.hasError('required') && value.control.touched"
|
|
|
|
|
class="tb-error">
|
|
|
|
|
warning
|
|
|
|
|
</mat-icon>
|
2019-08-29 20:04:59 +03:00
|
|
|
</mat-form-field>
|
2024-01-23 20:03:14 +02:00
|
|
|
<mat-form-field *ngIf="valueType === valueTypeEnum.INTEGER" fxFlex appearance="outline" subscriptSizing="dynamic" class="tb-inline-field flex tb-suffix-absolute number">
|
|
|
|
|
<input [disabled]="disabled" matInput required name="value" type="number" step="1" pattern="^-?[0-9]+$" #value="ngModel" [(ngModel)]="modelValue" (ngModelChange)="onValueChanged()"
|
|
|
|
|
placeholder="{{ 'value.integer-value' | translate }}*"/>
|
|
|
|
|
<mat-icon matSuffix
|
|
|
|
|
matTooltipPosition="above"
|
|
|
|
|
matTooltipClass="tb-error-tooltip"
|
|
|
|
|
[matTooltip]="value.hasError('required') ? ((requiredText ? requiredText : 'value.integer-value-required') | translate) :
|
|
|
|
|
('value.invalid-integer-value' | translate)"
|
|
|
|
|
*ngIf="value.control.invalid && value.control.touched"
|
|
|
|
|
class="tb-error">
|
|
|
|
|
warning
|
|
|
|
|
</mat-icon>
|
2019-08-29 20:04:59 +03:00
|
|
|
</mat-form-field>
|
2024-01-23 20:03:14 +02:00
|
|
|
<mat-form-field *ngIf="valueType === valueTypeEnum.DOUBLE" fxFlex appearance="outline" subscriptSizing="dynamic" class="tb-inline-field flex tb-suffix-absolute number">
|
|
|
|
|
<input [disabled]="disabled" matInput required name="value" type="number" step="any" #value="ngModel" [(ngModel)]="modelValue" (ngModelChange)="onValueChanged()"
|
|
|
|
|
placeholder="{{ 'value.double-value' | translate }}*"/>
|
|
|
|
|
<mat-icon matSuffix
|
|
|
|
|
matTooltipPosition="above"
|
|
|
|
|
matTooltipClass="tb-error-tooltip"
|
|
|
|
|
[matTooltip]="(requiredText ? requiredText : 'value.double-value-required') | translate"
|
|
|
|
|
*ngIf="value.hasError('required') && value.control.touched"
|
|
|
|
|
class="tb-error">
|
|
|
|
|
warning
|
|
|
|
|
</mat-icon>
|
2019-08-29 20:04:59 +03:00
|
|
|
</mat-form-field>
|
2024-01-23 20:03:14 +02:00
|
|
|
<mat-chip-listbox *ngIf="valueType === valueTypeEnum.BOOLEAN" fxFlex class="tb-boolean-input center-stretch"
|
|
|
|
|
[disabled]="disabled" name="value" #value="ngModel" [(ngModel)]="modelValue" (ngModelChange)="onValueChanged()">
|
|
|
|
|
<mat-chip-option [selectable]="!modelValue" [value]="true">{{ trueLabel | translate }}</mat-chip-option>
|
|
|
|
|
<mat-chip-option [selectable]="modelValue" [value]="false">{{ falseLabel | translate }}</mat-chip-option>
|
|
|
|
|
</mat-chip-listbox>
|
|
|
|
|
<div *ngIf="valueType === valueTypeEnum.JSON" fxFlex fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
|
|
|
|
|
<mat-form-field fxFlex appearance="outline" subscriptSizing="dynamic" class="tb-inline-field flex tb-suffix-absolute">
|
2020-03-02 17:55:29 +02:00
|
|
|
<input [disabled]="disabled" matInput tb-json-to-string required name="value" #value="ngModel"
|
2024-01-23 20:03:14 +02:00
|
|
|
[(ngModel)]="modelValue" (ngModelChange)="onValueChanged()" placeholder="{{ 'value.json-value' | translate }}*"/>
|
|
|
|
|
<mat-icon matSuffix
|
|
|
|
|
matTooltipPosition="above"
|
|
|
|
|
matTooltipClass="tb-error-tooltip"
|
|
|
|
|
[matTooltip]="value.hasError('invalidJSON') ?
|
|
|
|
|
('value.json-value-invalid' | translate) :
|
|
|
|
|
((requiredText ? requiredText : 'value.json-value-required') | translate)"
|
|
|
|
|
*ngIf="value.control.invalid && value.control.touched"
|
|
|
|
|
class="tb-error">
|
|
|
|
|
warning
|
|
|
|
|
</mat-icon>
|
2020-03-02 17:55:29 +02:00
|
|
|
</mat-form-field>
|
2024-01-23 20:03:14 +02:00
|
|
|
<button mat-icon-button class="tb-mat-32" (click)="openEditJSONDialog($event)">
|
|
|
|
|
<mat-icon class="tb-mat-20">open_in_new</mat-icon>
|
|
|
|
|
</button>
|
2020-03-02 17:55:29 +02:00
|
|
|
</div>
|
2019-08-29 20:04:59 +03:00
|
|
|
</section>
|
|
|
|
|
</form>
|