Merge pull request #14081 from ChantsovaEkaterina/bug/timewindow-hidden-option-displayed

Timewindow: fix hidden options displaying when switching between Realtime and History
This commit is contained in:
Igor Kulikov 2025-10-01 15:36:04 +03:00 committed by GitHub
commit 20e4b3970b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 37 additions and 25 deletions

View File

@ -411,9 +411,10 @@ export class TimewindowConfigDialogComponent extends PageComponent implements On
const timewindowFormValue = this.timewindowForm.getRawValue();
const realtimeDisableCustomInterval = timewindowFormValue.realtime.disableCustomInterval;
const historyDisableCustomInterval = timewindowFormValue.history.disableCustomInterval;
updateFormValuesOnTimewindowTypeChange(selectedTab, this.quickIntervalOnly, this.timewindowForm,
updateFormValuesOnTimewindowTypeChange(selectedTab, this.timewindowForm,
realtimeDisableCustomInterval, historyDisableCustomInterval,
timewindowFormValue.realtime.advancedParams, timewindowFormValue.history.advancedParams);
timewindowFormValue.realtime.advancedParams, timewindowFormValue.history.advancedParams,
this.realtimeTimewindowOptions, this.historyTimewindowOptions);
this.timewindowForm.patchValue({
hideAggregation: timewindowFormValue.hideAggregation,
hideAggInterval: timewindowFormValue.hideAggInterval,

View File

@ -400,9 +400,10 @@ export class TimewindowPanelComponent extends PageComponent implements OnInit, O
}
private onTimewindowTypeChange(selectedTab: TimewindowType) {
updateFormValuesOnTimewindowTypeChange(selectedTab, this.quickIntervalOnly, this.timewindowForm,
updateFormValuesOnTimewindowTypeChange(selectedTab, this.timewindowForm,
this.realtimeDisableCustomInterval, this.historyDisableCustomInterval,
this.realtimeAdvancedParams, this.historyAdvancedParams);
this.realtimeAdvancedParams, this.historyAdvancedParams,
this.realtimeTimewindowOptions, this.historyTimewindowOptions);
}
update() {

View File

@ -20,6 +20,7 @@ import moment_ from 'moment';
import * as momentTz from 'moment-timezone';
import { IntervalType } from '@shared/models/telemetry/telemetry.models';
import { FormGroup } from '@angular/forms';
import { ToggleHeaderOption } from '@shared/components/toggle-header.component';
const moment = moment_;
@ -526,17 +527,20 @@ export const timewindowTypeChanged = (newTimewindow: Timewindow, oldTimewindow:
};
export const updateFormValuesOnTimewindowTypeChange = (selectedTab: TimewindowType,
quickIntervalOnly: boolean, timewindowForm: FormGroup,
timewindowForm: FormGroup,
realtimeDisableCustomInterval: boolean, historyDisableCustomInterval: boolean,
realtimeAdvancedParams?: TimewindowAdvancedParams,
historyAdvancedParams?: TimewindowAdvancedParams) => {
realtimeAdvancedParams: TimewindowAdvancedParams,
historyAdvancedParams: TimewindowAdvancedParams,
realtimeTimewindowOptions: ToggleHeaderOption[],
historyTimewindowOptions: ToggleHeaderOption[]) => {
const timewindowFormValue = timewindowForm.getRawValue();
if (selectedTab === TimewindowType.REALTIME) {
if (timewindowFormValue.history.historyType !== HistoryWindowType.FIXED
&& !(quickIntervalOnly && timewindowFormValue.history.historyType === HistoryWindowType.LAST_INTERVAL)) {
if (Object.keys(RealtimeWindowType).includes(HistoryWindowType[timewindowFormValue.history.historyType])) {
timewindowForm.get('realtime.realtimeType').patchValue(RealtimeWindowType[HistoryWindowType[timewindowFormValue.history.historyType]]);
}
const sameWindowTypeOptionAvailable = realtimeTimewindowOptions.some(
option => {
return option.value === RealtimeWindowType[HistoryWindowType[timewindowFormValue.history.historyType]]
});
if (sameWindowTypeOptionAvailable) {
timewindowForm.get('realtime.realtimeType').patchValue(RealtimeWindowType[HistoryWindowType[timewindowFormValue.history.historyType]]);
if (!realtimeDisableCustomInterval ||
!realtimeAdvancedParams?.allowedLastIntervals?.length || realtimeAdvancedParams.allowedLastIntervals.includes(timewindowFormValue.history.timewindowMs)) {
timewindowForm.get('realtime.timewindowMs').patchValue(timewindowFormValue.history.timewindowMs);
@ -554,20 +558,26 @@ export const updateFormValuesOnTimewindowTypeChange = (selectedTab: TimewindowTy
}
}
} else {
timewindowForm.get('history.historyType').patchValue(HistoryWindowType[RealtimeWindowType[timewindowFormValue.realtime.realtimeType]]);
if (!historyDisableCustomInterval ||
const sameWindowTypeOptionAvailable = historyTimewindowOptions.some(
option => {
return option.value === HistoryWindowType[RealtimeWindowType[timewindowFormValue.realtime.realtimeType]]
});
if (sameWindowTypeOptionAvailable) {
timewindowForm.get('history.historyType').patchValue(HistoryWindowType[RealtimeWindowType[timewindowFormValue.realtime.realtimeType]]);
if (!historyDisableCustomInterval ||
!historyAdvancedParams?.allowedLastIntervals?.length || historyAdvancedParams.allowedLastIntervals?.includes(timewindowFormValue.realtime.timewindowMs)) {
timewindowForm.get('history.timewindowMs').patchValue(timewindowFormValue.realtime.timewindowMs);
}
if (!historyAdvancedParams?.allowedQuickIntervals?.length || historyAdvancedParams.allowedQuickIntervals?.includes(timewindowFormValue.realtime.quickInterval)) {
timewindowForm.get('history.quickInterval').patchValue(timewindowFormValue.realtime.quickInterval);
}
const defaultAggInterval = historyDefaultAggInterval(timewindowForm.getRawValue(), historyAdvancedParams);
const allowedAggIntervals = historyAllowedAggIntervals(timewindowForm.getRawValue(), historyAdvancedParams);
if (defaultAggInterval || !allowedAggIntervals.length || allowedAggIntervals.includes(timewindowFormValue.realtime.interval)) {
setTimeout(() => timewindowForm.get('history.interval').patchValue(
defaultAggInterval ?? timewindowFormValue.realtime.interval
));
timewindowForm.get('history.timewindowMs').patchValue(timewindowFormValue.realtime.timewindowMs);
}
if (!historyAdvancedParams?.allowedQuickIntervals?.length || historyAdvancedParams.allowedQuickIntervals?.includes(timewindowFormValue.realtime.quickInterval)) {
timewindowForm.get('history.quickInterval').patchValue(timewindowFormValue.realtime.quickInterval);
}
const defaultAggInterval = historyDefaultAggInterval(timewindowForm.getRawValue(), historyAdvancedParams);
const allowedAggIntervals = historyAllowedAggIntervals(timewindowForm.getRawValue(), historyAdvancedParams);
if (defaultAggInterval || !allowedAggIntervals.length || allowedAggIntervals.includes(timewindowFormValue.realtime.interval)) {
setTimeout(() => timewindowForm.get('history.interval').patchValue(
defaultAggInterval ?? timewindowFormValue.realtime.interval
));
}
}
}
timewindowForm.patchValue({