Browse Source

[4114] Updated version checks

pull/11516/head
mpetrov 2 years ago
parent
commit
13e7e4a61d
  1. 8
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/abstract/gateway-connector-version-processor.abstract.ts
  2. 3
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/dialog/add-connector-dialog.component.ts
  3. 2
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.html
  4. 2
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts
  5. 5
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-widget.models.ts

8
ui-ngx/src/app/modules/home/components/widget/lib/gateway/abstract/gateway-connector-version-processor.abstract.ts

@ -1,4 +1,4 @@
import { GatewayConnector } from '@home/components/widget/lib/gateway/gateway-widget.models';
import { GatewayConnector, GatewayVersion } from '@home/components/widget/lib/gateway/gateway-widget.models';
export abstract class GatewayConnectorVersionProcessor<BasicConfig> {
gatewayVersion: number;
@ -11,7 +11,7 @@ export abstract class GatewayConnectorVersionProcessor<BasicConfig> {
getProcessedByVersion(): GatewayConnector<BasicConfig> {
if (this.isVersionUpdateNeeded()) {
return !this.configVersion || this.configVersion < this.gatewayVersion
return this.isVersionUpgradeNeeded()
? this.getUpgradedVersion()
: this.getDowngradedVersion();
}
@ -27,6 +27,10 @@ export abstract class GatewayConnectorVersionProcessor<BasicConfig> {
return this.configVersion !== this.gatewayVersion;
}
private isVersionUpgradeNeeded(): boolean {
return (!this.configVersion || this.configVersion < this.gatewayVersion) && this.gatewayVersionStr === GatewayVersion.Current;
}
private parseVersion(version: string): number {
return Number(version?.replace(/\./g, ''));
}

3
ui-ngx/src/app/modules/home/components/widget/lib/gateway/dialog/add-connector-dialog.component.ts

@ -29,6 +29,7 @@ import {
GatewayConnector,
GatewayConnectorDefaultTypesTranslatesMap,
GatewayLogLevel,
GatewayVersion,
GatewayVersionedDefaultConfig,
noLeadTrailSpacesRegex
} from '@home/components/widget/lib/gateway/gateway-widget.models';
@ -102,7 +103,7 @@ export class AddConnectorDialogComponent
if (gatewayVersion) {
value.configVersion = gatewayVersion;
}
value.configurationJson = (gatewayVersion
value.configurationJson = (gatewayVersion === GatewayVersion.Current
? defaultConfig[this.data.gatewayVersion]
: defaultConfig.legacy)
?? defaultConfig;

2
ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.html

@ -178,7 +178,7 @@
<ng-container [ngSwitch]="initialConnector.type">
<ng-container *ngSwitchCase="ConnectorType.MQTT">
<tb-mqtt-basic-config
*ngIf="connectorForm.get('configVersion').value else legacy"
*ngIf="connectorForm.get('configVersion').value === GatewayVersion.Current else legacy"
formControlName="basicConfig"
[generalTabContent]="generalTabContent"
/>

2
ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-connectors.component.ts

@ -59,6 +59,7 @@ import {
GatewayConnectorDefaultTypesTranslatesMap,
GatewayLogLevel,
noLeadTrailSpacesRegex,
GatewayVersion,
} from './gateway-widget.models';
import { MatDialog } from '@angular/material/dialog';
import { AddConnectorDialogComponent } from '@home/components/widget/lib/gateway/dialog/add-connector-dialog.component';
@ -101,6 +102,7 @@ export class GatewayConnectorComponent extends PageComponent implements AfterVie
readonly displayedColumns = ['enabled', 'key', 'type', 'syncStatus', 'errors', 'actions'];
readonly GatewayConnectorTypesTranslatesMap = GatewayConnectorDefaultTypesTranslatesMap;
readonly ConnectorConfigurationModes = ConfigurationModes;
readonly GatewayVersion = GatewayVersion;
pageLink: PageLink;
dataSource: MatTableDataSource<GatewayAttributeData>;

5
ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-widget.models.ts

@ -188,6 +188,11 @@ export interface ConnectorSecurity {
mode?: ModeType;
}
export enum GatewayVersion {
Current = '3.5.1',
Legacy = 'legacy'
}
export type ConnectorMapping = DeviceConnectorMapping | RequestMappingValue | ConverterConnectorMapping;
export type ConnectorMappingFormValue = DeviceConnectorMapping | RequestMappingFormValue | ConverterMappingFormValue;

Loading…
Cancel
Save