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 { TbPopoverService } from '@shared/components/popover.service';
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 { of, shareReplay, timer } from 'rxjs';
import { MINUTE, SECOND } from '@shared/models/time/time.models';
import { DebugSettings } from '@shared/models/entity.models';
import { SECOND, MINUTE } from '@shared/models/time/time.models';
import { EntityDebugSettings } from '@shared/models/entity.models';
import { map, switchMap, takeWhile } from 'rxjs/operators';
import { getCurrentAuthState } from '@core/auth/auth.selectors';
import { AppState } from '@core/core.state';
@ -41,8 +41,8 @@ import { Store } from '@ngrx/store';
import { ControlValueAccessor, FormBuilder, NG_VALUE_ACCESSOR } from '@angular/forms';
@Component({
selector: 'tb-debug-settings-button',
templateUrl: './debug-settings-button.component.html',
selector: 'tb-entity-debug-settings-button',
templateUrl: './entity-debug-settings-button.component.html',
standalone: true,
imports: [
CommonModule,
@ -52,13 +52,13 @@ import { ControlValueAccessor, FormBuilder, NG_VALUE_ACCESSOR } from '@angular/f
providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => DebugSettingsButtonComponent),
useExisting: forwardRef(() => EntityDebugSettingsButtonComponent),
multi: true
},
],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class DebugSettingsButtonComponent implements ControlValueAccessor {
export class EntityDebugSettingsButtonComponent implements ControlValueAccessor {
@Input() debugLimitsConfiguration: string;
@ -88,7 +88,7 @@ export class DebugSettingsButtonComponent implements ControlValueAccessor {
readonly maxDebugModeDuration = getCurrentAuthState(this.store).maxDebugModeDurationMinutes * MINUTE;
private propagateChange: (settings: DebugSettings) => void = () => {};
private propagateChange: (settings: EntityDebugSettings) => void = () => {};
constructor(private popoverService: TbPopoverService,
private renderer: Renderer2,
@ -127,7 +127,7 @@ export class DebugSettingsButtonComponent implements ControlValueAccessor {
this.popoverService.hidePopover(trigger);
} else {
const debugStrategyPopover = this.popoverService.displayPopover(trigger, this.renderer,
this.viewContainerRef, DebugSettingsPanelComponent, 'bottom', true, null,
this.viewContainerRef, EntityDebugSettingsPanelComponent, 'bottom', true, null,
{
...debugSettings,
maxDebugModeDuration: this.maxDebugModeDuration,
@ -136,7 +136,7 @@ export class DebugSettingsButtonComponent implements ControlValueAccessor {
{},
{}, {}, true);
debugStrategyPopover.tbComponentRef.instance.popover = debugStrategyPopover;
debugStrategyPopover.tbComponentRef.instance.onSettingsApplied.subscribe((settings: DebugSettings) => {
debugStrategyPopover.tbComponentRef.instance.onSettingsApplied.subscribe((settings: EntityDebugSettings) => {
this.debugSettingsFormGroup.patchValue(settings);
this.cd.markForCheck();
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;
}
registerOnTouched(_: () => void): void {}
writeValue(settings: DebugSettings): void {
writeValue(settings: EntityDebugSettings): void {
this.debugSettingsFormGroup.patchValue(settings, {emitEvent: false});
this.allEnabled.set(settings?.allEnabled);
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 { of, shareReplay, timer } from 'rxjs';
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';
@Component({
selector: 'tb-debug-settings-panel',
templateUrl: './debug-settings-panel.component.html',
selector: 'tb-entity-debug-settings-panel',
templateUrl: './entity-debug-settings-panel.component.html',
standalone: true,
imports: [
SharedModule,
@ -46,9 +46,9 @@ import { distinctUntilChanged, map, startWith, switchMap, takeWhile } from 'rxjs
],
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 }) allEnabled = false;
@Input() allEnabledUntil = 0;
@ -78,7 +78,7 @@ export class DebugSettingsPanelComponent extends PageComponent implements OnInit
shareReplay(1),
);
onSettingsApplied = new EventEmitter<DebugSettings>();
onSettingsApplied = new EventEmitter<EntityDebugSettings>();
constructor(private fb: FormBuilder,
private cd: ChangeDetectorRef) {

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

@ -35,7 +35,7 @@
</mat-error>
</mat-form-field>
<section class="mb-5 flex max-w-xs flex-row">
<tb-debug-settings-button
<tb-entity-debug-settings-button
class="mr-2"
formControlName="debugSettings"
[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 { HttpStatusCode } from '@angular/common/http';
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;
@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();
}

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 { RuleNodeConfigComponent } from './rule-node-config.component';
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({
declarations: [
@ -63,7 +63,7 @@ import { DebugSettingsButtonComponent } from '@home/components/debug-settings/de
HomeComponentsModule,
RuleChainRoutingModule,
DurationLeftPipe,
DebugSettingsButtonComponent
EntityDebugSettingsButtonComponent
]
})
export class RuleChainModule { }

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

@ -193,11 +193,11 @@ export interface HasVersion {
version?: number;
}
export interface HasDebugSettings {
debugSettings?: DebugSettings;
export interface HasEntityDebugSettings {
debugSettings?: EntityDebugSettings;
}
export interface DebugSettings {
export interface EntityDebugSettings {
failuresEnabled?: boolean;
allEnabled?: boolean;
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 { RuleChainType } from '@shared/models/rule-chain.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 {
[key: string]: any;
}
export interface RuleNode extends BaseData<RuleNodeId>, HasDebugSettings {
export interface RuleNode extends BaseData<RuleNodeId>, HasEntityDebugSettings {
ruleChainId?: RuleChainId;
type: string;
name: string;
@ -331,7 +331,7 @@ export interface RuleNodeComponentDescriptor extends ComponentDescriptor {
configurationDescriptor?: RuleNodeConfigurationDescriptor;
}
export interface FcRuleNodeType extends FcNode, HasDebugSettings {
export interface FcRuleNodeType extends FcNode, HasEntityDebugSettings {
component?: RuleNodeComponentDescriptor;
singletonMode?: boolean;
queueName?: string;

Loading…
Cancel
Save