diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table-config.ts b/ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table-config.ts index d0bb2e12f4..8cc5d10fc6 100644 --- a/ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table-config.ts +++ b/ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table-config.ts @@ -125,7 +125,7 @@ export class CalculatedFieldsTableConfig extends EntityTableConfig('createdTime', 'common.created-time', this.datePipe, '150px')); this.columns.push(new EntityTableColumn('name', 'common.name', '33%')); - this.columns.push(new EntityTableColumn('type', 'common.type', '170px', entity => this.translate.instant(CalculatedFieldTypeTranslations.get(entity.type)), () => ({whiteSpace: 'nowrap' }))); + this.columns.push(new EntityTableColumn('type', 'common.type', '170px', entity => this.translate.instant(CalculatedFieldTypeTranslations.get(entity.type).name), () => ({whiteSpace: 'nowrap' }))); this.columns.push(expressionColumn); this.cellActionDescriptors.push( diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.html b/ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.html index 75636deb60..753df131a5 100644 --- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.html @@ -57,9 +57,12 @@ {{ 'common.type' | translate }} @for (type of fieldTypes; track type) { - {{ CalculatedFieldTypeTranslations.get(type) | translate}} + {{ CalculatedFieldTypeTranslations.get(type).name | translate}} } + @if (CalculatedFieldTypeTranslations.get(fieldFormGroup.get('type').value).hint) { + {{ CalculatedFieldTypeTranslations.get(fieldFormGroup.get('type').value).hint | translate }} + } @switch (fieldFormGroup.get('type').value) { diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/geofencing-configuration/geofencing-configuration.component.ts b/ui-ngx/src/app/modules/home/components/calculated-fields/components/geofencing-configuration/geofencing-configuration.component.ts index 0ed0e7eb28..bbf43e93e4 100644 --- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/geofencing-configuration/geofencing-configuration.component.ts +++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/geofencing-configuration/geofencing-configuration.component.ts @@ -34,7 +34,7 @@ import { notEmptyObjectValidator, OutputType } from '@shared/models/calculated-field.models'; -import { AttributeScope, DataKeyType } from '@shared/models/telemetry/telemetry.models'; +import { DataKeyType } from '@shared/models/telemetry/telemetry.models'; import { getCurrentAuthState } from '@core/auth/auth.selectors'; import { Store } from '@ngrx/store'; import { AppState } from '@core/core.state'; @@ -80,7 +80,7 @@ export class GeofencingConfigurationComponent implements ControlValueAccessor, V zoneGroups: this.fb.control>({}, notEmptyObjectValidator()), scheduledUpdateEnabled: [true], scheduledUpdateInterval: [this.minAllowedScheduledUpdateIntervalInSecForCF], - output: this.fb.control({scope: AttributeScope.SERVER_SCOPE, type: OutputType.Timeseries}) + output: this.fb.control({type: OutputType.Timeseries}) }); currentEntityFilter: EntityFilter; diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/propagation-configuration/propagation-configuration.component.ts b/ui-ngx/src/app/modules/home/components/calculated-fields/components/propagation-configuration/propagation-configuration.component.ts index 27a0445bf3..4fb8bb561e 100644 --- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/propagation-configuration/propagation-configuration.component.ts +++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/propagation-configuration/propagation-configuration.component.ts @@ -38,7 +38,6 @@ import { PropagationDirectionTranslations, PropagationWithExpression } from '@shared/models/calculated-field.models'; -import { AttributeScope } from '@shared/models/telemetry/telemetry.models'; import { map } from 'rxjs/operators'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { ScriptLanguage } from '@app/shared/models/rule-node.models'; @@ -83,7 +82,6 @@ export class PropagationConfigurationComponent implements ControlValueAccessor, }), expression: [calculatedFieldDefaultScript], output: this.fb.control({ - scope: AttributeScope.SERVER_SCOPE, type: OutputType.Timeseries, }), }); diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/related-entities-aggregation-configuration/related-entities-aggregation-component.component.ts b/ui-ngx/src/app/modules/home/components/calculated-fields/components/related-entities-aggregation-configuration/related-entities-aggregation-component.component.ts index af21e0ebdf..2a3eca6f1b 100644 --- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/related-entities-aggregation-configuration/related-entities-aggregation-component.component.ts +++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/related-entities-aggregation-configuration/related-entities-aggregation-component.component.ts @@ -36,7 +36,6 @@ import { OutputType, PropagationDirectionTranslations } from '@shared/models/calculated-field.models'; -import { AttributeScope } from '@shared/models/telemetry/telemetry.models'; import { map } from 'rxjs/operators'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { ScriptLanguage } from '@app/shared/models/rule-node.models'; @@ -89,7 +88,6 @@ export class RelatedEntitiesAggregationComponentComponent implements ControlValu metrics: this.fb.control({}, notEmptyObjectValidator()), deduplicationIntervalInSec: [this.minAllowedDeduplicationIntervalInSecForCF], output: this.fb.control({ - scope: AttributeScope.SERVER_SCOPE, type: OutputType.Timeseries, }), useLatestTs: [false] diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/simple-configuration/simple-configuration.component.ts b/ui-ngx/src/app/modules/home/components/calculated-fields/components/simple-configuration/simple-configuration.component.ts index 669795258e..065556081c 100644 --- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/simple-configuration/simple-configuration.component.ts +++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/simple-configuration/simple-configuration.component.ts @@ -35,7 +35,6 @@ import { getCalculatedFieldArgumentsHighlights, OutputType } from '@shared/models/calculated-field.models'; -import { AttributeScope } from '@shared/models/telemetry/telemetry.models'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { deepClone } from '@core/utils'; import { EntityId } from '@shared/models/id/entity-id'; @@ -87,7 +86,6 @@ export class SimpleConfigurationComponent implements ControlValueAccessor, Valid expressionSCRIPT: [calculatedFieldDefaultScript], output: this.fb.control({ name: '', - scope: AttributeScope.SERVER_SCOPE, type: OutputType.Timeseries, decimalsByDefault: null }), 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 58d06e2482..5988c308de 100644 --- a/ui-ngx/src/app/shared/models/calculated-field.models.ts +++ b/ui-ngx/src/app/shared/models/calculated-field.models.ts @@ -79,13 +79,29 @@ export enum CalculatedFieldType { ALARM = 'ALARM', } -export const CalculatedFieldTypeTranslations = new Map( +interface CalculatedFieldTypeTranslate { + name: string; + hint?: string; +} + +export const CalculatedFieldTypeTranslations = new Map( [ - [CalculatedFieldType.SIMPLE, 'calculated-fields.type.simple'], - [CalculatedFieldType.SCRIPT, 'calculated-fields.type.script'], - [CalculatedFieldType.GEOFENCING, 'calculated-fields.type.geofencing'], - [CalculatedFieldType.PROPAGATION, 'calculated-fields.type.propagation'], - [CalculatedFieldType.RELATED_ENTITIES_AGGREGATION, 'calculated-fields.type.related-entities-aggregation'], + [CalculatedFieldType.SIMPLE, { + name: 'calculated-fields.type.simple' + }], + [CalculatedFieldType.SCRIPT, { + name: 'calculated-fields.type.script' + }], + [CalculatedFieldType.GEOFENCING, { + name: 'calculated-fields.type.geofencing' + }], + [CalculatedFieldType.PROPAGATION, { + name: 'calculated-fields.type.propagation' + }], + [CalculatedFieldType.RELATED_ENTITIES_AGGREGATION, { + name: 'calculated-fields.type.related-entities-aggregation', + hint: 'calculated-fields.type.related-entities-aggregation-hint' + }], ] ) @@ -127,7 +143,7 @@ export interface CalculatedFieldRelatedAggregationConfiguration { metrics: Record; deduplicationIntervalInSec: number; useLatestTs: boolean; - output: Omit; + output: CalculatedFieldOutput & { decimalsByDefault?: number; }; } interface BasePropagationConfiguration { @@ -161,12 +177,20 @@ export type CalculatedFieldPropagationConfiguration = | PropagationWithNoExpression | PropagationWithExpression; -export interface CalculatedFieldOutput { - type: OutputType; - scope?: AttributeScope; +export type CalculatedFieldOutput = + | CalculatedFieldOutputAttribute + | CalculatedFieldOutputTimeSeries; + +export interface CalculatedFieldOutputAttribute { + type: OutputType.Attribute, + scope: AttributeScope; +} + +export interface CalculatedFieldOutputTimeSeries { + type: OutputType.Timeseries; } -export interface CalculatedFieldSimpleOutput extends CalculatedFieldOutput { +export type CalculatedFieldSimpleOutput = CalculatedFieldOutput & { name: string; decimalsByDefault?: number; } diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 977a2a5c74..7f807f6beb 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -1057,7 +1057,8 @@ "script": "Script", "geofencing" : "Geofencing", "propagation": "Propagation", - "related-entities-aggregation": "Related entities aggregation" + "related-entities-aggregation": "Related entities aggregation", + "related-entities-aggregation-hint": "Aggregation of data from related entities" }, "arguments": "Arguments", "decimals-by-default": "Decimals by default",