thingsboard/ui-ngx/src/app/shared/components/time/timewindow-panel.component.html

203 lines
9.7 KiB
HTML
Raw Normal View History

2019-08-12 19:34:23 +03:00
<!--
2024-01-09 10:46:16 +02:00
Copyright © 2016-2024 The Thingsboard Authors
2019-08-12 19:34:23 +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.
-->
<form [formGroup]="timewindowForm" class="tb-timewindow-form">
<div class="tb-timewindow-form-header tb-form-panel no-border no-padding-bottom" *ngIf="!historyOnly">
<tb-toggle-select class="tb-timewindow-form-type-options" appearance="fill"
[options]="timewindowTypeOptions" formControlName="selectedTab">
</tb-toggle-select>
<button mat-icon-button type="button" class="tb-timewindow-form-settings-btn tb-mat-24"
*ngIf="isEdit"
(click)="openTimewindowConfig()">
<mat-icon>settings</mat-icon>
</button>
</div>
<div class="tb-timewindow-form-content tb-form-panel no-border">
<ng-container *ngIf="timewindowForm.get('selectedTab').value === timewindowTypes.REALTIME">
<section class="tb-form-panel stroked" *ngIf="realtimeIntervalSelectionAvailable; else timezoneSelectionPanel">
<div class="tb-flex space-between"
[class.align-end]="realtimeTypeSelectionAvailable"
[class.align-center]="!realtimeTypeSelectionAvailable">
2024-09-11 18:32:53 +03:00
<div class="tb-flex-xs column">
<div class="tb-form-panel-title">{{ 'timewindow.timewindow' | translate }}</div>
<ng-container formGroupName="realtime" *ngIf="realtimeTypeSelectionAvailable">
<tb-toggle-select appearance="stroked" [options]="realtimeTimewindowOptions" formControlName="realtimeType">
</tb-toggle-select>
</ng-container>
2023-03-10 12:55:53 +02:00
</div>
<ng-container *ngTemplateOutlet="timezoneSelection">
</ng-container>
</div>
<div class="tb-form-row no-border no-padding" formGroupName="realtime">
2024-09-06 14:57:41 +03:00
<tb-timeinterval
*ngIf="timewindowForm.get('realtime.realtimeType').value === realtimeTypes.LAST_INTERVAL"
formControlName="timewindowMs"
subscriptSizing="dynamic"
appearance="outline"
[disabledAdvanced]="timewindow.realtime.disableCustomInterval"
[required]="timewindowForm.get('selectedTab').value === timewindowTypes.REALTIME &&
2024-09-06 14:57:41 +03:00
timewindowForm.get('realtime.realtimeType').value === realtimeTypes.LAST_INTERVAL">
</tb-timeinterval>
2024-09-06 14:57:41 +03:00
<tb-quick-time-interval
*ngIf="timewindowForm.get('realtime.realtimeType').value === realtimeTypes.INTERVAL"
displayLabel="false"
formControlName="quickInterval"
onlyCurrentInterval="true"
subscriptSizing="dynamic"
appearance="outline"
[required]="timewindowForm.get('selectedTab').value === timewindowTypes.REALTIME &&
2024-09-06 14:57:41 +03:00
timewindowForm.get('realtime.realtimeType').value === realtimeTypes.INTERVAL">
</tb-quick-time-interval>
</div>
</section>
</ng-container>
<ng-container *ngIf="timewindowForm.get('selectedTab').value === timewindowTypes.HISTORY">
<section class="tb-form-panel stroked" *ngIf="historyIntervalSelectionAvailable; else timezoneSelectionPanel">
<div class="tb-flex space-between"
[class.align-end]="historyTypeSelectionAvailable"
[class.align-center]="!historyTypeSelectionAvailable">
2024-09-11 18:32:53 +03:00
<div class="tb-flex-xs column">
<div class="tb-form-panel-title">{{ 'timewindow.timewindow' | translate }}</div>
<ng-container formGroupName="history" *ngIf="historyTypeSelectionAvailable">
<tb-toggle-select appearance="stroked" [options]="historyTimewindowOptions" formControlName="historyType">
</tb-toggle-select>
</ng-container>
2023-03-10 12:55:53 +02:00
</div>
<ng-container *ngTemplateOutlet="timezoneSelection">
</ng-container>
</div>
<div class="tb-form-row no-border no-padding"
formGroupName="history" *ngIf="historyIntervalSelectionAvailable &&
timewindowForm.get('history.historyType').value !== historyTypes.FOR_ALL_TIME">
2024-09-06 14:57:41 +03:00
<tb-timeinterval
*ngIf="timewindowForm.get('history.historyType').value === historyTypes.LAST_INTERVAL"
formControlName="timewindowMs"
subscriptSizing="dynamic"
appearance="outline"
[disabledAdvanced]="timewindow.history.disableCustomInterval"
[required]="timewindowForm.get('selectedTab').value === timewindowTypes.HISTORY &&
2024-09-06 14:57:41 +03:00
timewindowForm.get('history.historyType').value === historyTypes.LAST_INTERVAL">
</tb-timeinterval>
2024-09-06 14:57:41 +03:00
<tb-datetime-period
*ngIf="timewindowForm.get('history.historyType').value === historyTypes.FIXED"
formControlName="fixedTimewindow"
subscriptSizing="dynamic"
appearance="outline"
class="history-time-input"
[required]="timewindowForm.get('selectedTab').value === timewindowTypes.HISTORY &&
2024-09-06 14:57:41 +03:00
timewindowForm.get('history.historyType').value === historyTypes.FIXED">
</tb-datetime-period>
<tb-quick-time-interval
*ngIf="timewindowForm.get('history.historyType').value === historyTypes.INTERVAL"
displayLabel="false"
formControlName="quickInterval"
subscriptSizing="dynamic"
appearance="outline"
[required]="timewindowForm.get('selectedTab').value === timewindowTypes.HISTORY &&
2024-09-06 14:57:41 +03:00
timewindowForm.get('history.historyType').value === historyTypes.INTERVAL">
</tb-quick-time-interval>
</div>
</section>
</ng-container>
<ng-container *ngIf="aggregationOptionsAvailable">
<ng-container formGroupName="aggregation">
<section class="tb-form-row column-xs space-between same-padding" *ngIf="isEdit || !timewindow.hideAggregation">
<div class="fixed-title-width-180">{{ 'aggregation.aggregation' | translate }}</div>
<tb-aggregation-type-select class="flex" subscriptSizing="dynamic" appearance="outline" displayLabel="false"
formControlName="type" [allowedAggregationTypes]="allowedAggTypes">
</tb-aggregation-type-select>
</section>
<section class="tb-form-row column-xs space-between same-padding"
*ngIf="timewindowForm.get('aggregation.type').value === aggregationTypes.NONE && (isEdit || !timewindow.hideAggInterval)">
<div>{{ 'aggregation.limit' | translate }}</div>
<tb-datapoints-limit formControlName="limit"
[required]="timewindowForm.get('aggregation.type').value === aggregationTypes.MIN">
</tb-datapoints-limit>
</section>
</ng-container>
<section class="tb-form-row column-xs same-padding" [class.!hidden]="!(isEdit || !timewindow.hideAggInterval)
|| timewindowForm.get('aggregation.type').value === aggregationTypes.NONE">
<ng-container formGroupName="realtime" *ngIf="timewindowForm.get('selectedTab').value === timewindowTypes.REALTIME">
<tb-timeinterval
formControlName="interval"
[min]="minRealtimeAggInterval()" [max]="maxRealtimeAggInterval()"
useCalendarIntervals
subscriptSizing="dynamic"
appearance="outline"
[disabledAdvanced]="timewindow.realtime.disableCustomGroupInterval">
<div class="fixed-title-width-180">{{ 'aggregation.group-interval' | translate }}</div>
</tb-timeinterval>
</ng-container>
<ng-container formGroupName="history" *ngIf="timewindowForm.get('selectedTab').value === timewindowTypes.HISTORY">
<tb-timeinterval
formControlName="interval"
[min]="minHistoryAggInterval()" [max]="maxHistoryAggInterval()"
useCalendarIntervals
subscriptSizing="dynamic"
appearance="outline"
[disabledAdvanced]="timewindow.history.disableCustomGroupInterval">
<div class="fixed-title-width-180">{{ 'aggregation.group-interval' | translate }}</div>
</tb-timeinterval>
</ng-container>
2023-03-10 12:55:53 +02:00
</section>
</ng-container>
</div>
2024-08-02 13:47:50 +03:00
<ng-template #timezoneSelectionPanel>
2024-09-11 18:32:53 +03:00
<section class="tb-form-row space-between same-padding">
<div>{{ 'timezone.timezone' | translate }}</div>
2024-08-02 13:47:50 +03:00
<ng-container *ngTemplateOutlet="timezoneSelection">
</ng-container>
</section>
</ng-template>
<ng-template #timezoneSelection>
2024-09-06 14:57:41 +03:00
<tb-timezone *ngIf="timezone && (isEdit || !timewindow.hideTimezone)"
asButton strokedButton noMargin
localBrowserTimezonePlaceholderOnEmpty="true"
formControlName="timezone">
</tb-timezone>
</ng-template>
2024-09-11 17:39:21 +03:00
<mat-divider></mat-divider>
<div class="tb-panel-actions tb-flex flex-end no-gap">
<button type="button"
mat-button
[disabled]="(isLoading$ | async)"
(click)="cancel()">
{{ 'action.cancel' | translate }}
</button>
<button type="button"
mat-raised-button
color="primary"
(click)="update()"
[disabled]="(isLoading$ | async) || timewindowForm.invalid || !timewindowForm.dirty">
{{ 'action.update' | translate }}
</button>
</div>
2019-08-12 19:34:23 +03:00
</form>