2019-10-17 18:23:53 +03:00
|
|
|
<!--
|
|
|
|
|
|
2023-01-31 10:43:56 +02:00
|
|
|
Copyright © 2016-2023 The Thingsboard Authors
|
2019-10-17 18:23:53 +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.
|
|
|
|
|
|
|
|
|
|
-->
|
2023-02-23 19:01:53 +02:00
|
|
|
<mat-form-field [formGroup]="keysListFormGroup" class="mat-block tb-chip-list">
|
2023-02-24 19:25:19 +02:00
|
|
|
<mat-chip-grid #chipList formControlName="keys">
|
|
|
|
|
<div class="tb-datakeys-container"
|
|
|
|
|
[dndDropzone]="[dndId]"
|
|
|
|
|
[dndHorizontal]="true"
|
|
|
|
|
dndEffectAllowed="move"
|
|
|
|
|
dndAllowExternal="false"
|
|
|
|
|
[dndDisableIf]="disabled"
|
|
|
|
|
(dndDrop)="onChipDrop($event)">
|
|
|
|
|
<mat-chip-row #placeholderChipRow
|
|
|
|
|
dndPlaceholderRef
|
|
|
|
|
class="tb-datakey-chip tb-datakey-chip-dnd-placeholder">
|
|
|
|
|
</mat-chip-row>
|
|
|
|
|
<mat-chip-row #chipRow *ngFor="let key of keys; let $index = index"
|
|
|
|
|
class="tb-datakey-chip"
|
|
|
|
|
(dndStart)="chipDragStart($index, chipRow, placeholderChipRow)"
|
|
|
|
|
(dndEnd)="chipDragEnd()"
|
|
|
|
|
[dndDraggable]="key"
|
|
|
|
|
[dndDisableIf]="disabled"
|
|
|
|
|
dndType="{{ dndId }}"
|
|
|
|
|
dndEffectAllowed="move"
|
|
|
|
|
dndDraggingSourceClass="tb-chip-dragging"
|
|
|
|
|
[removable]="!disabled && !isEntityCountDatasource"
|
|
|
|
|
(removed)="remove(key)">
|
|
|
|
|
<div dndDragImageRef fxLayout="row" fxLayoutAlign="start center" class="tb-attribute-chip"
|
|
|
|
|
[ngClass]="{'tb-dragging-chip-image': $index === dragIndex}">
|
|
|
|
|
<div class="tb-absolute-fill tb-dragging-chip-image-fill"></div>
|
|
|
|
|
<div dndHandle *ngIf="!disabled" class="tb-chip-drag-handle" style="margin-right: 5px;">
|
|
|
|
|
<mat-icon class="tb-mat-20">drag_handle</mat-icon>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="tb-color-preview" (click)="showColorPicker(key)" style="margin-right: 5px;">
|
|
|
|
|
<div class="tb-color-result" [ngStyle]="{background: key.color}"></div>
|
2019-10-17 18:23:53 +03:00
|
|
|
</div>
|
2023-02-24 19:25:19 +02:00
|
|
|
<div class="tb-chip-labels">
|
|
|
|
|
<div class="tb-chip-label">
|
|
|
|
|
<ng-container *ngIf="datasourceType === datasourceTypes.entity">
|
|
|
|
|
<mat-icon class="tb-mat-20 tb-datakey-icon" *ngIf="key.type === dataKeyTypes.alarm"
|
|
|
|
|
matTooltip="{{'datakey.alarm' | translate }}"
|
|
|
|
|
matTooltipPosition="above">notifications</mat-icon>
|
|
|
|
|
<mat-icon class="tb-mat-20 tb-datakey-icon" *ngIf="key.type === dataKeyTypes.attribute"
|
|
|
|
|
matTooltip="{{'datakey.attributes' | translate }}"
|
|
|
|
|
matTooltipPosition="above" svgIcon="mdi:alpha-a-circle-outline"></mat-icon>
|
|
|
|
|
<mat-icon class="tb-mat-20 tb-datakey-icon" *ngIf="key.type === dataKeyTypes.entityField"
|
|
|
|
|
matTooltip="{{'datakey.entity-field' | translate }}"
|
|
|
|
|
matTooltipPosition="above" svgIcon="mdi:alpha-e-circle-outline"></mat-icon>
|
|
|
|
|
<mat-icon class="tb-mat-20 tb-datakey-icon" *ngIf="key.type === dataKeyTypes.timeseries"
|
|
|
|
|
matTooltip="{{'datakey.timeseries' | translate }}"
|
|
|
|
|
matTooltipPosition="above">timeline</mat-icon>
|
|
|
|
|
</ng-container>
|
|
|
|
|
{{key.label}}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="tb-chip-separator">: </div>
|
|
|
|
|
<div class="tb-chip-label">
|
|
|
|
|
<strong>
|
|
|
|
|
<ng-container *ngTemplateOutlet="keyName; context:{key: key}"></ng-container>
|
|
|
|
|
</strong>
|
|
|
|
|
</div>
|
2023-02-23 19:01:53 +02:00
|
|
|
</div>
|
2023-02-24 19:25:19 +02:00
|
|
|
<button *ngIf="!disabled"
|
|
|
|
|
type="button"
|
|
|
|
|
(click)="editDataKey(key, $index)" mat-icon-button class="tb-mat-32">
|
|
|
|
|
<mat-icon class="tb-mat-20">edit</mat-icon>
|
|
|
|
|
</button>
|
|
|
|
|
<mat-icon matChipRemove *ngIf="!disabled && !isEntityCountDatasource">close</mat-icon>
|
2019-10-17 18:23:53 +03:00
|
|
|
</div>
|
2023-02-24 19:25:19 +02:00
|
|
|
</mat-chip-row>
|
|
|
|
|
<input matInput type="text" placeholder="{{ !disabled ? (keys.length ? secondaryPlaceholder : placeholder) : '' }}"
|
|
|
|
|
[ngClass]="{'tb-dragging': dragIndex > -1}"
|
|
|
|
|
style="max-width: 200px;"
|
|
|
|
|
#keyInput
|
|
|
|
|
formControlName="key"
|
|
|
|
|
matAutocompleteOrigin
|
|
|
|
|
[readonly]="isEntityCountDatasource"
|
|
|
|
|
#origin="matAutocompleteOrigin"
|
|
|
|
|
[matAutocompleteConnectedTo]="origin"
|
|
|
|
|
(focusin)="onFocus()"
|
|
|
|
|
(drop)="$event.preventDefault();"
|
|
|
|
|
[matAutocomplete]="keyAutocomplete"
|
|
|
|
|
[matAutocompleteDisabled]="isEntityCountDatasource"
|
|
|
|
|
[matChipInputFor]="chipList"
|
|
|
|
|
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
|
|
|
|
|
(matChipInputTokenEnd)="add($event)">
|
|
|
|
|
</div>
|
2023-02-17 19:24:01 +02:00
|
|
|
</mat-chip-grid>
|
2019-10-17 18:23:53 +03:00
|
|
|
<mat-autocomplete #keyAutocomplete="matAutocomplete"
|
|
|
|
|
class="tb-autocomplete"
|
2023-02-23 19:01:53 +02:00
|
|
|
panelWidth="fit-content"
|
2019-10-17 18:23:53 +03:00
|
|
|
[displayWith]="displayKeyFn">
|
|
|
|
|
<mat-option *ngFor="let key of filteredKeys | async" [value]="key">
|
|
|
|
|
<span style="white-space: nowrap;">
|
2023-02-23 19:01:53 +02:00
|
|
|
<ng-container *ngIf="datasourceType === datasourceTypes.entity">
|
|
|
|
|
<mat-icon class="tb-datakey-icon" *ngIf="key.type === dataKeyTypes.alarm"
|
|
|
|
|
matTooltip="{{'datakey.alarm' | translate }}"
|
|
|
|
|
matTooltipPosition="above">notifications</mat-icon>
|
|
|
|
|
<mat-icon class="tb-datakey-icon" *ngIf="key.type === dataKeyTypes.attribute"
|
|
|
|
|
matTooltip="{{'datakey.attributes' | translate }}"
|
|
|
|
|
matTooltipPosition="above" svgIcon="mdi:alpha-a-circle-outline"></mat-icon>
|
|
|
|
|
<mat-icon class="tb-datakey-icon" *ngIf="key.type === dataKeyTypes.entityField"
|
|
|
|
|
matTooltip="{{'datakey.entity-field' | translate }}"
|
|
|
|
|
matTooltipPosition="above" svgIcon="mdi:alpha-e-circle-outline"></mat-icon>
|
|
|
|
|
<mat-icon class="tb-datakey-icon" *ngIf="key.type === dataKeyTypes.timeseries"
|
|
|
|
|
matTooltip="{{'datakey.timeseries' | translate }}"
|
|
|
|
|
matTooltipPosition="above">timeline</mat-icon>
|
|
|
|
|
</ng-container>
|
2019-10-17 18:23:53 +03:00
|
|
|
<span [innerHTML]="key.name | highlight:searchText"></span>
|
|
|
|
|
</span>
|
|
|
|
|
</mat-option>
|
|
|
|
|
<mat-option *ngIf="!(filteredKeys | async)?.length" [value]="null" class="tb-not-found">
|
|
|
|
|
<div class="tb-not-found-content" (click)="$event.stopPropagation()">
|
|
|
|
|
<div *ngIf="!textIsNotEmpty(searchText); else searchNotEmpty">
|
|
|
|
|
<span translate>entity.no-keys-found</span>
|
|
|
|
|
</div>
|
|
|
|
|
<ng-template #searchNotEmpty>
|
|
|
|
|
<span>
|
|
|
|
|
{{ translate.get('entity.no-key-matching',
|
|
|
|
|
{key: truncate.transform(searchText, true, 6, '...')}) | async }}
|
|
|
|
|
</span>
|
2021-03-09 17:05:35 +02:00
|
|
|
<span *ngIf="datasourceType !== datasourceTypes.entity; else createEntityKey">
|
2019-10-17 18:23:53 +03:00
|
|
|
<a translate (click)="createKey(searchText)">entity.create-new-key</a>
|
|
|
|
|
</span>
|
|
|
|
|
<ng-template #createEntityKey>
|
|
|
|
|
<span>{{'entity.create-new-key' | translate }} </span>
|
2023-02-23 19:01:53 +02:00
|
|
|
<mat-icon class="tb-datakey-icon new-key" *ngIf="widgetType === widgetTypes.alarm"
|
|
|
|
|
matTooltip="{{'datakey.alarm' | translate }}"
|
|
|
|
|
matTooltipPosition="above"
|
|
|
|
|
(click)="createKey(searchText, dataKeyTypes.alarm)">notifications</mat-icon>
|
|
|
|
|
<mat-icon class="tb-datakey-icon new-key" *ngIf="widgetType === widgetTypes.latest || widgetType === widgetTypes.alarm"
|
|
|
|
|
matTooltip="{{'datakey.attributes' | translate }}"
|
|
|
|
|
matTooltipPosition="above" svgIcon="mdi:alpha-a-circle-outline"
|
|
|
|
|
(click)="createKey(searchText, dataKeyTypes.attribute)"></mat-icon>
|
|
|
|
|
<mat-icon class="tb-datakey-icon new-key" *ngIf="widgetType === widgetTypes.latest || widgetType === widgetTypes.alarm"
|
|
|
|
|
matTooltip="{{'datakey.entity-field' | translate }}"
|
|
|
|
|
matTooltipPosition="above" svgIcon="mdi:alpha-e-circle-outline"
|
|
|
|
|
(click)="createKey(searchText, dataKeyTypes.entityField)"></mat-icon>
|
|
|
|
|
<mat-icon class="tb-datakey-icon new-key"
|
|
|
|
|
matTooltip="{{'datakey.timeseries' | translate }}"
|
|
|
|
|
matTooltipPosition="above"
|
|
|
|
|
(click)="createKey(searchText, dataKeyTypes.timeseries)">timeline</mat-icon>
|
2019-10-17 18:23:53 +03:00
|
|
|
</ng-template>
|
|
|
|
|
</ng-template>
|
|
|
|
|
</div>
|
|
|
|
|
</mat-option>
|
|
|
|
|
</mat-autocomplete>
|
|
|
|
|
<mat-error *ngIf="keysListFormGroup.get('keys').hasError('required')">
|
|
|
|
|
{{ requiredText }}
|
|
|
|
|
</mat-error>
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
<div class="mat-caption" style="color: rgba(0,0,0,0.57);" *ngIf="maxDataKeys !== null && maxDataKeys > -1">
|
|
|
|
|
{{ maxDataKeysText() }}
|
|
|
|
|
</div>
|
2023-02-23 19:01:53 +02:00
|
|
|
<ng-template #keyName let-key="key">
|
|
|
|
|
<ng-container *ngIf="dataKeyHasPostprocessing(key); else keyName">
|
|
|
|
|
<span>f(</span><ng-container *ngTemplateOutlet="keyNameTemplate; context:{key: key}"></ng-container><span>)</span>
|
|
|
|
|
</ng-container>
|
|
|
|
|
<ng-template #keyName>
|
|
|
|
|
<ng-container *ngTemplateOutlet="keyNameTemplate; context:{key: key}"></ng-container>
|
|
|
|
|
</ng-template>
|
|
|
|
|
</ng-template>
|
|
|
|
|
<ng-template #keyNameTemplate let-key="key">
|
|
|
|
|
<ng-container *ngIf="dataKeyHasAggregation(key); else keyName;">
|
|
|
|
|
<span class="tb-agg-func">{{ key.aggregationType }}</span><span>({{ key.name }})</span>
|
|
|
|
|
</ng-container>
|
|
|
|
|
<ng-template #keyName>
|
|
|
|
|
<span>{{key.name}}</span>
|
|
|
|
|
</ng-template>
|
|
|
|
|
</ng-template>
|