From bbb2b1683e3518d21db24599338946036cd9a8d5 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Fri, 5 Jul 2024 15:19:23 +0300 Subject: [PATCH] UI: Refactoring gateway connectors configuration --- .../type-value-panel.component.html | 2 +- .../type-value-panel.component.ts | 16 ++---- .../dialog/mapping-dialog.component.ts | 50 +++++++++---------- .../lib/gateway/gateway-widget.models.ts | 8 +-- 4 files changed, 34 insertions(+), 42 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/type-value-panel/type-value-panel.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/type-value-panel/type-value-panel.component.html index 7ce7fb94f0..a31fe4ff94 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/type-value-panel/type-value-panel.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/type-value-panel/type-value-panel.component.html @@ -32,7 +32,7 @@
gateway.type
- +
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/type-value-panel/type-value-panel.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/type-value-panel/type-value-panel.component.ts index e163d463ed..32d0b2bddb 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/type-value-panel/type-value-panel.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/type-value-panel/type-value-panel.component.ts @@ -14,12 +14,7 @@ /// limitations under the License. /// -import { - Component, - forwardRef, - OnDestroy, - OnInit, -} from '@angular/core'; +import { Component, forwardRef, OnDestroy, OnInit } from '@angular/core'; import { AbstractControl, ControlValueAccessor, @@ -31,7 +26,6 @@ import { Validator, Validators } from '@angular/forms'; -import { DataKeyType } from '@shared/models/telemetry/telemetry.models'; import { isDefinedAndNotNull } from '@core/utils'; import { MappingDataKey, @@ -60,12 +54,10 @@ import { Subject } from 'rxjs'; ] }) export class TypeValuePanelComponent implements ControlValueAccessor, Validator, OnInit, OnDestroy { - valueTypeKeys = Object.values(MappingValueType); - valueTypeEnum = MappingValueType; + + valueTypeKeys: MappingValueType[] = Object.values(MappingValueType); valueTypes = mappingValueTypesMap; - dataKeyType: DataKeyType; valueListFormArray: UntypedFormArray; - errorText = ''; private destroy$ = new Subject(); private propagateChange = (v: any) => {}; @@ -138,7 +130,7 @@ export class TypeValuePanelComponent implements ControlValueAccessor, Validator, }; } - updateView(value: any): void { + private updateView(value: any): void { this.propagateChange(value); } } 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 a2b6a67490..3812fa161e 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 @@ -22,6 +22,8 @@ import { FormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; import { DialogComponent } from '@shared/components/dialog.component'; import { Router } from '@angular/router'; import { + Attribute, + AttributesUpdate, ConvertorType, ConvertorTypeTranslationsMap, DataConversionTranslationsMap, @@ -34,16 +36,19 @@ import { MappingKeysPanelTitleTranslationsMap, MappingKeysType, MappingType, - MappingTypeTranslationsMap, MappingValue, + MappingTypeTranslationsMap, + MappingValue, noLeadTrailSpacesRegex, OPCUaSourceTypes, QualityTypes, QualityTypeTranslationsMap, RequestType, RequestTypesTranslationsMap, + RpcMethod, ServerSideRPCType, SourceTypes, - SourceTypeTranslationsMap + SourceTypeTranslationsMap, + Timeseries } from '@home/components/widget/lib/gateway/gateway-widget.models'; import { Subject } from 'rxjs'; import { startWith, takeUntil } from 'rxjs/operators'; @@ -66,17 +71,17 @@ export class MappingDialogComponent extends DialogComponent; OPCUaSourceTypesEnum = OPCUaSourceTypes; sourceTypesEnum = SourceTypes; SourceTypeTranslationsMap = SourceTypeTranslationsMap; - requestTypes = Object.values(RequestType); + requestTypes: RequestType[] = Object.values(RequestType); RequestTypeEnum = RequestType; RequestTypesTranslationsMap = RequestTypesTranslationsMap; @@ -92,12 +97,8 @@ export class MappingDialogComponent extends DialogComponent(); constructor(protected store: Store, @@ -116,30 +117,30 @@ export class MappingDialogComponent extends DialogComponent { if (this.converterType) { - return this.mappingForm.get('converter').get(this.converterType).value.attributes.map(value => value.key); + return this.mappingForm.get('converter').get(this.converterType).value.attributes.map((value: Attribute) => value.key); } } get converterTelemetry(): Array { if (this.converterType) { - return this.mappingForm.get('converter').get(this.converterType).value.timeseries.map(value => value.key); + return this.mappingForm.get('converter').get(this.converterType).value.timeseries.map((value: Timeseries) => value.key); } } get opcAttributes(): Array { - return this.mappingForm.get('attributes').value?.map(value => value.key) || []; + return this.mappingForm.get('attributes').value?.map((value: Attribute) => value.key) || []; } get opcTelemetry(): Array { - return this.mappingForm.get('timeseries').value?.map(value => value.key) || []; + return this.mappingForm.get('timeseries').value?.map((value: Timeseries) => value.key) || []; } get opcRpcMethods(): Array { - return this.mappingForm.get('rpc_methods').value?.map(value => value.method) || []; + return this.mappingForm.get('rpc_methods').value?.map((value: RpcMethod) => value.method) || []; } get opcAttributesUpdates(): Array { - return this.mappingForm.get('attributes_updates')?.value?.map(value => value.key) || []; + return this.mappingForm.get('attributes_updates')?.value?.map((value: AttributesUpdate) => value.key) || []; } get converterType(): ConvertorType { @@ -197,7 +198,6 @@ export class MappingDialogComponent extends DialogComponent