datasource.component.html
5.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!--
    Copyright © 2016-2024 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.
-->
<section class="tb-datasource-section" [formGroup]="datasourceFormGroup">
  <mat-form-field *ngIf="!basicMode" class="tb-datasource-type" hideRequiredMarker>
    <mat-label translate>widget-config.datasource-type</mat-label>
    <mat-select formControlName="type">
      <mat-option *ngFor="let datasourceType of datasourceTypes" [value]="datasourceType">
        {{ datasourceTypesTranslations.get(datasourceType) | translate }}
      </mat-option>
    </mat-select>
  </mat-form-field>
  <section fxLayout="column" [ngSwitch]="datasourceFormGroup.get('type').value">
    <ng-template [ngSwitchCase]="datasourceType.function">
      <mat-form-field *ngIf="!hideDatasourceLabel" fxFlex>
        <mat-label translate>datasource.label</mat-label>
        <input matInput
               formControlName="name">
      </mat-form-field>
    </ng-template>
    <ng-template [ngSwitchCase]="datasourceFormGroup.get('type').value === datasourceType.device ||
                                 datasourceFormGroup.get('type').value === datasourceType.entity ||
                                 datasourceFormGroup.get('type').value === datasourceType.entityCount ||
                                 datasourceFormGroup.get('type').value === datasourceType.alarmCount ? datasourceFormGroup.get('type').value : ''">
      <tb-alarm-filter-config *ngIf="datasourceFormGroup.get('type').value === datasourceType.alarmCount"
                              propagatedFilter="false"
                              [initialAlarmFilterConfig]="{ statusList: [alarmSearchStatus.ACTIVE] }"
                              style="height: 56px; margin-bottom: 22px;"
                              formControlName="alarmFilterConfig"></tb-alarm-filter-config>
      <tb-entity-autocomplete *ngIf="datasourceFormGroup.get('type').value === datasourceType.device"
                              [required]="!datasourcesOptional"
                              [entityType]="entityType.DEVICE"
                              formControlName="deviceId">
      </tb-entity-autocomplete>
      <tb-entity-alias-select
        *ngIf="datasourceFormGroup.get('type').value !== datasourceType.device && datasourceFormGroup.get('type').value !== datasourceType.alarmCount"
        [showLabel]="true"
        [tbRequired]="!datasourcesOptional"
        [aliasController]="aliasController"
        formControlName="entityAliasId"
        [callbacks]="entityAliasSelectCallbacks">
      </tb-entity-alias-select>
      <mat-form-field *ngIf="!hideDatasourceLabel && [datasourceType.entityCount, datasourceType.alarmCount].includes(datasourceFormGroup.get('type').value)"
                      fxFlex>
        <input matInput
               placeholder="{{ 'datasource.label' | translate }}"
               formControlName="name">
      </mat-form-field>
    </ng-template>
  </section>
  <section *ngIf="!hideDataKeys" fxLayout="column" fxLayoutAlign="stretch" fxFlex>
    <tb-data-keys class="tb-data-keys" fxFlex
                  [widgetType]="widgetType"
                  [datasourceType]="datasourceFormGroup.get('type').value"
                  [maxDataKeys]="maxDataKeys"
                  [optDataKeys]="isDataKeysOptional(datasourceFormGroup.get('type').value)"
                  [simpleDataKeysLabel]="!hasAdditionalLatestDataKeys"
                  [aliasController]="aliasController"
                  [datakeySettingsSchema]="dataKeySettingsSchema"
                  [dataKeySettingsDirective]="dataKeySettingsDirective"
                  [datakeySettingsFunction]="dataKeySettingsFunction"
                  [dashboard]="dashboard"
                  [widget]="widget"
                  [callbacks]="dataKeysCallbacks"
                  [entityAliasId]="datasourceFormGroup.get('entityAliasId').value"
                  [deviceId]="datasourceFormGroup.get('deviceId').value"
                  formControlName="dataKeys">
    </tb-data-keys>
    <tb-data-keys *ngIf="hasAdditionalLatestDataKeys" class="tb-data-keys" fxFlex
                  [widgetType]="widgetTypes.latest"
                  [datasourceType]="datasourceFormGroup.get('type').value"
                  latestDataKeys
                  [optDataKeys]="true"
                  [aliasController]="aliasController"
                  [datakeySettingsSchema]="latestDataKeySettingsSchema"
                  [dataKeySettingsDirective]="latestDataKeySettingsDirective"
                  [datakeySettingsFunction]="dataKeySettingsFunction"
                  [dashboard]="dashboard"
                  [widget]="widget"
                  [callbacks]="dataKeysCallbacks"
                  [entityAliasId]="datasourceFormGroup.get('entityAliasId').value"
                  [deviceId]="datasourceFormGroup.get('deviceId').value"
                  formControlName="latestDataKeys">
    </tb-data-keys>
  </section>
  <tb-filter-select
    *ngIf="(!basicMode || displayDatasourceFilterForBasicMode) && ![datasourceType.function, datasourceType.alarmCount].includes(datasourceFormGroup.get('type').value)"
    [showLabel]="true"
    [aliasController]="aliasController"
    formControlName="filterId"
    [callbacks]="filterSelectCallbacks">
  </tb-filter-select>
</section>