2023-07-07 17:27:59 +03:00
|
|
|
<!--
|
|
|
|
|
|
2025-02-25 09:39:16 +02:00
|
|
|
Copyright © 2016-2025 The Thingsboard Authors
|
2023-07-07 17:27: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.
|
|
|
|
|
|
|
|
|
|
-->
|
2025-04-25 17:56:36 +03:00
|
|
|
<mat-form-field appearance="outline" class="tb-inline-field tb-suffix-show-on-hover w-full flex-1" subscriptSizing="dynamic">
|
2023-07-07 17:27:59 +03:00
|
|
|
<input matInput #unitInput [formControl]="unitsFormControl"
|
|
|
|
|
placeholder="{{ 'widget-config.set' | translate }}"
|
|
|
|
|
(focusin)="onFocus()"
|
|
|
|
|
[matAutocomplete]="unitsAutocomplete">
|
2025-04-25 17:56:36 +03:00
|
|
|
<button type="button"
|
|
|
|
|
*ngIf="!disabled && allowConverted"
|
|
|
|
|
class="tb-icon-24"
|
|
|
|
|
[class.mr-2]="!unitsFormControl.value || disabled || unitsFormControl.invalid"
|
|
|
|
|
matSuffix mat-icon-button (click)="openConvertSettingsPopup($event)">
|
|
|
|
|
<tb-icon>mdi:tape-measure</tb-icon>
|
|
|
|
|
</button>
|
2023-09-12 15:07:33 +03:00
|
|
|
<button *ngIf="unitsFormControl.value && !disabled && unitsFormControl.valid"
|
2023-07-07 17:27:59 +03:00
|
|
|
type="button"
|
2025-03-12 13:47:03 +02:00
|
|
|
class="tb-icon-24 mr-2"
|
2023-07-07 17:27:59 +03:00
|
|
|
matSuffix mat-icon-button aria-label="Clear"
|
|
|
|
|
(click)="clear()">
|
|
|
|
|
<mat-icon class="material-icons">close</mat-icon>
|
|
|
|
|
</button>
|
2023-09-12 15:07:33 +03:00
|
|
|
<mat-icon matSuffix
|
|
|
|
|
matTooltipPosition="above"
|
|
|
|
|
matTooltipClass="tb-error-tooltip"
|
|
|
|
|
[matTooltip]="'widget-config.units-required' | translate"
|
|
|
|
|
*ngIf="unitsFormControl.hasError('required')" class="material-icons tb-suffix-show-always tb-error">
|
|
|
|
|
warning
|
|
|
|
|
</mat-icon>
|
2023-07-07 17:27:59 +03:00
|
|
|
<mat-autocomplete
|
|
|
|
|
#unitsAutocomplete="matAutocomplete"
|
|
|
|
|
class="tb-autocomplete tb-unit-input-autocomplete"
|
|
|
|
|
panelWidth="fit-content"
|
2025-04-25 17:56:36 +03:00
|
|
|
[displayWith]="displayUnitFn.bind(this)">
|
2025-04-28 18:27:35 +03:00
|
|
|
@for (group of filteredUnits | async; track group[0]) {
|
|
|
|
|
@if ((fetchUnits$ | async).length > 1) {
|
|
|
|
|
<mat-optgroup [label]="'unit.measures.' + group[0] | translate">
|
|
|
|
|
@for(unit of group[1]; track unit.abbr) {
|
|
|
|
|
<mat-option [value]="unit">
|
|
|
|
|
<span class="tb-unit-name flex-1" [innerHTML]="unit.name | highlight:searchText:true:'ig'"></span>
|
|
|
|
|
<span class="tb-unit-symbol" [innerHTML]="unit.abbr | highlight:searchText:true:'ig'"></span>
|
|
|
|
|
</mat-option>
|
|
|
|
|
}
|
|
|
|
|
</mat-optgroup>
|
|
|
|
|
} @else {
|
|
|
|
|
@for(unit of group[1]; track unit.abbr) {
|
|
|
|
|
<mat-option [value]="unit">
|
|
|
|
|
<span class="tb-unit-name flex-1" [innerHTML]="unit.name | highlight:searchText:true:'ig'"></span>
|
|
|
|
|
<span class="tb-unit-symbol" [innerHTML]="unit.abbr | highlight:searchText:true:'ig'"></span>
|
|
|
|
|
</mat-option>
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-04-25 17:56:36 +03:00
|
|
|
}
|
2023-07-07 17:27:59 +03:00
|
|
|
</mat-autocomplete>
|
|
|
|
|
</mat-form-field>
|