Merge pull request #9307 from rusikv/enhancement/timewindow-switch-tab
Timewindow config transfer on tab switch
This commit is contained in:
commit
f6c99385b4
@ -17,7 +17,7 @@
|
||||
-->
|
||||
<form [formGroup]="timewindowForm" class="mat-content">
|
||||
<mat-tab-group [ngClass]="{'tb-headless': historyOnly}"
|
||||
(selectedIndexChange)="timewindowForm.markAsDirty()" [(selectedIndex)]="timewindow.selectedTab">
|
||||
(selectedTabChange)="onTimewindowTypeChange()" [(selectedIndex)]="timewindow.selectedTab">
|
||||
<mat-tab label="{{ 'timewindow.realtime' | translate }}">
|
||||
<section fxLayout="row">
|
||||
<section *ngIf="isEdit" fxLayout="column" fxLayoutAlign="start center"
|
||||
|
||||
@ -20,6 +20,7 @@ import {
|
||||
AggregationType,
|
||||
DAY,
|
||||
HistoryWindowType,
|
||||
QuickTimeInterval,
|
||||
quickTimeIntervalPeriod,
|
||||
RealtimeWindowType,
|
||||
Timewindow,
|
||||
@ -186,6 +187,38 @@ export class TimewindowPanelComponent extends PageComponent implements OnInit {
|
||||
this.timewindowForm.get('aggregation.limit').updateValueAndValidity({emitEvent: false});
|
||||
}
|
||||
|
||||
onTimewindowTypeChange() {
|
||||
this.timewindowForm.markAsDirty();
|
||||
const timewindowFormValue = this.timewindowForm.getRawValue();
|
||||
if (this.timewindow.selectedTab === TimewindowType.REALTIME) {
|
||||
if (timewindowFormValue.history.historyType !== HistoryWindowType.FIXED) {
|
||||
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: timewindowFormValue.history.quickInterval.startsWith('CURRENT') ?
|
||||
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…
x
Reference in New Issue
Block a user