diff --git a/ui-ngx/src/app/modules/home/components/profile/device-profile-autocomplete.component.ts b/ui-ngx/src/app/modules/home/components/profile/device-profile-autocomplete.component.ts index c59a2cb9b3..42aa997aca 100644 --- a/ui-ngx/src/app/modules/home/components/profile/device-profile-autocomplete.component.ts +++ b/ui-ngx/src/app/modules/home/components/profile/device-profile-autocomplete.component.ts @@ -46,7 +46,7 @@ import { DeviceProfileService } from '@core/http/device-profile.service'; import { DeviceProfileDialogComponent, DeviceProfileDialogData } from './device-profile-dialog.component'; import { MatAutocomplete } from '@angular/material/autocomplete'; import { AddDeviceProfileDialogComponent, AddDeviceProfileDialogData } from './add-device-profile-dialog.component'; -import { emptyPageData } from "@shared/models/page/page-data"; +import { emptyPageData } from '@shared/models/page/page-data'; @Component({ selector: 'tb-device-profile-autocomplete', @@ -146,7 +146,6 @@ export class DeviceProfileAutocompleteComponent implements ControlValueAccessor, ngOnInit() { this.filteredDeviceProfiles = this.selectDeviceProfileFormGroup.get('deviceProfile').valueChanges .pipe( - debounceTime(150), tap((value: DeviceProfileInfo | string) => { let modelValue: DeviceProfileInfo | null; if (typeof value === 'string' || !value) { @@ -173,6 +172,7 @@ export class DeviceProfileAutocompleteComponent implements ControlValueAccessor, return ''; } }), + debounceTime(150), distinctUntilChanged(), switchMap(name => this.fetchDeviceProfiles(name)), share() 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 68e82fc7e1..fd7391dacc 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 @@ -303,13 +303,14 @@ export class DeviceWizardDialogComponent extends deviceProfile.defaultRuleChainId = new RuleChainId(this.deviceWizardFormGroup.get('defaultRuleChainId').value); } return this.deviceProfileService.saveDeviceProfile(deepTrim(deviceProfile)).pipe( - map(profile => profile.id), - tap((profileId) => { + tap((profile) => { + this.currentDeviceProfileTransportType = profile.transportType; this.deviceWizardFormGroup.patchValue({ - deviceProfileId: profileId, + deviceProfileId: profile.id, addProfileType: 0 }); - }) + }), + map(profile => profile.id) ); } else { return of(this.deviceWizardFormGroup.get('deviceProfileId').value); @@ -334,7 +335,12 @@ export class DeviceWizardDialogComponent extends id: this.customerFormGroup.get('customerId').value }; } - return this.data.entitiesTableConfig.saveEntity(deepTrim(device)); + return this.data.entitiesTableConfig.saveEntity(deepTrim(device)).pipe( + catchError(e => { + this.addDeviceWizardStepper.selectedIndex = 0; + return throwError(e); + }) + ); } private saveCredentials(device: BaseData): Observable { @@ -345,6 +351,7 @@ export class DeviceWizardDialogComponent extends const deviceCredentialsValue = {...deviceCredentials, ...this.credentialsFormGroup.value.credential}; return this.deviceService.saveDeviceCredentials(deviceCredentialsValue).pipe( catchError(e => { + this.addDeviceWizardStepper.selectedIndex = 1; return this.deviceService.deleteDevice(device.id.id).pipe( mergeMap(() => { return throwError(e);