Commit 1028273d25956e7ea08afd149446459ba86f3d3d
1 parent
2ce709e3
UI: Fixed processing error in device wizard: move to error step and save transport type
Showing
2 changed files
with
14 additions
and
7 deletions
@@ -46,7 +46,7 @@ import { DeviceProfileService } from '@core/http/device-profile.service'; | @@ -46,7 +46,7 @@ import { DeviceProfileService } from '@core/http/device-profile.service'; | ||
46 | import { DeviceProfileDialogComponent, DeviceProfileDialogData } from './device-profile-dialog.component'; | 46 | import { DeviceProfileDialogComponent, DeviceProfileDialogData } from './device-profile-dialog.component'; |
47 | import { MatAutocomplete } from '@angular/material/autocomplete'; | 47 | import { MatAutocomplete } from '@angular/material/autocomplete'; |
48 | import { AddDeviceProfileDialogComponent, AddDeviceProfileDialogData } from './add-device-profile-dialog.component'; | 48 | import { AddDeviceProfileDialogComponent, AddDeviceProfileDialogData } from './add-device-profile-dialog.component'; |
49 | -import { emptyPageData } from "@shared/models/page/page-data"; | 49 | +import { emptyPageData } from '@shared/models/page/page-data'; |
50 | 50 | ||
51 | @Component({ | 51 | @Component({ |
52 | selector: 'tb-device-profile-autocomplete', | 52 | selector: 'tb-device-profile-autocomplete', |
@@ -146,7 +146,6 @@ export class DeviceProfileAutocompleteComponent implements ControlValueAccessor, | @@ -146,7 +146,6 @@ export class DeviceProfileAutocompleteComponent implements ControlValueAccessor, | ||
146 | ngOnInit() { | 146 | ngOnInit() { |
147 | this.filteredDeviceProfiles = this.selectDeviceProfileFormGroup.get('deviceProfile').valueChanges | 147 | this.filteredDeviceProfiles = this.selectDeviceProfileFormGroup.get('deviceProfile').valueChanges |
148 | .pipe( | 148 | .pipe( |
149 | - debounceTime(150), | ||
150 | tap((value: DeviceProfileInfo | string) => { | 149 | tap((value: DeviceProfileInfo | string) => { |
151 | let modelValue: DeviceProfileInfo | null; | 150 | let modelValue: DeviceProfileInfo | null; |
152 | if (typeof value === 'string' || !value) { | 151 | if (typeof value === 'string' || !value) { |
@@ -173,6 +172,7 @@ export class DeviceProfileAutocompleteComponent implements ControlValueAccessor, | @@ -173,6 +172,7 @@ export class DeviceProfileAutocompleteComponent implements ControlValueAccessor, | ||
173 | return ''; | 172 | return ''; |
174 | } | 173 | } |
175 | }), | 174 | }), |
175 | + debounceTime(150), | ||
176 | distinctUntilChanged(), | 176 | distinctUntilChanged(), |
177 | switchMap(name => this.fetchDeviceProfiles(name)), | 177 | switchMap(name => this.fetchDeviceProfiles(name)), |
178 | share() | 178 | share() |
@@ -303,13 +303,14 @@ export class DeviceWizardDialogComponent extends | @@ -303,13 +303,14 @@ export class DeviceWizardDialogComponent extends | ||
303 | deviceProfile.defaultRuleChainId = new RuleChainId(this.deviceWizardFormGroup.get('defaultRuleChainId').value); | 303 | deviceProfile.defaultRuleChainId = new RuleChainId(this.deviceWizardFormGroup.get('defaultRuleChainId').value); |
304 | } | 304 | } |
305 | return this.deviceProfileService.saveDeviceProfile(deepTrim(deviceProfile)).pipe( | 305 | return this.deviceProfileService.saveDeviceProfile(deepTrim(deviceProfile)).pipe( |
306 | - map(profile => profile.id), | ||
307 | - tap((profileId) => { | 306 | + tap((profile) => { |
307 | + this.currentDeviceProfileTransportType = profile.transportType; | ||
308 | this.deviceWizardFormGroup.patchValue({ | 308 | this.deviceWizardFormGroup.patchValue({ |
309 | - deviceProfileId: profileId, | 309 | + deviceProfileId: profile.id, |
310 | addProfileType: 0 | 310 | addProfileType: 0 |
311 | }); | 311 | }); |
312 | - }) | 312 | + }), |
313 | + map(profile => profile.id) | ||
313 | ); | 314 | ); |
314 | } else { | 315 | } else { |
315 | return of(this.deviceWizardFormGroup.get('deviceProfileId').value); | 316 | return of(this.deviceWizardFormGroup.get('deviceProfileId').value); |
@@ -334,7 +335,12 @@ export class DeviceWizardDialogComponent extends | @@ -334,7 +335,12 @@ export class DeviceWizardDialogComponent extends | ||
334 | id: this.customerFormGroup.get('customerId').value | 335 | id: this.customerFormGroup.get('customerId').value |
335 | }; | 336 | }; |
336 | } | 337 | } |
337 | - return this.data.entitiesTableConfig.saveEntity(deepTrim(device)); | 338 | + return this.data.entitiesTableConfig.saveEntity(deepTrim(device)).pipe( |
339 | + catchError(e => { | ||
340 | + this.addDeviceWizardStepper.selectedIndex = 0; | ||
341 | + return throwError(e); | ||
342 | + }) | ||
343 | + ); | ||
338 | } | 344 | } |
339 | 345 | ||
340 | private saveCredentials(device: BaseData<HasId>): Observable<boolean> { | 346 | private saveCredentials(device: BaseData<HasId>): Observable<boolean> { |
@@ -345,6 +351,7 @@ export class DeviceWizardDialogComponent extends | @@ -345,6 +351,7 @@ export class DeviceWizardDialogComponent extends | ||
345 | const deviceCredentialsValue = {...deviceCredentials, ...this.credentialsFormGroup.value.credential}; | 351 | const deviceCredentialsValue = {...deviceCredentials, ...this.credentialsFormGroup.value.credential}; |
346 | return this.deviceService.saveDeviceCredentials(deviceCredentialsValue).pipe( | 352 | return this.deviceService.saveDeviceCredentials(deviceCredentialsValue).pipe( |
347 | catchError(e => { | 353 | catchError(e => { |
354 | + this.addDeviceWizardStepper.selectedIndex = 1; | ||
348 | return this.deviceService.deleteDevice(device.id.id).pipe( | 355 | return this.deviceService.deleteDevice(device.id.id).pipe( |
349 | mergeMap(() => { | 356 | mergeMap(() => { |
350 | return throwError(e); | 357 | return throwError(e); |