Browse Source

Merge pull request #12811 from maxunbearable/improvement/debug-settings-service

Added debug settings service
pull/12936/head
Igor Kulikov 2 years ago
committed by GitHub
parent
commit
6b5f197d05
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 79
      ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table-config.ts
  2. 12
      ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table.component.ts
  3. 12
      ui-ngx/src/app/modules/home/components/calculated-fields/components/debug-dialog/calculated-field-debug-dialog.component.ts
  4. 16
      ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.ts
  5. 10
      ui-ngx/src/app/modules/home/components/calculated-fields/components/test-dialog/calculated-field-script-test-dialog.component.ts
  6. 2
      ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings-button.component.html
  7. 49
      ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings-button.component.ts
  8. 3
      ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings-panel.component.ts
  9. 33
      ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings.model.ts
  10. 69
      ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings.service.ts
  11. 2
      ui-ngx/src/app/modules/home/components/home-components.module.ts
  12. 27
      ui-ngx/src/app/shared/models/calculated-field.models.ts
  13. 5
      ui-ngx/src/app/shared/models/entity.models.ts
  14. 2
      ui-ngx/src/app/shared/shared.module.ts

79
ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table-config.ts

@ -33,36 +33,32 @@ import { AppState } from '@core/core.state';
import { getCurrentAuthState, getCurrentAuthUser } from '@core/auth/auth.selectors';
import { DestroyRef, Renderer2 } from '@angular/core';
import { EntityDebugSettings } from '@shared/models/entity.models';
import { DurationLeftPipe } from '@shared/pipe/duration-left.pipe';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { TbPopoverService } from '@shared/components/popover.service';
import { EntityDebugSettingsPanelComponent } from '@home/components/entity/debug/entity-debug-settings-panel.component';
import { CalculatedFieldsService } from '@core/http/calculated-fields.service';
import { catchError, filter, switchMap, tap } from 'rxjs/operators';
import {
ArgumentType,
CalculatedField,
CalculatedFieldEventArguments,
CalculatedFieldDebugDialogData,
CalculatedFieldDialogData,
CalculatedFieldTestScriptDialogData,
CalculatedFieldType,
CalculatedFieldTypeTranslations,
getCalculatedFieldArgumentsEditorCompleter,
getCalculatedFieldArgumentsHighlights,
CalculatedFieldTypeTranslations,
CalculatedFieldType,
} from '@shared/models/calculated-field.models';
import {
CalculatedFieldDebugDialogComponent,
CalculatedFieldDebugDialogComponent, CalculatedFieldDebugDialogData,
CalculatedFieldDialogComponent,
CalculatedFieldScriptTestDialogComponent
CalculatedFieldDialogData,
CalculatedFieldScriptTestDialogComponent,
CalculatedFieldTestScriptDialogData
} from './components/public-api';
import { ImportExportService } from '@shared/import-export/import-export.service';
import { isObject } from '@core/utils';
import { EntityDebugSettingsService } from '@home/components/entity/debug/entity-debug-settings.service';
import { DatePipe } from '@angular/common';
export class CalculatedFieldsTableConfig extends EntityTableConfig<CalculatedField, PageLink> {
export class CalculatedFieldsTableConfig extends EntityTableConfig<CalculatedField> {
// TODO: [Calculated Fields] remove hardcode when BE variable implemented
readonly calculatedFieldsDebugPerTenantLimitsConfiguration =
getCurrentAuthState(this.store)['calculatedFieldsDebugPerTenantLimitsConfiguration'] || '1:1';
readonly maxDebugModeDuration = getCurrentAuthState(this.store).maxDebugModeDurationMinutes * MINUTE;
@ -78,12 +74,11 @@ export class CalculatedFieldsTableConfig extends EntityTableConfig<CalculatedFie
private datePipe: DatePipe,
public entityId: EntityId = null,
private store: Store<AppState>,
private durationLeft: DurationLeftPipe,
private popoverService: TbPopoverService,
private destroyRef: DestroyRef,
private renderer: Renderer2,
public entityName: string,
private importExportService: ImportExportService
private importExportService: ImportExportService,
private entityDebugSettingsService: EntityDebugSettingsService,
) {
super();
this.tableTitle = this.translate.instant('entity.type-calculated-fields');
@ -147,10 +142,10 @@ export class CalculatedFieldsTableConfig extends EntityTableConfig<CalculatedFie
},
{
name: '',
nameFunction: entity => this.getDebugConfigLabel(entity?.debugSettings),
nameFunction: entity => this.entityDebugSettingsService.getDebugConfigLabel(entity?.debugSettings),
icon: 'mdi:bug',
isEnabled: () => true,
iconFunction: ({ debugSettings }) => this.isDebugActive(debugSettings?.allEnabledUntil) || debugSettings?.failuresEnabled ? 'mdi:bug' : 'mdi:bug-outline',
iconFunction: ({ debugSettings }) => this.entityDebugSettingsService.isDebugActive(debugSettings?.allEnabledUntil) || debugSettings?.failuresEnabled ? 'mdi:bug' : 'mdi:bug-outline',
onAction: ($event, entity) => this.onOpenDebugConfig($event, entity),
},
{
@ -180,30 +175,26 @@ export class CalculatedFieldsTableConfig extends EntityTableConfig<CalculatedFie
...this.additionalDebugActionConfig,
action: () => this.openDebugEventsDialog(calculatedField)
};
const { viewContainerRef } = this.getTable();
if ($event) {
$event.stopPropagation();
}
const trigger = $event.target as Element;
if (this.popoverService.hasPopover(trigger)) {
this.popoverService.hidePopover(trigger);
} else {
const debugStrategyPopover = this.popoverService.displayPopover(trigger, this.renderer,
viewContainerRef, EntityDebugSettingsPanelComponent, 'bottom', true, null,
{
debugLimitsConfiguration: this.calculatedFieldsDebugPerTenantLimitsConfiguration,
maxDebugModeDuration: this.maxDebugModeDuration,
entityLabel: this.translate.instant('debug-settings.calculated-field'),
additionalActionConfig,
...debugSettings
},
{},
{}, {}, true);
debugStrategyPopover.tbComponentRef.instance.onSettingsApplied.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((settings: EntityDebugSettings) => {
this.onDebugConfigChanged(id.id, settings);
debugStrategyPopover.hide();
});
const { viewContainerRef, renderer } = this.entityDebugSettingsService;
if (!viewContainerRef || !renderer) {
this.entityDebugSettingsService.viewContainerRef = this.getTable().viewContainerRef;
this.entityDebugSettingsService.renderer = this.renderer;
}
this.entityDebugSettingsService.openDebugStrategyPanel({
debugSettings,
debugConfig: {
debugLimitsConfiguration: this.calculatedFieldsDebugPerTenantLimitsConfiguration,
maxDebugModeDuration: this.maxDebugModeDuration,
entityLabel: this.translate.instant('debug-settings.calculated-field'),
additionalActionConfig,
},
onSettingsAppliedFn: settings => this.onDebugConfigChanged(id.id, settings)
}, $event.target as Element);
}
private editCalculatedField(calculatedField: CalculatedField, isDirty = false): void {
@ -263,20 +254,6 @@ export class CalculatedFieldsTableConfig extends EntityTableConfig<CalculatedFie
.subscribe(() => this.updateData());
}
private getDebugConfigLabel(debugSettings: EntityDebugSettings): string {
const isDebugActive = this.isDebugActive(debugSettings?.allEnabledUntil);
if (!isDebugActive) {
return debugSettings?.failuresEnabled ? this.translate.instant('debug-settings.failures') : this.translate.instant('common.disabled');
} else {
return this.durationLeft.transform(debugSettings?.allEnabledUntil);
}
}
private isDebugActive(allEnabledUntil: number): boolean {
return allEnabledUntil > new Date().getTime();
}
private onDebugConfigChanged(id: string, debugSettings: EntityDebugSettings): void {
this.calculatedFieldsService.getCalculatedFieldById(id).pipe(
switchMap(field => this.calculatedFieldsService.saveCalculatedField({ ...field, debugSettings })),

12
ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table.component.ts

@ -31,10 +31,9 @@ import { MatDialog } from '@angular/material/dialog';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import { CalculatedFieldsTableConfig } from '@home/components/calculated-fields/calculated-fields-table-config';
import { DurationLeftPipe } from '@shared/pipe/duration-left.pipe';
import { TbPopoverService } from '@shared/components/popover.service';
import { CalculatedFieldsService } from '@core/http/calculated-fields.service';
import { ImportExportService } from '@shared/import-export/import-export.service';
import { EntityDebugSettingsService } from '@home/components/entity/debug/entity-debug-settings.service';
import { DatePipe } from '@angular/common';
@Component({
@ -42,6 +41,7 @@ import { DatePipe } from '@angular/common';
templateUrl: './calculated-fields-table.component.html',
styleUrls: ['./calculated-fields-table.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [EntityDebugSettingsService]
})
export class CalculatedFieldsTableComponent {
@ -58,11 +58,10 @@ export class CalculatedFieldsTableComponent {
private dialog: MatDialog,
private store: Store<AppState>,
private datePipe: DatePipe,
private durationLeft: DurationLeftPipe,
private popoverService: TbPopoverService,
private cd: ChangeDetectorRef,
private renderer: Renderer2,
private importExportService: ImportExportService,
private entityDebugSettingsService: EntityDebugSettingsService,
private destroyRef: DestroyRef) {
effect(() => {
@ -74,12 +73,11 @@ export class CalculatedFieldsTableComponent {
this.datePipe,
this.entityId(),
this.store,
this.durationLeft,
this.popoverService,
this.destroyRef,
this.renderer,
this.entityName(),
this.importExportService
this.importExportService,
this.entityDebugSettingsService,
);
this.cd.markForCheck();
}

12
ui-ngx/src/app/modules/home/components/calculated-fields/components/debug-dialog/calculated-field-debug-dialog.component.ts

@ -22,7 +22,17 @@ import { Router } from '@angular/router';
import { DialogComponent } from '@shared/components/dialog.component';
import { CalculatedFieldEventBody, DebugEventType, EventType } from '@shared/models/event.models';
import { EventTableComponent } from '@home/components/event/event-table.component';
import { CalculatedFieldDebugDialogData, CalculatedFieldType } from '@shared/models/calculated-field.models';
import {
CalculatedField,
CalculatedFieldTestScriptFn,
CalculatedFieldType
} from '@shared/models/calculated-field.models';
export interface CalculatedFieldDebugDialogData {
tenantId: string;
value: CalculatedField;
getTestScriptDialogFn: CalculatedFieldTestScriptFn;
}
@Component({
selector: 'tb-calculated-field-debug-dialog',

16
ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.ts

@ -25,7 +25,7 @@ import {
CalculatedField,
CalculatedFieldConfiguration,
calculatedFieldDefaultScript,
CalculatedFieldDialogData,
CalculatedFieldTestScriptFn,
CalculatedFieldType,
CalculatedFieldTypeTranslations,
getCalculatedFieldArgumentsEditorCompleter,
@ -41,6 +41,20 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ScriptLanguage } from '@shared/models/rule-node.models';
import { CalculatedFieldsService } from '@core/http/calculated-fields.service';
import { Observable } from 'rxjs';
import { EntityId } from '@shared/models/id/entity-id';
import { AdditionalDebugActionConfig } from '@home/components/entity/debug/entity-debug-settings.model';
export interface CalculatedFieldDialogData {
value?: CalculatedField;
buttonTitle: string;
entityId: EntityId;
debugLimitsConfiguration: string;
tenantId: string;
entityName?: string;
additionalDebugActionConfig: AdditionalDebugActionConfig<(calculatedField: CalculatedField) => void>;
getTestScriptDialogFn: CalculatedFieldTestScriptFn;
isDirty?: boolean;
}
@Component({
selector: 'tb-calculated-field-dialog',

10
ui-ngx/src/app/modules/home/components/calculated-fields/components/test-dialog/calculated-field-script-test-dialog.component.ts

@ -42,9 +42,17 @@ import { filter } from 'rxjs/operators';
import {
ArgumentType,
CalculatedFieldEventArguments,
CalculatedFieldTestScriptDialogData,
CalculatedFieldTestScriptInputParams,
TestArgumentTypeMap
} from '@shared/models/calculated-field.models';
import { TbEditorCompleter } from '@shared/models/ace/completion.models';
import { AceHighlightRules } from '@shared/models/ace/ace.models';
export interface CalculatedFieldTestScriptDialogData extends CalculatedFieldTestScriptInputParams {
argumentsEditorCompleter: TbEditorCompleter;
argumentsHighlightRules: AceHighlightRules;
openCalculatedFieldEdit?: boolean;
}
@Component({
selector: 'tb-calculated-field-script-test-dialog',

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

@ -21,7 +21,7 @@
#matButton
[class.active]="((isDebugAllActive$ | async) || failuresEnabled) && !disabled"
[disabled]="disabled"
(click)="openDebugStrategyPanel($event, matButton)">
(click)="onOpenDebugStrategyPanel($event, matButton)">
<mat-icon [color]="debugSettingsFormGroup.disabled ? 'inherit' : 'primary'">bug_report</mat-icon>
@if (isDebugAllActive$ | async) {
{{ (allEnabled$ | async) === false ? (allEnabledUntil | durationLeft) : (maxDebugModeDuration | milliSecondsToTimeString: true : true) }}

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

@ -20,24 +20,22 @@ import {
Component,
forwardRef,
Input,
Renderer2,
ViewContainerRef
} from '@angular/core';
import { CommonModule } from '@angular/common';
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 { EntityDebugSettingsPanelComponent } from './entity-debug-settings-panel.component';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { BehaviorSubject, of, shareReplay, timer } from 'rxjs';
import { SECOND, MINUTE } from '@shared/models/time/time.models';
import { AdditionalDebugActionConfig, EntityDebugSettings } from '@shared/models/entity.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';
import { Store } from '@ngrx/store';
import { ControlValueAccessor, FormBuilder, NG_VALUE_ACCESSOR } from '@angular/forms';
import { EntityDebugSettingsService } from '@home/components/entity/debug/entity-debug-settings.service';
import { AdditionalDebugActionConfig } from '@home/components/entity/debug/entity-debug-settings.model';
@Component({
selector: 'tb-entity-debug-settings-button',
@ -54,6 +52,7 @@ import { ControlValueAccessor, FormBuilder, NG_VALUE_ACCESSOR } from '@angular/f
useExisting: forwardRef(() => EntityDebugSettingsButtonComponent),
multi: true
},
EntityDebugSettingsService
],
changeDetection: ChangeDetectionStrategy.OnPush
})
@ -92,11 +91,9 @@ export class EntityDebugSettingsButtonComponent implements ControlValueAccessor
private propagateChange: (settings: EntityDebugSettings) => void = () => {};
constructor(private popoverService: TbPopoverService,
private renderer: Renderer2,
private store: Store<AppState>,
private viewContainerRef: ViewContainerRef,
constructor(private store: Store<AppState>,
private fb: FormBuilder,
private entityDebugSettingsService: EntityDebugSettingsService,
private cd : ChangeDetectorRef,
) {
this.debugSettingsFormGroup.valueChanges.pipe(
@ -118,33 +115,23 @@ export class EntityDebugSettingsButtonComponent implements ControlValueAccessor
return this.debugSettingsFormGroup.get('allEnabledUntil').value;
}
openDebugStrategyPanel($event: Event, matButton: MatButton): void {
onOpenDebugStrategyPanel($event: Event, matButton: MatButton): void {
if ($event) {
$event.stopPropagation();
}
const trigger = matButton._elementRef.nativeElement;
const debugSettings = this.debugSettingsFormGroup.value;
if (this.popoverService.hasPopover(trigger)) {
this.popoverService.hidePopover(trigger);
} else {
const debugStrategyPopover = this.popoverService.displayPopover(trigger, this.renderer,
this.viewContainerRef, EntityDebugSettingsPanelComponent, 'bottom', true, null,
{
...debugSettings,
maxDebugModeDuration: this.maxDebugModeDuration,
debugLimitsConfiguration: this.debugLimitsConfiguration,
entityLabel: this.entityLabel,
additionalActionConfig: this.additionalActionConfig,
},
{},
{}, {}, true);
debugStrategyPopover.tbComponentRef.instance.onSettingsApplied.subscribe((settings: EntityDebugSettings) => {
this.entityDebugSettingsService.openDebugStrategyPanel({
debugSettings: this.debugSettingsFormGroup.value,
debugConfig: {
maxDebugModeDuration: this.maxDebugModeDuration,
debugLimitsConfiguration: this.debugLimitsConfiguration,
entityLabel: this.entityLabel,
additionalActionConfig: this.additionalActionConfig,
},
onSettingsAppliedFn: settings => {
this.debugSettingsFormGroup.patchValue(settings);
this.cd.markForCheck();
debugStrategyPopover.hide();
});
}
}
}, matButton._elementRef.nativeElement);
}
registerOnChange(fn: (settings: EntityDebugSettings) => void): void {

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

@ -32,8 +32,9 @@ 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 { AdditionalDebugActionConfig, EntityDebugSettings } from '@shared/models/entity.models';
import { EntityDebugSettings } from '@shared/models/entity.models';
import { distinctUntilChanged, map, startWith, switchMap, takeWhile } from 'rxjs/operators';
import { AdditionalDebugActionConfig } from '@home/components/entity/debug/entity-debug-settings.model';
@Component({
selector: 'tb-entity-debug-settings-panel',

33
ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings.model.ts

@ -0,0 +1,33 @@
///
/// Copyright © 2016-2025 The Thingsboard Authors
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
import { EntityDebugSettings } from '@shared/models/entity.models';
export interface AdditionalDebugActionConfig<Action = (...args: unknown[]) => void> {
action: Action;
title: string;
}
export interface EntityDebugSettingPanelConfig {
debugSettings: EntityDebugSettings;
debugConfig: {
maxDebugModeDuration: number;
debugLimitsConfiguration: string;
entityLabel?: string;
additionalActionConfig?: AdditionalDebugActionConfig;
}
onSettingsAppliedFn: (settings: EntityDebugSettings) => void;
}

69
ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings.service.ts

@ -0,0 +1,69 @@
///
/// Copyright © 2016-2025 The Thingsboard Authors
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
import { Injectable, Optional, Renderer2, ViewContainerRef } from '@angular/core';
import { EntityDebugSettingsPanelComponent } from '@home/components/entity/debug/entity-debug-settings-panel.component';
import { EntityDebugSettings } from '@shared/models/entity.models';
import { TbPopoverService } from '@shared/components/popover.service';
import { TranslateService } from '@ngx-translate/core';
import { DurationLeftPipe } from '@shared/pipe/duration-left.pipe';
import { EntityDebugSettingPanelConfig } from '@home/components/entity/debug/entity-debug-settings.model';
@Injectable()
export class EntityDebugSettingsService {
constructor(
private popoverService: TbPopoverService,
@Optional() public renderer: Renderer2,
@Optional() public viewContainerRef: ViewContainerRef,
private translate: TranslateService,
private durationLeft: DurationLeftPipe,
) {}
openDebugStrategyPanel(panelConfig: EntityDebugSettingPanelConfig, trigger: Element): void {
if (this.popoverService.hasPopover(trigger)) {
this.popoverService.hidePopover(trigger);
} else {
const debugStrategyPopover = this.popoverService.displayPopover(trigger, this.renderer,
this.viewContainerRef, EntityDebugSettingsPanelComponent, 'bottom', true, null,
{
...panelConfig.debugSettings,
...panelConfig.debugConfig,
},
{},
{}, {}, true);
debugStrategyPopover.tbComponentRef.instance.onSettingsApplied.subscribe(settings => {
panelConfig.onSettingsAppliedFn(settings);
debugStrategyPopover.hide();
});
}
}
getDebugConfigLabel(debugSettings: EntityDebugSettings): string {
const isDebugActive = this.isDebugActive(debugSettings?.allEnabledUntil);
if (!isDebugActive) {
return debugSettings?.failuresEnabled ? this.translate.instant('debug-settings.failures') : this.translate.instant('common.disabled');
} else {
return this.durationLeft.transform(debugSettings?.allEnabledUntil);
}
}
isDebugActive(allEnabledUntil: number): boolean {
return allEnabledUntil > new Date().getTime();
}
}

2
ui-ngx/src/app/modules/home/components/home-components.module.ts

@ -184,7 +184,6 @@ import {
import { EntityChipsComponent } from '@home/components/entity/entity-chips.component';
import { DashboardViewComponent } from '@home/components/dashboard-view/dashboard-view.component';
import { CalculatedFieldsTableComponent } from '@home/components/calculated-fields/calculated-fields-table.component';
import { DurationLeftPipe } from '@shared/pipe/duration-left.pipe';
import { CalculatedFieldDialogComponent } from '@home/components/calculated-fields/components/dialog/calculated-field-dialog.component';
import {
EntityDebugSettingsButtonComponent
@ -504,7 +503,6 @@ import {
providers: [
WidgetComponentService,
CustomDialogService,
DurationLeftPipe,
{provide: EMBED_DASHBOARD_DIALOG_TOKEN, useValue: EmbedDashboardDialogComponent},
{provide: COMPLEX_FILTER_PREDICATE_DIALOG_COMPONENT_TOKEN, useValue: ComplexFilterPredicateDialogComponent},
{provide: DASHBOARD_PAGE_COMPONENT_TOKEN, useValue: DashboardPageComponent},

27
ui-ngx/src/app/shared/models/calculated-field.models.ts

@ -15,7 +15,6 @@
///
import {
AdditionalDebugActionConfig,
HasEntityDebugSettings,
HasTenantId,
HasVersion
@ -149,35 +148,11 @@ export interface CalculatedFieldArgumentValue extends CalculatedFieldArgument {
export type CalculatedFieldTestScriptFn = (calculatedField: CalculatedField, argumentsObj?: Record<string, unknown>, closeAllOnSave?: boolean) => Observable<string>;
export interface CalculatedFieldDialogData {
value?: CalculatedField;
buttonTitle: string;
entityId: EntityId;
debugLimitsConfiguration: string;
tenantId: string;
entityName?: string;
additionalDebugActionConfig: AdditionalDebugActionConfig<(calculatedField: CalculatedField) => void>;
getTestScriptDialogFn: CalculatedFieldTestScriptFn;
isDirty?: boolean;
}
export interface CalculatedFieldDebugDialogData {
tenantId: string;
value: CalculatedField;
getTestScriptDialogFn: CalculatedFieldTestScriptFn;
}
export interface CalculatedFieldTestScriptInputParams {
arguments: CalculatedFieldEventArguments;
expression: string;
}
export interface CalculatedFieldTestScriptDialogData extends CalculatedFieldTestScriptInputParams {
argumentsEditorCompleter: TbEditorCompleter;
argumentsHighlightRules: AceHighlightRules;
openCalculatedFieldEdit?: boolean;
}
export interface ArgumentEntityTypeParams {
title: string;
entityType: EntityType
@ -622,7 +597,7 @@ const calculatedFieldSingleArgumentValueHighlightRules: AceHighlightRules = {
}
const calculatedFieldRollingArgumentValueFunctionsHighlightRules: Array<AceHighlightRule> =
['max', 'min', 'avg', 'mean', 'std', 'median', 'count', 'last', 'first', 'sum', 'merge', 'mergeAll'].map(funcName => ({
Object.keys(CalculatedFieldRollingValueArgumentFunctionsAutocomplete).map(funcName => ({
token: 'tb.calculated-field-func',
regex: `\\b${funcName}\\b`,
next: 'no_regex'

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

@ -208,9 +208,4 @@ export interface EntityTestScriptResult {
error: string;
}
export interface AdditionalDebugActionConfig<Action = (...args: unknown[]) => void> {
action: Action;
title: string;
}
export type VersionedEntity = EntityInfoData & HasVersion | RuleChainMetaData;

2
ui-ngx/src/app/shared/shared.module.ts

@ -225,6 +225,7 @@ import { GroupingIntervalOptionsComponent } from '@shared/components/time/aggreg
import { JsFuncModulesComponent } from '@shared/components/js-func-modules.component';
import { JsFuncModuleRowComponent } from '@shared/components/js-func-module-row.component';
import { EntityKeyAutocompleteComponent } from '@shared/components/entity/entity-key-autocomplete.component';
import { DurationLeftPipe } from '@shared/pipe/duration-left.pipe';
export function MarkedOptionsFactory(markedOptionsService: MarkedOptionsService) {
return markedOptionsService;
@ -244,6 +245,7 @@ export function MarkedOptionsFactory(markedOptionsService: MarkedOptionsService)
ShortNumberPipe,
ImagePipe,
CustomTranslatePipe,
DurationLeftPipe,
{
provide: FlowInjectionToken,
useValue: Flow

Loading…
Cancel
Save