From dd8e82fb2c7efd97fa338f28be3f3dc16716d13e Mon Sep 17 00:00:00 2001 From: ArtemDzhereleiko Date: Thu, 6 Nov 2025 16:37:09 +0200 Subject: [PATCH] UI: Refactoring type --- ui-ngx/src/app/core/http/calculated-fields.service.ts | 3 +-- .../alarm-rules/alarm-rule-dialog.component.ts | 5 +++-- .../components/alarm-rules/alarm-rules-table-config.ts | 2 +- .../cf-alarm-rule-condition-dialog.component.ts | 4 ++-- ...m-rule-complex-filter-predicate-dialog.component.ts | 8 +++----- .../calculated-field-argument-panel.component.ts | 2 +- .../debug/entity-debug-settings-panel.component.ts | 7 ++----- .../entity/debug/entity-debug-settings.model.ts | 2 +- .../src/app/shared/models/calculated-field.models.ts | 10 +++++++--- 9 files changed, 21 insertions(+), 22 deletions(-) diff --git a/ui-ngx/src/app/core/http/calculated-fields.service.ts b/ui-ngx/src/app/core/http/calculated-fields.service.ts index 9c77f8007f..631550ae9e 100644 --- a/ui-ngx/src/app/core/http/calculated-fields.service.ts +++ b/ui-ngx/src/app/core/http/calculated-fields.service.ts @@ -51,8 +51,7 @@ export class CalculatedFieldsService { } public getCalculatedFields({ entityType, id }: EntityId, pageLink: PageLink, type?: CalculatedFieldType, config?: RequestConfig): Observable> { - let url = `/api/${entityType}/${id}/calculatedFields${pageLink.toQuery()}`; - return this.http.get>(url, createDefaultHttpOptions(type ? {type} : null, config)); + return this.http.get>(`/api/${entityType}/${id}/calculatedFields${pageLink.toQuery()}`, createDefaultHttpOptions(type ? {type} : null, config)); } public testScript(inputParams: CalculatedFieldTestScriptInputParams, config?: RequestConfig): Observable { diff --git a/ui-ngx/src/app/modules/home/components/alarm-rules/alarm-rule-dialog.component.ts b/ui-ngx/src/app/modules/home/components/alarm-rules/alarm-rule-dialog.component.ts index fe222c57bc..0ea3bd036e 100644 --- a/ui-ngx/src/app/modules/home/components/alarm-rules/alarm-rule-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/alarm-rules/alarm-rule-dialog.component.ts @@ -55,6 +55,7 @@ export class AlarmRuleDialogComponent extends DialogComponent { debugSettings, debugConfig: { entityType: EntityType.CALCULATED_FIELD, - isAlarmRule: true, + entityLabel: 'alarm-rule.alarm-rule', additionalActionConfig, }, onSettingsAppliedFn: settings => this.onDebugConfigChanged(id.id, settings) diff --git a/ui-ngx/src/app/modules/home/components/alarm-rules/cf-alarm-rule-condition-dialog.component.ts b/ui-ngx/src/app/modules/home/components/alarm-rules/cf-alarm-rule-condition-dialog.component.ts index 99ccd8ea21..48b290b32c 100644 --- a/ui-ngx/src/app/modules/home/components/alarm-rules/cf-alarm-rule-condition-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/alarm-rules/cf-alarm-rule-condition-dialog.component.ts @@ -74,11 +74,11 @@ export class CfAlarmRuleConditionDialogComponent extends DialogComponent(null, [Validators.required, Validators.min(1), Validators.max(2147483647), Validators.pattern('[0-9]*')]), - dynamicValueArgument: this.fb.control(null, Validators.required), + dynamicValueArgument: this.fb.control('', Validators.required), }), count: this.fb.group({ staticValue: this.fb.control(null, [Validators.required, Validators.min(1), Validators.max(2147483647), Validators.pattern('[0-9]*')]), - dynamicValueArgument: this.fb.control(null, Validators.required), + dynamicValueArgument: this.fb.control('', Validators.required), }), }); diff --git a/ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-complex-filter-predicate-dialog.component.ts b/ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-complex-filter-predicate-dialog.component.ts index 245d866403..dab366f960 100644 --- a/ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-complex-filter-predicate-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-complex-filter-predicate-dialog.component.ts @@ -80,10 +80,8 @@ export class AlarmRuleComplexFilterPredicateDialogComponent extends } save(): void { - if (this.complexFilterFormGroup.valid) { - const predicate: ComplexAlarmRuleFilterPredicate = this.complexFilterFormGroup.value as ComplexAlarmRuleFilterPredicate; - predicate.type = FilterPredicateType.COMPLEX; - this.dialogRef.close(predicate); - } + const predicate = this.complexFilterFormGroup.value as ComplexAlarmRuleFilterPredicate; + predicate.type = FilterPredicateType.COMPLEX; + this.dialogRef.close(predicate); } } diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/calculated-field-arguments/calculated-field-argument-panel.component.ts b/ui-ngx/src/app/modules/home/components/calculated-fields/components/calculated-field-arguments/calculated-field-argument-panel.component.ts index c0dbc23984..4e8abbe841 100644 --- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/calculated-field-arguments/calculated-field-argument-panel.component.ts +++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/calculated-field-arguments/calculated-field-argument-panel.component.ts @@ -315,7 +315,7 @@ export class CalculatedFieldArgumentPanelComponent implements OnInit, AfterViewI } private updatedRefEntityIdState(type: ArgumentEntityType, emitEvent = true): void { - const isEntityWithId = !!type && type !== ArgumentEntityType.Tenant && type !== ArgumentEntityType.Current; + const isEntityWithId = !!type && ![ArgumentEntityType.Tenant, ArgumentEntityType.Current, ArgumentEntityType.Owner].includes(type); this.argumentFormGroup.get('refEntityId')[isEntityWithId ? 'enable' : 'disable']({emitEvent}); if (!isEntityWithId) { this.entityNameSubject.next(null); diff --git a/ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings-panel.component.ts b/ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings-panel.component.ts index bb2194d13f..c3083d2180 100644 --- a/ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings-panel.component.ts +++ b/ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings-panel.component.ts @@ -53,7 +53,7 @@ export class EntityDebugSettingsPanelComponent extends PageComponent implements @Input({ transform: booleanAttribute }) failuresEnabled = false; @Input({ transform: booleanAttribute }) allEnabled = false; - @Input({ transform: booleanAttribute }) isAlarmRule = false; + @Input() entityLabel = ''; @Input() entityType: EntityType; @Input() allEnabledUntil = 0; @Input() maxDebugModeDuration = getCurrentAuthState(this.store).maxDebugModeDurationMinutes * MINUTE; @@ -65,7 +65,6 @@ export class EntityDebugSettingsPanelComponent extends PageComponent implements maxMessagesCount: string; maxTimeFrameDuration: number; initialAllEnabled: boolean; - entityLabel: string; isDebugAllActive$ = this.debugAllControl.valueChanges.pipe( startWith(this.debugAllControl.value), @@ -110,9 +109,7 @@ export class EntityDebugSettingsPanelComponent extends PageComponent implements this.onFailuresControl.patchValue(this.failuresEnabled); this.debugAllControl.patchValue(this.allEnabled); this.initialAllEnabled = this.allEnabled || this.allEnabledUntil > new Date().getTime(); - if (this.isAlarmRule) { - this.entityLabel = 'alarm-rule.alarm-rule'; - } else { + if (!this.entityLabel) { this.entityLabel = entityTypeTranslations.has(this.entityType) ? entityTypeTranslations.get(this.entityType).type : 'debug-settings.entity'; } } diff --git a/ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings.model.ts b/ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings.model.ts index f6e730b32a..f3b19d3737 100644 --- a/ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings.model.ts +++ b/ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings.model.ts @@ -28,7 +28,7 @@ export interface EntityDebugSettingPanelConfig { maxDebugModeDuration?: number; additionalActionConfig?: AdditionalDebugActionConfig; entityType: EntityType; - isAlarmRule?: boolean; + entityLabel?: string; } onSettingsAppliedFn: (settings: EntityDebugSettings) => void; } diff --git a/ui-ngx/src/app/shared/models/calculated-field.models.ts b/ui-ngx/src/app/shared/models/calculated-field.models.ts index e0107ec6e4..58d06e2482 100644 --- a/ui-ngx/src/app/shared/models/calculated-field.models.ts +++ b/ui-ngx/src/app/shared/models/calculated-field.models.ts @@ -276,6 +276,10 @@ export interface CalculatedFieldArgument { timeWindow?: number; } +export interface RefDynamicSourceConfiguration { + type: ArgumentEntityType.Owner; +} + export enum AggFunction { AVG='AVG', MIN='MIN', @@ -328,14 +332,14 @@ export interface CalculatedFieldGeofencing { perimeterKeyName: string; reportStrategy: GeofencingReportStrategy; refEntityId?: RefEntityId; - refDynamicSourceConfiguration: RefDynamicSourceConfiguration; + refDynamicSourceConfiguration: RefDynamicSourceGeofencingConfiguration; createRelationsWithMatchedZones: boolean; relationType: string; direction: EntitySearchDirection; } -export interface RefDynamicSourceConfiguration { - type?: ArgumentEntityType.RelationQuery | ArgumentEntityType.Owner; +export interface RefDynamicSourceGeofencingConfiguration { + type: ArgumentEntityType.RelationQuery | ArgumentEntityType.Owner; levels?: Array; }