diff --git a/ui-ngx/src/app/shared/components/time/timewindow-config-dialog.component.html b/ui-ngx/src/app/shared/components/time/timewindow-config-dialog.component.html index 1f08c8ac8f..dc663febd9 100644 --- a/ui-ngx/src/app/shared/components/time/timewindow-config-dialog.component.html +++ b/ui-ngx/src/app/shared/components/time/timewindow-config-dialog.component.html @@ -23,176 +23,206 @@
@if (timewindowForm.get('selectedTab').value === timewindowTypes.REALTIME) { -
-
{{ 'timewindow.timewindow' | translate }}
+
- - {{ 'timewindow.hide-timewindow-section' | translate }} + + {{ 'timewindow.hide-realtime-tab' | translate }}
- @if (realtimeTypeSelectionAvailable) { - - +
+ @if (!timewindowForm.get('hideRealtime').value) { + @if (timewindowForm.hasError('realtimeSectionEmpty')) { + } - @if (timewindowForm.get('realtime.realtimeType').value === realtimeTypes.LAST_INTERVAL) { +
+
{{ 'timewindow.timewindow' | translate }}
- - {{ 'timewindow.disable-custom-interval' | translate }} + + {{ 'timewindow.hide-timewindow-section' | translate }}
-
- @if (!quickIntervalOnly) { - -
- {{ 'timewindow.hide' | translate }} -
-
+ @if (!timewindowForm.get('realtime.hideInterval').value) { + @if (realtimeTypeSelectionAvailable) { + + } - - @if (!(timewindowForm.get('realtime.hideLastInterval').value || - timewindowForm.get('realtime.hideInterval').value)) { - - } - -
- } - @if (timewindowForm.get('realtime.realtimeType').value === realtimeTypes.INTERVAL) { -
- @if (!quickIntervalOnly) { - -
- {{ 'timewindow.hide' | translate }} -
-
+ @if (timewindowForm.get('realtime.realtimeType').value === realtimeTypes.LAST_INTERVAL) { +
+ + {{ 'timewindow.disable-custom-interval' | translate }} + +
+
+ @if (!quickIntervalOnly) { + +
+ {{ 'timewindow.hide' | translate }} +
+
+ } + + @if (!timewindowForm.get('realtime.hideLastInterval').value) { + + } + +
} - - @if (!(timewindowForm.get('realtime.hideQuickInterval').value || - timewindowForm.get('realtime.hideInterval').value)) { - - } - -
- } -
+ @if (timewindowForm.get('realtime.realtimeType').value === realtimeTypes.INTERVAL) { +
+ @if (!quickIntervalOnly) { + +
+ {{ 'timewindow.hide' | translate }} +
+
+ } + + @if (!timewindowForm.get('realtime.hideQuickInterval').value) { + + } + +
+ } + } +
+ } } @if (timewindowForm.get('selectedTab').value === timewindowTypes.HISTORY) { -
-
{{ 'timewindow.timewindow' | translate }}
+
- - {{ 'timewindow.hide-timewindow-section' | translate }} + + {{ 'timewindow.hide-history-tab' | translate }}
- - - @if (timewindowForm.get('history.historyType').value === historyTypes.LAST_INTERVAL) { +
+ @if (!timewindowForm.get('hideHistory').value) { + @if (timewindowForm.hasError('historySectionEmpty')) { + + } +
+
{{ 'timewindow.timewindow' | translate }}
- - {{ 'timewindow.disable-custom-interval' | translate }} + + {{ 'timewindow.hide-timewindow-section' | translate }}
-
- -
- {{ 'timewindow.hide' | translate }} + @if (!timewindowForm.get('history.hideInterval').value) { + + + @if (timewindowForm.get('history.historyType').value === historyTypes.LAST_INTERVAL) { +
+ + {{ 'timewindow.disable-custom-interval' | translate }} +
- - - @if (!(timewindowForm.get('history.hideLastInterval').value || - timewindowForm.get('history.hideInterval').value)) { - - } - -
- } - @if (timewindowForm.get('history.historyType').value === historyTypes.FIXED) { -
- -
- {{ 'timewindow.hide' | translate }} +
+ +
+ {{ 'timewindow.hide' | translate }} +
+
+ + @if (!timewindowForm.get('history.hideLastInterval').value) { + + } +
- - - -
- } - @if (timewindowForm.get('history.historyType').value === historyTypes.INTERVAL) { -
- -
- {{ 'timewindow.hide' | translate }} + } + @if (timewindowForm.get('history.historyType').value === historyTypes.FIXED) { +
+ +
+ {{ 'timewindow.hide' | translate }} +
+
+ +
- - - @if (!(timewindowForm.get('history.hideQuickInterval').value || - timewindowForm.get('history.hideInterval').value)) { - - } - -
- } -
+ } + @if (timewindowForm.get('history.historyType').value === historyTypes.INTERVAL) { +
+ +
+ {{ 'timewindow.hide' | translate }} +
+
+ + @if (!timewindowForm.get('history.hideQuickInterval').value) { + + } + +
+ } + } +
+ } } - @if (aggregation) { + @if (!selectedTabHidden) { + @if (aggregation) {
{{ 'aggregation.aggregation' | translate }}
@@ -318,6 +348,7 @@
} + }
diff --git a/ui-ngx/src/app/shared/components/time/timewindow-config-dialog.component.scss b/ui-ngx/src/app/shared/components/time/timewindow-config-dialog.component.scss index 9a2962eb2e..d6de2c20df 100644 --- a/ui-ngx/src/app/shared/components/time/timewindow-config-dialog.component.scss +++ b/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; + } + } } } 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 0cbb5ef0a7..01acc34b0c 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 @@ -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(); 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 5aa7c80aa9..589c3c9bfb 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 @@ -5,11 +5,15 @@ -->
- @if (!historyOnly) { + @if (timewindowTypeOptions.length || isEdit) {
- - + @if (timewindowTypeSelectionAvailable) { + + + } @else if (timewindowTypeOptions.length) { +
{{ timewindowTypeOptions[0].name }}
+ } @if (isEdit) {
- } @else { + } @else if (timezone && !timewindow.hideTimezone) {
{{ 'timezone.timezone' | translate }}
@@ -130,7 +134,7 @@
} - } @else { + } @else if (timezone && !timewindow.hideTimezone) {
{{ 'timezone.timezone' | translate }}
@@ -141,7 +145,7 @@ @if (aggregationOptionsAvailable) { - @if (isEdit || !timewindow.hideAggregation) { + @if (!timewindow.hideAggregation) {
{{ 'aggregation.aggregation' | translate }}
} - @if (timewindowForm.get('aggregation.type').value === aggregationTypes.NONE && (isEdit || !timewindow.hideAggInterval)) { + @if (timewindowForm.get('aggregation.type').value === aggregationTypes.NONE && !timewindow.hideAggInterval) {
{{ 'aggregation.limit' | translate }}
@@ -161,7 +165,7 @@ @if (timewindowForm.get('aggregation.type').value !== aggregationTypes.NONE) {
+ [class.!hidden]="timewindow.hideAggInterval"> @if (timewindowForm.get('selectedTab').value === timewindowTypes.REALTIME) { - @if (timezone && (isEdit || !timewindow.hideTimezone)) { + @if (timezone && !timewindow.hideTimezone) {