From fe45f40209b1d940955aa08277e645c587769298 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Mon, 3 Nov 2025 13:15:24 +0200 Subject: [PATCH] UI: Calculated field Entity aggregation change model and default value --- ...ntity-aggregation-component.component.html | 26 +++++++----- .../entity-aggregation-component.component.ts | 34 ++++++++-------- ...culated-field-metrics-panel.component.html | 8 ++++ ...alculated-field-metrics-panel.component.ts | 40 +++++++++---------- .../calculated-field-metrics-table.module.ts | 1 - .../shared/models/calculated-field.models.ts | 5 ++- .../assets/locale/locale.constant-en_US.json | 14 ++++--- 7 files changed, 71 insertions(+), 57 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/entity-aggregation-configuration/entity-aggregation-component.component.html b/ui-ngx/src/app/modules/home/components/calculated-fields/components/entity-aggregation-configuration/entity-aggregation-component.component.html index 84dcb23d4c..5114a4cdc1 100644 --- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/entity-aggregation-configuration/entity-aggregation-component.component.html +++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/entity-aggregation-configuration/entity-aggregation-component.component.html @@ -62,30 +62,32 @@ @if (entityAggregationConfiguration.get('interval.type').value === AggIntervalType.CUSTOM) { + formControlName="durationSec"> }
- +
{{ 'calculated-fields.entity-aggregation.apply-offset' | translate }}
- @if (entityAggregationConfiguration.get('interval.allowOffsetMillis').value) { + @if (entityAggregationConfiguration.get('interval.allowOffsetSec').value) { + formControlName="offsetSec"> }
@@ -99,21 +101,23 @@ @if (entityAggregationConfiguration.get('allowWatermark').value) { diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/entity-aggregation-configuration/entity-aggregation-component.component.ts b/ui-ngx/src/app/modules/home/components/calculated-fields/components/entity-aggregation-configuration/entity-aggregation-component.component.ts index 9f48187b55..5fd958518b 100644 --- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/entity-aggregation-configuration/entity-aggregation-component.component.ts +++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/entity-aggregation-configuration/entity-aggregation-component.component.ts @@ -41,7 +41,7 @@ import { HOUR, MINUTE, SECOND } from '@shared/models/time/time.models'; import { isDefinedAndNotNull } from '@core/utils'; interface CalculatedFieldEntityAggregationConfigurationValue extends CalculatedFieldEntityAggregationConfiguration { - interval: AggInterval & {allowOffsetMillis?: boolean}; + interval: AggInterval & {allowOffsetSec?: boolean}; allowWatermark: boolean; } @@ -79,14 +79,14 @@ export class EntityAggregationComponentComponent implements ControlValueAccessor interval: this.fb.group({ type: [AggIntervalType.HOUR], tz: ['', Validators.required], - multiplier: [HOUR/SECOND, Validators.required], - allowOffsetMillis: [false], - offsetMillis: [MINUTE/SECOND, Validators.required], + durationSec: [HOUR/SECOND, Validators.required], + allowOffsetSec: [false], + offsetSec: [MINUTE/SECOND, Validators.required], }), allowWatermark: [false], watermark: this.fb.group({ - duration: [6 * MINUTE / SECOND, Validators.required], - checkInterval: [MINUTE / SECOND, Validators.required], + duration: [HOUR/SECOND, Validators.required], + checkInterval: [10 * MINUTE / SECOND, Validators.required], }), output: this.fb.control({ type: OutputType.Timeseries, @@ -111,7 +111,7 @@ export class EntityAggregationComponentComponent implements ControlValueAccessor this.checkAggIntervalType(type); }); - this.entityAggregationConfiguration.get('interval.allowOffsetMillis').valueChanges.pipe( + this.entityAggregationConfiguration.get('interval.allowOffsetSec').valueChanges.pipe( takeUntilDestroyed() ).subscribe((allow: boolean) => { this.checkIntervalDuration(allow); @@ -138,11 +138,11 @@ export class EntityAggregationComponentComponent implements ControlValueAccessor const data: CalculatedFieldEntityAggregationConfigurationValue = { ...value, allowWatermark: isDefinedAndNotNull(value.watermark), - interval: {...value.interval, allowOffsetMillis: isDefinedAndNotNull(value?.interval?.offsetMillis)} + interval: {...value.interval, allowOffsetSec: isDefinedAndNotNull(value?.interval?.offsetSec)} } this.entityAggregationConfiguration.patchValue(data, {emitEvent: false}); this.checkAggIntervalType(this.entityAggregationConfiguration.get('interval.type').value); - this.checkIntervalDuration(this.entityAggregationConfiguration.get('interval.allowOffsetMillis').value); + this.checkIntervalDuration(this.entityAggregationConfiguration.get('interval.allowOffsetSec').value); this.checkWatermark(this.entityAggregationConfiguration.get('allowWatermark').value); setTimeout(() => { this.entityAggregationConfiguration.get('arguments').updateValueAndValidity({onlySelf: true}); @@ -161,17 +161,17 @@ export class EntityAggregationComponentComponent implements ControlValueAccessor } else { this.entityAggregationConfiguration.enable({emitEvent: false}); this.checkAggIntervalType(this.entityAggregationConfiguration.get('interval.type').value); - this.checkIntervalDuration(this.entityAggregationConfiguration.get('interval.allowOffsetMillis').value); + this.checkIntervalDuration(this.entityAggregationConfiguration.get('interval.allowOffsetSec').value); this.checkWatermark(this.entityAggregationConfiguration.get('allowWatermark').value); } } private updatedModel(value: CalculatedFieldEntityAggregationConfigurationValue): void { value.type = CalculatedFieldType.ENTITY_AGGREGATION; - if (!value.interval.allowOffsetMillis) { - delete value.interval.offsetMillis; + if (!value.interval.allowOffsetSec) { + delete value.interval.offsetSec; } - delete value.interval.offsetMillis; + delete value.interval.offsetSec; if (!value.allowWatermark) { delete value.watermark; } @@ -181,17 +181,17 @@ export class EntityAggregationComponentComponent implements ControlValueAccessor private checkAggIntervalType(type: AggIntervalType) { if (type === AggIntervalType.CUSTOM) { - this.entityAggregationConfiguration.get('interval.multiplier').enable({emitEvent: false}); + this.entityAggregationConfiguration.get('interval.durationSec').enable({emitEvent: false}); } else { - this.entityAggregationConfiguration.get('interval.multiplier').disable({emitEvent: false}); + this.entityAggregationConfiguration.get('interval.durationSec').disable({emitEvent: false}); } } private checkIntervalDuration(allow: boolean) { if (allow) { - this.entityAggregationConfiguration.get('interval.offsetMillis').enable({emitEvent: false}); + this.entityAggregationConfiguration.get('interval.offsetSec').enable({emitEvent: false}); } else { - this.entityAggregationConfiguration.get('interval.offsetMillis').disable({emitEvent: false}); + this.entityAggregationConfiguration.get('interval.offsetSec').disable({emitEvent: false}); } } diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/metrics/calculated-field-metrics-panel.component.html b/ui-ngx/src/app/modules/home/components/calculated-fields/components/metrics/calculated-field-metrics-panel.component.html index d57a487dbd..eda8a779ad 100644 --- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/metrics/calculated-field-metrics-panel.component.html +++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/metrics/calculated-field-metrics-panel.component.html @@ -160,6 +160,14 @@ } + @if (simpleMode) { +
+
{{ 'calculated-fields.default-value' | translate }}
+ + + +
+ }