Browse Source

Merge pull request #12226 from maxunbearable/refactoring/debug-settings

Debug Settings minor refactoring
pull/12255/head
Igor Kulikov 2 years ago
committed by GitHub
parent
commit
d263fece7e
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 0
      ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings-button.component.html
  2. 24
      ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings-button.component.ts
  3. 0
      ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings-panel.component.html
  4. 12
      ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings-panel.component.ts
  5. 2
      ui-ngx/src/app/modules/home/pages/rulechain/rule-node-details.component.html
  6. 4
      ui-ngx/src/app/modules/home/pages/rulechain/rulechain-page.component.ts
  7. 4
      ui-ngx/src/app/modules/home/pages/rulechain/rulechain.module.ts
  8. 6
      ui-ngx/src/app/shared/models/entity.models.ts
  9. 6
      ui-ngx/src/app/shared/models/rule-node.models.ts

0
ui-ngx/src/app/modules/home/components/debug-settings/debug-settings-button.component.html → ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings-button.component.html

24
ui-ngx/src/app/modules/home/components/debug-settings/debug-settings-button.component.ts → ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings-button.component.ts

@ -29,11 +29,11 @@ import { SharedModule } from '@shared/shared.module';
import { DurationLeftPipe } from '@shared/pipe/duration-left.pipe'; import { DurationLeftPipe } from '@shared/pipe/duration-left.pipe';
import { TbPopoverService } from '@shared/components/popover.service'; import { TbPopoverService } from '@shared/components/popover.service';
import { MatButton } from '@angular/material/button'; import { MatButton } from '@angular/material/button';
import { DebugSettingsPanelComponent } from './debug-settings-panel.component'; import { EntityDebugSettingsPanelComponent } from './entity-debug-settings-panel.component';
import { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop'; import { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';
import { of, shareReplay, timer } from 'rxjs'; import { of, shareReplay, timer } from 'rxjs';
import { MINUTE, SECOND } from '@shared/models/time/time.models'; import { SECOND, MINUTE } from '@shared/models/time/time.models';
import { DebugSettings } from '@shared/models/entity.models'; import { EntityDebugSettings } from '@shared/models/entity.models';
import { map, switchMap, takeWhile } from 'rxjs/operators'; import { map, switchMap, takeWhile } from 'rxjs/operators';
import { getCurrentAuthState } from '@core/auth/auth.selectors'; import { getCurrentAuthState } from '@core/auth/auth.selectors';
import { AppState } from '@core/core.state'; import { AppState } from '@core/core.state';
@ -41,8 +41,8 @@ import { Store } from '@ngrx/store';
import { ControlValueAccessor, FormBuilder, NG_VALUE_ACCESSOR } from '@angular/forms'; import { ControlValueAccessor, FormBuilder, NG_VALUE_ACCESSOR } from '@angular/forms';
@Component({ @Component({
selector: 'tb-debug-settings-button', selector: 'tb-entity-debug-settings-button',
templateUrl: './debug-settings-button.component.html', templateUrl: './entity-debug-settings-button.component.html',
standalone: true, standalone: true,
imports: [ imports: [
CommonModule, CommonModule,
@ -52,13 +52,13 @@ import { ControlValueAccessor, FormBuilder, NG_VALUE_ACCESSOR } from '@angular/f
providers: [ providers: [
{ {
provide: NG_VALUE_ACCESSOR, provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => DebugSettingsButtonComponent), useExisting: forwardRef(() => EntityDebugSettingsButtonComponent),
multi: true multi: true
}, },
], ],
changeDetection: ChangeDetectionStrategy.OnPush changeDetection: ChangeDetectionStrategy.OnPush
}) })
export class DebugSettingsButtonComponent implements ControlValueAccessor { export class EntityDebugSettingsButtonComponent implements ControlValueAccessor {
@Input() debugLimitsConfiguration: string; @Input() debugLimitsConfiguration: string;
@ -88,7 +88,7 @@ export class DebugSettingsButtonComponent implements ControlValueAccessor {
readonly maxDebugModeDuration = getCurrentAuthState(this.store).maxDebugModeDurationMinutes * MINUTE; readonly maxDebugModeDuration = getCurrentAuthState(this.store).maxDebugModeDurationMinutes * MINUTE;
private propagateChange: (settings: DebugSettings) => void = () => {}; private propagateChange: (settings: EntityDebugSettings) => void = () => {};
constructor(private popoverService: TbPopoverService, constructor(private popoverService: TbPopoverService,
private renderer: Renderer2, private renderer: Renderer2,
@ -127,7 +127,7 @@ export class DebugSettingsButtonComponent implements ControlValueAccessor {
this.popoverService.hidePopover(trigger); this.popoverService.hidePopover(trigger);
} else { } else {
const debugStrategyPopover = this.popoverService.displayPopover(trigger, this.renderer, const debugStrategyPopover = this.popoverService.displayPopover(trigger, this.renderer,
this.viewContainerRef, DebugSettingsPanelComponent, 'bottom', true, null, this.viewContainerRef, EntityDebugSettingsPanelComponent, 'bottom', true, null,
{ {
...debugSettings, ...debugSettings,
maxDebugModeDuration: this.maxDebugModeDuration, maxDebugModeDuration: this.maxDebugModeDuration,
@ -136,7 +136,7 @@ export class DebugSettingsButtonComponent implements ControlValueAccessor {
{}, {},
{}, {}, true); {}, {}, true);
debugStrategyPopover.tbComponentRef.instance.popover = debugStrategyPopover; debugStrategyPopover.tbComponentRef.instance.popover = debugStrategyPopover;
debugStrategyPopover.tbComponentRef.instance.onSettingsApplied.subscribe((settings: DebugSettings) => { debugStrategyPopover.tbComponentRef.instance.onSettingsApplied.subscribe((settings: EntityDebugSettings) => {
this.debugSettingsFormGroup.patchValue(settings); this.debugSettingsFormGroup.patchValue(settings);
this.cd.markForCheck(); this.cd.markForCheck();
debugStrategyPopover.hide(); debugStrategyPopover.hide();
@ -144,13 +144,13 @@ export class DebugSettingsButtonComponent implements ControlValueAccessor {
} }
} }
registerOnChange(fn: (settings: DebugSettings) => void): void { registerOnChange(fn: (settings: EntityDebugSettings) => void): void {
this.propagateChange = fn; this.propagateChange = fn;
} }
registerOnTouched(_: () => void): void {} registerOnTouched(_: () => void): void {}
writeValue(settings: DebugSettings): void { writeValue(settings: EntityDebugSettings): void {
this.debugSettingsFormGroup.patchValue(settings, {emitEvent: false}); this.debugSettingsFormGroup.patchValue(settings, {emitEvent: false});
this.allEnabled.set(settings?.allEnabled); this.allEnabled.set(settings?.allEnabled);
this.debugSettingsFormGroup.get('allEnabled').updateValueAndValidity({onlySelf: true}); this.debugSettingsFormGroup.get('allEnabled').updateValueAndValidity({onlySelf: true});

0
ui-ngx/src/app/modules/home/components/debug-settings/debug-settings-panel.component.html → ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings-panel.component.html

12
ui-ngx/src/app/modules/home/components/debug-settings/debug-settings-panel.component.ts → ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings-panel.component.ts

@ -32,12 +32,12 @@ import { SECOND } from '@shared/models/time/time.models';
import { DurationLeftPipe } from '@shared/pipe/duration-left.pipe'; import { DurationLeftPipe } from '@shared/pipe/duration-left.pipe';
import { of, shareReplay, timer } from 'rxjs'; import { of, shareReplay, timer } from 'rxjs';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { DebugSettings } from '@shared/models/entity.models'; import { EntityDebugSettings } from '@shared/models/entity.models';
import { distinctUntilChanged, map, startWith, switchMap, takeWhile } from 'rxjs/operators'; import { distinctUntilChanged, map, startWith, switchMap, takeWhile } from 'rxjs/operators';
@Component({ @Component({
selector: 'tb-debug-settings-panel', selector: 'tb-entity-debug-settings-panel',
templateUrl: './debug-settings-panel.component.html', templateUrl: './entity-debug-settings-panel.component.html',
standalone: true, standalone: true,
imports: [ imports: [
SharedModule, SharedModule,
@ -46,9 +46,9 @@ import { distinctUntilChanged, map, startWith, switchMap, takeWhile } from 'rxjs
], ],
changeDetection: ChangeDetectionStrategy.OnPush changeDetection: ChangeDetectionStrategy.OnPush
}) })
export class DebugSettingsPanelComponent extends PageComponent implements OnInit { export class EntityDebugSettingsPanelComponent extends PageComponent implements OnInit {
@Input() popover: TbPopoverComponent<DebugSettingsPanelComponent>; @Input() popover: TbPopoverComponent<EntityDebugSettingsPanelComponent>;
@Input({ transform: booleanAttribute }) failuresEnabled = false; @Input({ transform: booleanAttribute }) failuresEnabled = false;
@Input({ transform: booleanAttribute }) allEnabled = false; @Input({ transform: booleanAttribute }) allEnabled = false;
@Input() allEnabledUntil = 0; @Input() allEnabledUntil = 0;
@ -78,7 +78,7 @@ export class DebugSettingsPanelComponent extends PageComponent implements OnInit
shareReplay(1), shareReplay(1),
); );
onSettingsApplied = new EventEmitter<DebugSettings>(); onSettingsApplied = new EventEmitter<EntityDebugSettings>();
constructor(private fb: FormBuilder, constructor(private fb: FormBuilder,
private cd: ChangeDetectorRef) { private cd: ChangeDetectorRef) {

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

@ -35,7 +35,7 @@
</mat-error> </mat-error>
</mat-form-field> </mat-form-field>
<section class="mb-5 flex max-w-xs flex-row"> <section class="mb-5 flex max-w-xs flex-row">
<tb-debug-settings-button <tb-entity-debug-settings-button
class="mr-2" class="mr-2"
formControlName="debugSettings" formControlName="debugSettings"
[debugLimitsConfiguration]="ruleChainDebugPerTenantLimitsConfiguration" [debugLimitsConfiguration]="ruleChainDebugPerTenantLimitsConfiguration"

4
ui-ngx/src/app/modules/home/pages/rulechain/rulechain-page.component.ts

@ -95,7 +95,7 @@ import { ComponentClusteringMode } from '@shared/models/component-descriptor.mod
import { MatDrawer } from '@angular/material/sidenav'; import { MatDrawer } from '@angular/material/sidenav';
import { HttpStatusCode } from '@angular/common/http'; import { HttpStatusCode } from '@angular/common/http';
import { TbContextMenuEvent } from '@shared/models/jquery-event.models'; import { TbContextMenuEvent } from '@shared/models/jquery-event.models';
import { DebugSettings } from '@shared/models/entity.models'; import { EntityDebugSettings } from '@shared/models/entity.models';
import Timeout = NodeJS.Timeout; import Timeout = NodeJS.Timeout;
@Component({ @Component({
@ -1437,7 +1437,7 @@ export class RuleChainPageComponent extends PageComponent
} }
} }
private isDebugSettingsActive(debugSettings: DebugSettings): boolean { private isDebugSettingsActive(debugSettings: EntityDebugSettings): boolean {
return debugSettings.allEnabled || debugSettings.failuresEnabled || debugSettings.allEnabledUntil > new Date().getTime(); return debugSettings.allEnabled || debugSettings.failuresEnabled || debugSettings.allEnabledUntil > new Date().getTime();
} }

4
ui-ngx/src/app/modules/home/pages/rulechain/rulechain.module.ts

@ -33,7 +33,7 @@ import { RuleNodeLinkComponent } from './rule-node-link.component';
import { LinkLabelsComponent } from '@home/pages/rulechain/link-labels.component'; import { LinkLabelsComponent } from '@home/pages/rulechain/link-labels.component';
import { RuleNodeConfigComponent } from './rule-node-config.component'; import { RuleNodeConfigComponent } from './rule-node-config.component';
import { DurationLeftPipe } from '@shared/pipe/duration-left.pipe'; import { DurationLeftPipe } from '@shared/pipe/duration-left.pipe';
import { DebugSettingsButtonComponent } from '@home/components/debug-settings/debug-settings-button.component'; import { EntityDebugSettingsButtonComponent } from '@home/components/entity/debug/entity-debug-settings-button.component';
@NgModule({ @NgModule({
declarations: [ declarations: [
@ -63,7 +63,7 @@ import { DebugSettingsButtonComponent } from '@home/components/debug-settings/de
HomeComponentsModule, HomeComponentsModule,
RuleChainRoutingModule, RuleChainRoutingModule,
DurationLeftPipe, DurationLeftPipe,
DebugSettingsButtonComponent EntityDebugSettingsButtonComponent
] ]
}) })
export class RuleChainModule { } export class RuleChainModule { }

6
ui-ngx/src/app/shared/models/entity.models.ts

@ -193,11 +193,11 @@ export interface HasVersion {
version?: number; version?: number;
} }
export interface HasDebugSettings { export interface HasEntityDebugSettings {
debugSettings?: DebugSettings; debugSettings?: EntityDebugSettings;
} }
export interface DebugSettings { export interface EntityDebugSettings {
failuresEnabled?: boolean; failuresEnabled?: boolean;
allEnabled?: boolean; allEnabled?: boolean;
allEnabledUntil?: number; allEnabledUntil?: number;

6
ui-ngx/src/app/shared/models/rule-node.models.ts

@ -27,13 +27,13 @@ import { AppState } from '@core/core.state';
import { AbstractControl, UntypedFormGroup } from '@angular/forms'; import { AbstractControl, UntypedFormGroup } from '@angular/forms';
import { RuleChainType } from '@shared/models/rule-chain.models'; import { RuleChainType } from '@shared/models/rule-chain.models';
import { DebugRuleNodeEventBody } from '@shared/models/event.models'; import { DebugRuleNodeEventBody } from '@shared/models/event.models';
import { HasDebugSettings } from '@shared/models/entity.models'; import { HasEntityDebugSettings } from '@shared/models/entity.models';
export interface RuleNodeConfiguration { export interface RuleNodeConfiguration {
[key: string]: any; [key: string]: any;
} }
export interface RuleNode extends BaseData<RuleNodeId>, HasDebugSettings { export interface RuleNode extends BaseData<RuleNodeId>, HasEntityDebugSettings {
ruleChainId?: RuleChainId; ruleChainId?: RuleChainId;
type: string; type: string;
name: string; name: string;
@ -331,7 +331,7 @@ export interface RuleNodeComponentDescriptor extends ComponentDescriptor {
configurationDescriptor?: RuleNodeConfigurationDescriptor; configurationDescriptor?: RuleNodeConfigurationDescriptor;
} }
export interface FcRuleNodeType extends FcNode, HasDebugSettings { export interface FcRuleNodeType extends FcNode, HasEntityDebugSettings {
component?: RuleNodeComponentDescriptor; component?: RuleNodeComponentDescriptor;
singletonMode?: boolean; singletonMode?: boolean;
queueName?: string; queueName?: string;

Loading…
Cancel
Save