admin: internal-only superadmin console (users, payments, DB stats)
New independent `admin` service (admin.main:app) on the same image, reusing app.db/app.models read-only. Never runs migrations or the scheduler; issues SELECTs only. - Password-gated (ADMIN_CONSOLE_PASSWORD) with a 12h signed cookie; closed by default when the password is empty. - Bound to 127.0.0.1:8091 (SSH-tunnel access); off the intranet/NPM network. - Pages: overview stats, user list + search, per-user history/payment detail, DB usage (information_schema size + row estimates). - Compose: base `admin` service (+prod DB-host override, test mount); Dockerfile bakes admin/ into runtime + test stages. - Tests: tests/test_admin_console.py (auth, queries, page wiring) — 12 passing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
8946dee2e0
commit
411094d7b8
20 changed files with 1143 additions and 1 deletions
31
admin/templates/db.html
Normal file
31
admin/templates/db.html
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{% extends "base.html" %}
|
||||
{% block title %}database{% endblock %}
|
||||
{% block body %}
|
||||
<h1>Database usage</h1>
|
||||
<div class="cards">
|
||||
<div class="card"><div class="n">{{ stats.total_bytes|bytes }}</div><div class="l">Total size</div></div>
|
||||
<div class="card"><div class="n">{{ "{:,}".format(stats.total_rows) }}</div><div class="l">Total rows (est.)</div></div>
|
||||
<div class="card"><div class="n">{{ stats.tables|length }}</div><div class="l">Tables</div></div>
|
||||
</div>
|
||||
|
||||
<h2>Per table</h2>
|
||||
<table>
|
||||
<thead><tr><th>Table</th><th>Rows (est.)</th><th>Data</th><th>Index</th><th>Total</th><th style="width:160px">Share</th></tr></thead>
|
||||
<tbody>
|
||||
{% for t in stats.tables %}
|
||||
<tr>
|
||||
<td>{{ t.name }}</td>
|
||||
<td>{{ "{:,}".format(t.rows) }}</td>
|
||||
<td class="muted">{{ t.data_bytes|bytes }}</td>
|
||||
<td class="muted">{{ t.index_bytes|bytes }}</td>
|
||||
<td>{{ t.total_bytes|bytes }}</td>
|
||||
<td>
|
||||
<div class="bar"><span style="width:{{ t.pct }}%"></span></div>
|
||||
<span class="muted">{{ t.pct }}%</span>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<p class="muted">Row counts are the storage engine's estimate for InnoDB; sizes are exact on-disk bytes.</p>
|
||||
{% endblock %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue