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 8603a063a9..15af06ae24 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 @@ -355,14 +355,6 @@ export class TimewindowConfigDialogComponent extends PageComponent implements On && !(this.quickIntervalOnly && timewindowFormValue.history.historyType === HistoryWindowType.LAST_INTERVAL)) { const allowedLastIntervals = timewindowFormValue.realtime.advancedParams.allowedLastIntervals; const allowedQuickIntervals = timewindowFormValue.realtime.advancedParams.allowedQuickIntervals; - // 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 - // }); if (Object.keys(RealtimeWindowType).includes(HistoryWindowType[timewindowFormValue.history.historyType])) { this.timewindowForm.get('realtime.realtimeType').patchValue(RealtimeWindowType[HistoryWindowType[timewindowFormValue.history.historyType]]); } @@ -378,11 +370,6 @@ export class TimewindowConfigDialogComponent extends PageComponent implements On } else { const allowedLastIntervals = timewindowFormValue.history.advancedParams.allowedLastIntervals; const allowedQuickIntervals = timewindowFormValue.history.advancedParams.allowedQuickIntervals; - // this.timewindowForm.get('history').patchValue({ - // historyType: HistoryWindowType[RealtimeWindowType[timewindowFormValue.realtime.realtimeType]], - // timewindowMs: timewindowFormValue.realtime.timewindowMs, - // quickInterval: timewindowFormValue.realtime.quickInterval - // }); this.timewindowForm.get('history.historyType').patchValue(HistoryWindowType[RealtimeWindowType[timewindowFormValue.realtime.realtimeType]]); if (!allowedLastIntervals?.length || allowedLastIntervals?.includes(timewindowFormValue.realtime.timewindowMs)) { this.timewindowForm.get('history.timewindowMs').patchValue(timewindowFormValue.realtime.timewindowMs); @@ -407,11 +394,42 @@ export class TimewindowConfigDialogComponent extends PageComponent implements On update() { const timewindowFormValue = this.timewindowForm.getRawValue(); this.timewindow = mergeDeep(this.timewindow, timewindowFormValue); + + if (timewindowFormValue.realtime.advancedParams.allowedLastIntervals?.length) { + this.timewindow.realtime.advancedParams.allowedLastIntervals = timewindowFormValue.realtime.advancedParams.allowedLastIntervals; + } else { + delete this.timewindow.realtime.advancedParams.allowedLastIntervals; + } + if (timewindowFormValue.realtime.advancedParams.allowedQuickIntervals?.length) { + this.timewindow.realtime.advancedParams.allowedQuickIntervals = timewindowFormValue.realtime.advancedParams.allowedQuickIntervals; + } else { + delete this.timewindow.realtime.advancedParams.allowedQuickIntervals; + } + + if (timewindowFormValue.history.advancedParams.allowedLastIntervals?.length) { + this.timewindow.history.advancedParams.allowedLastIntervals = timewindowFormValue.history.advancedParams.allowedLastIntervals; + } else { + delete this.timewindow.history.advancedParams.allowedLastIntervals; + } + if (timewindowFormValue.history.advancedParams.allowedQuickIntervals?.length) { + this.timewindow.history.advancedParams.allowedQuickIntervals = timewindowFormValue.history.advancedParams.allowedQuickIntervals; + } else { + delete this.timewindow.history.advancedParams.allowedQuickIntervals; + } + + if (!Object.keys(this.timewindow.realtime.advancedParams).length) { + delete this.timewindow.realtime.advancedParams; + } + if (!Object.keys(this.timewindow.history.advancedParams).length) { + delete this.timewindow.history.advancedParams; + } + if (timewindowFormValue.allowedAggTypes?.length) { this.timewindow.allowedAggTypes = timewindowFormValue.allowedAggTypes; } else { delete this.timewindow.allowedAggTypes; } + if (!this.aggregation) { delete this.timewindow.aggregation; } diff --git a/ui-ngx/src/app/shared/components/time/timewindow-panel.component.html b/ui-ngx/src/app/shared/components/time/timewindow-panel.component.html index 054e0fb9eb..787b7c842a 100644 --- a/ui-ngx/src/app/shared/components/time/timewindow-panel.component.html +++ b/ui-ngx/src/app/shared/components/time/timewindow-panel.component.html @@ -51,6 +51,7 @@ formControlName="timewindowMs" subscriptSizing="dynamic" appearance="outline" + [allowedIntervals]="realtimeAllowedLastIntervals" [disabledAdvanced]="timewindow.realtime.disableCustomInterval" [required]="timewindowForm.get('selectedTab').value === timewindowTypes.REALTIME && timewindowForm.get('realtime.realtimeType').value === realtimeTypes.LAST_INTERVAL"> @@ -63,6 +64,7 @@ onlyCurrentInterval="true" subscriptSizing="dynamic" appearance="outline" + [allowedIntervals]="realtimeAllowedQuickIntervals" [required]="timewindowForm.get('selectedTab').value === timewindowTypes.REALTIME && timewindowForm.get('realtime.realtimeType').value === realtimeTypes.INTERVAL"> @@ -95,6 +97,7 @@ formControlName="timewindowMs" subscriptSizing="dynamic" appearance="outline" + [allowedIntervals]="historyAllowedLastIntervals" [disabledAdvanced]="timewindow.history.disableCustomInterval" [required]="timewindowForm.get('selectedTab').value === timewindowTypes.HISTORY && timewindowForm.get('history.historyType').value === historyTypes.LAST_INTERVAL"> @@ -116,6 +119,7 @@ formControlName="quickInterval" subscriptSizing="dynamic" appearance="outline" + [allowedIntervals]="historyAllowedQuickIntervals" [required]="timewindowForm.get('selectedTab').value === timewindowTypes.HISTORY && timewindowForm.get('history.historyType').value === historyTypes.INTERVAL"> diff --git a/ui-ngx/src/app/shared/components/time/timewindow-panel.component.ts b/ui-ngx/src/app/shared/components/time/timewindow-panel.component.ts index 03bfb25849..42108b5379 100644 --- a/ui-ngx/src/app/shared/components/time/timewindow-panel.component.ts +++ b/ui-ngx/src/app/shared/components/time/timewindow-panel.component.ts @@ -20,6 +20,8 @@ import { DAY, HistoryWindowType, historyWindowTypeTranslations, + Interval, + QuickTimeInterval, quickTimeIntervalPeriod, RealtimeWindowType, realtimeWindowTypeTranslations, @@ -103,6 +105,10 @@ export class TimewindowPanelComponent extends PageComponent implements OnInit, O historyIntervalSelectionAvailable: boolean; aggregationOptionsAvailable: boolean; + realtimeAllowedLastIntervals: Array; + realtimeAllowedQuickIntervals: Array; + historyAllowedLastIntervals: Array; + historyAllowedQuickIntervals: Array; allowedAggTypes: Array; private destroy$ = new Subject(); @@ -124,7 +130,7 @@ export class TimewindowPanelComponent extends PageComponent implements OnInit, O this.timezone = data.timezone; this.isEdit = data.isEdit; - this.allowedAggTypes = this.timewindow.allowedAggTypes; + this.updateTimewindowAdvancedParams(); if (!this.historyOnly) { this.timewindowTypeOptions.unshift({ @@ -370,9 +376,32 @@ export class TimewindowPanelComponent extends PageComponent implements OnInit, O fixedTimewindow: timewindowFormValue.history.fixedTimewindow, quickInterval: timewindowFormValue.history.quickInterval, }}; - if (!this.timewindow.allowedAggTypes?.length) { - delete this.timewindow.allowedAggTypes; - } + + // if (!this.timewindow.realtime.advancedParams?.allowedLastIntervals?.length) { + // delete this.timewindow.realtime.advancedParams.allowedLastIntervals; + // } + // if (!this.timewindow.realtime.advancedParams?.allowedQuickIntervals?.length) { + // delete this.timewindow.realtime.advancedParams.allowedQuickIntervals; + // } + // + // if (!this.timewindow.history.advancedParams?.allowedLastIntervals?.length) { + // delete this.timewindow.history.advancedParams.allowedLastIntervals; + // } + // if (!this.timewindow.history.advancedParams?.allowedQuickIntervals?.length) { + // } else { + // delete this.timewindow.history.advancedParams.allowedQuickIntervals; + // } + // + // if (!Object.keys(this.timewindow.realtime.advancedParams).length) { + // delete this.timewindow.realtime.advancedParams; + // } + // if (!Object.keys(this.timewindow.history.advancedParams).length) { + // delete this.timewindow.history.advancedParams; + // } + // + // if (!this.timewindow.allowedAggTypes?.length) { + // delete this.timewindow.allowedAggTypes; + // } if (this.aggregation) { this.timewindow.aggregation = { type: timewindowFormValue.aggregation.type, @@ -515,10 +544,28 @@ export class TimewindowPanelComponent extends PageComponent implements OnInit, O .subscribe((res) => { if (res) { this.timewindow = res; - this.allowedAggTypes = this.timewindow.allowedAggTypes; + this.updateTimewindowAdvancedParams(); this.updateTimewindowForm(); } }); } + private updateTimewindowAdvancedParams() { + if (this.timewindow.realtime.advancedParams) { + this.realtimeAllowedLastIntervals = this.timewindow.realtime.advancedParams.allowedLastIntervals; + this.realtimeAllowedQuickIntervals = this.timewindow.realtime.advancedParams.allowedQuickIntervals; + } else { + this.realtimeAllowedLastIntervals = null; + this.realtimeAllowedQuickIntervals = null; + } + if (this.timewindow.history.advancedParams) { + this.historyAllowedLastIntervals = this.timewindow.history.advancedParams.allowedLastIntervals; + this.historyAllowedQuickIntervals = this.timewindow.history.advancedParams.allowedQuickIntervals; + } else { + this.historyAllowedLastIntervals = null; + this.historyAllowedQuickIntervals = null; + } + this.allowedAggTypes = this.timewindow.allowedAggTypes; + } + } diff --git a/ui-ngx/src/app/shared/models/time/time.models.ts b/ui-ngx/src/app/shared/models/time/time.models.ts index 9656f26aed..9b7bfc1e6e 100644 --- a/ui-ngx/src/app/shared/models/time/time.models.ts +++ b/ui-ngx/src/app/shared/models/time/time.models.ts @@ -366,6 +366,10 @@ export const initModelFromDefaultTimewindow = (value: Timewindow, quickIntervalO if (isDefined(value.realtime.timewindowMs)) { model.realtime.timewindowMs = value.realtime.timewindowMs; } + + if (value.realtime.advancedParams) { + model.realtime.advancedParams = value.realtime.advancedParams; + } } if (isDefined(value.history)) { if (isDefinedAndNotNull(value.history.hideInterval)) { @@ -409,6 +413,10 @@ export const initModelFromDefaultTimewindow = (value: Timewindow, quickIntervalO model.history.fixedTimewindow.endTimeMs = value.history.fixedTimewindow.endTimeMs; } } + + if (value.history.advancedParams) { + model.history.advancedParams = value.history.advancedParams; + } } if (value.aggregation) { if (value.aggregation.type) { @@ -467,6 +475,9 @@ export const toHistoryTimewindow = (timewindow: Timewindow, startTimeMs: number, }, timezone: timewindow.timezone }; + if (timewindow.history?.advancedParams) { + historyTimewindow.history.advancedParams = timewindow.history.advancedParams; + } if (timewindow.allowedAggTypes?.length) { historyTimewindow.allowedAggTypes = timewindow.allowedAggTypes; }