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:
		
						commit
						20e4b3970b
					
				@ -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,
 | 
			
		||||
 | 
			
		||||
@ -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() {
 | 
			
		||||
 | 
			
		||||
@ -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])) {
 | 
			
		||||
    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,6 +558,11 @@ export const updateFormValuesOnTimewindowTypeChange = (selectedTab: TimewindowTy
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  } else {
 | 
			
		||||
    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)) {
 | 
			
		||||
@ -570,6 +579,7 @@ export const updateFormValuesOnTimewindowTypeChange = (selectedTab: TimewindowTy
 | 
			
		||||
        ));
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  timewindowForm.patchValue({
 | 
			
		||||
    aggregation: {
 | 
			
		||||
      type: timewindowFormValue.aggregation.type,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user