Browse Source

refactoring

pull/11861/head
mpetrov 2 years ago
parent
commit
e332fb3718
  1. 41
      ui-ngx/src/app/modules/home/pages/rulechain/debug-config-panel.component.ts

41
ui-ngx/src/app/modules/home/pages/rulechain/debug-config-panel.component.ts

@ -14,7 +14,15 @@
/// limitations under the License. /// limitations under the License.
/// ///
import { ChangeDetectorRef, Component, DestroyRef, EventEmitter, Input, OnInit } from '@angular/core'; import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
DestroyRef,
EventEmitter,
Input,
OnInit
} from '@angular/core';
import { PageComponent } from '@shared/components/page.component'; import { PageComponent } from '@shared/components/page.component';
import { TbPopoverComponent } from '@shared/components/popover.component'; import { TbPopoverComponent } from '@shared/components/popover.component';
import { FormControl, UntypedFormBuilder } from '@angular/forms'; import { FormControl, UntypedFormBuilder } from '@angular/forms';
@ -37,7 +45,8 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
SharedModule, SharedModule,
CommonModule, CommonModule,
DebugDurationLeftPipe DebugDurationLeftPipe
] ],
changeDetection: ChangeDetectionStrategy.OnPush
}) })
export class DebugConfigPanelComponent extends PageComponent implements OnInit { export class DebugConfigPanelComponent extends PageComponent implements OnInit {
@ -64,17 +73,8 @@ export class DebugConfigPanelComponent extends PageComponent implements OnInit {
this.onFailuresControl = this.fb.control(false); this.onFailuresControl = this.fb.control(false);
this.debugAllControl = this.fb.control(false); this.debugAllControl = this.fb.control(false);
interval(SECOND)
.pipe(takeUntilDestroyed(this.destroyRef)) this.observeDebugAllChange();
.subscribe(() => {
this.debugAllControl.patchValue(this.isDebugAllOn(), { emitEvent: false });
this.cdr.markForCheck();
});
this.debugAllControl.valueChanges.pipe(takeUntilDestroyed()).subscribe(value => {
this.debugAllUntil = value? new Date().getTime() + this.maxRuleNodeDebugDurationMinutes * MINUTE : 0;
this.debugAll = value;
this.cdr.markForCheck();
});
} }
ngOnInit(): void { ngOnInit(): void {
@ -102,4 +102,19 @@ export class DebugConfigPanelComponent extends PageComponent implements OnInit {
isDebugAllOn(): boolean { isDebugAllOn(): boolean {
return this.debugAllUntil > new Date().getTime(); return this.debugAllUntil > new Date().getTime();
} }
private observeDebugAllChange(): void {
interval(SECOND)
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(() => {
this.debugAllControl.patchValue(this.isDebugAllOn(), { emitEvent: false });
this.cdr.markForCheck();
});
this.debugAllControl.valueChanges.pipe(takeUntilDestroyed()).subscribe(value => {
this.debugAllUntil = value? new Date().getTime() + this.maxRuleNodeDebugDurationMinutes * MINUTE : 0;
this.debugAll = value;
this.cdr.markForCheck();
});
}
} }

Loading…
Cancel
Save