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();
|
const admin = await adminRes.json();
|
||||||
if (!admin.ok) {
|
if (!admin.ok) {
|
||||||
setStatus('Caddy admin API unreachable', 'warn');
|
setEditable(false, admin.error || 'Caddy admin API unreachable');
|
||||||
toast('Caddy admin API is not reachable — deploy will fail', 'warn');
|
|
||||||
} else {
|
} else {
|
||||||
setStatus('Ready', '');
|
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 ───────────────────────────────────────────────────────────────────
|
// ─── Deploy ───────────────────────────────────────────────────────────────────
|
||||||
async function preDeploy() {
|
async function preDeploy() {
|
||||||
collectSites();
|
collectSites();
|
||||||
@@ -543,16 +550,6 @@ async function doDeploy() {
|
|||||||
setDeployBtn(true, 'Deploying…');
|
setDeployBtn(true, 'Deploying…');
|
||||||
setStatus('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 {
|
try {
|
||||||
const payload = {
|
const payload = {
|
||||||
|
|||||||
Reference in new issue
Block a user