[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> {
|
export abstract class GatewayConnectorVersionProcessor<BasicConfig> {
|
||||||
gatewayVersion: number;
|
gatewayVersion: number;
|
||||||
@ -11,7 +11,7 @@ export abstract class GatewayConnectorVersionProcessor<BasicConfig> {
|
|||||||
|
|
||||||
getProcessedByVersion(): GatewayConnector<BasicConfig> {
|
getProcessedByVersion(): GatewayConnector<BasicConfig> {
|
||||||
if (this.isVersionUpdateNeeded()) {
|
if (this.isVersionUpdateNeeded()) {
|
||||||
return !this.configVersion || this.configVersion < this.gatewayVersion
|
return this.isVersionUpgradeNeeded()
|
||||||
? this.getUpgradedVersion()
|
? this.getUpgradedVersion()
|
||||||
: this.getDowngradedVersion();
|
: this.getDowngradedVersion();
|
||||||
}
|
}
|
||||||
@ -27,6 +27,10 @@ export abstract class GatewayConnectorVersionProcessor<BasicConfig> {
|
|||||||
return this.configVersion !== this.gatewayVersion;
|
return this.configVersion !== this.gatewayVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private isVersionUpgradeNeeded(): boolean {
|
||||||
|
return (!this.configVersion || this.configVersion < this.gatewayVersion) && this.gatewayVersionStr === GatewayVersion.Current;
|
||||||
|
}
|
||||||
|
|
||||||
private parseVersion(version: string): number {
|
private parseVersion(version: string): number {
|
||||||
return Number(version?.replace(/\./g, ''));
|
return Number(version?.replace(/\./g, ''));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,6 +29,7 @@ import {
|
|||||||
GatewayConnector,
|
GatewayConnector,
|
||||||
GatewayConnectorDefaultTypesTranslatesMap,
|
GatewayConnectorDefaultTypesTranslatesMap,
|
||||||
GatewayLogLevel,
|
GatewayLogLevel,
|
||||||
|
GatewayVersion,
|
||||||
GatewayVersionedDefaultConfig,
|
GatewayVersionedDefaultConfig,
|
||||||
noLeadTrailSpacesRegex
|
noLeadTrailSpacesRegex
|
||||||
} from '@home/components/widget/lib/gateway/gateway-widget.models';
|
} from '@home/components/widget/lib/gateway/gateway-widget.models';
|
||||||
@ -102,7 +103,7 @@ export class AddConnectorDialogComponent
|
|||||||
if (gatewayVersion) {
|
if (gatewayVersion) {
|
||||||
value.configVersion = gatewayVersion;
|
value.configVersion = gatewayVersion;
|
||||||
}
|
}
|
||||||
value.configurationJson = (gatewayVersion
|
value.configurationJson = (gatewayVersion === GatewayVersion.Current
|
||||||
? defaultConfig[this.data.gatewayVersion]
|
? defaultConfig[this.data.gatewayVersion]
|
||||||
: defaultConfig.legacy)
|
: defaultConfig.legacy)
|
||||||
?? defaultConfig;
|
?? defaultConfig;
|
||||||
|
|||||||
@ -178,7 +178,7 @@
|
|||||||
<ng-container [ngSwitch]="initialConnector.type">
|
<ng-container [ngSwitch]="initialConnector.type">
|
||||||
<ng-container *ngSwitchCase="ConnectorType.MQTT">
|
<ng-container *ngSwitchCase="ConnectorType.MQTT">
|
||||||
<tb-mqtt-basic-config
|
<tb-mqtt-basic-config
|
||||||
*ngIf="connectorForm.get('configVersion').value else legacy"
|
*ngIf="connectorForm.get('configVersion').value === GatewayVersion.Current else legacy"
|
||||||
formControlName="basicConfig"
|
formControlName="basicConfig"
|
||||||
[generalTabContent]="generalTabContent"
|
[generalTabContent]="generalTabContent"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -59,6 +59,7 @@ import {
|
|||||||
GatewayConnectorDefaultTypesTranslatesMap,
|
GatewayConnectorDefaultTypesTranslatesMap,
|
||||||
GatewayLogLevel,
|
GatewayLogLevel,
|
||||||
noLeadTrailSpacesRegex,
|
noLeadTrailSpacesRegex,
|
||||||
|
GatewayVersion,
|
||||||
} from './gateway-widget.models';
|
} from './gateway-widget.models';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { AddConnectorDialogComponent } from '@home/components/widget/lib/gateway/dialog/add-connector-dialog.component';
|
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 displayedColumns = ['enabled', 'key', 'type', 'syncStatus', 'errors', 'actions'];
|
||||||
readonly GatewayConnectorTypesTranslatesMap = GatewayConnectorDefaultTypesTranslatesMap;
|
readonly GatewayConnectorTypesTranslatesMap = GatewayConnectorDefaultTypesTranslatesMap;
|
||||||
readonly ConnectorConfigurationModes = ConfigurationModes;
|
readonly ConnectorConfigurationModes = ConfigurationModes;
|
||||||
|
readonly GatewayVersion = GatewayVersion;
|
||||||
|
|
||||||
pageLink: PageLink;
|
pageLink: PageLink;
|
||||||
dataSource: MatTableDataSource<GatewayAttributeData>;
|
dataSource: MatTableDataSource<GatewayAttributeData>;
|
||||||
|
|||||||
@ -188,6 +188,11 @@ export interface ConnectorSecurity {
|
|||||||
mode?: ModeType;
|
mode?: ModeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum GatewayVersion {
|
||||||
|
Current = '3.5.1',
|
||||||
|
Legacy = 'legacy'
|
||||||
|
}
|
||||||
|
|
||||||
export type ConnectorMapping = DeviceConnectorMapping | RequestMappingValue | ConverterConnectorMapping;
|
export type ConnectorMapping = DeviceConnectorMapping | RequestMappingValue | ConverterConnectorMapping;
|
||||||
|
|
||||||
export type ConnectorMappingFormValue = DeviceConnectorMapping | RequestMappingFormValue | ConverterMappingFormValue;
|
export type ConnectorMappingFormValue = DeviceConnectorMapping | RequestMappingFormValue | ConverterMappingFormValue;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user