diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/mapping-table/mapping-table.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/mapping-table/mapping-table.component.ts index 51847d2c70..9c04a32296 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/mapping-table/mapping-table.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/mapping-table/mapping-table.component.ts @@ -33,7 +33,6 @@ import { debounceTime, distinctUntilChanged, map, take, takeUntil } from 'rxjs/o import { ControlValueAccessor, FormBuilder, - FormGroup, NG_VALIDATORS, NG_VALUE_ACCESSOR, UntypedFormArray, @@ -192,7 +191,7 @@ export class MappingTableComponent implements ControlValueAccessor, Validator, A $event.stopPropagation(); } const value = isDefinedAndNotNull(index) ? this.mappingFormGroup.at(index).value : {}; - this.dialog.open(MappingDialogComponent, { + this.dialog.open(MappingDialogComponent, { disableClose: true, panelClass: ['tb-dialog', 'tb-fullscreen-dialog'], data: { @@ -207,26 +206,13 @@ export class MappingTableComponent implements ControlValueAccessor, Validator, A if (isDefinedAndNotNull(index)) { this.mappingFormGroup.at(index).patchValue(res); } else { - this.mappingFormGroup.push(this.getMappedDialogDataFormGroup(res)); + this.pushDataAsFormArrays([res]); } this.mappingFormGroup.markAsDirty(); } }); } - private getMappedDialogDataFormGroup(mappingValue: MappingValue): FormGroup { - Object.keys(mappingValue).forEach(key => { - if (Array.isArray(mappingValue[key])) { - mappingValue = { - ...mappingValue, - [key]: this.fb.control(mappingValue[key]), - }; - } - }); - - return this.fb.group(mappingValue); - } - private updateTableData(value: ConnectorMapping[], textSearch?: string): void { let tableValue = value.map(mappingValue => this.getMappingValue(mappingValue)); if (textSearch) { diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/dialog/mapping-dialog.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/dialog/mapping-dialog.component.ts index 3812fa161e..31a43314cc 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/dialog/mapping-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/dialog/mapping-dialog.component.ts @@ -24,9 +24,13 @@ import { Router } from '@angular/router'; import { Attribute, AttributesUpdate, + ConnectorMapping, + ConnectorMappingFormValue, + ConverterMappingFormValue, ConvertorType, ConvertorTypeTranslationsMap, DataConversionTranslationsMap, + DeviceConnectorMapping, DeviceInfoType, MappingHintTranslationsMap, MappingInfo, @@ -37,11 +41,11 @@ import { MappingKeysType, MappingType, MappingTypeTranslationsMap, - MappingValue, noLeadTrailSpacesRegex, OPCUaSourceTypes, QualityTypes, QualityTypeTranslationsMap, + RequestMappingFormValue, RequestType, RequestTypesTranslationsMap, RpcMethod, @@ -62,7 +66,7 @@ import { MappingDataKeysPanelComponent } from '@home/components/widget/lib/gatew templateUrl: './mapping-dialog.component.html', styleUrls: ['./mapping-dialog.component.scss'] }) -export class MappingDialogComponent extends DialogComponent implements OnDestroy { +export class MappingDialogComponent extends DialogComponent implements OnDestroy { mappingForm: UntypedFormGroup; @@ -104,7 +108,7 @@ export class MappingDialogComponent extends DialogComponent, protected router: Router, @Inject(MAT_DIALOG_DATA) public data: MappingInfo, - public dialogRef: MatDialogRef, + public dialogRef: MatDialogRef, private fb: FormBuilder, private popoverService: TbPopoverService, private renderer: Renderer2, @@ -247,7 +251,7 @@ export class MappingDialogComponent extends DialogComponent & { + converter: { + type: ConvertorType; + } & Record; +}; + export interface DeviceConnectorMapping { deviceNodePattern: string; deviceNodeSource: string; deviceInfo: DeviceInfo; - attributes: Attribute[]; - timeseries: Timeseries[]; - rpc_methods: RpcMethod[]; - attributes_updates: AttributesUpdate[]; + attributes?: Attribute[]; + timeseries?: Timeseries[]; + rpc_methods?: RpcMethod[]; + attributes_updates?: AttributesUpdate[]; } export enum ConnectorType { @@ -597,6 +605,10 @@ export interface RequestMappingData { requestValue: RequestDataItem; } +export type RequestMappingFormValue = Omit & { + requestValue: Record; +}; + export interface RequestDataItem { type: string; details: string;