|
|
|
@ -25,7 +25,9 @@ import { DeviceCredentials, DeviceProfileInfo, DeviceTransportType } from '@shar |
|
|
|
import { DialogComponent } from '@shared/components/dialog.component'; |
|
|
|
import { Router } from '@angular/router'; |
|
|
|
import { DeviceProfileService } from '@core/http/device-profile.service'; |
|
|
|
import { forkJoin } from 'rxjs'; |
|
|
|
import { forkJoin, throwError } from 'rxjs'; |
|
|
|
import { catchError } from 'rxjs/operators'; |
|
|
|
import { HttpStatusCode } from '@angular/common/http'; |
|
|
|
|
|
|
|
export interface DeviceCredentialsDialogData { |
|
|
|
isReadOnly: boolean; |
|
|
|
@ -102,7 +104,16 @@ export class DeviceCredentialsDialogComponent extends |
|
|
|
this.submitted = true; |
|
|
|
const deviceCredentialsValue = this.deviceCredentialsFormGroup.value.credential; |
|
|
|
this.deviceCredentials = {...this.deviceCredentials, ...deviceCredentialsValue}; |
|
|
|
this.deviceService.saveDeviceCredentials(this.deviceCredentials).subscribe( |
|
|
|
this.deviceService.saveDeviceCredentials(this.deviceCredentials) |
|
|
|
.pipe( |
|
|
|
catchError((err) => { |
|
|
|
if (err.status === HttpStatusCode.Conflict) { |
|
|
|
return this.deviceService.getDeviceCredentials(this.deviceCredentials.deviceId.id); |
|
|
|
} |
|
|
|
return throwError(() => err); |
|
|
|
}) |
|
|
|
) |
|
|
|
.subscribe( |
|
|
|
(deviceCredentials) => { |
|
|
|
this.dialogRef.close(deviceCredentials); |
|
|
|
} |
|
|
|
|