diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/abstract/gateway-connector-version-processor.abstract.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/abstract/gateway-connector-version-processor.abstract.ts index 1a1c4f05bc..31b8ba8cf8 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/abstract/gateway-connector-version-processor.abstract.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/abstract/gateway-connector-version-processor.abstract.ts @@ -11,9 +11,9 @@ export abstract class GatewayConnectorVersionProcessor { getProcessedByVersion(): BasicConfig { if (this.isVersionUpdateNeeded()) { - return this.configVersion > this.gatewayVersion - ? this.getDowngradedVersion() - : this.getUpgradedVersion(); + return this.configVersion < this.gatewayVersion + ? this.getUpgradedVersion() + : this.getDowngradedVersion(); } return this.connector.configurationJson as unknown as BasicConfig; diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/abstract/mqtt-version-processor.abstract.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/abstract/mqtt-version-processor.abstract.ts index 2a7bea0e1b..875b238d7e 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/abstract/mqtt-version-processor.abstract.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/abstract/mqtt-version-processor.abstract.ts @@ -1,15 +1,14 @@ -import { - GatewayConnectorVersionProcessor -} from '@home/components/widget/lib/gateway/abstract/gateway-connector-version-processor.abstract'; +import { isEqual } from '@core/utils'; import { GatewayConnector, - MQTTBasicConfig, MQTTBasicConfig_v3_5_2, + MQTTBasicConfig, + MQTTBasicConfig_v3_5_2, MQTTLegacyBasicConfig, RequestMappingData, RequestType, -} from '@home/components/widget/lib/gateway/gateway-widget.models'; -import { isEqual } from '@core/utils'; -import { MqttVersionMappingUtil } from '@home/components/widget/lib/gateway/utils/mqtt-version-mapping.util'; +} from '../gateway-widget.models'; +import { MqttVersionMappingUtil } from '../utils/mqtt-version-mapping.util'; +import { GatewayConnectorVersionProcessor } from './gateway-connector-version-processor.abstract'; export class MqttVersionProcessor extends GatewayConnectorVersionProcessor { private readonly mqttRequestTypeKeys = Object.values(RequestType); @@ -20,7 +19,7 @@ export class MqttVersionProcessor extends GatewayConnectorVersionProcessor { - const { [key]: removedKey, ...rest } = configurationJson as MQTTLegacyBasicConfig; + const { [key]: removedValue, ...rest } = configurationJson as MQTTLegacyBasicConfig; configurationJson = { ...rest } as any; }); this.cleanUpConfigJson(configurationJson as MQTTBasicConfig_v3_5_2); - return configurationJson as MQTTBasicConfig; + return configurationJson as MQTTBasicConfig_v3_5_2; } getDowngradedVersion(): MQTTLegacyBasicConfig { diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/mqtt/basic-config/mqtt-basic-config.abstract.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/mqtt/basic-config/mqtt-basic-config.abstract.ts index 072d8ba834..0394604d42 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/mqtt/basic-config/mqtt-basic-config.abstract.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/mqtt/basic-config/mqtt-basic-config.abstract.ts @@ -32,7 +32,9 @@ export abstract class AbstractMqttBasicConfigComponent implements C basicFormGroup: FormGroup; mappingTypes = MappingType; + private destroy$ = new Subject(); + private onChange: (value: BasicConfig) => void; private onTouched: () => void; diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/mqtt/basic-config/mqtt-basic-config.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/mqtt/basic-config/mqtt-basic-config.component.ts index e2c9918179..541866dab8 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/mqtt/basic-config/mqtt-basic-config.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/mqtt/basic-config/mqtt-basic-config.component.ts @@ -80,8 +80,8 @@ export class MqttBasicConfigComponent extends AbstractMqttBasicConfigComponent), }; diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts index 96e15a110f..b6e2dfc093 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts @@ -243,10 +243,6 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie delete value.class; } - if (this.gatewayVersion && !value.configVersion) { - value.configVersion = this.gatewayVersion; - } - value.ts = Date.now(); return value; @@ -482,7 +478,7 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie value.configurationJson = {} as ConnectorBaseConfig; } value.basicConfig = value.configurationJson; - this.updateConnector({...value, configVersion: this.gatewayVersion ?? ''}); + this.updateConnector(value); this.generate('basicConfig.broker.clientId'); setTimeout(() => this.saveConnector()); }); diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/utils/mqtt-version-mapping.util.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/utils/mqtt-version-mapping.util.ts index ffd517c3e9..23cc03dc4e 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/utils/mqtt-version-mapping.util.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/utils/mqtt-version-mapping.util.ts @@ -40,7 +40,7 @@ export class MqttVersionMappingUtil { ['attributeNameExpressionSource', 'responseTopicQoS', 'extensionConfig']; static mapMappingToUpgradedVersion( - mapping: LegacyConverterConnectorMapping[] | ConverterConnectorMapping[] + mapping: LegacyConverterConnectorMapping[] ): ConverterConnectorMapping[] { return mapping?.map(({ converter, topicFilter, subscriptionQos = 1 }) => { const deviceInfo = converter.deviceInfo ?? this.extractConverterDeviceInfo(converter); @@ -54,12 +54,12 @@ export class MqttVersionMappingUtil { this.cleanUpOldFields(newConverter); return { converter: newConverter, topicFilter, subscriptionQos }; - }); + }) as ConverterConnectorMapping[]; } static mapRequestsToUpgradedVersion( requestMapping: Record + LegacyRequestMappingData[]> ): Record { return this.mqttRequestTypeKeys.reduce((acc, key: RequestType) => { if (!requestMapping[key]) {