lock UI if caddy admin unreachable on load
This commit is contained in:
1 parent
4af62acfc1
commit
e955f032a8
1 file changed
+9
-12
+9
-12
@@ -494,8 +494,7 @@ async function init() {
|
||||
|
||||
const admin = await adminRes.json();
|
||||
if (!admin.ok) {
|
||||
setStatus('Caddy admin API unreachable', 'warn');
|
||||
toast('Caddy admin API is not reachable — deploy will fail', 'warn');
|
||||
setEditable(false, admin.error || 'Caddy admin API unreachable');
|
||||
} else {
|
||||
setStatus('Ready', '');
|
||||
}
|
||||
@@ -504,6 +503,14 @@ async function init() {
|
||||
}
|
||||
}
|
||||
|
||||
function setEditable(enabled, reason) {
|
||||
document.querySelectorAll('textarea, input, button').forEach(el => el.disabled = !enabled);
|
||||
if (!enabled) {
|
||||
setStatus(reason, 'error');
|
||||
document.getElementById('deploy-btn').disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Deploy ───────────────────────────────────────────────────────────────────
|
||||
async function preDeploy() {
|
||||
collectSites();
|
||||
@@ -543,16 +550,6 @@ async function doDeploy() {
|
||||
setDeployBtn(true, 'Deploying…');
|
||||
setStatus('Deploying…', '');
|
||||
|
||||
try {
|
||||
const r = await fetch('?action=check_admin');
|
||||
const d = await r.json();
|
||||
if (!d.ok) {
|
||||
setStatus('Caddy admin API unreachable', 'warn');
|
||||
toast(d.error || 'Caddy admin API is not reachable', 'error');
|
||||
setDeployBtn(false, 'Deploy');
|
||||
return;
|
||||
}
|
||||
} catch (e) { /* proceed anyway */ }
|
||||
|
||||
try {
|
||||
const payload = {
|
||||
|
||||
Reference in new issue
Block a user