html/admin.html + admin.js — a passphrase-gated console served at /admin.html: - API connectivity check (clearly flags the /api/ 404 if the proxy isn't routing). - Database snapshot (project/SOP/WP/comment counts via the API). - End-to-end smoke test in the browser (mirrors smoketest.py: issue gate, status, metrics, comments) with self-cleanup. - Demo data: seed a DEMO project + clean DEMO-/SMOKE- projects. Gate is SHA-256-based (default passphrase "prime-admin"; documented how to change) — obfuscation only, not real auth; restrict at the network/proxy for real protection. Not linked from the main nav. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
108 lines
6.3 KiB
HTML
108 lines
6.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Admin Console — Work Package Suite</title>
|
|
<link rel="icon" href="favicon.ico" sizes="any">
|
|
<style>
|
|
:root{ --bg:#f4f5f7; --surface:#fff; --border:#e3e6ec; --border-strong:#d0d5de; --text:#1a2230;
|
|
--muted:#5a6675; --dim:#9aa3b2; --accent:#2563d6; --green:#15924f; --green-bg:#e4f6ec;
|
|
--red:#cf3b3b; --red-bg:#fbeaea; --amber:#b87100; --amber-bg:#fdf2e0; --mono:'Cascadia Mono',Consolas,monospace; }
|
|
*{ box-sizing:border-box; }
|
|
body{ margin:0; font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif; background:var(--bg); color:var(--text); }
|
|
.wrap{ max-width:860px; margin:0 auto; padding:28px 20px 80px; }
|
|
h1{ font-size:20px; margin:0 0 2px; }
|
|
.sub{ color:var(--muted); font-size:13px; margin-bottom:18px; }
|
|
.card{ background:var(--surface); border:1px solid var(--border); border-radius:10px; padding:18px 20px; margin-bottom:16px; }
|
|
.card h2{ font-size:14px; margin:0 0 12px; text-transform:uppercase; letter-spacing:.03em; color:var(--accent); }
|
|
button{ font:inherit; font-size:13px; font-weight:600; border-radius:6px; padding:8px 14px; cursor:pointer;
|
|
border:1px solid var(--border-strong); background:#fff; color:var(--text); }
|
|
button:hover{ border-color:var(--accent); color:var(--accent); }
|
|
button.primary{ background:var(--accent); border-color:var(--accent); color:#fff; }
|
|
button.primary:hover{ background:#1e54bb; color:#fff; }
|
|
button.danger{ border-color:var(--red); color:var(--red); }
|
|
button.danger:hover{ background:var(--red-bg); }
|
|
.row{ display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
|
|
.banner{ padding:10px 14px; border-radius:8px; font-size:13px; font-weight:600; margin-top:10px; border:1px solid var(--border); background:var(--surface); }
|
|
.banner.ok{ background:var(--green-bg); color:var(--green); border-color:var(--green); }
|
|
.banner.bad{ background:var(--red-bg); color:var(--red); border-color:var(--red); }
|
|
pre.out{ background:#0f1525; color:#d7e0f5; border-radius:8px; padding:12px 14px; font-family:var(--mono);
|
|
font-size:12px; line-height:1.55; white-space:pre-wrap; max-height:340px; overflow:auto; margin:12px 0 0; }
|
|
pre.out .p{ color:#56d364; font-weight:700; } pre.out .f{ color:#ff7b72; font-weight:700; }
|
|
table.kv{ border-collapse:collapse; font-size:13px; margin-top:8px; }
|
|
table.kv th{ text-align:left; padding:5px 18px 5px 0; color:var(--muted); font-weight:600; }
|
|
table.kv td{ padding:5px 0; font-variant-numeric:tabular-nums; font-weight:700; }
|
|
.note{ font-size:12px; color:var(--dim); margin-top:10px; }
|
|
.gate-overlay{ position:fixed; inset:0; background:var(--bg); display:flex; align-items:center; justify-content:center; padding:20px; }
|
|
.gate-box{ background:var(--surface); border:1px solid var(--border); border-radius:12px; padding:28px; max-width:380px; width:100%; box-shadow:0 8px 30px rgba(20,30,50,.12); }
|
|
.gate-box h2{ margin:0 0 4px; font-size:17px; }
|
|
.gate-box p{ color:var(--muted); font-size:13px; margin:0 0 16px; }
|
|
.gate-box input{ width:100%; padding:10px 12px; font-size:14px; border:1px solid var(--border-strong); border-radius:6px; margin-bottom:12px; }
|
|
.gate-msg{ color:var(--red); font-size:12px; min-height:16px; margin-bottom:8px; }
|
|
.secwarn{ background:var(--amber-bg); color:var(--amber); border:1px solid var(--amber); border-radius:8px; padding:9px 13px; font-size:12px; margin-bottom:16px; }
|
|
a.home{ color:var(--accent); font-size:13px; text-decoration:none; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<!-- GATE -->
|
|
<div class="gate-overlay" id="admin-gate">
|
|
<div class="gate-box">
|
|
<h2>🔒 Admin Console</h2>
|
|
<p>Enter the admin passphrase to continue.</p>
|
|
<input type="password" id="gate-input" placeholder="Passphrase" autocomplete="off"
|
|
onkeydown="if(event.key==='Enter') tryUnlock()">
|
|
<div class="gate-msg" id="gate-msg"></div>
|
|
<button class="primary" style="width:100%" onclick="tryUnlock()">Unlock</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- CONSOLE -->
|
|
<div class="wrap" id="admin-main" style="display:none">
|
|
<div class="row" style="justify-content:space-between">
|
|
<div><h1>Work Package Suite — Admin Console</h1><div class="sub">Stack diagnostics & tests · talks to <code>/api</code> on this host</div></div>
|
|
<div class="row"><a class="home" href="index.html">← Site</a> <button onclick="lock()">Lock</button></div>
|
|
</div>
|
|
|
|
<div class="secwarn">⚠ This page is gated client-side only — that stops casual access, not a determined user. For real protection, restrict this host/route at the network or reverse-proxy layer.</div>
|
|
|
|
<!-- CONNECTIVITY -->
|
|
<div class="card">
|
|
<h2>API connectivity</h2>
|
|
<div class="row"><button class="primary" onclick="checkHealth()">Check /api/health</button></div>
|
|
<div class="banner" id="health-banner">—</div>
|
|
</div>
|
|
|
|
<!-- DB SNAPSHOT -->
|
|
<div class="card">
|
|
<h2>Database snapshot</h2>
|
|
<div class="row"><button onclick="snapshot()">Refresh counts</button></div>
|
|
<div id="snapshot-out" class="note">Click refresh to read row counts from SQL via the API.</div>
|
|
</div>
|
|
|
|
<!-- SMOKE TEST -->
|
|
<div class="card">
|
|
<h2>End-to-end smoke test</h2>
|
|
<div class="sub" style="margin-bottom:8px">Creates a throwaway project, exercises the issue gate / status / metrics / comments, then deletes it (cascade). Mirrors <code>server/smoketest.py</code>.</div>
|
|
<div class="row"><button class="primary" onclick="runSmokeTest()">Run smoke test</button></div>
|
|
<pre class="out" id="smoke-out">Ready.</pre>
|
|
</div>
|
|
|
|
<!-- DEMO DATA -->
|
|
<div class="card">
|
|
<h2>Demo data</h2>
|
|
<div class="sub" style="margin-bottom:8px">Seed a realistic <code>DEMO</code> project (SOP + a spread of Work Packages) into SQL, or remove all <code>DEMO-</code>/<code>SMOKE-</code> projects.</div>
|
|
<div class="row">
|
|
<button class="primary" onclick="seedDemo()">Seed demo project</button>
|
|
<button class="danger" onclick="cleanDemo()">Clean DEMO / SMOKE projects</button>
|
|
</div>
|
|
<pre class="out" id="demo-out">Ready.</pre>
|
|
<div class="note">Note: the seeded <strong>project</strong> appears in the home picker; its SOP/WPs live in SQL but won't render in the Creator/Dashboard until the front end is wired to the API (Phase 2).</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="admin.js"></script>
|
|
</body>
|
|
</html>
|