[4114] Updated version checks
This commit is contained in:
parent
53d86dd31e
commit
13e7e4a61d
@ -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, ''));
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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"
|
||||
/>
|
||||
|
||||
@ -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>;
|
||||
|
||||
@ -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…
x
Reference in New Issue
Block a user