2023-05-19 17:54:27 +03:00
|
|
|
<!--
|
|
|
|
|
|
|
|
|
|
Copyright © 2016-2023 The Thingsboard Authors
|
|
|
|
|
|
|
|
|
|
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-07-06 12:43:15 +03:00
|
|
|
<div [formGroup]="datasourcesFormGroup" class="tb-form-panel tb-datasources" [ngClass]="{'no-padding-bottom': !showAddDatasource}">
|
2023-05-19 17:54:27 +03:00
|
|
|
<div fxLayout="column">
|
2023-05-30 12:37:47 +03:00
|
|
|
<div fxLayout="row" fxLayoutAlign="space-between center">
|
2023-07-06 12:43:15 +03:00
|
|
|
<div class="tb-form-panel-title">{{ (singleDatasource ? (isAlarmSource ? 'widget-config.alarm-source' : 'widget-config.datasource') : 'widget-config.datasources') | translate }}</div>
|
2023-05-19 17:54:27 +03:00
|
|
|
<div fxFlex fxLayout="row" fxLayoutAlign="center center" *ngIf="timeseriesKeyError">
|
|
|
|
|
<mat-error >{{ 'widget-config.timeseries-key-error' | translate }}</mat-error>
|
|
|
|
|
</div>
|
2023-09-14 18:45:22 +03:00
|
|
|
<tb-toggle-select *ngIf="basicMode && !hideDatasourcesMode" [ngModel]="datasourcesMode" (ngModelChange)="datasourcesModeChange($event)"
|
2023-07-03 17:09:35 +03:00
|
|
|
[ngModelOptions]="{ standalone: true }">
|
|
|
|
|
<tb-toggle-option [value]="datasourceType.device">{{ 'device.device' | translate }}</tb-toggle-option>
|
|
|
|
|
<tb-toggle-option [value]="datasourceType.entity">{{ 'entity.entity-alias' | translate }}</tb-toggle-option>
|
|
|
|
|
</tb-toggle-select>
|
2023-05-19 17:54:27 +03:00
|
|
|
</div>
|
|
|
|
|
<div *ngIf="maxDatasources > 1"
|
2023-07-06 12:43:15 +03:00
|
|
|
class="tb-form-panel-hint">{{ 'widget-config.maximum-datasources' | translate:{count: maxDatasources} }}</div>
|
2023-05-19 17:54:27 +03:00
|
|
|
</div>
|
|
|
|
|
<div *ngIf="datasourcesFormArray.length === 0; else datasourcesTemplate">
|
|
|
|
|
<span translate fxLayoutAlign="center center"
|
|
|
|
|
class="tb-prompt">datasource.add-datasource-prompt</span>
|
|
|
|
|
</div>
|
|
|
|
|
<ng-template #datasourcesTemplate>
|
|
|
|
|
<div style="overflow: auto;">
|
|
|
|
|
<mat-list class="tb-drop-list"
|
|
|
|
|
cdkDropList
|
|
|
|
|
cdkDropListOrientation="vertical"
|
|
|
|
|
(cdkDropListDropped)="onDatasourceDrop($event)"
|
|
|
|
|
[cdkDropListDisabled]="dragDisabled"
|
|
|
|
|
formArrayName="datasources">
|
|
|
|
|
<mat-list-item *ngFor="let datasourceControl of datasourcesControls; trackBy: trackByDatasource; let $index = index;"
|
2023-08-03 19:26:35 +03:00
|
|
|
class="tb-datasource-list-item tb-draggable" cdkDrag
|
2023-05-19 17:54:27 +03:00
|
|
|
[cdkDragDisabled]="dragDisabled">
|
2023-08-03 19:26:35 +03:00
|
|
|
<div class="tb-datasource-row">
|
|
|
|
|
<div *ngIf="!singleDatasource" class="tb-datasource-index-container">
|
2023-05-19 17:54:27 +03:00
|
|
|
<div class="tb-datasource-index">{{$index + 1}}</div>
|
|
|
|
|
</div>
|
2023-08-03 19:26:35 +03:00
|
|
|
<div class="tb-datasource-params">
|
|
|
|
|
<div class="tb-datasource-item">
|
|
|
|
|
<tb-datasource [formControl]="datasourceControl">
|
2023-05-19 17:54:27 +03:00
|
|
|
</tb-datasource>
|
2023-08-03 19:26:35 +03:00
|
|
|
<div *ngIf="!singleDatasource && !disabled" class="tb-datasource-buttons">
|
|
|
|
|
<button class="tb-box-button" type="button"
|
|
|
|
|
mat-icon-button
|
2023-05-19 17:54:27 +03:00
|
|
|
(click)="removeDatasource($index)"
|
|
|
|
|
matTooltip="{{ 'widget-config.remove-datasource' | translate }}"
|
|
|
|
|
matTooltipPosition="above">
|
|
|
|
|
<mat-icon>delete</mat-icon>
|
|
|
|
|
</button>
|
|
|
|
|
<button *ngIf="!dragDisabled"
|
2023-08-03 19:26:35 +03:00
|
|
|
class="tb-box-button"
|
|
|
|
|
mat-icon-button
|
2023-05-19 17:54:27 +03:00
|
|
|
type="button"
|
|
|
|
|
cdkDragHandle
|
|
|
|
|
matTooltip="{{ 'action.drag' | translate }}"
|
|
|
|
|
matTooltipPosition="above">
|
|
|
|
|
<mat-icon>drag_indicator</mat-icon>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<tb-error class="tb-datasource-error" [error]="datasourceError[$index] ? datasourceError[$index] : ''"></tb-error>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</mat-list-item>
|
|
|
|
|
</mat-list>
|
|
|
|
|
</div>
|
|
|
|
|
</ng-template>
|
2023-05-25 17:03:52 +03:00
|
|
|
<div *ngIf="showAddDatasource">
|
2023-05-19 17:54:27 +03:00
|
|
|
<button type="button"
|
|
|
|
|
mat-stroked-button color="primary"
|
|
|
|
|
(click)="addDatasource()"
|
|
|
|
|
matTooltip="{{ 'widget-config.add-datasource' | translate }}"
|
|
|
|
|
matTooltipPosition="above">
|
|
|
|
|
<span translate>widget-config.add-datasource</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|