Browse Source

refactoring

pull/11861/head
mpetrov 2 years ago
parent
commit
fa9c043253
  1. 2
      ui-ngx/src/app/core/auth/auth.models.ts
  2. 2
      ui-ngx/src/app/core/auth/auth.reducer.ts
  3. 17
      ui-ngx/src/app/modules/home/components/debug-config/debug-config-button.component.ts
  4. 4
      ui-ngx/src/app/modules/home/components/debug-config/debug-config-panel.component.html
  5. 19
      ui-ngx/src/app/modules/home/components/debug-config/debug-config-panel.component.ts
  6. 6
      ui-ngx/src/app/modules/home/components/event/event-table-config.ts
  7. 2
      ui-ngx/src/app/modules/home/components/event/event-table.component.ts
  8. 2
      ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.ts
  9. 3
      ui-ngx/src/app/modules/home/pages/rulechain/rule-node-details.component.html
  10. 1
      ui-ngx/src/app/modules/home/pages/rulechain/rule-node-details.component.ts

2
ui-ngx/src/app/core/auth/auth.models.ts

@ -27,7 +27,7 @@ export interface SysParamsState {
mobileQrEnabled: boolean; mobileQrEnabled: boolean;
userSettings: UserSettings; userSettings: UserSettings;
maxResourceSize: number; maxResourceSize: number;
maxRuleNodeDebugDurationMinutes: number; maxDebugModeDurationMinutes: number;
ruleChainDebugPerTenantLimitsConfiguration?: string; ruleChainDebugPerTenantLimitsConfiguration?: string;
} }

2
ui-ngx/src/app/core/auth/auth.reducer.ts

@ -32,7 +32,7 @@ const emptyUserAuthState: AuthPayload = {
mobileQrEnabled: false, mobileQrEnabled: false,
maxResourceSize: 0, maxResourceSize: 0,
userSettings: initialUserSettings, userSettings: initialUserSettings,
maxRuleNodeDebugDurationMinutes: 0, maxDebugModeDurationMinutes: 0,
}; };
export const initialState: AuthState = { export const initialState: AuthState = {

17
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 { MatButton } from '@angular/material/button';
import { DebugConfigPanelComponent } from './debug-config-panel.component'; import { DebugConfigPanelComponent } from './debug-config-panel.component';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; 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 { SECOND } from '@shared/models/time/time.models';
import { HasDebugConfig } from '@shared/models/entity.models'; import { HasDebugConfig } from '@shared/models/entity.models';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { getCurrentAuthState } from '@core/auth/auth.selectors';
import { AppState } from '@core/core.state';
import { Store } from '@ngrx/store';
@Component({ @Component({
selector: 'tb-debug-config-button', selector: 'tb-debug-config-button',
@ -53,15 +56,17 @@ export class DebugConfigButtonComponent {
@Input() debugAll = false; @Input() debugAll = false;
@Input() debugAllUntil = 0; @Input() debugAllUntil = 0;
@Input() disabled = false; @Input() disabled = false;
@Input() maxRuleNodeDebugDurationMinutes: number; @Input() debugLimitsConfiguration: string;
@Input() ruleChainDebugPerTenantLimitsConfiguration: string;
@Output() onDebugConfigChanged = new EventEmitter<HasDebugConfig>(); @Output() onDebugConfigChanged = new EventEmitter<HasDebugConfig>();
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, constructor(private popoverService: TbPopoverService,
private renderer: Renderer2, private renderer: Renderer2,
private store: Store<AppState>,
private viewContainerRef: ViewContainerRef, private viewContainerRef: ViewContainerRef,
private destroyRef: DestroyRef, private destroyRef: DestroyRef,
) {} ) {}
@ -80,8 +85,8 @@ export class DebugConfigButtonComponent {
debugFailures: this.debugFailures, debugFailures: this.debugFailures,
debugAll: this.debugAll, debugAll: this.debugAll,
debugAllUntil: this.debugAllUntil, debugAllUntil: this.debugAllUntil,
maxRuleNodeDebugDurationMinutes: this.maxRuleNodeDebugDurationMinutes, maxDebugModeDurationMinutes: this.maxDebugModeDurationMinutes,
ruleChainDebugPerTenantLimitsConfiguration: this.ruleChainDebugPerTenantLimitsConfiguration debugLimitsConfiguration: this.debugLimitsConfiguration
}, },
{}, {},
{}, {}, true); {}, {}, true);

4
ui-ngx/src/app/modules/home/components/debug-config/debug-config-panel.component.html

@ -19,7 +19,7 @@
<div class="tb-form-panel-title" translate>debug-config.label</div> <div class="tb-form-panel-title" translate>debug-config.label</div>
<div class="hint-container"> <div class="hint-container">
<div class="tb-form-hint tb-primary-fill tb-flex center"> <div class="tb-form-hint tb-primary-fill tb-flex center">
<span *ngIf="ruleChainDebugPerTenantLimitsConfiguration else noLimitHint"> <span *ngIf="debugLimitsConfiguration else noLimitHint">
{{ 'debug-config.hint.main-limited' | translate: { msg: maxMessagesCount, sec: maxTimeFrameSec } }} {{ 'debug-config.hint.main-limited' | translate: { msg: maxMessagesCount, sec: maxTimeFrameSec } }}
</span> </span>
<ng-template #noLimitHint>{{ 'debug-config.hint.main' | translate }}</ng-template> <ng-template #noLimitHint>{{ 'debug-config.hint.main' | translate }}</ng-template>
@ -34,7 +34,7 @@
<div class="flex justify-between align-center"> <div class="flex justify-between align-center">
<mat-slide-toggle class="mat-slide" [formControl]="debugAllControl"> <mat-slide-toggle class="mat-slide" [formControl]="debugAllControl">
<div tb-hint-tooltip-icon="{{ 'debug-config.hint.all-messages' | translate }}"> <div tb-hint-tooltip-icon="{{ 'debug-config.hint.all-messages' | translate }}">
{{ '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 }) } }}
</div> </div>
</mat-slide-toggle> </mat-slide-toggle>
<button mat-icon-button *ngIf="(isDebugAllActive$ | async)" <button mat-icon-button *ngIf="(isDebugAllActive$ | async)"

19
ui-ngx/src/app/modules/home/components/debug-config/debug-config-panel.component.ts

@ -29,7 +29,7 @@ import { CommonModule } from '@angular/common';
import { SharedModule } from '@shared/shared.module'; import { SharedModule } from '@shared/shared.module';
import { MINUTE, SECOND } from '@shared/models/time/time.models'; import { MINUTE, SECOND } from '@shared/models/time/time.models';
import { DurationLeftPipe } from '@shared/pipe/duration-left.pipe'; import { DurationLeftPipe } from '@shared/pipe/duration-left.pipe';
import { timer } from 'rxjs'; import { shareReplay, timer } from 'rxjs';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { HasDebugConfig } from '@shared/models/entity.models'; import { HasDebugConfig } from '@shared/models/entity.models';
import { distinctUntilChanged, map, tap } from 'rxjs/operators'; import { distinctUntilChanged, map, tap } from 'rxjs/operators';
@ -51,8 +51,8 @@ export class DebugConfigPanelComponent extends PageComponent implements OnInit {
@Input() debugFailures = false; @Input() debugFailures = false;
@Input() debugAll = false; @Input() debugAll = false;
@Input() debugAllUntil = 0; @Input() debugAllUntil = 0;
@Input() maxRuleNodeDebugDurationMinutes: number; @Input() maxDebugModeDurationMinutes: number;
@Input() ruleChainDebugPerTenantLimitsConfiguration: string; @Input() debugLimitsConfiguration: string;
onFailuresControl = this.fb.control(false); onFailuresControl = this.fb.control(false);
debugAllControl = this.fb.control(false); debugAllControl = this.fb.control(false);
@ -63,10 +63,11 @@ export class DebugConfigPanelComponent extends PageComponent implements OnInit {
isDebugAllActive$ = timer(0, SECOND).pipe( isDebugAllActive$ = timer(0, SECOND).pipe(
map(() => { map(() => {
this.cd.markForCheck(); this.cd.markForCheck();
return this.debugAllUntil > new Date().getTime() return this.debugAllUntil > new Date().getTime();
}), }),
distinctUntilChanged(), distinctUntilChanged(),
tap(isDebugOn => this.debugAllControl.patchValue(isDebugOn, { emitEvent: false })) tap(isDebugOn => this.debugAllControl.patchValue(isDebugOn, { emitEvent: false })),
shareReplay(1),
); );
onConfigApplied = new EventEmitter<HasDebugConfig>(); onConfigApplied = new EventEmitter<HasDebugConfig>();
@ -78,8 +79,8 @@ export class DebugConfigPanelComponent extends PageComponent implements OnInit {
} }
ngOnInit(): void { ngOnInit(): void {
this.maxMessagesCount = this.ruleChainDebugPerTenantLimitsConfiguration?.split(':')[0]; this.maxMessagesCount = this.debugLimitsConfiguration?.split(':')[0];
this.maxTimeFrameSec = this.ruleChainDebugPerTenantLimitsConfiguration?.split(':')[1]; this.maxTimeFrameSec = this.debugLimitsConfiguration?.split(':')[1];
this.onFailuresControl.patchValue(this.debugFailures); this.onFailuresControl.patchValue(this.debugFailures);
} }
@ -97,12 +98,12 @@ export class DebugConfigPanelComponent extends PageComponent implements OnInit {
onReset(): void { onReset(): void {
this.debugAll = true; this.debugAll = true;
this.debugAllUntil = new Date().getTime() + this.maxRuleNodeDebugDurationMinutes * MINUTE; this.debugAllUntil = new Date().getTime() + this.maxDebugModeDurationMinutes * MINUTE;
} }
private observeDebugAllChange(): void { private observeDebugAllChange(): void {
this.debugAllControl.valueChanges.pipe(takeUntilDestroyed()).subscribe(value => { this.debugAllControl.valueChanges.pipe(takeUntilDestroyed()).subscribe(value => {
this.debugAllUntil = value? new Date().getTime() + this.maxRuleNodeDebugDurationMinutes * MINUTE : 0; this.debugAllUntil = value? new Date().getTime() + this.maxDebugModeDurationMinutes * MINUTE : 0;
this.debugAll = value; this.debugAll = value;
}); });
} }

6
ui-ngx/src/app/modules/home/components/event/event-table-config.ts

@ -62,7 +62,7 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> {
private filterParams: FilterEventBody = {}; private filterParams: FilterEventBody = {};
private filterColumns: FilterEntityColumn[] = []; private filterColumns: FilterEntityColumn[] = [];
private readonly maxRuleNodeDebugDurationMinutes = getCurrentAuthState(this.store).maxRuleNodeDebugDurationMinutes; private readonly maxDebugModeDurationMinutes = getCurrentAuthState(this.store).maxDebugModeDurationMinutes;
set eventType(eventType: EventType | DebugEventType) { set eventType(eventType: EventType | DebugEventType) {
if (this.eventTypeValue !== eventType) { if (this.eventTypeValue !== eventType) {
@ -92,14 +92,14 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> {
private overlay: Overlay, private overlay: Overlay,
private viewContainerRef: ViewContainerRef, private viewContainerRef: ViewContainerRef,
private cd: ChangeDetectorRef, private cd: ChangeDetectorRef,
protected store: Store<AppState>, private store: Store<AppState>,
public testButtonLabel?: string, public testButtonLabel?: string,
private debugEventSelected?: EventEmitter<EventBody>) { private debugEventSelected?: EventEmitter<EventBody>) {
super(); super();
this.loadDataOnInit = false; this.loadDataOnInit = false;
this.tableTitle = ''; this.tableTitle = '';
this.useTimePageLink = true; this.useTimePageLink = true;
this.defaultTimewindowInterval = this.maxRuleNodeDebugDurationMinutes ? historyInterval(this.maxRuleNodeDebugDurationMinutes * MINUTE) : historyInterval(DAY); this.defaultTimewindowInterval = this.maxDebugModeDurationMinutes ? historyInterval(this.maxDebugModeDurationMinutes * MINUTE) : historyInterval(DAY);
this.detailsPanelEnabled = false; this.detailsPanelEnabled = false;
this.selectionEnabled = false; this.selectionEnabled = false;
this.searchEnabled = false; this.searchEnabled = false;

2
ui-ngx/src/app/modules/home/components/event/event-table.component.ts

@ -125,7 +125,7 @@ export class EventTableComponent implements OnInit, AfterViewInit, OnDestroy {
private dialog: MatDialog, private dialog: MatDialog,
private overlay: Overlay, private overlay: Overlay,
private viewContainerRef: ViewContainerRef, private viewContainerRef: ViewContainerRef,
protected store: Store<AppState>, private store: Store<AppState>,
private cd: ChangeDetectorRef) { private cd: ChangeDetectorRef) {
} }

2
ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.ts

@ -85,7 +85,7 @@ export class DefaultTenantProfileConfigurationComponent implements ControlValueA
tenantNotificationRequestsRateLimit: [null, []], tenantNotificationRequestsRateLimit: [null, []],
tenantNotificationRequestsPerRuleRateLimit: [null, []], tenantNotificationRequestsPerRuleRateLimit: [null, []],
maxTransportMessages: [null, [Validators.required, Validators.min(0)]], maxTransportMessages: [null, [Validators.required, Validators.min(0)]],
maxRuleNodeDebugDurationMinutes: [null, [Validators.required, Validators.min(0)]], maxDebugModeDurationMinutes: [null, [Validators.required, Validators.min(0)]],
maxTransportDataPoints: [null, [Validators.required, Validators.min(0)]], maxTransportDataPoints: [null, [Validators.required, Validators.min(0)]],
maxREExecutions: [null, [Validators.required, Validators.min(0)]], maxREExecutions: [null, [Validators.required, Validators.min(0)]],
maxJSExecutions: [null, [Validators.required, Validators.min(0)]], maxJSExecutions: [null, [Validators.required, Validators.min(0)]],

3
ui-ngx/src/app/modules/home/pages/rulechain/rule-node-details.component.html

@ -40,8 +40,7 @@
[debugAll]="ruleNode.debugAll" [debugAll]="ruleNode.debugAll"
[debugFailures]="ruleNode.debugFailures" [debugFailures]="ruleNode.debugFailures"
[debugAllUntil]="ruleNode.debugAllUntil" [debugAllUntil]="ruleNode.debugAllUntil"
[maxRuleNodeDebugDurationMinutes]="maxRuleNodeDebugDurationMinutes" [debugLimitsConfiguration]="ruleChainDebugPerTenantLimitsConfiguration"
[ruleChainDebugPerTenantLimitsConfiguration]="ruleChainDebugPerTenantLimitsConfiguration"
(onDebugConfigChanged)="onDebugConfigChanged($event)" (onDebugConfigChanged)="onDebugConfigChanged($event)"
/> />
<button mat-stroked-button <button mat-stroked-button

1
ui-ngx/src/app/modules/home/pages/rulechain/rule-node-details.component.ts

@ -81,7 +81,6 @@ export class RuleNodeDetailsComponent extends PageComponent implements OnInit, O
ruleNodeFormGroup: UntypedFormGroup; ruleNodeFormGroup: UntypedFormGroup;
readonly maxRuleNodeDebugDurationMinutes = getCurrentAuthState(this.store).maxRuleNodeDebugDurationMinutes;
readonly ruleChainDebugPerTenantLimitsConfiguration = getCurrentAuthState(this.store).ruleChainDebugPerTenantLimitsConfiguration; readonly ruleChainDebugPerTenantLimitsConfiguration = getCurrentAuthState(this.store).ruleChainDebugPerTenantLimitsConfiguration;
private destroy$ = new Subject<void>(); private destroy$ = new Subject<void>();

Loading…
Cancel
Save