Files
llmgw/internal/web/templates/admin_users.html
T
Ilker ManapandClaude Opus 5 859f08da9b Approve accounts from the browser, and draw the traffic
Two things the dashboard was missing: it could not act, and it was a column of
numbers.

Account administration moves to /admin/users — approving into a project,
suspending, reinstating. That is the work an operator does constantly and it
should not need a terminal. Three things stay on the CLI, and the line is not
arbitrary: promoting someone to admin, resetting a password, and issuing a key
on another person's behalf each turn a stolen admin session into more than it
was — permanent access, or somebody else's account. Approving and suspending
do not. Suspending signs the account out everywhere, or suspension is advisory
until the session happens to expire, and an admin cannot suspend themselves,
which is not a thing an interface should let you do by misclicking.

The charts are inline SVG generated in Go. A charting library would mean a
JavaScript toolchain in CI and a megabyte of bundle for what is a list of
rectangles, and the single-binary goal rules that out. Hourly over a day: fine
enough to show a working day, coarse enough that one slow minute is not an
incident. Empty hours are filled in, because a chart with hours missing where
nothing happened reads as a chart with hours missing from the data.

The SVG is marked as trusted HTML, so everything that reaches it is either a
number this package computed or escaped explicitly, and a bar's colour can only
be one of four names — a colour that could be anything is a way to write CSS
into every page the chart appears on. There are tests for both.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-16 12:01:42 +02:00

69 lines
2.8 KiB
HTML

{{define "admin_users"}}<!doctype html>
<html lang="en"><head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>Accounts · llmgw</title><link rel="stylesheet" href="/_static/base.css">
</head><body><div class="wrap">
<header>
<h1>Accounts</h1>
<p class="sub">{{len .Pending}} waiting for approval · {{len .Active}} active</p>
<nav><a href="/admin">cluster</a> <a href="/profile">your keys</a></nav>
</header>
{{if .Error}}<p class="error">{{.Error}}</p>{{end}}
{{if .Message}}<p class="ok">{{.Message}}</p>{{end}}
<h2>Waiting for approval</h2>
{{if .Pending}}
<table><tr><th>Email</th><th>Name</th><th>Signed up</th><th>Project</th><th></th></tr>
{{range .Pending}}<tr>
<td>{{.Email}}</td><td>{{.Name}}</td><td>{{ago .CreatedAt}}</td>
<td colspan="2">
<form method="post" action="/admin/users/{{.ID}}/approve" class="inline">
<input type="hidden" name="csrf" value="{{$.CSRF}}">
<select name="project">
{{range $.Projects}}<option value="{{.ID}}">{{.Path}}</option>{{end}}
</select>
<button type="submit">Approve</button>
</form>
<form method="post" action="/admin/users/{{.ID}}/suspend" class="inline">
<input type="hidden" name="csrf" value="{{$.CSRF}}">
<button type="submit" class="link danger">Reject</button>
</form>
</td>
</tr>{{end}}</table>
{{else}}<p class="empty">Nobody is waiting.</p>{{end}}
<h2>Accounts</h2>
{{if .Active}}
<table><tr><th>Email</th><th>State</th><th>Admin</th><th>Project</th><th>Last login</th><th></th></tr>
{{range .Active}}<tr>
<td>{{.Email}}</td>
<td class="state state-{{.State}}">{{.State}}</td>
<td>{{if .IsAdmin}}yes{{else}}—{{end}}</td>
<td>{{or .ProjectID "—"}}</td>
<td>{{ago .LastLoginAt}}</td>
<td>
{{if eq (printf "%s" .State) "active"}}
<form method="post" action="/admin/users/{{.ID}}/suspend" class="inline">
<input type="hidden" name="csrf" value="{{$.CSRF}}">
<button type="submit" class="link danger">Suspend</button>
</form>
{{else}}
<form method="post" action="/admin/users/{{.ID}}/reinstate" class="inline">
<input type="hidden" name="csrf" value="{{$.CSRF}}">
<button type="submit" class="link">Reinstate</button>
</form>
{{end}}
</td>
</tr>{{end}}</table>
{{else}}<p class="empty">No accounts yet.</p>{{end}}
<p class="note">Three things are deliberately not here. Making someone an admin,
resetting a password and issuing keys on another person's behalf all need a
shell on the control plane — <code>llmgw users promote</code>,
<code>reset-password</code>, <code>llmgw keys</code>. A stolen admin session can
approve and suspend; it cannot hand itself more access or take over an account.</p>
<footer><span>llmgw {{.Version}}</span><span>{{.Now}}</span></footer>
</div></body></html>{{end}}