Browse Source

UI: add timewindow panel transfering of data between tabs on switch

pull/9307/head
rusikv 3 years ago
parent
commit
a21ce12528
  1. 3
      ui-ngx/src/app/shared/components/time/timewindow-panel.component.html
  2. 31
      ui-ngx/src/app/shared/components/time/timewindow-panel.component.ts

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

@ -17,7 +17,8 @@
-->
<form [formGroup]="timewindowForm" class="mat-content">
<mat-tab-group [ngClass]="{'tb-headless': historyOnly}"
(selectedIndexChange)="timewindowForm.markAsDirty()" [(selectedIndex)]="timewindow.selectedTab">
(selectedIndexChange)="timewindowForm.markAsDirty()" [(selectedIndex)]="timewindow.selectedTab"
(selectedTabChange)="onTimewindowTypeChange()">
<mat-tab label="{{ 'timewindow.realtime' | translate }}">
<section fxLayout="row">
<section *ngIf="isEdit" fxLayout="column" fxLayoutAlign="start center"

31
ui-ngx/src/app/shared/components/time/timewindow-panel.component.ts

@ -20,6 +20,7 @@ import {
AggregationType,
DAY,
HistoryWindowType,
QuickTimeInterval,
quickTimeIntervalPeriod,
RealtimeWindowType,
Timewindow,
@ -186,6 +187,36 @@ export class TimewindowPanelComponent extends PageComponent implements OnInit {
this.timewindowForm.get('aggregation.limit').updateValueAndValidity({emitEvent: false});
}
onTimewindowTypeChange() {
const timewindowFormValue = this.timewindowForm.getRawValue();
if (this.timewindow.selectedTab === TimewindowType.REALTIME) {
this.timewindowForm.get('realtime').patchValue({
realtimeType: Object.keys(RealtimeWindowType).includes(HistoryWindowType[timewindowFormValue.history.historyType]) ?
RealtimeWindowType[HistoryWindowType[timewindowFormValue.history.historyType]] :
timewindowFormValue.realtime.realtimeType,
timewindowMs: timewindowFormValue.history.timewindowMs,
quickInterval: Object.values(QuickTimeInterval).filter(interval => interval.startsWith('CURRENT_'))
.includes(QuickTimeInterval[timewindowFormValue.history.quickInterval]) ? timewindowFormValue.history.quickInterval :
timewindowFormValue.realtime.quickInterval
});
setTimeout(() => this.timewindowForm.get('realtime.interval').patchValue(timewindowFormValue.history.interval));
} else {
this.timewindowForm.get('history').patchValue({
historyType: HistoryWindowType[RealtimeWindowType[timewindowFormValue.realtime.realtimeType]],
timewindowMs: timewindowFormValue.realtime.timewindowMs,
quickInterval: timewindowFormValue.realtime.quickInterval
});
setTimeout(() => this.timewindowForm.get('history.interval').patchValue(timewindowFormValue.realtime.interval));
}
this.timewindowForm.patchValue({
aggregation: {
type: timewindowFormValue.aggregation.type,
limit: timewindowFormValue.aggregation.limit
},
timezone: timewindowFormValue.timezone
});
}
update() {
const timewindowFormValue = this.timewindowForm.getRawValue();
this.timewindow.realtime = {

Loading…
Cancel
Save