|
|
@ -21,13 +21,16 @@ import { Store } from '@ngrx/store'; |
|
|
import { AppState } from '@core/core.state'; |
|
|
import { AppState } from '@core/core.state'; |
|
|
import { FormBuilder, FormControl, FormGroup, FormGroupDirective, NgForm } from '@angular/forms'; |
|
|
import { FormBuilder, FormControl, FormGroup, FormGroupDirective, NgForm } from '@angular/forms'; |
|
|
import { DeviceService } from '@core/http/device.service'; |
|
|
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 { DialogComponent } from '@shared/components/dialog.component'; |
|
|
import { Router } from '@angular/router'; |
|
|
import { Router } from '@angular/router'; |
|
|
|
|
|
import { DeviceProfileService } from '@core/http/device-profile.service'; |
|
|
|
|
|
import { forkJoin } from 'rxjs'; |
|
|
|
|
|
|
|
|
export interface DeviceCredentialsDialogData { |
|
|
export interface DeviceCredentialsDialogData { |
|
|
isReadOnly: boolean; |
|
|
isReadOnly: boolean; |
|
|
deviceId: string; |
|
|
deviceId: string; |
|
|
|
|
|
deviceProfileId: string; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
|
@ -47,18 +50,13 @@ export class DeviceCredentialsDialogComponent extends |
|
|
|
|
|
|
|
|
submitted = false; |
|
|
submitted = false; |
|
|
|
|
|
|
|
|
deviceCredentialsType = DeviceCredentialsType; |
|
|
deviceTransportType: DeviceTransportType; |
|
|
|
|
|
|
|
|
credentialsTypes = Object.keys(DeviceCredentialsType); |
|
|
|
|
|
|
|
|
|
|
|
credentialTypeNamesMap = credentialTypeNames; |
|
|
|
|
|
|
|
|
|
|
|
hidePassword = true; |
|
|
|
|
|
|
|
|
|
|
|
constructor(protected store: Store<AppState>, |
|
|
constructor(protected store: Store<AppState>, |
|
|
protected router: Router, |
|
|
protected router: Router, |
|
|
@Inject(MAT_DIALOG_DATA) public data: DeviceCredentialsDialogData, |
|
|
@Inject(MAT_DIALOG_DATA) public data: DeviceCredentialsDialogData, |
|
|
private deviceService: DeviceService, |
|
|
private deviceService: DeviceService, |
|
|
|
|
|
private deviceProfileService: DeviceProfileService, |
|
|
@SkipSelf() private errorStateMatcher: ErrorStateMatcher, |
|
|
@SkipSelf() private errorStateMatcher: ErrorStateMatcher, |
|
|
public dialogRef: MatDialogRef<DeviceCredentialsDialogComponent, DeviceCredentials>, |
|
|
public dialogRef: MatDialogRef<DeviceCredentialsDialogComponent, DeviceCredentials>, |
|
|
public fb: FormBuilder) { |
|
|
public fb: FormBuilder) { |
|
|
@ -84,14 +82,16 @@ export class DeviceCredentialsDialogComponent extends |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
loadDeviceCredentials() { |
|
|
loadDeviceCredentials() { |
|
|
this.deviceService.getDeviceCredentials(this.data.deviceId).subscribe( |
|
|
const task = []; |
|
|
(deviceCredentials) => { |
|
|
task.push(this.deviceService.getDeviceCredentials(this.data.deviceId)); |
|
|
this.deviceCredentials = deviceCredentials; |
|
|
task.push(this.deviceProfileService.getDeviceProfileInfo(this.data.deviceProfileId)); |
|
|
this.deviceCredentialsFormGroup.patchValue({ |
|
|
forkJoin(task).subscribe(([deviceCredentials, deviceProfile]: [DeviceCredentials, DeviceProfileInfo]) => { |
|
|
credential: deviceCredentials |
|
|
this.deviceTransportType = deviceProfile.transportType; |
|
|
}, {emitEvent: false}); |
|
|
this.deviceCredentials = deviceCredentials; |
|
|
} |
|
|
this.deviceCredentialsFormGroup.patchValue({ |
|
|
); |
|
|
credential: deviceCredentials |
|
|
|
|
|
}, {emitEvent: false}); |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
cancel(): void { |
|
|
cancel(): void { |
|
|
|