From fa9c04325327fbd3eefa4e54fb432cc9228c92c2 Mon Sep 17 00:00:00 2001 From: mpetrov Date: Wed, 13 Nov 2024 15:09:29 +0200 Subject: [PATCH] refactoring --- ui-ngx/src/app/core/auth/auth.models.ts | 2 +- ui-ngx/src/app/core/auth/auth.reducer.ts | 2 +- .../debug-config-button.component.ts | 17 +++++++++++------ .../debug-config-panel.component.html | 4 ++-- .../debug-config-panel.component.ts | 19 ++++++++++--------- .../components/event/event-table-config.ts | 6 +++--- .../components/event/event-table.component.ts | 2 +- ...-tenant-profile-configuration.component.ts | 2 +- .../rule-node-details.component.html | 3 +-- .../rulechain/rule-node-details.component.ts | 1 - 10 files changed, 31 insertions(+), 27 deletions(-) diff --git a/ui-ngx/src/app/core/auth/auth.models.ts b/ui-ngx/src/app/core/auth/auth.models.ts index e4d05e7d21..840984b34e 100644 --- a/ui-ngx/src/app/core/auth/auth.models.ts +++ b/ui-ngx/src/app/core/auth/auth.models.ts @@ -27,7 +27,7 @@ export interface SysParamsState { mobileQrEnabled: boolean; userSettings: UserSettings; maxResourceSize: number; - maxRuleNodeDebugDurationMinutes: number; + maxDebugModeDurationMinutes: number; ruleChainDebugPerTenantLimitsConfiguration?: string; } diff --git a/ui-ngx/src/app/core/auth/auth.reducer.ts b/ui-ngx/src/app/core/auth/auth.reducer.ts index e2ff1fae25..072f3f62a5 100644 --- a/ui-ngx/src/app/core/auth/auth.reducer.ts +++ b/ui-ngx/src/app/core/auth/auth.reducer.ts @@ -32,7 +32,7 @@ const emptyUserAuthState: AuthPayload = { mobileQrEnabled: false, maxResourceSize: 0, userSettings: initialUserSettings, - maxRuleNodeDebugDurationMinutes: 0, + maxDebugModeDurationMinutes: 0, }; export const initialState: AuthState = { diff --git a/ui-ngx/src/app/modules/home/components/debug-config/debug-config-button.component.ts b/ui-ngx/src/app/modules/home/components/debug-config/debug-config-button.component.ts index ad64833ace..154bacf69f 100644 --- a/ui-ngx/src/app/modules/home/components/debug-config/debug-config-button.component.ts +++ b/ui-ngx/src/app/modules/home/components/debug-config/debug-config-button.component.ts @@ -31,10 +31,13 @@ import { TbPopoverService } from '@shared/components/popover.service'; import { MatButton } from '@angular/material/button'; import { DebugConfigPanelComponent } from './debug-config-panel.component'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; -import { timer } from 'rxjs'; +import { shareReplay, timer } from 'rxjs'; import { SECOND } from '@shared/models/time/time.models'; import { HasDebugConfig } from '@shared/models/entity.models'; import { map } from 'rxjs/operators'; +import { getCurrentAuthState } from '@core/auth/auth.selectors'; +import { AppState } from '@core/core.state'; +import { Store } from '@ngrx/store'; @Component({ selector: 'tb-debug-config-button', @@ -53,15 +56,17 @@ export class DebugConfigButtonComponent { @Input() debugAll = false; @Input() debugAllUntil = 0; @Input() disabled = false; - @Input() maxRuleNodeDebugDurationMinutes: number; - @Input() ruleChainDebugPerTenantLimitsConfiguration: string; + @Input() debugLimitsConfiguration: string; @Output() onDebugConfigChanged = new EventEmitter(); - isDebugAllActive$ = timer(0, SECOND).pipe(map(() => this.debugAllUntil > new Date().getTime())); + isDebugAllActive$ = timer(0, SECOND).pipe(map(() => this.debugAllUntil > new Date().getTime()), shareReplay(1)); + + readonly maxDebugModeDurationMinutes = getCurrentAuthState(this.store).maxDebugModeDurationMinutes; constructor(private popoverService: TbPopoverService, private renderer: Renderer2, + private store: Store, private viewContainerRef: ViewContainerRef, private destroyRef: DestroyRef, ) {} @@ -80,8 +85,8 @@ export class DebugConfigButtonComponent { debugFailures: this.debugFailures, debugAll: this.debugAll, debugAllUntil: this.debugAllUntil, - maxRuleNodeDebugDurationMinutes: this.maxRuleNodeDebugDurationMinutes, - ruleChainDebugPerTenantLimitsConfiguration: this.ruleChainDebugPerTenantLimitsConfiguration + maxDebugModeDurationMinutes: this.maxDebugModeDurationMinutes, + debugLimitsConfiguration: this.debugLimitsConfiguration }, {}, {}, {}, true); diff --git a/ui-ngx/src/app/modules/home/components/debug-config/debug-config-panel.component.html b/ui-ngx/src/app/modules/home/components/debug-config/debug-config-panel.component.html index b463882110..2e3eb94648 100644 --- a/ui-ngx/src/app/modules/home/components/debug-config/debug-config-panel.component.html +++ b/ui-ngx/src/app/modules/home/components/debug-config/debug-config-panel.component.html @@ -19,7 +19,7 @@
debug-config.label
- + {{ 'debug-config.hint.main-limited' | translate: { msg: maxMessagesCount, sec: maxTimeFrameSec } }} {{ 'debug-config.hint.main' | translate }} @@ -34,7 +34,7 @@
- {{ 'debug-config.all-messages' | translate: { time: (isDebugAllActive$ | async) ? (debugAllUntil | durationLeft) : ('debug-config.min' | translate: { number: maxRuleNodeDebugDurationMinutes }) } }} + {{ 'debug-config.all-messages' | translate: { time: (isDebugAllActive$ | async) ? (debugAllUntil | durationLeft) : ('debug-config.min' | translate: { number: maxDebugModeDurationMinutes }) } }}