Open-source IoT Platform - Device management, data collection, processing and visualization.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

81 lines
4.1 KiB

<!--
SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
-->
<section class="tb-kv-map flex flex-col" [formGroup]="kvListFormGroup">
<label translate class="tb-title">{{ titleText }}</label>
@for (keyValControl of keyValsFormArray().controls; track $index) {
<div class="flex flex-row justify-start gap-2" [class.items-center]="!secretValues" [class.items-start]="secretValues" [class.mb-1]="!$last" formArrayName="keyVals">
<mat-form-field class="mat-block flex-1" subscriptSizing="{{ subscriptSizing }}" [appearance]="appearance">
<input [formControl]="keyValControl.get('key')" matInput required
placeholder="{{ (keyPlaceholderText ? keyPlaceholderText : 'key-val.key') | translate }}{{ showRequiredErrors ? '*' : '' }}"/>
@if (showRequiredErrors && keyValControl.get('key').hasError('required')) {
<mat-error tbTruncateWithTooltip translate>key-val.key-required</mat-error>
}
</mat-form-field>
@if (secretValues) {
<tb-secret-key-input class="flex-1"
[formControl]="keyValControl.get('value')"
[required]="isValueRequired"
[appearance]="appearance"
[requiredText]="showRequiredErrors ? ('key-val.value-required' | translate) : ''"
placeholder="{{ (valuePlaceholderText ? valuePlaceholderText : 'key-val.value') | translate }}{{ showRequiredErrors && isValueRequired ? '*' : '' }}">
</tb-secret-key-input>
} @else {
<mat-form-field class="mat-block flex-1" subscriptSizing="{{ subscriptSizing }}" [appearance]="appearance">
<input [formControl]="keyValControl.get('value')" matInput [required]="isValueRequired"
placeholder="{{ (valuePlaceholderText ? valuePlaceholderText : 'key-val.value') | translate }}{{ showRequiredErrors && isValueRequired ? '*' : '' }}"/>
@if (showRequiredErrors && keyValControl.get('value').hasError('required')) {
<mat-error tbTruncateWithTooltip translate>key-val.value-required</mat-error>
}
</mat-form-field>
}
<button mat-icon-button color="primary" [class.mt-1]="secretValues"
[class.!hidden]="disabled"
type="button"
(click)="removeKeyVal($index)"
[disabled]="isLoading$ | async"
matTooltip="{{ 'key-val.remove-entry' | translate }}"
matTooltipPosition="above">
<mat-icon>close</mat-icon>
</button>
</div>
}
<span [class]="{
'disabled': disabled,
'!hidden': keyValsFormArray().length
}"
class="no-data-found flex items-center justify-center" translate>{{noDataText ? noDataText : 'key-val.no-data'}}</span>
@if (secretValues || secretHint) {
<div class="tb-form-hint tb-primary-fill mt-2">
<mat-icon>info_outline</mat-icon>
<span [innerHTML]="(secretValues ? 'secret-storage.picker-hint' : 'secret-storage.placeholder-hint') | translate | safe: 'html'"></span>
</div>
}
<div style="margin-top: 8px;">
@if (!isStrokedButton) {
<button mat-button mat-raised-button color="primary"
[class.!hidden]="disabled || (isSingleMode && keyValsFormArray().length)"
[disabled]="isLoading$ | async"
(click)="addKeyVal()"
type="button"
matTooltip="{{ 'key-val.add-entry' | translate }}"
matTooltipPosition="above">
{{ 'action.add' | translate }}
</button>
} @else {
<button mat-button mat-stroked-button color="primary"
[class.!hidden]="disabled || (isSingleMode && keyValsFormArray().length)"
[disabled]="isLoading$ | async"
(click)="addKeyVal()"
type="button"
matTooltip="{{ 'key-val.add-entry' | translate }}"
matTooltipPosition="above">
{{ 'action.add' | translate }}
</button>
}
</div>
</section>