diff --git a/app/index.php b/app/index.php index 9e2924e..5d2fb86 100644 --- a/app/index.php +++ b/app/index.php @@ -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 = {