Browse Source

Merge 5c446be47c into 745553362e

pull/16158/merge
Oleksandr Mykytenko 5 hours ago
committed by GitHub
parent
commit
75b460e838
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 325
      ui-ngx/src/app/shared/components/time/timewindow-config-dialog.component.html
  2. 16
      ui-ngx/src/app/shared/components/time/timewindow-config-dialog.component.scss
  3. 37
      ui-ngx/src/app/shared/components/time/timewindow-config-dialog.component.ts
  4. 24
      ui-ngx/src/app/shared/components/time/timewindow-panel.component.html
  5. 106
      ui-ngx/src/app/shared/components/time/timewindow-panel.component.ts
  6. 27
      ui-ngx/src/app/shared/components/time/timewindow.component.ts
  7. 19
      ui-ngx/src/app/shared/models/time/time.models.ts
  8. 4
      ui-ngx/src/assets/locale/locale.constant-en_US.json

325
ui-ngx/src/app/shared/components/time/timewindow-config-dialog.component.html

@ -23,176 +23,206 @@
</div>
<div class="tb-timewindow-form-content tb-form-panel no-border">
@if (timewindowForm.get('selectedTab').value === timewindowTypes.REALTIME) {
<section
formGroupName="realtime" class="tb-form-panel">
<div class="tb-form-panel-title">{{ 'timewindow.timewindow' | translate }}</div>
<section class="tb-form-panel">
<div class="tb-form-row">
<mat-slide-toggle class="mat-slide fixed-title-width" formControlName="hideInterval">
{{ 'timewindow.hide-timewindow-section' | translate }}
<mat-slide-toggle class="mat-slide fixed-title-width" formControlName="hideRealtime">
{{ 'timewindow.hide-realtime-tab' | translate }}
</mat-slide-toggle>
</div>
@if (realtimeTypeSelectionAvailable) {
<tb-toggle-select
appearance="stroked" [options]="realtimeTimewindowOptions" formControlName="realtimeType">
</tb-toggle-select>
</section>
@if (!timewindowForm.get('hideRealtime').value) {
@if (timewindowForm.hasError('realtimeSectionEmpty')) {
<div class="tb-form-hint tb-section-empty-hint flex items-start gap-2" role="alert">
<mat-icon>error</mat-icon>
<span translate>timewindow.realtime-section-empty</span>
</div>
}
@if (timewindowForm.get('realtime.realtimeType').value === realtimeTypes.LAST_INTERVAL) {
<section
formGroupName="realtime" class="tb-form-panel">
<div class="tb-form-panel-title">{{ 'timewindow.timewindow' | translate }}</div>
<div class="tb-form-row">
<mat-slide-toggle class="mat-slide fixed-title-width" formControlName="disableCustomInterval">
{{ 'timewindow.disable-custom-interval' | translate }}
<mat-slide-toggle class="mat-slide fixed-title-width" formControlName="hideInterval">
{{ 'timewindow.hide-timewindow-section' | translate }}
</mat-slide-toggle>
</div>
<div class="tb-form-row column-xs">
@if (!quickIntervalOnly) {
<mat-slide-toggle
class="mat-slide" formControlName="hideLastInterval">
<div tb-hint-tooltip-icon="{{'timewindow.hide-last-interval' | translate}}">
{{ 'timewindow.hide' | translate }}
</div>
</mat-slide-toggle>
@if (!timewindowForm.get('realtime.hideInterval').value) {
@if (realtimeTypeSelectionAvailable) {
<tb-toggle-select
appearance="stroked" [options]="realtimeTimewindowOptions" formControlName="realtimeType">
</tb-toggle-select>
}
<tb-timeinterval
formControlName="timewindowMs"
subscriptSizing="dynamic"
appearance="outline"
[allowedIntervals]="timewindowForm.get('realtime.advancedParams.allowedLastIntervals').value"
[disabledAdvanced]="timewindowForm.get('realtime.disableCustomInterval').value"
[required]="timewindowForm.get('selectedTab').value === timewindowTypes.REALTIME &&
timewindowForm.get('realtime.realtimeType').value === realtimeTypes.LAST_INTERVAL">
@if (!(timewindowForm.get('realtime.hideLastInterval').value ||
timewindowForm.get('realtime.hideInterval').value)) {
<button
matSuffix mat-icon-button type="button"
(click)="configureRealtimeLastIntervalOptions($event)">
<mat-icon>edit</mat-icon>
</button>
}
</tb-timeinterval>
</div>
}
@if (timewindowForm.get('realtime.realtimeType').value === realtimeTypes.INTERVAL) {
<div
class="tb-form-row column-xs">
@if (!quickIntervalOnly) {
<mat-slide-toggle
class="mat-slide" formControlName="hideQuickInterval">
<div tb-hint-tooltip-icon="{{'timewindow.hide-relative-interval' | translate}}">
{{ 'timewindow.hide' | translate }}
</div>
</mat-slide-toggle>
@if (timewindowForm.get('realtime.realtimeType').value === realtimeTypes.LAST_INTERVAL) {
<div class="tb-form-row">
<mat-slide-toggle class="mat-slide fixed-title-width" formControlName="disableCustomInterval">
{{ 'timewindow.disable-custom-interval' | translate }}
</mat-slide-toggle>
</div>
<div class="tb-form-row column-xs">
@if (!quickIntervalOnly) {
<mat-slide-toggle
class="mat-slide" formControlName="hideLastInterval">
<div tb-hint-tooltip-icon="{{'timewindow.hide-last-interval' | translate}}">
{{ 'timewindow.hide' | translate }}
</div>
</mat-slide-toggle>
}
<tb-timeinterval
formControlName="timewindowMs"
subscriptSizing="dynamic"
appearance="outline"
[allowedIntervals]="timewindowForm.get('realtime.advancedParams.allowedLastIntervals').value"
[disabledAdvanced]="timewindowForm.get('realtime.disableCustomInterval').value"
[required]="timewindowForm.get('selectedTab').value === timewindowTypes.REALTIME &&
timewindowForm.get('realtime.realtimeType').value === realtimeTypes.LAST_INTERVAL">
@if (!timewindowForm.get('realtime.hideLastInterval').value) {
<button
matSuffix mat-icon-button type="button"
(click)="configureRealtimeLastIntervalOptions($event)">
<mat-icon>edit</mat-icon>
</button>
}
</tb-timeinterval>
</div>
}
<tb-quick-time-interval
displayLabel="false"
formControlName="quickInterval"
onlyCurrentInterval="true"
subscriptSizing="dynamic"
appearance="outline"
[allowedIntervals]="timewindowForm.get('realtime.advancedParams.allowedQuickIntervals').value"
[required]="timewindowForm.get('selectedTab').value === timewindowTypes.REALTIME &&
timewindowForm.get('realtime.realtimeType').value === realtimeTypes.INTERVAL">
@if (!(timewindowForm.get('realtime.hideQuickInterval').value ||
timewindowForm.get('realtime.hideInterval').value)) {
<button
matSuffix mat-icon-button type="button"
(click)="configureRealtimeQuickIntervalOptions($event)">
<mat-icon>edit</mat-icon>
</button>
}
</tb-quick-time-interval>
</div>
}
</section>
@if (timewindowForm.get('realtime.realtimeType').value === realtimeTypes.INTERVAL) {
<div class="tb-form-row column-xs">
@if (!quickIntervalOnly) {
<mat-slide-toggle
class="mat-slide" formControlName="hideQuickInterval">
<div tb-hint-tooltip-icon="{{'timewindow.hide-relative-interval' | translate}}">
{{ 'timewindow.hide' | translate }}
</div>
</mat-slide-toggle>
}
<tb-quick-time-interval
displayLabel="false"
formControlName="quickInterval"
onlyCurrentInterval="true"
subscriptSizing="dynamic"
appearance="outline"
[allowedIntervals]="timewindowForm.get('realtime.advancedParams.allowedQuickIntervals').value"
[required]="timewindowForm.get('selectedTab').value === timewindowTypes.REALTIME &&
timewindowForm.get('realtime.realtimeType').value === realtimeTypes.INTERVAL">
@if (!timewindowForm.get('realtime.hideQuickInterval').value) {
<button
matSuffix mat-icon-button type="button"
(click)="configureRealtimeQuickIntervalOptions($event)">
<mat-icon>edit</mat-icon>
</button>
}
</tb-quick-time-interval>
</div>
}
}
</section>
}
}
@if (timewindowForm.get('selectedTab').value === timewindowTypes.HISTORY) {
<section
formGroupName="history" class="tb-form-panel">
<div class="tb-form-panel-title">{{ 'timewindow.timewindow' | translate }}</div>
<section class="tb-form-panel">
<div class="tb-form-row">
<mat-slide-toggle class="mat-slide fixed-title-width" formControlName="hideInterval">
{{ 'timewindow.hide-timewindow-section' | translate }}
<mat-slide-toggle class="mat-slide fixed-title-width" formControlName="hideHistory">
{{ 'timewindow.hide-history-tab' | translate }}
</mat-slide-toggle>
</div>
<tb-toggle-select appearance="stroked" [options]="historyTimewindowOptions" formControlName="historyType">
</tb-toggle-select>
@if (timewindowForm.get('history.historyType').value === historyTypes.LAST_INTERVAL) {
</section>
@if (!timewindowForm.get('hideHistory').value) {
@if (timewindowForm.hasError('historySectionEmpty')) {
<div class="tb-form-hint tb-section-empty-hint flex items-start gap-2" role="alert">
<mat-icon>error</mat-icon>
<span translate>timewindow.history-section-empty</span>
</div>
}
<section
formGroupName="history" class="tb-form-panel">
<div class="tb-form-panel-title">{{ 'timewindow.timewindow' | translate }}</div>
<div class="tb-form-row">
<mat-slide-toggle class="mat-slide fixed-title-width" formControlName="disableCustomInterval">
{{ 'timewindow.disable-custom-interval' | translate }}
<mat-slide-toggle class="mat-slide fixed-title-width" formControlName="hideInterval">
{{ 'timewindow.hide-timewindow-section' | translate }}
</mat-slide-toggle>
</div>
<div class="tb-form-row column-xs">
<mat-slide-toggle class="mat-slide" formControlName="hideLastInterval">
<div tb-hint-tooltip-icon="{{'timewindow.hide-last-interval' | translate}}">
{{ 'timewindow.hide' | translate }}
@if (!timewindowForm.get('history.hideInterval').value) {
<tb-toggle-select appearance="stroked" [options]="historyTimewindowOptions" formControlName="historyType">
</tb-toggle-select>
@if (timewindowForm.get('history.historyType').value === historyTypes.LAST_INTERVAL) {
<div class="tb-form-row">
<mat-slide-toggle class="mat-slide fixed-title-width" formControlName="disableCustomInterval">
{{ 'timewindow.disable-custom-interval' | translate }}
</mat-slide-toggle>
</div>
</mat-slide-toggle>
<tb-timeinterval
formControlName="timewindowMs"
subscriptSizing="dynamic"
appearance="outline"
[allowedIntervals]="timewindowForm.get('history.advancedParams.allowedLastIntervals').value"
[disabledAdvanced]="timewindowForm.get('history.disableCustomInterval').value"
[required]="timewindowForm.get('selectedTab').value === timewindowTypes.HISTORY &&
timewindowForm.get('history.historyType').value === historyTypes.LAST_INTERVAL">
@if (!(timewindowForm.get('history.hideLastInterval').value ||
timewindowForm.get('history.hideInterval').value)) {
<button
matSuffix mat-icon-button type="button"
(click)="configureHistoryLastIntervalOptions($event)">
<mat-icon>edit</mat-icon>
</button>
}
</tb-timeinterval>
</div>
}
@if (timewindowForm.get('history.historyType').value === historyTypes.FIXED) {
<div class="tb-form-row column-xs">
<mat-slide-toggle class="mat-slide" formControlName="hideFixedInterval">
<div tb-hint-tooltip-icon="{{'timewindow.hide-fixed-interval' | translate}}">
{{ 'timewindow.hide' | translate }}
<div class="tb-form-row column-xs">
<mat-slide-toggle class="mat-slide" formControlName="hideLastInterval">
<div tb-hint-tooltip-icon="{{'timewindow.hide-last-interval' | translate}}">
{{ 'timewindow.hide' | translate }}
</div>
</mat-slide-toggle>
<tb-timeinterval
formControlName="timewindowMs"
subscriptSizing="dynamic"
appearance="outline"
[allowedIntervals]="timewindowForm.get('history.advancedParams.allowedLastIntervals').value"
[disabledAdvanced]="timewindowForm.get('history.disableCustomInterval').value"
[required]="timewindowForm.get('selectedTab').value === timewindowTypes.HISTORY &&
timewindowForm.get('history.historyType').value === historyTypes.LAST_INTERVAL">
@if (!timewindowForm.get('history.hideLastInterval').value) {
<button
matSuffix mat-icon-button type="button"
(click)="configureHistoryLastIntervalOptions($event)">
<mat-icon>edit</mat-icon>
</button>
}
</tb-timeinterval>
</div>
</mat-slide-toggle>
<tb-datetime-period
formControlName="fixedTimewindow"
subscriptSizing="dynamic"
appearance="outline"
class="history-time-input"
[required]="timewindowForm.get('selectedTab').value === timewindowTypes.HISTORY &&
timewindowForm.get('history.historyType').value === historyTypes.FIXED">
</tb-datetime-period>
</div>
}
@if (timewindowForm.get('history.historyType').value === historyTypes.INTERVAL) {
<div class="tb-form-row column-xs">
<mat-slide-toggle class="mat-slide" formControlName="hideQuickInterval">
<div tb-hint-tooltip-icon="{{'timewindow.hide-relative-interval' | translate}}">
{{ 'timewindow.hide' | translate }}
}
@if (timewindowForm.get('history.historyType').value === historyTypes.FIXED) {
<div class="tb-form-row column-xs">
<mat-slide-toggle class="mat-slide" formControlName="hideFixedInterval">
<div tb-hint-tooltip-icon="{{'timewindow.hide-fixed-interval' | translate}}">
{{ 'timewindow.hide' | translate }}
</div>
</mat-slide-toggle>
<tb-datetime-period
formControlName="fixedTimewindow"
subscriptSizing="dynamic"
appearance="outline"
class="history-time-input"
[required]="timewindowForm.get('selectedTab').value === timewindowTypes.HISTORY &&
timewindowForm.get('history.historyType').value === historyTypes.FIXED">
</tb-datetime-period>
</div>
</mat-slide-toggle>
<tb-quick-time-interval
displayLabel="false"
formControlName="quickInterval"
subscriptSizing="dynamic"
appearance="outline"
[allowedIntervals]="timewindowForm.get('history.advancedParams.allowedQuickIntervals').value"
[required]="timewindowForm.get('selectedTab').value === timewindowTypes.HISTORY &&
timewindowForm.get('history.historyType').value === historyTypes.INTERVAL">
@if (!(timewindowForm.get('history.hideQuickInterval').value ||
timewindowForm.get('history.hideInterval').value)) {
<button
matSuffix mat-icon-button type="button"
(click)="configureHistoryQuickIntervalOptions($event)">
<mat-icon>edit</mat-icon>
</button>
}
</tb-quick-time-interval>
</div>
}
</section>
}
@if (timewindowForm.get('history.historyType').value === historyTypes.INTERVAL) {
<div class="tb-form-row column-xs">
<mat-slide-toggle class="mat-slide" formControlName="hideQuickInterval">
<div tb-hint-tooltip-icon="{{'timewindow.hide-relative-interval' | translate}}">
{{ 'timewindow.hide' | translate }}
</div>
</mat-slide-toggle>
<tb-quick-time-interval
displayLabel="false"
formControlName="quickInterval"
subscriptSizing="dynamic"
appearance="outline"
[allowedIntervals]="timewindowForm.get('history.advancedParams.allowedQuickIntervals').value"
[required]="timewindowForm.get('selectedTab').value === timewindowTypes.HISTORY &&
timewindowForm.get('history.historyType').value === historyTypes.INTERVAL">
@if (!timewindowForm.get('history.hideQuickInterval').value) {
<button
matSuffix mat-icon-button type="button"
(click)="configureHistoryQuickIntervalOptions($event)">
<mat-icon>edit</mat-icon>
</button>
}
</tb-quick-time-interval>
</div>
}
}
</section>
}
}
@if (aggregation) {
@if (!selectedTabHidden) {
@if (aggregation) {
<section class="tb-form-panel">
<div class="tb-form-panel-title">{{ 'aggregation.aggregation' | translate }}</div>
<div class="tb-form-row column-xs">
@ -318,6 +348,7 @@
</div>
</section>
}
}
</div>
<mat-divider></mat-divider>
<div mat-dialog-actions class="tb-dialog-actions tb-flex flex-end no-gap">

16
ui-ngx/src/app/shared/components/time/timewindow-config-dialog.component.scss

@ -12,6 +12,22 @@
tb-timezone-select {
flex: 1;
}
.tb-section-empty-hint {
color: rgb(221, 44, 0);
background-color: rgba(221, 44, 0, 0.08);
border: 1px solid rgb(221, 44, 0);
border-radius: 8px;
.mat-icon {
flex-shrink: 0;
color: rgb(221, 44, 0);
}
span {
min-width: 0;
}
}
}
}

37
ui-ngx/src/app/shared/components/time/timewindow-config-dialog.component.ts

@ -20,7 +20,7 @@ import {
import { PageComponent } from '@shared/components/page.component';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { AbstractControl, FormBuilder, FormGroup, ValidationErrors, Validators } from '@angular/forms';
import { TimeService } from '@core/services/time.service';
import {
deepClean,
@ -237,7 +237,11 @@ export class TimewindowConfigDialogComponent extends PageComponent implements On
? this.timewindow.hideTimezone : false ],
hideSaveAsDefault: [ isDefinedAndNotNull(this.timewindow.hideSaveAsDefault)
? this.timewindow.hideSaveAsDefault : false ],
hideRealtime: [ isDefinedAndNotNull(this.timewindow.hideRealtime) ? this.timewindow.hideRealtime : false ],
hideHistory: [ isDefinedAndNotNull(this.timewindow.hideHistory) ? this.timewindow.hideHistory : false ],
});
this.timewindowForm.setValidators(this.sectionsNotEmptyValidator);
this.timewindowForm.updateValueAndValidity({emitEvent: false});
this.updateValidators(this.timewindowForm.get('aggregation.type').value);
if (this.aggregation) {
@ -302,6 +306,7 @@ export class TimewindowConfigDialogComponent extends PageComponent implements On
).subscribe((selectedTab: TimewindowType) => {
this.onTimewindowTypeChange(selectedTab);
});
this.timewindowForm.get('realtime.hideInterval').valueChanges.pipe(
takeUntil(this.destroy$)
).subscribe((value: boolean) => {
@ -401,6 +406,36 @@ export class TimewindowConfigDialogComponent extends PageComponent implements On
}
}
get selectedTabHidden(): boolean {
const selectedTab = this.timewindowForm.get('selectedTab').value;
return (selectedTab === TimewindowType.REALTIME && this.timewindowForm.get('hideRealtime').value) ||
(selectedTab === TimewindowType.HISTORY && this.timewindowForm.get('hideHistory').value);
}
private sectionsNotEmptyValidator = (control: AbstractControl): ValidationErrors | null => {
const value = (control as FormGroup).getRawValue();
const timezoneAvailable = !value.hideTimezone;
const aggregationAvailable = this.aggregation && !(value.hideAggregation && value.hideAggInterval);
const realtimeIntervalAvailable = !(value.realtime.hideInterval ||
(value.realtime.hideLastInterval && value.realtime.hideQuickInterval));
const historyIntervalAvailable = !(value.history.hideInterval ||
(value.history.hideLastInterval && value.history.hideQuickInterval && value.history.hideFixedInterval));
const realtimeHasContent = realtimeIntervalAvailable || aggregationAvailable || timezoneAvailable;
const historyHasContent = historyIntervalAvailable || aggregationAvailable || timezoneAvailable;
const errors: ValidationErrors = {};
if (!value.hideRealtime && !realtimeHasContent) {
errors.realtimeSectionEmpty = true;
}
if (!value.hideHistory && !historyHasContent) {
errors.historySectionEmpty = true;
}
return Object.keys(errors).length ? errors : null;
};
private updateValidators(aggType: AggregationType) {
if (aggType !== AggregationType.NONE) {
this.timewindowForm.get('aggregation.limit').clearValidators();

24
ui-ngx/src/app/shared/components/time/timewindow-panel.component.html

@ -5,11 +5,15 @@
-->
<form [formGroup]="timewindowForm" class="tb-timewindow-form">
@if (!historyOnly) {
@if (timewindowTypeOptions.length || isEdit) {
<div class="tb-timewindow-form-header tb-form-panel no-border no-padding-bottom">
<tb-toggle-select class="tb-timewindow-form-type-options" appearance="fill"
[options]="timewindowTypeOptions" formControlName="selectedTab">
</tb-toggle-select>
@if (timewindowTypeSelectionAvailable) {
<tb-toggle-select class="tb-timewindow-form-type-options" appearance="fill"
[options]="timewindowTypeOptions" formControlName="selectedTab">
</tb-toggle-select>
} @else if (timewindowTypeOptions.length) {
<div class="tb-timewindow-form-type-options tb-form-panel-title">{{ timewindowTypeOptions[0].name }}</div>
}
@if (isEdit) {
<button mat-icon-button type="button" class="tb-timewindow-form-settings-btn tb-mat-24"
(click)="openTimewindowConfig()">
@ -64,7 +68,7 @@
}
</div>
</section>
} @else {
} @else if (timezone && !timewindow.hideTimezone) {
<section class="tb-form-row space-between same-padding">
<div>{{ 'timezone.timezone' | translate }}</div>
<ng-container *ngTemplateOutlet="timezoneSelection">
@ -130,7 +134,7 @@
</div>
}
</section>
} @else {
} @else if (timezone && !timewindow.hideTimezone) {
<section class="tb-form-row space-between same-padding">
<div>{{ 'timezone.timezone' | translate }}</div>
<ng-container *ngTemplateOutlet="timezoneSelection">
@ -141,7 +145,7 @@
@if (aggregationOptionsAvailable) {
<ng-container formGroupName="aggregation">
@if (isEdit || !timewindow.hideAggregation) {
@if (!timewindow.hideAggregation) {
<section class="tb-form-row column-xs space-between same-padding">
<div class="fixed-title-width-180">{{ 'aggregation.aggregation' | translate }}</div>
<tb-aggregation-type-select class="flex" subscriptSizing="dynamic" appearance="outline" displayLabel="false"
@ -149,7 +153,7 @@
</tb-aggregation-type-select>
</section>
}
@if (timewindowForm.get('aggregation.type').value === aggregationTypes.NONE && (isEdit || !timewindow.hideAggInterval)) {
@if (timewindowForm.get('aggregation.type').value === aggregationTypes.NONE && !timewindow.hideAggInterval) {
<section class="tb-form-row column-xs space-between same-padding"
>
<div>{{ 'aggregation.limit' | translate }}</div>
@ -161,7 +165,7 @@
</ng-container>
@if (timewindowForm.get('aggregation.type').value !== aggregationTypes.NONE) {
<section class="tb-form-row column-xs same-padding"
[class.!hidden]="!(isEdit || !timewindow.hideAggInterval)">
[class.!hidden]="timewindow.hideAggInterval">
@if (timewindowForm.get('selectedTab').value === timewindowTypes.REALTIME) {
<ng-container formGroupName="realtime">
<tb-timeinterval
@ -201,7 +205,7 @@
</div>
<ng-template #timezoneSelection>
@if (timezone && (isEdit || !timewindow.hideTimezone)) {
@if (timezone && !timewindow.hideTimezone) {
<tb-timezone
asButton strokedButton noMargin
localBrowserTimezonePlaceholderOnEmpty="true"

106
ui-ngx/src/app/shared/components/time/timewindow-panel.component.ts

@ -106,15 +106,13 @@ export class TimewindowPanelComponent extends PageComponent implements OnInit, O
saveTimewindow: boolean;
saveTimewindowControl: FormControl;
timewindowTypeOptions: ToggleHeaderOption[] = [{
name: this.translate.instant('timewindow.history'),
value: this.timewindowTypes.HISTORY
}];
timewindowTypeOptions: ToggleHeaderOption[] = [];
realtimeTimewindowOptions: ToggleHeaderOption[] = [];
historyTimewindowOptions: ToggleHeaderOption[] = [];
timewindowTypeSelectionAvailable: boolean;
realtimeTypeSelectionAvailable: boolean;
realtimeIntervalSelectionAvailable: boolean;
historyTypeSelectionAvailable: boolean;
@ -160,21 +158,51 @@ export class TimewindowPanelComponent extends PageComponent implements OnInit, O
this.updateTimewindowAdvancedParams();
if (!this.historyOnly) {
this.timewindowTypeOptions.unshift({
this.realtimeIntervalSelectionAvailable = !(this.timewindow.realtime?.hideInterval ||
(this.timewindow.realtime?.hideLastInterval && this.timewindow.realtime?.hideQuickInterval));
this.historyIntervalSelectionAvailable = !(this.timewindow.history?.hideInterval ||
(this.timewindow.history?.hideLastInterval && this.timewindow.history?.hideQuickInterval && this.timewindow.history?.hideFixedInterval));
this.aggregationOptionsAvailable = this.aggregation &&
!(this.timewindow.hideAggregation && this.timewindow.hideAggInterval);
const timezoneAvailable = this.timezone && !this.timewindow.hideTimezone;
// Whether a tab has anything left to show; steers the selected tab away from one that would render empty.
const realtimeHasContent = this.realtimeIntervalSelectionAvailable || this.aggregationOptionsAvailable || timezoneAvailable;
const historyHasContent = this.historyIntervalSelectionAvailable || this.aggregationOptionsAvailable || timezoneAvailable;
if (this.timewindow.selectedTab === TimewindowType.REALTIME && !realtimeHasContent && historyHasContent) {
this.timewindow.selectedTab = TimewindowType.HISTORY;
} else if (this.timewindow.selectedTab === TimewindowType.HISTORY && !historyHasContent && realtimeHasContent) {
this.timewindow.selectedTab = TimewindowType.REALTIME;
}
// When only one tab is hidden, the other stays the sole tab as usual (no switcher, hidden one unreachable).
// Only when BOTH are hidden does edit mode need a way back to either tab to configure their defaults.
const bothTabsHidden = this.timewindow.hideRealtime && this.timewindow.hideHistory;
if (!this.historyOnly && (!this.timewindow.hideRealtime || (this.isEdit && bothTabsHidden)) && realtimeHasContent) {
this.timewindowTypeOptions.push({
name: this.translate.instant('timewindow.realtime'),
value: this.timewindowTypes.REALTIME
});
}
if ((this.isEdit || !this.timewindow.realtime?.hideLastInterval) && !this.quickIntervalOnly) {
if ((!this.timewindow.hideHistory || (this.isEdit && bothTabsHidden)) && historyHasContent) {
this.timewindowTypeOptions.push({
name: this.translate.instant('timewindow.history'),
value: this.timewindowTypes.HISTORY
});
}
if (!this.timewindow.realtime?.hideLastInterval && !this.quickIntervalOnly) {
this.realtimeTimewindowOptions.push({
name: this.translate.instant(realtimeWindowTypeTranslations.get(RealtimeWindowType.LAST_INTERVAL)),
value: this.realtimeTypes.LAST_INTERVAL
});
}
if (this.isEdit || !this.timewindow.realtime?.hideQuickInterval || this.quickIntervalOnly) {
if (!this.timewindow.realtime?.hideQuickInterval || this.quickIntervalOnly) {
this.realtimeTimewindowOptions.push({
name: this.translate.instant(realtimeWindowTypeTranslations.get(RealtimeWindowType.INTERVAL)),
value: this.realtimeTypes.INTERVAL
@ -188,36 +216,30 @@ export class TimewindowPanelComponent extends PageComponent implements OnInit, O
});
}
if (this.isEdit || !this.timewindow.history?.hideLastInterval) {
if (!this.timewindow.history?.hideLastInterval) {
this.historyTimewindowOptions.push({
name: this.translate.instant(historyWindowTypeTranslations.get(HistoryWindowType.LAST_INTERVAL)),
value: this.historyTypes.LAST_INTERVAL
});
}
if (this.isEdit || !this.timewindow.history?.hideFixedInterval) {
if (!this.timewindow.history?.hideFixedInterval) {
this.historyTimewindowOptions.push({
name: this.translate.instant(historyWindowTypeTranslations.get(HistoryWindowType.FIXED)),
value: this.historyTypes.FIXED
});
}
if (this.isEdit || !this.timewindow.history?.hideQuickInterval) {
if (!this.timewindow.history?.hideQuickInterval) {
this.historyTimewindowOptions.push({
name: this.translate.instant(historyWindowTypeTranslations.get(HistoryWindowType.INTERVAL)),
value: this.historyTypes.INTERVAL
});
}
this.timewindowTypeSelectionAvailable = this.timewindowTypeOptions.length > 1;
this.realtimeTypeSelectionAvailable = this.realtimeTimewindowOptions.length > 1;
this.historyTypeSelectionAvailable = this.historyTimewindowOptions.length > 1;
this.realtimeIntervalSelectionAvailable = this.isEdit || !(this.timewindow.realtime?.hideInterval ||
(this.timewindow.realtime?.hideLastInterval && this.timewindow.realtime?.hideQuickInterval));
this.historyIntervalSelectionAvailable = this.isEdit || !(this.timewindow.history?.hideInterval ||
(this.timewindow.history?.hideLastInterval && this.timewindow.history?.hideQuickInterval && this.timewindow.history?.hideFixedInterval));
this.aggregationOptionsAvailable = this.aggregation && (this.isEdit ||
!(this.timewindow.hideAggregation && this.timewindow.hideAggInterval));
this.saveAsDefaultAvailable = this.data.showSaveAsDefault && (!this.timewindow.hideSaveAsDefault || this.isEdit);
}
@ -231,34 +253,32 @@ export class TimewindowPanelComponent extends PageComponent implements OnInit, O
const history = this.timewindow.history;
const aggregation = this.timewindow.aggregation;
if (!this.isEdit) {
if (realtime?.hideLastInterval && !realtime?.hideQuickInterval) {
realtime.realtimeType = RealtimeWindowType.INTERVAL;
}
if (realtime?.hideQuickInterval && !realtime?.hideLastInterval) {
realtime.realtimeType = RealtimeWindowType.LAST_INTERVAL;
}
if (realtime?.hideLastInterval && !realtime?.hideQuickInterval) {
realtime.realtimeType = RealtimeWindowType.INTERVAL;
}
if (realtime?.hideQuickInterval && !realtime?.hideLastInterval) {
realtime.realtimeType = RealtimeWindowType.LAST_INTERVAL;
}
if (history?.hideLastInterval) {
if (!history.hideFixedInterval) {
history.historyType = HistoryWindowType.FIXED;
} else if (!history.hideQuickInterval) {
history.historyType = HistoryWindowType.INTERVAL;
}
if (history?.hideLastInterval) {
if (!history.hideFixedInterval) {
history.historyType = HistoryWindowType.FIXED;
} else if (!history.hideQuickInterval) {
history.historyType = HistoryWindowType.INTERVAL;
}
if (history?.hideFixedInterval) {
if (!history.hideLastInterval) {
history.historyType = HistoryWindowType.LAST_INTERVAL;
} else if (!history.hideQuickInterval) {
history.historyType = HistoryWindowType.INTERVAL;
}
}
if (history?.hideFixedInterval) {
if (!history.hideLastInterval) {
history.historyType = HistoryWindowType.LAST_INTERVAL;
} else if (!history.hideQuickInterval) {
history.historyType = HistoryWindowType.INTERVAL;
}
if (history?.hideQuickInterval) {
if (!history.hideLastInterval) {
history.historyType = HistoryWindowType.LAST_INTERVAL;
} else if (!history.hideFixedInterval) {
history.historyType = HistoryWindowType.FIXED;
}
}
if (history?.hideQuickInterval) {
if (!history.hideLastInterval) {
history.historyType = HistoryWindowType.LAST_INTERVAL;
} else if (!history.hideFixedInterval) {
history.historyType = HistoryWindowType.FIXED;
}
}

27
ui-ngx/src/app/shared/components/time/timewindow.component.ts

@ -381,15 +381,24 @@ export class TimewindowComponent implements ControlValueAccessor, OnInit, OnChan
}
private isTimewindowDisabled(): boolean {
return this.disabled ||
(!this.isEdit && (!this.innerValue || (
((this.innerValue.realtime?.hideInterval && this.innerValue.history?.hideInterval) ||
(this.innerValue.realtime?.hideLastInterval && this.innerValue.realtime?.hideQuickInterval &&
this.innerValue.history?.hideLastInterval && this.innerValue.history?.hideFixedInterval &&
this.innerValue.history?.hideQuickInterval)) &&
(!this.aggregation || this.innerValue.hideAggregation && this.innerValue.hideAggInterval) &&
(!this.timezone || this.innerValue.hideTimezone)
)));
if (this.disabled || this.isEdit) {
return this.disabled;
}
if (!this.innerValue) {
return true;
}
if (this.innerValue.hideRealtime && this.innerValue.hideHistory) {
return true;
}
return (
(this.innerValue.hideRealtime || (this.innerValue.realtime?.hideInterval ||
(this.innerValue.realtime?.hideLastInterval && this.innerValue.realtime?.hideQuickInterval))) &&
(this.innerValue.hideHistory || (this.innerValue.history?.hideInterval ||
(this.innerValue.history?.hideLastInterval && this.innerValue.history?.hideFixedInterval &&
this.innerValue.history?.hideQuickInterval))) &&
(!this.aggregation || (this.innerValue.hideAggregation && this.innerValue.hideAggInterval)) &&
(!this.timezone || this.innerValue.hideTimezone)
);
}
private createPanel() {

19
ui-ngx/src/app/shared/models/time/time.models.ts

@ -151,6 +151,8 @@ export interface Timewindow {
hideAggregation?: boolean;
hideAggInterval?: boolean;
hideTimezone?: boolean;
hideRealtime?: boolean;
hideHistory?: boolean;
selectedTab?: TimewindowType;
realtime?: RealtimeWindow;
history?: HistoryWindow;
@ -331,8 +333,19 @@ export const initModelFromDefaultTimewindow = (value: Timewindow, quickIntervalO
if (value.hideSaveAsDefault) {
model.hideSaveAsDefault = value.hideSaveAsDefault;
}
if (value.hideRealtime) {
model.hideRealtime = value.hideRealtime;
}
if (value.hideHistory) {
model.hideHistory = value.hideHistory;
}
model.selectedTab = getTimewindowType(value);
if (model.hideRealtime && model.selectedTab === TimewindowType.REALTIME) {
model.selectedTab = TimewindowType.HISTORY;
} else if (model.hideHistory && model.selectedTab === TimewindowType.HISTORY) {
model.selectedTab = TimewindowType.REALTIME;
}
// for backward compatibility
if ((value as any).hideInterval) {
@ -1121,6 +1134,12 @@ export const cloneSelectedTimewindow = (timewindow: Timewindow): Timewindow => {
if (timewindow.hideSaveAsDefault) {
cloned.hideSaveAsDefault = timewindow.hideSaveAsDefault;
}
if (timewindow.hideRealtime) {
cloned.hideRealtime = timewindow.hideRealtime;
}
if (timewindow.hideHistory) {
cloned.hideHistory = timewindow.hideHistory;
}
if (isDefined(timewindow.selectedTab)) {
cloned.selectedTab = timewindow.selectedTab;
}

4
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -14303,6 +14303,10 @@
"preview": "Preview",
"relative": "Relative",
"range": "Range",
"hide-realtime-tab": "Hide 'Realtime' tab from end-users",
"hide-history-tab": "Hide 'History' tab from end-users",
"realtime-section-empty": "All 'Realtime' options are hidden, leaving nothing for end users to configure. Keep at least one option visible, or hide the entire 'Realtime' tab instead.",
"history-section-empty": "All 'History' options are hidden, leaving nothing for end users to configure. Keep at least one option visible, or hide the entire 'History' tab instead.",
"hide-timewindow-section": "Hide time window section from end-users",
"hide-last-interval": "Hide last interval from end-users",
"hide-relative-interval": "Hide relative interval from end-users",

Loading…
Cancel
Save