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-06-30 19:59:13 +03:00
|
|
|
<div *ngIf="dataKeyConfigMode === dataKeyConfigModes.general; else advanced"
|
2023-06-20 18:52:13 +03:00
|
|
|
[formGroup]="dataKeyFormGroup">
|
|
|
|
|
<div class="mat-padding" fxLayout="column" style="gap: 16px;">
|
2023-07-06 12:43:15 +03:00
|
|
|
<div class="tb-form-panel">
|
|
|
|
|
<div class="tb-form-panel-title" translate>datakey.general</div>
|
2023-06-20 18:52:13 +03:00
|
|
|
<mat-form-field *ngIf="modelValue.type !== dataKeyTypes.function" subscriptSizing="dynamic">
|
2019-10-17 18:23:53 +03:00
|
|
|
<mat-label>{{ 'entity.key' | translate }}</mat-label>
|
|
|
|
|
<input matInput type="text" placeholder="{{ 'entity.key-name' | translate }}"
|
|
|
|
|
#keyInput
|
|
|
|
|
formControlName="name"
|
|
|
|
|
required
|
|
|
|
|
[matAutocomplete]="keyAutocomplete">
|
2021-03-02 12:04:45 +02:00
|
|
|
<button *ngIf="dataKeyFormGroup.get('name').value && !dataKeyFormGroup.get('name').disabled"
|
2019-10-17 18:23:53 +03:00
|
|
|
type="button"
|
2020-04-21 11:53:26 +03:00
|
|
|
matSuffix mat-icon-button aria-label="Clear"
|
2019-10-17 18:23:53 +03:00
|
|
|
(click)="clearKey()">
|
|
|
|
|
<mat-icon class="material-icons">close</mat-icon>
|
|
|
|
|
</button>
|
|
|
|
|
<mat-autocomplete
|
|
|
|
|
class="tb-autocomplete"
|
|
|
|
|
#keyAutocomplete="matAutocomplete">
|
|
|
|
|
<mat-option *ngFor="let key of filteredKeys | async" [value]="key">
|
|
|
|
|
<span [innerHTML]="key | highlight:keySearchText"></span>
|
|
|
|
|
</mat-option>
|
|
|
|
|
</mat-autocomplete>
|
|
|
|
|
</mat-form-field>
|
2023-06-20 18:52:13 +03:00
|
|
|
<mat-form-field *ngIf="!hideDataKeyLabel" subscriptSizing="dynamic">
|
|
|
|
|
<mat-label translate>datakey.label</mat-label>
|
|
|
|
|
<input matInput formControlName="label" required>
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
<ng-container *ngIf="modelValue.type !== dataKeyTypes.alarm">
|
2023-07-06 12:43:15 +03:00
|
|
|
<div class="tb-form-row space-between" *ngIf="!hideDataKeyUnits">
|
2023-06-20 18:52:13 +03:00
|
|
|
<div translate>widget-config.units-short</div>
|
2023-07-07 17:27:59 +03:00
|
|
|
<tb-unit-input
|
2023-06-20 18:52:13 +03:00
|
|
|
formControlName="units">
|
2023-07-07 17:27:59 +03:00
|
|
|
</tb-unit-input>
|
2023-06-20 18:52:13 +03:00
|
|
|
</div>
|
2023-07-06 12:43:15 +03:00
|
|
|
<div class="tb-form-row space-between" *ngIf="!hideDataKeyDecimals">
|
2023-06-20 18:52:13 +03:00
|
|
|
<div translate>widget-config.decimals-short</div>
|
2023-06-30 19:59:13 +03:00
|
|
|
<mat-form-field appearance="outline" class="number" subscriptSizing="dynamic">
|
2023-06-20 18:52:13 +03:00
|
|
|
<input matInput formControlName="decimals" type="number" min="0" max="15" step="1" placeholder="{{ 'widget-config.set' | translate }}">
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
</div>
|
|
|
|
|
</ng-container>
|
2023-07-06 12:43:15 +03:00
|
|
|
<div class="tb-form-row space-between same-padding" *ngIf="!hideDataKeyColor">
|
2023-06-20 18:52:13 +03:00
|
|
|
<div>{{ 'datakey.color' | translate }}</div>
|
|
|
|
|
<div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="16px">
|
|
|
|
|
<mat-divider vertical></mat-divider>
|
|
|
|
|
<tb-color-input asBoxInput
|
|
|
|
|
formControlName="color">
|
|
|
|
|
</tb-color-input>
|
|
|
|
|
</div>
|
2019-10-17 18:23:53 +03:00
|
|
|
</div>
|
2023-06-20 18:52:13 +03:00
|
|
|
<ng-container *ngIf="widgetType === widgetTypes.latest && modelValue.type === dataKeyTypes.timeseries">
|
|
|
|
|
<mat-form-field subscriptSizing="dynamic">
|
2022-09-15 17:26:28 +03:00
|
|
|
<mat-label translate>datakey.aggregation</mat-label>
|
2022-09-14 17:49:37 +03:00
|
|
|
<mat-select formControlName="aggregationType" style="min-width: 150px;">
|
|
|
|
|
<mat-option *ngFor="let aggregation of aggregations" [value]="aggregation">
|
2022-09-15 17:26:28 +03:00
|
|
|
{{ aggregationTypesTranslations.get(aggregationTypes[aggregation]) | translate }}
|
2022-09-14 17:49:37 +03:00
|
|
|
</mat-option>
|
|
|
|
|
</mat-select>
|
|
|
|
|
</mat-form-field>
|
2022-09-26 15:57:41 +03:00
|
|
|
<div class="tb-hint after-fields">
|
|
|
|
|
{{ dataKeyFormGroup.get('aggregationType').value ? (dataKeyAggregationTypeHintTranslations.get(aggregationTypes[dataKeyFormGroup.get('aggregationType').value]) | translate) : '' }}
|
|
|
|
|
<section *ngIf="dataKeyFormGroup.get('aggregationType').value !== aggregationTypes.NONE">
|
|
|
|
|
{{ 'datakey.aggregation-type-hint-common' | translate }}
|
|
|
|
|
</section>
|
|
|
|
|
</div>
|
2022-09-14 17:49:37 +03:00
|
|
|
<fieldset *ngIf="dataKeyFormGroup.get('aggregationType').value && dataKeyFormGroup.get('aggregationType').value !== aggregationTypes.NONE" class="fields-group fields-group-slider">
|
2022-09-15 17:26:28 +03:00
|
|
|
<legend class="group-title" translate>datakey.delta-calculation</legend>
|
2022-10-05 11:11:27 +03:00
|
|
|
<mat-expansion-panel class="tb-settings comparison" [expanded]="dataKeyFormGroup.get('comparisonEnabled').value" [disabled]="!dataKeyFormGroup.get('comparisonEnabled').value">
|
2023-06-20 18:52:13 +03:00
|
|
|
<mat-expansion-panel-header fxLayout="row wrap" class="fill-width">
|
2023-02-23 19:01:53 +02:00
|
|
|
<mat-panel-title fxLayout="column" fxLayoutAlign="center start">
|
|
|
|
|
<mat-slide-toggle formControlName="comparisonEnabled" (click)="$event.stopPropagation()">
|
2022-09-15 17:26:28 +03:00
|
|
|
{{ 'datakey.enable-delta-calculation' | translate }}
|
2022-09-14 17:49:37 +03:00
|
|
|
</mat-slide-toggle>
|
2022-09-15 17:26:28 +03:00
|
|
|
<mat-hint class="tb-hint" style="line-height: 15px; padding-left: 45px;">{{ 'datakey.enable-delta-calculation-hint' | translate }}</mat-hint>
|
2022-09-14 17:49:37 +03:00
|
|
|
</mat-panel-title>
|
|
|
|
|
</mat-expansion-panel-header>
|
|
|
|
|
<ng-template matExpansionPanelContent>
|
|
|
|
|
<section fxLayout="column" *ngIf="dataKeyFormGroup.get('comparisonEnabled').value">
|
|
|
|
|
<mat-form-field fxFlex class="mat-block">
|
|
|
|
|
<mat-label translate>widgets.chart.time-for-comparison</mat-label>
|
|
|
|
|
<mat-select formControlName="timeForComparison">
|
|
|
|
|
<mat-option [value]="'previousInterval'">
|
|
|
|
|
{{ 'widgets.chart.time-for-comparison-previous-interval' | translate }}
|
|
|
|
|
</mat-option>
|
|
|
|
|
<mat-option [value]="'days'">
|
|
|
|
|
{{ 'widgets.chart.time-for-comparison-days' | translate }}
|
|
|
|
|
</mat-option>
|
|
|
|
|
<mat-option [value]="'weeks'">
|
|
|
|
|
{{ 'widgets.chart.time-for-comparison-weeks' | translate }}
|
|
|
|
|
</mat-option>
|
|
|
|
|
<mat-option [value]="'months'">
|
|
|
|
|
{{ 'widgets.chart.time-for-comparison-months' | translate }}
|
|
|
|
|
</mat-option>
|
|
|
|
|
<mat-option [value]="'years'">
|
|
|
|
|
{{ 'widgets.chart.time-for-comparison-years' | translate }}
|
|
|
|
|
</mat-option>
|
|
|
|
|
<mat-option [value]="'customInterval'">
|
|
|
|
|
{{ 'widgets.chart.time-for-comparison-custom-interval' | translate }}
|
|
|
|
|
</mat-option>
|
|
|
|
|
</mat-select>
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
<mat-form-field *ngIf="dataKeyFormGroup.get('timeForComparison').value === 'customInterval'" fxFlex class="mat-block">
|
|
|
|
|
<mat-label translate>widgets.chart.custom-interval-value</mat-label>
|
|
|
|
|
<input required matInput type="number" min="0" formControlName="comparisonCustomIntervalValue">
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
<mat-form-field style="padding-bottom: 16px;">
|
2022-09-15 17:26:28 +03:00
|
|
|
<mat-label translate>datakey.delta-calculation-result</mat-label>
|
2022-09-14 17:49:37 +03:00
|
|
|
<mat-select formControlName="comparisonResultType" style="min-width: 150px;">
|
|
|
|
|
<mat-option *ngFor="let comparisonResultType of comparisonResults" [value]="comparisonResultType">
|
|
|
|
|
{{ comparisonResultTypeTranslations.get(comparisonResultTypes[comparisonResultType]) | translate }}
|
|
|
|
|
</mat-option>
|
|
|
|
|
</mat-select>
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
</section>
|
|
|
|
|
</ng-template>
|
|
|
|
|
</mat-expansion-panel>
|
|
|
|
|
</fieldset>
|
2023-06-20 18:52:13 +03:00
|
|
|
</ng-container>
|
2019-10-17 18:23:53 +03:00
|
|
|
<section fxLayout="column" *ngIf="modelValue.type === dataKeyTypes.function">
|
|
|
|
|
<span translate>datakey.data-generation-func</span>
|
|
|
|
|
<br/>
|
|
|
|
|
<tb-js-func #funcBodyEdit
|
2023-06-20 18:52:13 +03:00
|
|
|
[functionArgs]="['time', 'prevValue']"
|
2021-09-28 08:41:39 +03:00
|
|
|
[globalVariables]="functionScopeVariables"
|
2023-06-20 18:52:13 +03:00
|
|
|
[validationArgs]="[[1, 1],[1, '1']]"
|
2019-10-17 18:23:53 +03:00
|
|
|
resultType="any"
|
2023-06-20 18:52:13 +03:00
|
|
|
helpId="widget/config/datakey_generation_fn"
|
|
|
|
|
formControlName="funcBody">
|
2019-10-17 18:23:53 +03:00
|
|
|
</tb-js-func>
|
|
|
|
|
</section>
|
|
|
|
|
</div>
|
2023-07-06 12:43:15 +03:00
|
|
|
<div class="tb-form-panel tb-slide-toggle"
|
2023-06-20 18:52:13 +03:00
|
|
|
*ngIf="(modelValue.type === dataKeyTypes.timeseries || modelValue.type === dataKeyTypes.attribute || modelValue.type === dataKeyTypes.count) && showPostProcessing">
|
|
|
|
|
<mat-expansion-panel class="tb-settings" [expanded]="dataKeyFormGroup.get('usePostProcessing').value" [disabled]="!dataKeyFormGroup.get('usePostProcessing').value">
|
|
|
|
|
<mat-expansion-panel-header fxLayout="row wrap">
|
|
|
|
|
<mat-panel-title>
|
|
|
|
|
<mat-slide-toggle class="mat-slide" formControlName="usePostProcessing" (click)="$event.stopPropagation()"
|
|
|
|
|
fxLayoutAlign="center">
|
|
|
|
|
{{ 'datakey.use-data-post-processing-func' | translate }}
|
|
|
|
|
</mat-slide-toggle>
|
|
|
|
|
</mat-panel-title>
|
|
|
|
|
</mat-expansion-panel-header>
|
|
|
|
|
<ng-template matExpansionPanelContent>
|
|
|
|
|
<tb-js-func *ngIf="dataKeyFormGroup.get('usePostProcessing').value" #postFuncBodyEdit
|
|
|
|
|
[functionArgs]="['time', 'value', 'prevValue', 'timePrev', 'prevOrigValue']"
|
|
|
|
|
[globalVariables]="functionScopeVariables"
|
|
|
|
|
[validationArgs]="[[1, 1, 1, 1, 1],[1, '1', '1', 1, '1']]"
|
|
|
|
|
resultType="any"
|
|
|
|
|
helpId="widget/config/datakey_postprocess_fn"
|
|
|
|
|
formControlName="postFuncBody">
|
|
|
|
|
</tb-js-func>
|
|
|
|
|
<label *ngIf="dataKeyFormGroup.get('usePostProcessing').value" class="tb-title" style="margin-left: 15px;">
|
|
|
|
|
time - {{ 'datakey.time-description' | translate }}<br/>
|
|
|
|
|
value - {{ 'datakey.value-description' | translate }}<br/>
|
|
|
|
|
prevValue - {{ 'datakey.prev-value-description' | translate }}<br/>
|
|
|
|
|
timePrev - {{ 'datakey.time-prev-description' | translate }}<br/>
|
|
|
|
|
prevOrigValue - {{ 'datakey.prev-orig-value-description' | translate }}
|
|
|
|
|
</label>
|
|
|
|
|
</ng-template>
|
|
|
|
|
</mat-expansion-panel>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<ng-template #advanced>
|
2023-06-30 19:59:13 +03:00
|
|
|
<div class="mat-padding" fxLayout="column" [formGroup]="dataKeySettingsFormGroup">
|
|
|
|
|
<tb-widget-settings
|
|
|
|
|
[dashboard]="dashboard"
|
|
|
|
|
[aliasController]="aliasController"
|
|
|
|
|
[widget]="widget"
|
|
|
|
|
formControlName="settings">
|
|
|
|
|
</tb-widget-settings>
|
2023-06-20 18:52:13 +03:00
|
|
|
</div>
|
|
|
|
|
</ng-template>
|