testing: bootstrap UI, agent reliability, NS-01..04 + alert username
Smoothes the rough edges that came up exercising a live deployment.
First-run bootstrap UI: /bootstrap renders a username + password form
that uses the in-memory token directly (operator no longer copies it
out of the log); /login redirects there while bootstrap is available.
Agent reliability: failJob synthetic envelopes so command.run early
returns no longer hang the server-side job; runtime probe of restic
restore --help drives --no-ownership instead of version sniffing
(0.18.x had it removed). Server unit re-shaped: ProtectSystem=full
plus ReadWritePaths=/etc/restic-manager, no ProtectHome — restore
can now write anywhere a user might want.
Restore wizard: default target is /root/rm-restore/<job-id>/ with
clearer help text. Re-init confirm input uses .field (was .input,
which doesn't exist — text was invisible).
NS-01 host delete: store DeleteHost, admin-band /hosts/{id}/delete
with hostname-confirm danger zone, audit, FK cascade, live WS close.
NS-02 enrollment-token recovery: outstanding-tokens panel on
/hosts/new, regenerate (preserves attachments) and revoke handlers
+ audit, store-level ListOutstandingEnrollmentTokens and
DeleteEnrollmentToken.
NS-03 repo init / probe surface: migration 0020 adds
hosts.repo_status + repo_status_error; WS handler projects every
init job's outcome onto the host row (idempotent already-initialised
collapses to ready); creds-save resets status and dispatches a fresh
probe; /hosts/{id}/repo/probe retry endpoint with banner.
NS-04 dashboard live + sort + filter: query-string filter
(q/status/repo_status/tag/sort/dir), 5s htmx live poll mirroring the
alerts pattern with a localStorage live toggle, sortable column
headers, filter row + clear.
Alerts page: ack'd-by line resolves user_id ULID to username.
Compose.yaml ignored — host-specific.
This commit is contained in:
@@ -22,6 +22,45 @@
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
{{if $page.OutstandingTokens}}
|
||||
<div class="mt-7 panel rounded-[7px] px-5 py-4">
|
||||
<div class="flex items-center justify-between mb-3">
|
||||
<h3 class="text-[12px] font-semibold uppercase tracking-[0.08em] text-ink-mute">Outstanding install tokens</h3>
|
||||
<span class="text-[11.5px] text-ink-fade">closed the install snippet tab? regenerate to get a fresh URL</span>
|
||||
</div>
|
||||
<table class="w-full text-[12.5px]">
|
||||
<thead class="text-[11px] uppercase tracking-[0.08em] text-ink-fade">
|
||||
<tr>
|
||||
<th class="text-left font-medium pb-2 pr-4">id</th>
|
||||
<th class="text-left font-medium pb-2 pr-4">repo</th>
|
||||
<th class="text-left font-medium pb-2 pr-4">created</th>
|
||||
<th class="text-left font-medium pb-2 pr-4">expires</th>
|
||||
<th class="pb-2"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range $page.OutstandingTokens}}
|
||||
<tr class="border-t border-line-soft">
|
||||
<td class="py-2.5 pr-4 mono text-ink-mute">{{.ShortHash}}…</td>
|
||||
<td class="py-2.5 pr-4 mono text-ink-mid">{{if .RepoURL}}{{.RepoURL}}{{else}}<span class="text-ink-fade">—</span>{{end}}</td>
|
||||
<td class="py-2.5 pr-4 text-ink-mute">{{.CreatedAt | relTime}}</td>
|
||||
<td class="py-2.5 pr-4 text-ink-mute">{{.ExpiresAt | relTime}}</td>
|
||||
<td class="py-2.5 text-right whitespace-nowrap">
|
||||
<form method="post" action="/hosts/enrollment-tokens/{{.TokenHash}}/regenerate" class="inline">
|
||||
<button type="submit" class="btn btn-sm">Regenerate</button>
|
||||
</form>
|
||||
<form method="post" action="/hosts/enrollment-tokens/{{.TokenHash}}/revoke" class="inline ml-1"
|
||||
onsubmit="return confirm('Revoke this enrolment token? Any pending install using it will fail.');">
|
||||
<button type="submit" class="btn btn-sm btn-danger">Revoke</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<form method="post" action="/hosts/new" class="grid grid-cols-12 gap-8 mt-7">
|
||||
|
||||
<div class="col-span-7 panel rounded-[7px] px-8 py-7">
|
||||
|
||||
@@ -141,7 +141,7 @@
|
||||
</div>
|
||||
{{else}}
|
||||
{{range $page.Alerts}}
|
||||
{{template "alert_row" (dict "Alert" . "HostNames" $page.HostNames "Filter" $page.Filter)}}
|
||||
{{template "alert_row" (dict "Alert" . "HostNames" $page.HostNames "Usernames" $page.Usernames "Filter" $page.Filter)}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
{{define "title"}}Welcome · restic-manager{{end}}
|
||||
|
||||
{{define "content"}}
|
||||
{{$page := .Page}}
|
||||
<div class="flex-1 flex flex-col items-center justify-center px-8 py-12">
|
||||
|
||||
<div class="w-[420px]">
|
||||
<div class="flex justify-center mb-10">
|
||||
<div class="mono text-base text-ink font-medium tracking-[0.01em]">restic-manager</div>
|
||||
</div>
|
||||
|
||||
<h1 class="text-[22px] font-medium tracking-[-0.005em] text-center">
|
||||
Create the first administrator
|
||||
</h1>
|
||||
<p class="text-pretty text-[13px] text-ink-mute mt-3 leading-[1.6] text-center">
|
||||
This server has no users yet. The account you create here is the
|
||||
initial administrator. This page is only available until that
|
||||
account exists.
|
||||
</p>
|
||||
|
||||
{{if $page.Error}}
|
||||
<div class="mt-5 px-3 py-2.5 rounded-[5px] text-xs"
|
||||
style="background: color-mix(in oklch, var(--bad), transparent 88%); border: 1px solid color-mix(in oklch, var(--bad), transparent 70%); color: oklch(0.85 0.10 25);">
|
||||
{{$page.Error}}
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<form method="post" action="/bootstrap" class="mt-7 space-y-4">
|
||||
<div>
|
||||
<label class="field-label" for="bs-username">Username</label>
|
||||
<input id="bs-username" name="username" type="text"
|
||||
class="field mono" autocomplete="username" autofocus required
|
||||
value="{{$page.Username}}" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="field-label" for="bs-pw">Password</label>
|
||||
<input id="bs-pw" name="password" type="password" class="field"
|
||||
required minlength="12" autocomplete="new-password" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="field-label" for="bs-pw2">Confirm password</label>
|
||||
<input id="bs-pw2" name="password_confirm" type="password" class="field"
|
||||
required minlength="12" autocomplete="new-password" />
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary btn-block btn-lg">
|
||||
Create administrator
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<div class="mt-6 pt-5 border-t border-line-soft text-center">
|
||||
<p class="text-pretty text-xs text-ink-mute leading-[1.65]">
|
||||
Lost the browser session mid-flow? The bootstrap token is also
|
||||
printed in the server logs and can be POSTed to
|
||||
<span class="mono text-ink-mid">/api/bootstrap</span>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-20 flex gap-3.5 items-center text-[11px] text-ink-fade">
|
||||
<span class="mono">restic-manager {{.Version}}</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{{end}}
|
||||
@@ -121,21 +121,63 @@
|
||||
{{end}}
|
||||
|
||||
{{/* ---------- hosts table ---------- */}}
|
||||
{{$f := $page.Filter}}
|
||||
{{$sortURL := $page.SortURL}}
|
||||
<div class="pt-6 pb-4">
|
||||
<div class="flex items-center justify-between mb-3">
|
||||
<div class="flex items-center gap-3">
|
||||
<h2 class="text-[13px] font-semibold tracking-[0.01em]">Hosts</h2>
|
||||
<div class="text-xs text-ink-fade">{{$page.ShownCount}} of {{$page.HostCount}}</div>
|
||||
</div>
|
||||
<label style="display: inline-flex; align-items: center; gap: 5px; cursor: pointer; font-size: 10px;"
|
||||
class="text-ink-fade" title="auto-refresh every 5s">
|
||||
<input type="checkbox" id="dashboard-live-toggle" checked
|
||||
onchange="localStorage.setItem('rm-dashboard-live', this.checked ? 'on' : 'off'); document.getElementById('dashboard-live-dot').style.opacity = this.checked ? '1' : '0.3';"
|
||||
style="width: 11px; height: 11px; cursor: pointer; margin: 0;" />
|
||||
<span>live</span>
|
||||
<span id="dashboard-live-dot" class="text-accent">●</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{{/* Filter row (NS-04): GET /, every input is a hidden field
|
||||
for the filters not currently being edited so submit
|
||||
merges rather than clobbers state. */}}
|
||||
<form method="get" action="/" class="flex items-center gap-2 mb-3 text-[11.5px] flex-wrap">
|
||||
<input type="text" name="q" value="{{$f.Search}}" placeholder="search hostname…"
|
||||
class="field mono"
|
||||
style="padding: 6px 10px; font-size: 11.5px; width: 220px;">
|
||||
<select name="status" class="field"
|
||||
style="padding: 5px 8px; font-size: 11.5px; width: auto;"
|
||||
onchange="this.form.submit()">
|
||||
<option value="" {{if eq $f.Status ""}}selected{{end}}>any status</option>
|
||||
<option value="online" {{if eq $f.Status "online"}}selected{{end}}>online</option>
|
||||
<option value="offline" {{if eq $f.Status "offline"}}selected{{end}}>offline</option>
|
||||
<option value="never_seen" {{if eq $f.Status "never_seen"}}selected{{end}}>never seen</option>
|
||||
</select>
|
||||
<select name="repo_status" class="field"
|
||||
style="padding: 5px 8px; font-size: 11.5px; width: auto;"
|
||||
onchange="this.form.submit()">
|
||||
<option value="" {{if eq $f.RepoStatus ""}}selected{{end}}>any repo state</option>
|
||||
<option value="ready" {{if eq $f.RepoStatus "ready"}}selected{{end}}>ready</option>
|
||||
<option value="init_failed" {{if eq $f.RepoStatus "init_failed"}}selected{{end}}>init failed</option>
|
||||
<option value="unknown" {{if eq $f.RepoStatus "unknown"}}selected{{end}}>unknown</option>
|
||||
</select>
|
||||
{{if $f.Tag}}<input type="hidden" name="tag" value="{{$f.Tag}}">{{end}}
|
||||
{{if ne $f.Sort "name"}}<input type="hidden" name="sort" value="{{$f.Sort}}">{{end}}
|
||||
{{if eq $f.Dir "desc"}}<input type="hidden" name="dir" value="desc">{{end}}
|
||||
<button type="submit" class="btn btn-sm">Apply</button>
|
||||
{{if or $f.Search $f.Status $f.RepoStatus}}
|
||||
<a href="/{{if $f.Tag}}?tag={{$f.Tag}}{{end}}" class="text-ink-fade text-[11.5px] mono ml-1">clear</a>
|
||||
{{end}}
|
||||
</form>
|
||||
|
||||
{{/* Tag chip-row — only renders when at least one tag exists in
|
||||
the fleet. Active tag is highlighted; clicking the active
|
||||
tag clears the filter. The "All" pill is shown in the active
|
||||
state when no tag filter is set. */}}
|
||||
{{if $page.KnownTags}}
|
||||
<div class="flex items-center gap-1.5 flex-wrap mb-3 text-[11.5px]">
|
||||
<span class="text-ink-fade mr-1">filter</span>
|
||||
<span class="text-ink-fade mr-1">tag</span>
|
||||
<a href="/" class="tag {{if eq $page.ActiveTag ""}}tag-active{{end}}">All</a>
|
||||
{{range $page.KnownTags}}
|
||||
{{$t := .}}
|
||||
@@ -144,15 +186,24 @@
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<div class="panel rounded-[7px] overflow-hidden">
|
||||
{{/* Live-poll wrapper (NS-04, mirrors the alerts pattern). hx-get
|
||||
refetches with the current filter pinned; hx-select grabs only
|
||||
this same div from the response so the surrounding chrome
|
||||
doesn't flash. The toggle persists in localStorage so a
|
||||
refreshed tab honours the operator's previous choice. */}}
|
||||
<div id="hosts-table" class="panel rounded-[7px] overflow-hidden"
|
||||
hx-get="{{$page.RefreshURL}}"
|
||||
hx-trigger="every 5s [document.visibilityState==='visible' && localStorage.getItem('rm-dashboard-live')!=='off']"
|
||||
hx-select="#hosts-table"
|
||||
hx-swap="outerHTML">
|
||||
|
||||
<div class="host-row head hairline">
|
||||
<div></div>
|
||||
<div>Host</div>
|
||||
<div>OS · arch</div>
|
||||
<div>Last backup</div>
|
||||
<div class="text-right">Repo size</div>
|
||||
<div class="text-right">Snapshots</div>
|
||||
<div><a href="{{index $sortURL "name"}}" class="text-ink-mid hover:text-ink">Host{{if eq $f.Sort "name"}} {{if eq $f.Dir "desc"}}↓{{else}}↑{{end}}{{end}}</a></div>
|
||||
<div><a href="{{index $sortURL "os"}}" class="text-ink-mid hover:text-ink">OS · arch{{if eq $f.Sort "os"}} {{if eq $f.Dir "desc"}}↓{{else}}↑{{end}}{{end}}</a></div>
|
||||
<div><a href="{{index $sortURL "last_backup"}}" class="text-ink-mid hover:text-ink">Last backup{{if eq $f.Sort "last_backup"}} {{if eq $f.Dir "desc"}}↓{{else}}↑{{end}}{{end}}</a></div>
|
||||
<div class="text-right"><a href="{{index $sortURL "repo_size"}}" class="text-ink-mid hover:text-ink">Repo size{{if eq $f.Sort "repo_size"}} {{if eq $f.Dir "desc"}}↓{{else}}↑{{end}}{{end}}</a></div>
|
||||
<div class="text-right"><a href="{{index $sortURL "snapshot_count"}}" class="text-ink-mid hover:text-ink">Snapshots{{if eq $f.Sort "snapshot_count"}} {{if eq $f.Dir "desc"}}↓{{else}}↑{{end}}{{end}}</a></div>
|
||||
<div>Alerts</div>
|
||||
<div>Tags</div>
|
||||
<div></div>
|
||||
|
||||
@@ -110,10 +110,21 @@
|
||||
<div class="panel rounded-[7px] px-4 py-3.5">
|
||||
<div class="text-[11px] text-bad uppercase tracking-[0.1em] font-semibold mb-2.5">Danger zone</div>
|
||||
<p class="text-pretty text-[12px] text-ink-mute leading-[1.55] mb-3">
|
||||
Removes the host record. The repo data on the rest-server is left intact —
|
||||
you delete that yourself.
|
||||
Removes the host record and everything attached to it
|
||||
(schedules, source groups, jobs, snapshots metadata, alerts).
|
||||
The agent's bearer is revoked, so a re-installed instance
|
||||
comes back through the normal pending-host accept flow.
|
||||
The repo data on the rest-server is left intact — you delete
|
||||
that yourself.
|
||||
</p>
|
||||
<button class="btn btn-danger w-full justify-center" disabled title="lands later in Phase 1">Remove host…</button>
|
||||
<form method="post" action="/hosts/{{$host.ID}}/delete"
|
||||
class="space-y-2"
|
||||
onsubmit="return confirm('Remove host "{{$host.Name}}"? This cascades to every dependent row and cannot be undone.');">
|
||||
<input type="text" name="confirm_hostname" required autocomplete="off"
|
||||
placeholder="type hostname to confirm"
|
||||
class="field mono text-[12px]" />
|
||||
<button type="submit" class="btn btn-danger w-full justify-center">Remove host…</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</aside>
|
||||
|
||||
@@ -8,6 +8,31 @@
|
||||
|
||||
<div class="col-span-8">
|
||||
|
||||
{{/* ---------- Repo status (NS-03) ---------- */}}
|
||||
{{if eq $host.RepoStatus "init_failed"}}
|
||||
<div class="rounded-[7px] px-4 py-3.5 mb-5"
|
||||
style="border: 1px solid color-mix(in oklch, var(--bad), transparent 55%); background: color-mix(in oklch, var(--bad), transparent 90%);">
|
||||
<div class="flex items-center justify-between gap-3 mb-1.5">
|
||||
<div class="text-[12.5px] font-semibold text-bad uppercase tracking-[0.08em]">Repo unreachable</div>
|
||||
<form method="post" action="/hosts/{{$host.ID}}/repo/probe">
|
||||
<button type="submit" class="btn btn-sm"
|
||||
{{if $page.Online}}{{else}}disabled title="host is offline"{{end}}>Retry probe</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="text-[12.5px] text-ink-mid leading-[1.55]">
|
||||
The last init / probe against this host's repo failed. Fix the
|
||||
credentials below and save (the save kicks a fresh probe), or
|
||||
click <span class="mono">Retry probe</span> if you've changed
|
||||
something out-of-band.
|
||||
</div>
|
||||
{{if $host.RepoStatusError}}
|
||||
<pre class="mono text-[11.5px] text-ink-mid mt-2.5 whitespace-pre-wrap leading-[1.5]">{{$host.RepoStatusError}}</pre>
|
||||
{{end}}
|
||||
</div>
|
||||
{{else if eq $host.RepoStatus "ready"}}
|
||||
<div class="text-[12px] text-ok mono mb-5">✓ repo reachable with current credentials</div>
|
||||
{{end}}
|
||||
|
||||
{{/* ---------- Connection ---------- */}}
|
||||
<h2 class="text-[11.5px] font-semibold uppercase tracking-[0.08em] text-ink-mute mb-3.5">Connection</h2>
|
||||
<form method="post" action="/hosts/{{$host.ID}}/repo/credentials" class="panel rounded-[7px] p-5">
|
||||
@@ -269,7 +294,7 @@
|
||||
onsubmit="return confirm('Re-initialise the repo on host "{{$host.Name}}"? Existing snapshots are lost if the rest-server allows the wipe; restic refuses if it sees a config file already there.');">
|
||||
<input type="text" name="confirm_hostname" required autocomplete="off"
|
||||
placeholder="type hostname to confirm"
|
||||
class="input mono"
|
||||
class="field mono"
|
||||
style="width: 240px; height: 30px; padding: 0 8px; font-size: 12px;">
|
||||
<button type="submit" class="btn btn-danger btn-lg whitespace-nowrap"
|
||||
{{if eq $host.Status "online"}}{{else}}disabled title="host is offline"{{end}}>Re-init repo…</button>
|
||||
|
||||
@@ -175,12 +175,11 @@
|
||||
<input type="text" name="target_dir" id="target-dir-input"
|
||||
class="field mono text-[12px] flex-1"
|
||||
value="{{if $page.FormTargetDir}}{{$page.FormTargetDir}}{{else}}{{$page.DefaultTargetDir}}{{end}}"
|
||||
placeholder="$HOME/rm-restore/<job-id>/" />
|
||||
placeholder="/root/rm-restore/<job-id>/" />
|
||||
</div>
|
||||
<div class="text-[11.5px] text-ink-fade mt-1.5">
|
||||
<span class="mono">$HOME</span> resolves to the agent user's home;
|
||||
<span class="mono"><job-id></span> is substituted on dispatch.
|
||||
Edit if you want a specific directory.
|
||||
Edit if you want a specific directory
|
||||
(<span class="mono"><job-id></span> is substituted).
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{{define "alert_row"}}
|
||||
{{$a := .Alert}}
|
||||
{{$hostNames := .HostNames}}
|
||||
{{$usernames := .Usernames}}
|
||||
{{$filter := .Filter}}
|
||||
{{$status := alertStatus $a.ResolvedAt $a.AcknowledgedAt}}
|
||||
|
||||
@@ -81,7 +82,12 @@
|
||||
</form>
|
||||
{{else if eq $status "acknowledged"}}
|
||||
<span class="text-ink-fade" style="font-size: 11px;">
|
||||
ack'd{{if $a.AcknowledgedBy}} by {{deref $a.AcknowledgedBy}}{{end}} · {{relTime $a.AcknowledgedAt}}
|
||||
{{$ackedBy := ""}}
|
||||
{{if $a.AcknowledgedBy}}
|
||||
{{$id := deref $a.AcknowledgedBy}}
|
||||
{{if index $usernames $id}}{{$ackedBy = index $usernames $id}}{{else}}{{$ackedBy = $id}}{{end}}
|
||||
{{end}}
|
||||
ack'd{{if $ackedBy}} by {{$ackedBy}}{{end}} · {{relTime $a.AcknowledgedAt}}
|
||||
</span>
|
||||
<form method="post" action="/alerts/{{$a.ID}}/resolve">
|
||||
{{if $qs}}<input type="hidden" name="qs" value="{{$qs}}">{{end}}
|
||||
|
||||
Reference in New Issue
Block a user