Report failures where the operator can still see them
The 55 alert() calls carried the same suppression as the confirms, and go wrong in the worse direction: a silenced confirm makes a button do nothing, while a silenced alert lets the action run and says nothing about it failing. vvAlert returns a promise nobody has to await, so these converted by rename with no caller becoming async. The icon is inferred from the message rather than asked of fifty call sites, and an explicit type still wins.
This commit is contained in:
@@ -215,12 +215,12 @@ function vvApiKey(btn) {
|
||||
if (d.ok) {
|
||||
if (_vvPtReload) _vvPtReload();
|
||||
} else {
|
||||
alert('Failed: ' + (d.error ?? 'Unknown error'));
|
||||
vvAlert('Failed: ' + (d.error ?? 'Unknown error'));
|
||||
btn.disabled = false; btn.textContent = origText;
|
||||
}
|
||||
})
|
||||
.catch(e => {
|
||||
alert('Error: ' + e);
|
||||
vvAlert('Error: ' + e);
|
||||
btn.disabled = false; btn.textContent = origText;
|
||||
});
|
||||
}
|
||||
@@ -230,8 +230,8 @@ async function vvPtPhase2(btn, hostId) {
|
||||
btn.disabled = true;
|
||||
btn.textContent = '⟳ Starting…';
|
||||
_vvPtRun('Partnership/partnership_onboard.sh', '--phase2-only')
|
||||
.then(d => { if (!d.ok) alert('Failed: ' + (d.error ?? 'Unknown error')); })
|
||||
.catch(e => alert('Error: ' + e))
|
||||
.then(d => { if (!d.ok) vvAlert('Failed: ' + (d.error ?? 'Unknown error')); })
|
||||
.catch(e => vvAlert('Error: ' + e))
|
||||
.finally(() => setTimeout(() => { btn.disabled = false; btn.textContent = '▶ Run Phase 2 Manually'; }, 3000));
|
||||
}
|
||||
|
||||
@@ -240,8 +240,8 @@ async function vvPtOnboard(btn) {
|
||||
btn.disabled = true;
|
||||
btn.textContent = '⟳ Starting…';
|
||||
_vvPtRun('Partnership/partnership_onboard.sh')
|
||||
.then(d => { if (!d.ok) alert('Failed: ' + (d.error ?? 'Unknown error')); })
|
||||
.catch(e => alert('Error: ' + e))
|
||||
.then(d => { if (!d.ok) vvAlert('Failed: ' + (d.error ?? 'Unknown error')); })
|
||||
.catch(e => vvAlert('Error: ' + e))
|
||||
.finally(() => setTimeout(() => { btn.disabled = false; btn.textContent = '▶ Onboard (Mirror)'; }, 4000));
|
||||
}
|
||||
|
||||
@@ -250,8 +250,8 @@ async function vvPtPushConf(btn, hostId) {
|
||||
btn.disabled = true;
|
||||
btn.textContent = '⟳ Pushing…';
|
||||
_vvPtRun('Partnership/partnership_onboard.sh', '--phase1-only --skip-ssh')
|
||||
.then(d => { if (!d.ok) alert('Failed: ' + (d.error ?? 'Unknown error')); })
|
||||
.catch(e => alert('Error: ' + e))
|
||||
.then(d => { if (!d.ok) vvAlert('Failed: ' + (d.error ?? 'Unknown error')); })
|
||||
.catch(e => vvAlert('Error: ' + e))
|
||||
.finally(() => setTimeout(() => { btn.disabled = false; btn.textContent = '▶ Push Conf (key installed)'; }, 4000));
|
||||
}
|
||||
|
||||
@@ -260,8 +260,8 @@ async function vvPtLocalSetup(btn) {
|
||||
btn.disabled = true;
|
||||
btn.textContent = '⟳ Running…';
|
||||
_vvPtRun('Partnership/partnership_manager.sh', '--onboard --local-only')
|
||||
.then(d => { if (!d.ok) alert('Failed: ' + (d.error ?? 'Unknown error')); })
|
||||
.catch(e => alert('Error: ' + e))
|
||||
.then(d => { if (!d.ok) vvAlert('Failed: ' + (d.error ?? 'Unknown error')); })
|
||||
.catch(e => vvAlert('Error: ' + e))
|
||||
.finally(() => setTimeout(() => { btn.disabled = false; btn.textContent = '▶ Complete HOST1 Setup'; }, 4000));
|
||||
}
|
||||
|
||||
@@ -270,8 +270,8 @@ async function vvPtCancel(btn, hostId) {
|
||||
btn.disabled = true;
|
||||
btn.textContent = '⟳ Cancelling…';
|
||||
_vvPtRun('Partnership/onboard_cancel.sh', '--direction=both')
|
||||
.then(d => { if (!d.ok) alert('Failed: ' + (d.error ?? 'Unknown error')); })
|
||||
.catch(e => alert('Error: ' + e))
|
||||
.then(d => { if (!d.ok) vvAlert('Failed: ' + (d.error ?? 'Unknown error')); })
|
||||
.catch(e => vvAlert('Error: ' + e))
|
||||
.finally(() => setTimeout(() => { btn.disabled = false; btn.textContent = '✕ Cancel'; }, 4000));
|
||||
}
|
||||
|
||||
@@ -279,8 +279,8 @@ async function vvPtDeleteH1(btn, hostId) {
|
||||
if (!await vvConfirm(`Remove HOST1's key from ${hostId}?\n\n• Deletes local SSH key pair\n• Removes it from ${hostId}'s authorized_keys\n• Clears phase state`)) return;
|
||||
btn.disabled = true; btn.textContent = '⟳ Removing…';
|
||||
_vvPtRun('Partnership/onboard_cancel.sh', '--direction=h1')
|
||||
.then(d => { if (!d.ok) alert('Failed: ' + (d.error ?? 'Unknown error')); })
|
||||
.catch(e => alert('Error: ' + e))
|
||||
.then(d => { if (!d.ok) vvAlert('Failed: ' + (d.error ?? 'Unknown error')); })
|
||||
.catch(e => vvAlert('Error: ' + e))
|
||||
.finally(() => setTimeout(() => { btn.disabled = false; btn.textContent = '✕ Remove HOST1 key'; }, 4000));
|
||||
}
|
||||
|
||||
@@ -288,8 +288,8 @@ async function vvPtDeleteH2(btn, hostId) {
|
||||
if (!await vvConfirm(`Remove ${hostId}'s key from HOST1?\n\n• Removes ${hostId}'s public key from HOST1's authorized_keys\n• ${hostId} will no longer be able to SSH into HOST1`)) return;
|
||||
btn.disabled = true; btn.textContent = '⟳ Removing…';
|
||||
_vvPtRun('Partnership/onboard_cancel.sh', '--direction=h2')
|
||||
.then(d => { if (!d.ok) alert('Failed: ' + (d.error ?? 'Unknown error')); })
|
||||
.catch(e => alert('Error: ' + e))
|
||||
.then(d => { if (!d.ok) vvAlert('Failed: ' + (d.error ?? 'Unknown error')); })
|
||||
.catch(e => vvAlert('Error: ' + e))
|
||||
.finally(() => setTimeout(() => { btn.disabled = false; btn.textContent = `✕ Remove ${hostId} key`; }, 4000));
|
||||
}
|
||||
|
||||
@@ -299,8 +299,8 @@ async function vvPtOffboard(btn) {
|
||||
btn.disabled = true;
|
||||
btn.textContent = '⟳ Starting…';
|
||||
_vvPtRun('Partnership/partnership_offboard.sh')
|
||||
.then(d => { if (!d.ok) alert('Failed: ' + (d.error ?? 'Unknown error')); })
|
||||
.catch(e => alert('Error: ' + e))
|
||||
.then(d => { if (!d.ok) vvAlert('Failed: ' + (d.error ?? 'Unknown error')); })
|
||||
.catch(e => vvAlert('Error: ' + e))
|
||||
.finally(() => setTimeout(() => { btn.disabled = false; btn.textContent = '▶ Offboard'; }, 4000));
|
||||
}
|
||||
|
||||
@@ -311,8 +311,8 @@ async function vvPtTransfer(btn, token) {
|
||||
btn.disabled = true;
|
||||
btn.textContent = '⟳ Transferring…';
|
||||
_vvPtRun('Partnership/partnership_transfer.sh', '--confirm=' + token)
|
||||
.then(d => { if (!d.ok) alert('Failed: ' + (d.error ?? 'Unknown error')); })
|
||||
.catch(e => alert('Error: ' + e))
|
||||
.then(d => { if (!d.ok) vvAlert('Failed: ' + (d.error ?? 'Unknown error')); })
|
||||
.catch(e => vvAlert('Error: ' + e))
|
||||
.finally(() => setTimeout(() => { btn.disabled = false; btn.textContent = '⇄ Transfer Ownership'; }, 4000));
|
||||
}
|
||||
|
||||
@@ -349,9 +349,9 @@ function vvPtToggleSync(el, varName, enabled) {
|
||||
.then(r => r.json())
|
||||
.then(d => {
|
||||
if (d.ok) { if (_vvPtReload) _vvPtReload(); }
|
||||
else { alert('Failed: ' + (d.error ?? 'Unknown error')); el.style.pointerEvents = ''; el.style.opacity = ''; }
|
||||
else { vvAlert('Failed: ' + (d.error ?? 'Unknown error')); el.style.pointerEvents = ''; el.style.opacity = ''; }
|
||||
})
|
||||
.catch(e => { alert('Error: ' + e); el.style.pointerEvents = ''; el.style.opacity = ''; });
|
||||
.catch(e => { vvAlert('Error: ' + e); el.style.pointerEvents = ''; el.style.opacity = ''; });
|
||||
}
|
||||
|
||||
// ── Host Settings ─────────────────────────────────────────────────────────────
|
||||
@@ -407,10 +407,10 @@ async function vvPtSaveHosts(btn) {
|
||||
setTimeout(() => { btn.textContent = 'Save'; btn.style.display = 'none'; }, 2000);
|
||||
} else {
|
||||
btn.textContent = 'Save';
|
||||
alert('Save failed: ' + (d.error ?? 'Unknown error'));
|
||||
vvAlert('Save failed: ' + (d.error ?? 'Unknown error'));
|
||||
}
|
||||
})
|
||||
.catch(e => { btn.disabled = false; btn.textContent = 'Save'; alert('Error: ' + e); });
|
||||
.catch(e => { btn.disabled = false; btn.textContent = 'Save'; vvAlert('Error: ' + e); });
|
||||
}
|
||||
|
||||
// ── Array settings cards ───────────────────────────────────────────────────────
|
||||
@@ -507,10 +507,10 @@ async function vvPtSaveArrays(btn) {
|
||||
setTimeout(() => _vvInitArrayCards(), 600);
|
||||
} else {
|
||||
btn.textContent = 'Save Changes';
|
||||
alert('Save failed: ' + (d.error ?? 'Unknown error'));
|
||||
vvAlert('Save failed: ' + (d.error ?? 'Unknown error'));
|
||||
}
|
||||
})
|
||||
.catch(e => { btn.disabled = false; btn.textContent = 'Save Changes'; alert('Error: ' + e); });
|
||||
.catch(e => { btn.disabled = false; btn.textContent = 'Save Changes'; vvAlert('Error: ' + e); });
|
||||
}
|
||||
|
||||
// ── Settings panel ─────────────────────────────────────────────────────────────
|
||||
@@ -620,10 +620,10 @@ async function vvPtSaveSettings(btn) {
|
||||
setTimeout(() => { btn.textContent = 'Save Changes'; btn.style.display = 'none'; }, 2000);
|
||||
} else {
|
||||
btn.textContent = 'Save Changes';
|
||||
alert('Save failed: ' + (d.error ?? 'Unknown error'));
|
||||
vvAlert('Save failed: ' + (d.error ?? 'Unknown error'));
|
||||
}
|
||||
})
|
||||
.catch(e => { btn.disabled = false; btn.textContent = 'Save Changes'; alert('Error: ' + e); });
|
||||
.catch(e => { btn.disabled = false; btn.textContent = 'Save Changes'; vvAlert('Error: ' + e); });
|
||||
}
|
||||
|
||||
// ── Private page logic ─────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user