diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/test-arguments/calculated-field-test-arguments.component.html b/ui-ngx/src/app/modules/home/components/calculated-fields/components/test-arguments/calculated-field-test-arguments.component.html
index 6bf600c05a..af51d2ec82 100644
--- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/test-arguments/calculated-field-test-arguments.component.html
+++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/test-arguments/calculated-field-test-arguments.component.html
@@ -30,14 +30,14 @@
-
-
- {{ ArgumentTypeTranslations.get(group.get('type').value) | translate }}
+
+
+ {{ ArgumentTypeTranslations.get(argumentsTypeMap.get(group.get('argumentName').value)) | translate }}
- @if (group.get('type').value === ArgumentType.Rolling) {
+ @if (argumentsTypeMap.get(group.get('argumentName').value) === ArgumentType.Rolling) {
diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/test-arguments/calculated-field-test-arguments.component.ts b/ui-ngx/src/app/modules/home/components/calculated-fields/components/test-arguments/calculated-field-test-arguments.component.ts
index e3ab3b560c..c493c09e5c 100644
--- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/test-arguments/calculated-field-test-arguments.component.ts
+++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/test-arguments/calculated-field-test-arguments.component.ts
@@ -14,7 +14,7 @@
/// limitations under the License.
///
-import { AfterViewInit, Component, forwardRef } from '@angular/core';
+import { Component, forwardRef, Input } from '@angular/core';
import {
ControlValueAccessor,
NG_VALIDATORS,
@@ -60,7 +60,9 @@ import { MatDialog } from '@angular/material/dialog';
}
]
})
-export class CalculatedFieldTestArgumentsComponent extends PageComponent implements ControlValueAccessor, Validator, AfterViewInit {
+export class CalculatedFieldTestArgumentsComponent extends PageComponent implements ControlValueAccessor, Validator {
+
+ @Input() argumentsTypeMap: Map
;
argumentsFormArray = this.fb.array([]);
@@ -78,10 +80,6 @@ export class CalculatedFieldTestArgumentsComponent extends PageComponent impleme
.subscribe(() => this.propagateChange(this.getValue()));
}
- ngAfterViewInit(): void {
- this.argumentsFormArray.updateValueAndValidity();
- }
-
registerOnChange(propagateChange: (value: CalculatedFieldEventArguments) => void): void {
this.propagateChange = propagateChange;
}
@@ -122,27 +120,25 @@ export class CalculatedFieldTestArgumentsComponent extends PageComponent impleme
: group.patchValue({ ts: (result as CalculatedFieldSingleArgumentValue).ts, value: (result as CalculatedFieldSingleArgumentValue).value }) );
}
- private getSimpleArgumentFormGroup({ argumentName, type, ts, value }: CalculatedFieldSingleArgumentValue): FormGroup {
+ private getSimpleArgumentFormGroup({ argumentName, ts, value }: CalculatedFieldSingleArgumentValue): FormGroup {
return this.fb.group({
argumentName: [{ value: argumentName, disabled: true}],
- type: [{ value: type , disabled: true }],
ts: [ts],
value: [value]
}) as FormGroup;
}
- private getRollingArgumentFormGroup({ argumentName, type, timewindow, values }: CalculatedFieldRollingTelemetryArgumentValue): FormGroup {
+ private getRollingArgumentFormGroup({ argumentName, timewindow, values }: CalculatedFieldRollingTelemetryArgumentValue): FormGroup {
return this.fb.group({
...timewindow ?? {},
argumentName: [{ value: argumentName, disabled: true }],
- type: [{ value: type , disabled: true }],
values: [values]
}) as FormGroup;
}
private getValue(): CalculatedFieldEventArguments {
return this.argumentsFormArray.getRawValue().reduce((acc, rowItem) => {
- const { argumentName, type, ...value } = rowItem;
+ const { argumentName, ...value } = rowItem;
acc[argumentName] = value;
return acc;
}, {});
diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/test-dialog/calculated-field-script-test-dialog.component.html b/ui-ngx/src/app/modules/home/components/calculated-fields/components/test-dialog/calculated-field-script-test-dialog.component.html
index 3f35ecbc0c..6b0a273a51 100644
--- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/test-dialog/calculated-field-script-test-dialog.component.html
+++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/test-dialog/calculated-field-script-test-dialog.component.html
@@ -52,7 +52,7 @@
{{ 'calculated-fields.arguments' | translate }}
-
+
diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/test-dialog/calculated-field-script-test-dialog.component.ts b/ui-ngx/src/app/modules/home/components/calculated-fields/components/test-dialog/calculated-field-script-test-dialog.component.ts
index ea0164f9b8..b644afa96d 100644
--- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/test-dialog/calculated-field-script-test-dialog.component.ts
+++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/test-dialog/calculated-field-script-test-dialog.component.ts
@@ -38,7 +38,11 @@ import { beautifyJs } from '@shared/models/beautify.models';
import { CalculatedFieldsService } from '@core/http/calculated-fields.service';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { filter } from 'rxjs/operators';
-import { CalculatedFieldTestScriptDialogData } from '@shared/models/calculated-field.models';
+import {
+ ArgumentType, CalculatedFieldEventArguments,
+ CalculatedFieldTestScriptDialogData,
+ TestArgumentTypeMap
+} from '@shared/models/calculated-field.models';
@Component({
selector: 'tb-calculated-field-script-test-dialog',
@@ -61,6 +65,7 @@ export class CalculatedFieldScriptTestDialogComponent extends DialogComponent
();
readonly ContentType = ContentType;
readonly ScriptLanguage = ScriptLanguage;
@@ -81,7 +86,7 @@ export class CalculatedFieldScriptTestDialogComponent extends DialogComponent this.calculatedFieldScriptTestFormGroup.get('expression').patchValue(res, {emitEvent: false})
);
- this.calculatedFieldScriptTestFormGroup.get('arguments').patchValue(this.data.arguments);
+ this.calculatedFieldScriptTestFormGroup.get('arguments').patchValue(this.getArgumentsValue());
}
ngAfterViewInit(): void {
@@ -117,7 +122,7 @@ export class CalculatedFieldScriptTestDialogComponent extends DialogComponent {
if (result.error) {
@@ -157,6 +162,26 @@ export class CalculatedFieldScriptTestDialogComponent extends DialogComponent {
+ acc[key] = argumentsValue[key];
+ acc[key].type = TestArgumentTypeMap.get(this.argumentsTypeMap.get(key));
+ return acc;
+ }, {});
+ }
+
+ private getArgumentsValue(): CalculatedFieldEventArguments {
+ return Object.keys(this.data.arguments)
+ .reduce((acc, key) => {
+ const { type, ...argumentObj } = this.data.arguments[key];
+ this.argumentsTypeMap.set(key, type);
+ acc[key] = argumentObj;
+ return acc;
+ }, {});
+ }
+
private initSplitLayout(smallMode = false): void {
const [leftPanel, rightPanel, topRightPanel, bottomRightPanel] = [
this.leftPanelElmRef.nativeElement,
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 6c816cbb9b..5229fbe851 100644
--- a/ui-ngx/src/app/shared/models/calculated-field.models.ts
+++ b/ui-ngx/src/app/shared/models/calculated-field.models.ts
@@ -85,6 +85,19 @@ export enum ArgumentType {
Rolling = 'TS_ROLLING',
}
+export enum TestArgumentType {
+ Single = 'SINGLE_VALUE',
+ Rolling = 'TS_ROLLING',
+}
+
+export const TestArgumentTypeMap = new Map(
+ [
+ [ArgumentType.Attribute, TestArgumentType.Single],
+ [ArgumentType.LatestTelemetry, TestArgumentType.Single],
+ [ArgumentType.Rolling, TestArgumentType.Rolling],
+ ]
+)
+
export enum OutputType {
Attribute = 'ATTRIBUTES',
Timeseries = 'TIME_SERIES',