Merge pull request #5061 from vvlladd28/bug/device-wizard/cach-error

[3.3.0] UI: Fixed processing error in device wizard: move to error step and save transport type
This commit is contained in:
Igor Kulikov 2021-08-09 18:13:30 +03:00 committed by GitHub
commit 5478d8386d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 7 deletions

View File

@ -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()

View File

@ -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<HasId>): Observable<boolean> {
@ -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);