diff --git a/ui-ngx/src/app/modules/home/components/device/device-credentials.component.html b/ui-ngx/src/app/modules/home/components/device/device-credentials.component.html index 0cf349a074..76c1fa13bb 100644 --- a/ui-ngx/src/app/modules/home/components/device/device-credentials.component.html +++ b/ui-ngx/src/app/modules/home/components/device/device-credentials.component.html @@ -16,7 +16,7 @@ -->
- + device.credentials-type diff --git a/ui-ngx/src/app/modules/home/components/device/device-credentials.component.ts b/ui-ngx/src/app/modules/home/components/device/device-credentials.component.ts index a7d4b8008b..d558213ec4 100644 --- a/ui-ngx/src/app/modules/home/components/device/device-credentials.component.ts +++ b/ui-ngx/src/app/modules/home/components/device/device-credentials.component.ts @@ -29,6 +29,7 @@ import { } from '@angular/forms'; import { credentialTypeNames, + credentialTypesByTransportType, DeviceCredentialMQTTBasic, DeviceCredentials, DeviceCredentialsType, @@ -59,8 +60,21 @@ export class DeviceCredentialsComponent implements ControlValueAccessor, OnInit, @Input() disabled: boolean; + private deviceTransportTypeValue = DeviceTransportType.DEFAULT; + get deviceTransportType(): DeviceTransportType { + return this.deviceTransportTypeValue + } @Input() - deviceTransportType = DeviceTransportType.DEFAULT; + set deviceTransportType(type: DeviceTransportType) { + if (type) { + this.deviceTransportTypeValue = type; + this.credentialsTypes = credentialTypesByTransportType.get(type); + const currentType = this.deviceCredentialsFormGroup.get('credentialsType').value; + if (!this.credentialsTypes.includes(currentType)) { + this.deviceCredentialsFormGroup.get('credentialsType').patchValue(this.credentialsTypes[0], {onlySelf: true}); + } + } + } private destroy$ = new Subject(); @@ -68,7 +82,7 @@ export class DeviceCredentialsComponent implements ControlValueAccessor, OnInit, deviceCredentialsType = DeviceCredentialsType; - credentialsTypes = Object.values(DeviceCredentialsType); + credentialsTypes = credentialTypesByTransportType.get(DeviceTransportType.DEFAULT); credentialTypeNamesMap = credentialTypeNames; diff --git a/ui-ngx/src/app/modules/home/components/wizard/device-wizard-dialog.component.html b/ui-ngx/src/app/modules/home/components/wizard/device-wizard-dialog.component.html index 54cf110d5b..75c0819527 100644 --- a/ui-ngx/src/app/modules/home/components/wizard/device-wizard-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/wizard/device-wizard-dialog.component.html @@ -64,7 +64,8 @@ [ngClass]="{invisible: deviceWizardFormGroup.get('addProfileType').value !== 0}" [addNewProfile]="false" [selectDefaultProfile]="true" - [editProfileEnabled]="false"> + [editProfileEnabled]="false" + (deviceProfileChanged)="deviceProfileChanged($event)"> @@ -154,6 +155,7 @@ {{ 'device.wizard.add-credentials' | translate }} diff --git a/ui-ngx/src/app/modules/home/components/wizard/device-wizard-dialog.component.ts b/ui-ngx/src/app/modules/home/components/wizard/device-wizard-dialog.component.ts index b9c38d24dd..68e82fc7e1 100644 --- a/ui-ngx/src/app/modules/home/components/wizard/device-wizard-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/wizard/device-wizard-dialog.component.ts @@ -25,6 +25,7 @@ import { createDeviceProfileConfiguration, createDeviceProfileTransportConfiguration, DeviceProfile, + DeviceProfileInfo, DeviceProfileType, DeviceProvisionConfiguration, DeviceProvisionType, @@ -91,6 +92,7 @@ export class DeviceWizardDialogComponent extends serviceType = ServiceType.TB_RULE_ENGINE; private subscriptions: Subscription[] = []; + private currentDeviceProfileTransportType = DeviceTransportType.DEFAULT; constructor(protected store: Store, protected router: Router, @@ -265,6 +267,20 @@ export class DeviceWizardDialogComponent extends } } + get deviceTransportType(): DeviceTransportType { + if (this.deviceWizardFormGroup.get('addProfileType').value) { + return this.transportConfigFormGroup.get('transportType').value; + } else { + return this.currentDeviceProfileTransportType; + } + } + + deviceProfileChanged(deviceProfile: DeviceProfileInfo) { + if (deviceProfile) { + this.currentDeviceProfileTransportType = deviceProfile.transportType; + } + } + private createDeviceProfile(): Observable { if (this.deviceWizardFormGroup.get('addProfileType').value) { const deviceProvisionConfiguration: DeviceProvisionConfiguration = this.provisionConfigFormGroup.get('provisionConfiguration').value; diff --git a/ui-ngx/src/app/modules/home/pages/device/device-credentials-dialog.component.html b/ui-ngx/src/app/modules/home/pages/device/device-credentials-dialog.component.html index d246f3e1c6..8e1a67a8a9 100644 --- a/ui-ngx/src/app/modules/home/pages/device/device-credentials-dialog.component.html +++ b/ui-ngx/src/app/modules/home/pages/device/device-credentials-dialog.component.html @@ -17,7 +17,7 @@ -->
-

device.device-credentials

+

{{ 'device.device-credentials' | translate }}