From 9624fd2bc990cadaf7e3ce00902ffa1c28719ca8 Mon Sep 17 00:00:00 2001 From: Chantsova Ekaterina Date: Mon, 21 Oct 2024 19:23:15 +0300 Subject: [PATCH] Timewindow: update disable advanced option state on hiding interval --- .../timewindow-config-dialog.component.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ui-ngx/src/app/shared/components/time/timewindow-config-dialog.component.ts b/ui-ngx/src/app/shared/components/time/timewindow-config-dialog.component.ts index 8ebd6395c9..618d6daf8e 100644 --- a/ui-ngx/src/app/shared/components/time/timewindow-config-dialog.component.ts +++ b/ui-ngx/src/app/shared/components/time/timewindow-config-dialog.component.ts @@ -228,6 +228,7 @@ export class TimewindowConfigDialogComponent extends PageComponent implements On this.timewindowForm.get('realtime.hideLastInterval').enable({emitEvent: false}); this.timewindowForm.get('realtime.hideQuickInterval').enable({emitEvent: false}); } + this.updateDisableAdvancedOptionState('realtime.disableCustomInterval', value); }); this.timewindowForm.get('realtime.hideLastInterval').valueChanges.pipe( takeUntil(this.destroy$) @@ -235,6 +236,7 @@ export class TimewindowConfigDialogComponent extends PageComponent implements On if (hideLastInterval && !this.timewindowForm.get('realtime.hideQuickInterval').value) { this.timewindowForm.get('realtime.realtimeType').setValue(RealtimeWindowType.INTERVAL); } + this.updateDisableAdvancedOptionState('realtime.disableCustomInterval', hideLastInterval); }); this.timewindowForm.get('realtime.hideQuickInterval').valueChanges.pipe( takeUntil(this.destroy$) @@ -256,6 +258,7 @@ export class TimewindowConfigDialogComponent extends PageComponent implements On this.timewindowForm.get('history.hideQuickInterval').enable({emitEvent: false}); this.timewindowForm.get('history.hideFixedInterval').enable({emitEvent: false}); } + this.updateDisableAdvancedOptionState('history.disableCustomInterval', value); }); this.timewindowForm.get('history.hideLastInterval').valueChanges.pipe( takeUntil(this.destroy$) @@ -267,6 +270,7 @@ export class TimewindowConfigDialogComponent extends PageComponent implements On this.timewindowForm.get('history.historyType').setValue(HistoryWindowType.INTERVAL); } } + this.updateDisableAdvancedOptionState('history.disableCustomInterval', hideLastInterval); }); this.timewindowForm.get('history.hideFixedInterval').valueChanges.pipe( takeUntil(this.destroy$) @@ -290,6 +294,7 @@ export class TimewindowConfigDialogComponent extends PageComponent implements On } } }); + this.timewindowForm.get('hideAggregation').valueChanges.pipe( takeUntil(this.destroy$) ).subscribe((value: boolean) => { @@ -297,6 +302,12 @@ export class TimewindowConfigDialogComponent extends PageComponent implements On this.timewindowForm.get('allowedAggTypes').patchValue([]); } }); + this.timewindowForm.get('hideAggInterval').valueChanges.pipe( + takeUntil(this.destroy$) + ).subscribe((value: boolean) => { + this.updateDisableAdvancedOptionState('realtime.disableCustomGroupInterval', value); + this.updateDisableAdvancedOptionState('history.disableCustomGroupInterval', value); + }); } ngOnDestroy() { @@ -304,6 +315,15 @@ export class TimewindowConfigDialogComponent extends PageComponent implements On this.destroy$.complete(); } + private updateDisableAdvancedOptionState(controlName: string, intervalHidden: boolean) { + if (intervalHidden) { + this.timewindowForm.get(controlName).disable({emitEvent: false}); + this.timewindowForm.get(controlName).patchValue(false, {emitEvent: false}); + } else { + this.timewindowForm.get(controlName).enable({emitEvent: false}); + } + } + private updateValidators(aggType: AggregationType) { if (aggType !== AggregationType.NONE) { this.timewindowForm.get('aggregation.limit').clearValidators();