Browse Source

Install wizard: run the connection check when moving forward by the step header

pull/16617/head
dshvaika 3 weeks ago
parent
commit
479fc8907c
  1. 26
      ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts

26
ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts

@ -617,9 +617,8 @@ export class TbDeviceInstallDialogComponent extends DialogComponent<TbDeviceInst
return; return;
} }
// Checks the connection unless these values already passed the check; a failed check stops here // Checks the connection unless these values already passed the check; a failed check stops here
const check = this.connectionCheckOf(step); if (this.needsConnectionCheck(step)) {
if (check && !(check.status === 'success' && check.checkedValues === this.checkedValuesOf(step, check))) { if (this.connectionChecking(step) || !(await this.checkConnection(step))) {
if (check.status === 'checking' || !(await this.checkConnection(step))) {
return; return;
} }
} }
@ -632,6 +631,12 @@ export class TbDeviceInstallDialogComponent extends DialogComponent<TbDeviceInst
this.stepper.next(); this.stepper.next();
} }
/** True when the step checks the connection and its current values haven't passed the check yet. */
private needsConnectionCheck(ws: WizardStep): boolean {
const check = this.connectionCheckOf(ws);
return !!check && !(check.status === 'success' && check.checkedValues === this.checkedValuesOf(ws, check));
}
connectionCheckOf(ws: WizardStep): ConnectionCheck | undefined { connectionCheckOf(ws: WizardStep): ConnectionCheck | undefined {
if (this.reviewMode || ws.type !== 'form' || !ws.formFields) { if (this.reviewMode || ws.type !== 'form' || !ws.formFields) {
return undefined; return undefined;
@ -735,8 +740,19 @@ export class TbDeviceInstallDialogComponent extends DialogComponent<TbDeviceInst
} }
return; return;
} }
// Forward moves can come from the stepper header, which bypasses nextStep(), // Forward moves can come from the stepper header, which bypasses nextStep(). A step whose connection isn't
// so commit every step being passed over here. // checked for these values is left as Next leaves it: back to it, and Next checks the connection and moves on
// only when it passes. The stepper sets the new index after this event, so the move back waits for it.
for (let i = event.previouslySelectedIndex; i < event.selectedIndex; i++) {
if (this.needsConnectionCheck(this.wizardSteps[i])) {
queueMicrotask(() => {
this.stepper.selectedIndex = i;
void this.nextStep();
});
return;
}
}
// Commit every step being passed over here
let formValuesChanged = false; let formValuesChanged = false;
for (let i = event.previouslySelectedIndex; i < event.selectedIndex; i++) { for (let i = event.previouslySelectedIndex; i < event.selectedIndex; i++) {
const ws = this.wizardSteps[i]; const ws = this.wizardSteps[i];

Loading…
Cancel
Save