UI: Fixed processing error in device wizard: move to error step and save transport type
This commit is contained in:
parent
2ce709e363
commit
1028273d25
@ -46,7 +46,7 @@ import { DeviceProfileService } from '@core/http/device-profile.service';
|
|||||||
import { DeviceProfileDialogComponent, DeviceProfileDialogData } from './device-profile-dialog.component';
|
import { DeviceProfileDialogComponent, DeviceProfileDialogData } from './device-profile-dialog.component';
|
||||||
import { MatAutocomplete } from '@angular/material/autocomplete';
|
import { MatAutocomplete } from '@angular/material/autocomplete';
|
||||||
import { AddDeviceProfileDialogComponent, AddDeviceProfileDialogData } from './add-device-profile-dialog.component';
|
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({
|
@Component({
|
||||||
selector: 'tb-device-profile-autocomplete',
|
selector: 'tb-device-profile-autocomplete',
|
||||||
@ -146,7 +146,6 @@ export class DeviceProfileAutocompleteComponent implements ControlValueAccessor,
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.filteredDeviceProfiles = this.selectDeviceProfileFormGroup.get('deviceProfile').valueChanges
|
this.filteredDeviceProfiles = this.selectDeviceProfileFormGroup.get('deviceProfile').valueChanges
|
||||||
.pipe(
|
.pipe(
|
||||||
debounceTime(150),
|
|
||||||
tap((value: DeviceProfileInfo | string) => {
|
tap((value: DeviceProfileInfo | string) => {
|
||||||
let modelValue: DeviceProfileInfo | null;
|
let modelValue: DeviceProfileInfo | null;
|
||||||
if (typeof value === 'string' || !value) {
|
if (typeof value === 'string' || !value) {
|
||||||
@ -173,6 +172,7 @@ export class DeviceProfileAutocompleteComponent implements ControlValueAccessor,
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
debounceTime(150),
|
||||||
distinctUntilChanged(),
|
distinctUntilChanged(),
|
||||||
switchMap(name => this.fetchDeviceProfiles(name)),
|
switchMap(name => this.fetchDeviceProfiles(name)),
|
||||||
share()
|
share()
|
||||||
|
|||||||
@ -303,13 +303,14 @@ export class DeviceWizardDialogComponent extends
|
|||||||
deviceProfile.defaultRuleChainId = new RuleChainId(this.deviceWizardFormGroup.get('defaultRuleChainId').value);
|
deviceProfile.defaultRuleChainId = new RuleChainId(this.deviceWizardFormGroup.get('defaultRuleChainId').value);
|
||||||
}
|
}
|
||||||
return this.deviceProfileService.saveDeviceProfile(deepTrim(deviceProfile)).pipe(
|
return this.deviceProfileService.saveDeviceProfile(deepTrim(deviceProfile)).pipe(
|
||||||
map(profile => profile.id),
|
tap((profile) => {
|
||||||
tap((profileId) => {
|
this.currentDeviceProfileTransportType = profile.transportType;
|
||||||
this.deviceWizardFormGroup.patchValue({
|
this.deviceWizardFormGroup.patchValue({
|
||||||
deviceProfileId: profileId,
|
deviceProfileId: profile.id,
|
||||||
addProfileType: 0
|
addProfileType: 0
|
||||||
});
|
});
|
||||||
})
|
}),
|
||||||
|
map(profile => profile.id)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return of(this.deviceWizardFormGroup.get('deviceProfileId').value);
|
return of(this.deviceWizardFormGroup.get('deviceProfileId').value);
|
||||||
@ -334,7 +335,12 @@ export class DeviceWizardDialogComponent extends
|
|||||||
id: this.customerFormGroup.get('customerId').value
|
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> {
|
private saveCredentials(device: BaseData<HasId>): Observable<boolean> {
|
||||||
@ -345,6 +351,7 @@ export class DeviceWizardDialogComponent extends
|
|||||||
const deviceCredentialsValue = {...deviceCredentials, ...this.credentialsFormGroup.value.credential};
|
const deviceCredentialsValue = {...deviceCredentials, ...this.credentialsFormGroup.value.credential};
|
||||||
return this.deviceService.saveDeviceCredentials(deviceCredentialsValue).pipe(
|
return this.deviceService.saveDeviceCredentials(deviceCredentialsValue).pipe(
|
||||||
catchError(e => {
|
catchError(e => {
|
||||||
|
this.addDeviceWizardStepper.selectedIndex = 1;
|
||||||
return this.deviceService.deleteDevice(device.id.id).pipe(
|
return this.deviceService.deleteDevice(device.id.id).pipe(
|
||||||
mergeMap(() => {
|
mergeMap(() => {
|
||||||
return throwError(e);
|
return throwError(e);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user