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 21c8d40a42..a7d4b8008b 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
@@ -31,7 +31,8 @@ import {
credentialTypeNames,
DeviceCredentialMQTTBasic,
DeviceCredentials,
- DeviceCredentialsType
+ DeviceCredentialsType,
+ DeviceTransportType
} from '@shared/models/device.models';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
@@ -58,6 +59,9 @@ export class DeviceCredentialsComponent implements ControlValueAccessor, OnInit,
@Input()
disabled: boolean;
+ @Input()
+ deviceTransportType = DeviceTransportType.DEFAULT;
+
private destroy$ = new Subject();
deviceCredentialsFormGroup: FormGroup;
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 75d6beaaed..d246f3e1c6 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
@@ -31,6 +31,7 @@
diff --git a/ui-ngx/src/app/modules/home/pages/device/device-credentials-dialog.component.ts b/ui-ngx/src/app/modules/home/pages/device/device-credentials-dialog.component.ts
index dca62cd081..fe00156800 100644
--- a/ui-ngx/src/app/modules/home/pages/device/device-credentials-dialog.component.ts
+++ b/ui-ngx/src/app/modules/home/pages/device/device-credentials-dialog.component.ts
@@ -21,13 +21,16 @@ import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import { FormBuilder, FormControl, FormGroup, FormGroupDirective, NgForm } from '@angular/forms';
import { DeviceService } from '@core/http/device.service';
-import { credentialTypeNames, DeviceCredentials, DeviceCredentialsType } from '@shared/models/device.models';
+import { DeviceCredentials, DeviceProfileInfo, DeviceTransportType } from '@shared/models/device.models';
import { DialogComponent } from '@shared/components/dialog.component';
import { Router } from '@angular/router';
+import { DeviceProfileService } from '@core/http/device-profile.service';
+import { forkJoin } from 'rxjs';
export interface DeviceCredentialsDialogData {
isReadOnly: boolean;
deviceId: string;
+ deviceProfileId: string;
}
@Component({
@@ -47,18 +50,13 @@ export class DeviceCredentialsDialogComponent extends
submitted = false;
- deviceCredentialsType = DeviceCredentialsType;
-
- credentialsTypes = Object.keys(DeviceCredentialsType);
-
- credentialTypeNamesMap = credentialTypeNames;
-
- hidePassword = true;
+ deviceTransportType: DeviceTransportType;
constructor(protected store: Store
,
protected router: Router,
@Inject(MAT_DIALOG_DATA) public data: DeviceCredentialsDialogData,
private deviceService: DeviceService,
+ private deviceProfileService: DeviceProfileService,
@SkipSelf() private errorStateMatcher: ErrorStateMatcher,
public dialogRef: MatDialogRef,
public fb: FormBuilder) {
@@ -84,14 +82,16 @@ export class DeviceCredentialsDialogComponent extends
}
loadDeviceCredentials() {
- this.deviceService.getDeviceCredentials(this.data.deviceId).subscribe(
- (deviceCredentials) => {
- this.deviceCredentials = deviceCredentials;
- this.deviceCredentialsFormGroup.patchValue({
- credential: deviceCredentials
- }, {emitEvent: false});
- }
- );
+ const task = [];
+ task.push(this.deviceService.getDeviceCredentials(this.data.deviceId));
+ task.push(this.deviceProfileService.getDeviceProfileInfo(this.data.deviceProfileId));
+ forkJoin(task).subscribe(([deviceCredentials, deviceProfile]: [DeviceCredentials, DeviceProfileInfo]) => {
+ this.deviceTransportType = deviceProfile.transportType;
+ this.deviceCredentials = deviceCredentials;
+ this.deviceCredentialsFormGroup.patchValue({
+ credential: deviceCredentials
+ }, {emitEvent: false});
+ });
}
cancel(): void {
diff --git a/ui-ngx/src/app/modules/home/pages/device/devices-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/device/devices-table-config.resolver.ts
index 363117a2a4..516e0efa57 100644
--- a/ui-ngx/src/app/modules/home/pages/device/devices-table-config.resolver.ts
+++ b/ui-ngx/src/app/modules/home/pages/device/devices-table-config.resolver.ts
@@ -112,7 +112,8 @@ export class DevicesTableConfigResolver implements Resolve this.onDeviceAction(action);
- this.config.detailsReadonly = () => (this.config.componentsData.deviceScope === 'customer_user' || this.config.componentsData.deviceScope === 'edge_customer_user');
+ this.config.detailsReadonly = () =>
+ (this.config.componentsData.deviceScope === 'customer_user' || this.config.componentsData.deviceScope === 'edge_customer_user');
this.config.headerComponent = DeviceTableHeaderComponent;
@@ -528,6 +529,7 @@ export class DevicesTableConfigResolver implements Resolve {
diff --git a/ui-ngx/src/app/shared/models/device.models.ts b/ui-ngx/src/app/shared/models/device.models.ts
index 2c09d64113..ba2a7aefd9 100644
--- a/ui-ngx/src/app/shared/models/device.models.ts
+++ b/ui-ngx/src/app/shared/models/device.models.ts
@@ -680,6 +680,20 @@ export const credentialTypeNames = new Map(
]
);
+export const credentialTypesByTransportType = new Map(
+ [
+ [DeviceTransportType.DEFAULT, [
+ DeviceCredentialsType.ACCESS_TOKEN, DeviceCredentialsType.X509_CERTIFICATE, DeviceCredentialsType.MQTT_BASIC
+ ]],
+ [DeviceTransportType.MQTT, [
+ DeviceCredentialsType.ACCESS_TOKEN, DeviceCredentialsType.X509_CERTIFICATE, DeviceCredentialsType.MQTT_BASIC
+ ]],
+ [DeviceTransportType.COAP, [DeviceCredentialsType.ACCESS_TOKEN, DeviceCredentialsType.X509_CERTIFICATE]],
+ [DeviceTransportType.LWM2M, [DeviceCredentialsType.LWM2M_CREDENTIALS]],
+ [DeviceTransportType.SNMP, [DeviceCredentialsType.ACCESS_TOKEN, DeviceCredentialsType.X509_CERTIFICATE]]
+ ]
+);
+
export interface DeviceCredentials extends BaseData {
deviceId: DeviceId;
credentialsType: DeviceCredentialsType;