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;
userSettings: UserSettings;
maxResourceSize: number;
maxRuleNodeDebugDurationMinutes: number;
maxDebugModeDurationMinutes: number;
ruleChainDebugPerTenantLimitsConfiguration?: string;
}

2
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 = {

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 { 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<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,
private renderer: Renderer2,
private store: Store<AppState>,
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);

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="hint-container">
<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 } }}
</span>
<ng-template #noLimitHint>{{ 'debug-config.hint.main' | translate }}</ng-template>
@ -34,7 +34,7 @@
<div class="flex justify-between align-center">
<mat-slide-toggle class="mat-slide" [formControl]="debugAllControl">
<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>
</mat-slide-toggle>
<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 { MINUTE, SECOND } from '@shared/models/time/time.models';
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 { HasDebugConfig } from '@shared/models/entity.models';
import { distinctUntilChanged, map, tap } from 'rxjs/operators';
@ -51,8 +51,8 @@ export class DebugConfigPanelComponent extends PageComponent implements OnInit {
@Input() debugFailures = false;
@Input() debugAll = false;
@Input() debugAllUntil = 0;
@Input() maxRuleNodeDebugDurationMinutes: number;
@Input() ruleChainDebugPerTenantLimitsConfiguration: string;
@Input() maxDebugModeDurationMinutes: number;
@Input() debugLimitsConfiguration: string;
onFailuresControl = 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(
map(() => {
this.cd.markForCheck();
return this.debugAllUntil > new Date().getTime()
return this.debugAllUntil > new Date().getTime();
}),
distinctUntilChanged(),
tap(isDebugOn => this.debugAllControl.patchValue(isDebugOn, { emitEvent: false }))
tap(isDebugOn => this.debugAllControl.patchValue(isDebugOn, { emitEvent: false })),
shareReplay(1),
);
onConfigApplied = new EventEmitter<HasDebugConfig>();
@ -78,8 +79,8 @@ export class DebugConfigPanelComponent extends PageComponent implements OnInit {
}
ngOnInit(): void {
this.maxMessagesCount = this.ruleChainDebugPerTenantLimitsConfiguration?.split(':')[0];
this.maxTimeFrameSec = this.ruleChainDebugPerTenantLimitsConfiguration?.split(':')[1];
this.maxMessagesCount = this.debugLimitsConfiguration?.split(':')[0];
this.maxTimeFrameSec = this.debugLimitsConfiguration?.split(':')[1];
this.onFailuresControl.patchValue(this.debugFailures);
}
@ -97,12 +98,12 @@ export class DebugConfigPanelComponent extends PageComponent implements OnInit {
onReset(): void {
this.debugAll = true;
this.debugAllUntil = new Date().getTime() + this.maxRuleNodeDebugDurationMinutes * MINUTE;
this.debugAllUntil = new Date().getTime() + this.maxDebugModeDurationMinutes * MINUTE;
}
private observeDebugAllChange(): void {
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;
});
}

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 filterColumns: FilterEntityColumn[] = [];
private readonly maxRuleNodeDebugDurationMinutes = getCurrentAuthState(this.store).maxRuleNodeDebugDurationMinutes;
private readonly maxDebugModeDurationMinutes = getCurrentAuthState(this.store).maxDebugModeDurationMinutes;
set eventType(eventType: EventType | DebugEventType) {
if (this.eventTypeValue !== eventType) {
@ -92,14 +92,14 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> {
private overlay: Overlay,
private viewContainerRef: ViewContainerRef,
private cd: ChangeDetectorRef,
protected store: Store<AppState>,
private store: Store<AppState>,
public testButtonLabel?: string,
private debugEventSelected?: EventEmitter<EventBody>) {
super();
this.loadDataOnInit = false;
this.tableTitle = '';
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.selectionEnabled = 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 overlay: Overlay,
private viewContainerRef: ViewContainerRef,
protected store: Store<AppState>,
private store: Store<AppState>,
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, []],
tenantNotificationRequestsPerRuleRateLimit: [null, []],
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)]],
maxREExecutions: [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"
[debugFailures]="ruleNode.debugFailures"
[debugAllUntil]="ruleNode.debugAllUntil"
[maxRuleNodeDebugDurationMinutes]="maxRuleNodeDebugDurationMinutes"
[ruleChainDebugPerTenantLimitsConfiguration]="ruleChainDebugPerTenantLimitsConfiguration"
[debugLimitsConfiguration]="ruleChainDebugPerTenantLimitsConfiguration"
(onDebugConfigChanged)="onDebugConfigChanged($event)"
/>
<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;
readonly maxRuleNodeDebugDurationMinutes = getCurrentAuthState(this.store).maxRuleNodeDebugDurationMinutes;
readonly ruleChainDebugPerTenantLimitsConfiguration = getCurrentAuthState(this.store).ruleChainDebugPerTenantLimitsConfiguration;
private destroy$ = new Subject<void>();

Loading…
Cancel
Save