chore(ui): add module file and main stub

- chore(ui): add module file and main stub
- feat(ui): add layout, pages and partials
- feat(ui): add stylesheet and scripts
- feat(ui): add page renderer and static file handler
- test(ui): cover rendering, escaping and static serving
This commit is contained in:
bryanpedini committed 2026-11-19 15:46:12 +01:00
1 parent 7089a6f408
commit 5ac8f98f10
26 files changed
+3921

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
{{- /* SPDX-License-Identifier: GPL-2.0-or-later */ -}}
{{- /* Copyright (C) 2026 Bryan Joshua Pedini */ -}}
{{define "title"}}Account{{end}}
{{define "content"}}<div class="page-head">
<h1>Account</h1>
</div>
<section class="card" aria-labelledby="account-title">
<h2 id="account-title">Profile</h2>
<dl class="dl">
<dt>Username</dt><dd id="account-username">{{.Username}}</dd>
<dt>Role</dt><dd id="account-role">{{.Role}}</dd>
</dl>
</section>
{{if not .IsAdmin}}
<section class="card" aria-labelledby="account-zones-title">
<h2 id="account-zones-title">Delegated zones</h2>
<ul class="list" id="account-zones"></ul>
<p class="muted" id="account-zones-status" role="status">Loading...</p>
</section>
{{end}}
<section class="card" aria-labelledby="password-title">
<h2 id="password-title">Change password</h2>
<form class="form" id="password-form" novalidate>
<div class="field">
<label for="pw-current">Current password</label>
<input id="pw-current" name="current" type="password" autocomplete="current-password" maxlength="256">
</div>
<div class="field">
<label for="pw-new">New password</label>
<input id="pw-new" name="password" type="password" autocomplete="new-password" maxlength="256">
<p class="hint">12 to 256 characters.</p>
</div>
<div class="field">
<label for="pw-repeat">Repeat the new password</label>
<input id="pw-repeat" name="repeat" type="password" autocomplete="new-password" maxlength="256">
</div>
<div class="actions">
<button type="submit" class="btn btn-primary">Change password</button>
</div>
</form>
</section>
{{end}}
+66
View File
@@ -0,0 +1,66 @@
{{- /* SPDX-License-Identifier: GPL-2.0-or-later */ -}}
{{- /* Copyright (C) 2026 Bryan Joshua Pedini */ -}}
{{define "title"}}Audit{{end}}
{{define "content"}}<div class="page-head">
<h1>Audit</h1>
</div>
<section class="card" aria-labelledby="audit-filter-title">
<h2 id="audit-filter-title" class="visually-hidden">Filters</h2>
<form class="filters" id="audit-filters" novalidate>
<div class="field">
<label for="af-zone">Zone</label>
<input id="af-zone" name="zone" type="text" autocomplete="off" autocapitalize="none" spellcheck="false">
</div>
<div class="field">
<label for="af-actor">Actor</label>
<input id="af-actor" name="actor" type="text" autocomplete="off" autocapitalize="none" spellcheck="false">
</div>
<div class="field">
<label for="af-operation">Operation</label>
<select id="af-operation" name="operation">
<option value="">Any operation</option>
<option>account_read</option><option>login</option><option>logout</option><option>password_change</option>
<option>zone_list</option><option>zone_read</option><option>zone_create</option><option>zone_delete</option>
<option>record_list</option><option>record_create</option><option>record_update</option><option>record_delete</option><option>record_bulk_delete</option><option>soa_update</option>
<option>zone_check</option><option>check_all</option>
<option>zone_export</option><option>zone_import_preview</option><option>zone_import</option>
<option>delegation_list</option><option>delegation_grant</option><option>delegation_revoke</option>
<option>user_list</option><option>user_read</option><option>user_create</option><option>user_role</option><option>user_password</option><option>user_delete</option>
<option>audit_read</option>
</select>
</div>
<div class="field">
<label for="af-kind">Kind</label>
<select id="af-kind" name="kind">
<option value="">Reads and changes</option>
<option value="read">Reads</option>
<option value="change">Changes</option>
</select>
</div>
<div class="field">
<label for="af-outcome">Outcome</label>
<select id="af-outcome" name="outcome">
<option value="">Any outcome</option>
<option value="success">Success</option>
<option value="error">Error</option>
</select>
</div>
<div class="actions">
<button type="submit" class="btn btn-primary">Apply filters</button>
<button type="reset" class="btn" id="af-reset">Reset</button>
</div>
</form>
</section>
<div class="table-wrap">
<table class="table" id="audit-table">
<thead>
<tr><th scope="col">Time (UTC)</th><th scope="col">Actor</th><th scope="col">Origin</th><th scope="col">Operation</th><th scope="col">Status</th><th scope="col">Target</th><th scope="col">Details</th></tr>
</thead>
<tbody id="audit-body"></tbody>
</table>
</div>
<p class="muted" id="audit-status" role="status">Loading...</p>
<div class="actions">
<button type="button" class="btn" id="audit-more" hidden>Load older rows</button>
</div>
{{end}}
+8
View File
@@ -0,0 +1,8 @@
{{- /* SPDX-License-Identifier: GPL-2.0-or-later */ -}}
{{- /* Copyright (C) 2026 Bryan Joshua Pedini */ -}}
{{define "title"}}Forbidden{{end}}
{{define "content"}}<section class="card narrow">
<h1>Forbidden</h1>
<p>Your account is not allowed to open this page.</p>
<p><a href="/">Back to the zones</a></p>
</section>{{end}}
+39
View File
@@ -0,0 +1,39 @@
{{- /* SPDX-License-Identifier: GPL-2.0-or-later */ -}}
{{- /* Copyright (C) 2026 Bryan Joshua Pedini */ -}}
{{define "title"}}Import {{.Zone}}{{end}}
{{define "content"}}<p class="crumbs"><a href="/">Zones</a> / <a id="zone-link" href="/">{{.Zone}}</a></p>
<div class="page-head">
<h1>Import into {{.Zone}}</h1>
</div>
<section class="card" aria-labelledby="import-source-title">
<h2 id="import-source-title">Zone file</h2>
<form class="form" id="import-form" novalidate>
<fieldset class="field">
<legend>Mode</legend>
<label class="choice"><input type="radio" name="mode" value="merge" checked> Merge: add missing records and update TTLs</label>
<label class="choice"><input type="radio" name="mode" value="replace"> Replace: also delete records that are not in the file</label>
</fieldset>
<div class="field">
<label for="import-file">Load a file</label>
<input id="import-file" type="file" accept=".zone,.txt,text/plain">
</div>
<div class="field">
<label for="import-content">Zone file contents</label>
<textarea id="import-content" name="content" rows="14" class="mono" spellcheck="false" autocomplete="off" autocapitalize="none"></textarea>
</div>
<div class="actions">
<button type="submit" class="btn btn-primary" id="import-preview">Preview</button>
</div>
</form>
</section>
<section class="card" id="import-result" aria-labelledby="import-result-title" hidden>
<h2 id="import-result-title">Preview</h2>
<div id="import-errors" hidden></div>
<div id="import-summary"></div>
<div id="import-tables"></div>
<div class="actions">
<button type="button" class="btn btn-primary" id="import-apply" hidden>Apply import</button>
</div>
</section>
{{end}}
+25
View File
@@ -0,0 +1,25 @@
{{- /* SPDX-License-Identifier: GPL-2.0-or-later */ -}}
{{- /* Copyright (C) 2026 Bryan Joshua Pedini */ -}}
{{define "title"}}Sign in{{end}}
{{define "content"}}<section class="card narrow">
<h1>Sign in</h1>
{{if .Error}}<p class="alert alert-error" role="alert">{{.Error}}</p>
{{end}}{{if .NoActiveAdmin}}<div class="alert alert-info">
<p>No administrator exists yet. Create the first one by running this command on the host that runs the container:</p>
<pre class="code"><code>{{.BootstrapCommand}}</code></pre>
</div>
{{end}}<form class="form" method="post" action="/login">
<div class="field">
<label for="login-username">Username</label>
<input id="login-username" name="username" type="text" autocomplete="username" autocapitalize="none" spellcheck="false" maxlength="64" required autofocus>
</div>
<div class="field">
<label for="login-password">Password</label>
<input id="login-password" name="password" type="password" autocomplete="current-password" maxlength="256" required>
</div>
<input type="hidden" name="next" value="{{.Next}}">
<div class="actions">
<button type="submit" class="btn btn-primary">Sign in</button>
</div>
</form>
</section>{{end}}
+8
View File
@@ -0,0 +1,8 @@
{{- /* SPDX-License-Identifier: GPL-2.0-or-later */ -}}
{{- /* Copyright (C) 2026 Bryan Joshua Pedini */ -}}
{{define "title"}}Not found{{end}}
{{define "content"}}<section class="card narrow">
<h1>Not found</h1>
<p>The page you asked for does not exist.</p>
<p><a href="/">Back to the zones</a></p>
</section>{{end}}
+82
View File
@@ -0,0 +1,82 @@
{{- /* SPDX-License-Identifier: GPL-2.0-or-later */ -}}
{{- /* Copyright (C) 2026 Bryan Joshua Pedini */ -}}
{{define "title"}}User {{.TargetUser}}{{end}}
{{define "content"}}<p class="crumbs"><a href="/users">Users</a></p>
<div class="page-head">
<h1 id="user-title">{{.TargetUser}}</h1>
<span class="badge badge-muted" id="user-state" hidden></span>
</div>
<section class="card" aria-labelledby="user-info-title">
<h2 id="user-info-title">Details</h2>
<dl class="dl" id="user-summary"></dl>
<p class="muted" id="user-status" role="status">Loading...</p>
</section>
{{if eq .Username .TargetUser}}
<section class="card" id="user-self">
<p>This is your own account. Role, password and deletion are not available here. <a href="/account">Open your account page</a> to change your password.</p>
</section>
{{else}}
<div id="user-controls" hidden>
<section class="card" aria-labelledby="user-role-title">
<h2 id="user-role-title">Role</h2>
<form class="inline-form" id="role-form" novalidate>
<div class="field">
<label for="user-role">Role</label>
<select id="user-role" name="role">
<option value="user">user</option>
<option value="admin">admin</option>
</select>
</div>
<button type="submit" class="btn btn-small">Save role</button>
</form>
</section>
<section class="card" aria-labelledby="user-password-title">
<h2 id="user-password-title">Password</h2>
<p class="muted">Setting a password ends every session of this user.</p>
<form class="form" id="password-form" novalidate>
<div class="field">
<label for="up-password">New password</label>
<input id="up-password" name="password" type="password" autocomplete="new-password" maxlength="256">
<p class="hint">12 to 256 characters.</p>
</div>
<div class="field">
<label for="up-repeat">Repeat the new password</label>
<input id="up-repeat" name="repeat" type="password" autocomplete="new-password" maxlength="256">
</div>
<div class="actions">
<button type="submit" class="btn btn-small">Set password</button>
</div>
</form>
</section>
<section class="card" aria-labelledby="user-zones-title">
<h2 id="user-zones-title">Delegated zones</h2>
<ul class="list" id="user-zones"></ul>
<p class="muted" id="user-zones-status" role="status"></p>
<form class="inline-form" id="zone-add-form" novalidate>
<div class="field">
<label for="user-zone-pick">Delegate a zone</label>
<select id="user-zone-pick" name="zone"></select>
</div>
<button type="submit" class="btn btn-small">Add zone</button>
</form>
</section>
<section class="card danger-zone" aria-labelledby="user-danger-title">
<h2 id="user-danger-title">Danger zone</h2>
<p>Deleting the user ends their sessions and prevents them from signing in. The username stays taken and the history of the user stays in the audit.</p>
<form class="inline-form" id="user-delete-form" novalidate>
<div class="field">
<label for="user-delete-confirm">Type the username to confirm</label>
<input id="user-delete-confirm" name="confirm" type="text" autocomplete="off" autocapitalize="none" spellcheck="false">
</div>
<button type="submit" class="btn btn-danger" id="user-delete" disabled>Delete user</button>
</form>
</section>
</div>
<section class="card" id="user-readonly" hidden>
<h2>Delegated zones</h2>
<ul class="list" id="user-zones-readonly"></ul>
</section>
{{end}}{{end}}
+56
View File
@@ -0,0 +1,56 @@
{{- /* SPDX-License-Identifier: GPL-2.0-or-later */ -}}
{{- /* Copyright (C) 2026 Bryan Joshua Pedini */ -}}
{{define "title"}}Users{{end}}
{{define "content"}}<div class="page-head">
<h1>Users</h1>
<button type="button" class="btn btn-primary" id="new-user">New user</button>
</div>
<div class="toolbar">
<label class="choice" for="show-deleted"><input type="checkbox" id="show-deleted"> Show deleted users</label>
</div>
<div class="table-wrap">
<table class="table" id="users-table">
<thead>
<tr><th scope="col">Username</th><th scope="col">Role</th><th scope="col" class="num">Zones</th><th scope="col">Created (UTC)</th><th scope="col">Last login (UTC)</th><th scope="col">State</th></tr>
</thead>
<tbody id="users-body"></tbody>
</table>
</div>
<p class="muted" id="users-status" role="status">Loading users...</p>
<dialog id="user-dialog" class="dialog" aria-labelledby="user-dialog-title">
<form id="user-form" class="form" novalidate>
<div class="dialog-head">
<h2 id="user-dialog-title">New user</h2>
<button type="button" class="btn btn-icon" data-close aria-label="Close">&times;</button>
</div>
<div class="dialog-body">
<div class="field">
<label for="nu-username">Username</label>
<input id="nu-username" name="username" type="text" autocomplete="off" autocapitalize="none" spellcheck="false" maxlength="64" required>
<p class="hint">Lowercase letters, digits, dot, underscore and hyphen. A username can never be reused.</p>
</div>
<div class="field">
<label for="nu-role">Role</label>
<select id="nu-role" name="role">
<option value="user">user</option>
<option value="admin">admin</option>
</select>
</div>
<div class="field">
<label for="nu-password">Password</label>
<input id="nu-password" name="password" type="password" autocomplete="new-password" maxlength="256" required>
<p class="hint">12 to 256 characters.</p>
</div>
<div class="field">
<label for="nu-repeat">Repeat the password</label>
<input id="nu-repeat" name="repeat" type="password" autocomplete="new-password" maxlength="256" required>
</div>
</div>
<div class="dialog-actions">
<button type="button" class="btn" data-close>Cancel</button>
<button type="submit" class="btn btn-primary">Create user</button>
</div>
</form>
</dialog>
{{end}}
+94
View File
@@ -0,0 +1,94 @@
{{- /* SPDX-License-Identifier: GPL-2.0-or-later */ -}}
{{- /* Copyright (C) 2026 Bryan Joshua Pedini */ -}}
{{define "title"}}{{.Zone}}{{end}}
{{define "content"}}<p class="crumbs"><a href="/">Zones</a></p>
<div class="page-head">
<h1 id="zone-title">{{.Zone}}</h1>
<div class="actions">
<a class="btn" id="export-link" href="/">Export zone file</a>
<a class="btn" id="import-link" href="/">Import zone file</a>
</div>
</div>
<section class="card" aria-labelledby="soa-title">
<div class="section-head">
<h2 id="soa-title">SOA</h2>
<div class="actions">
<button type="button" class="btn btn-small" id="soa-managed" hidden>Use managed serial</button>
<button type="button" class="btn btn-small" id="soa-edit" disabled>Edit SOA</button>
</div>
</div>
<dl class="dl" id="soa-summary"></dl>
<p class="muted" id="soa-status" role="status">Loading...</p>
</section>
<section class="card" id="problems-panel" aria-labelledby="problems-title" hidden>
<h2 id="problems-title">Problems</h2>
<ul class="problems" id="problems-list"></ul>
</section>
<section class="card" aria-labelledby="records-title">
<div class="section-head">
<h2 id="records-title">Records</h2>
<div class="actions">
<button type="button" class="btn btn-danger btn-small" id="bulk-delete" disabled>Delete selected</button>
<button type="button" class="btn btn-primary btn-small" id="record-add">Add record</button>
</div>
</div>
<div class="toolbar">
<div class="field">
<label for="filter-type">Type</label>
<select id="filter-type"><option value="">All types</option></select>
</div>
<div class="field grow">
<label for="filter-text">Search records</label>
<input id="filter-text" type="search" autocomplete="off" spellcheck="false">
</div>
</div>
<div class="table-wrap">
<table class="table" id="records-table">
<thead>
<tr>
<th scope="col" class="check"><input type="checkbox" id="select-all" aria-label="Select all records on this page"></th>
<th scope="col">Name</th><th scope="col">Type</th><th scope="col">TTL</th><th scope="col">Value</th><th scope="col">Actions</th>
</tr>
</thead>
<tbody id="records-body"></tbody>
</table>
</div>
<p class="muted" id="records-status" role="status">Loading records...</p>
<div class="pager" id="pager" hidden>
<button type="button" class="btn btn-small" id="page-prev">Previous</button>
<span id="page-info"></span>
<button type="button" class="btn btn-small" id="page-next">Next</button>
</div>
</section>
{{if .IsAdmin}}
<section class="card" id="users-panel" aria-labelledby="users-title">
<h2 id="users-title">Users</h2>
<p class="muted">Users who can see and change this zone. Administrators always can.</p>
<ul class="list" id="zone-users"></ul>
<p class="muted" id="zone-users-status" role="status">Loading...</p>
<form class="inline-form" id="zone-user-form" novalidate>
<div class="field">
<label for="zone-user-pick">Delegate this zone to</label>
<select id="zone-user-pick" name="username"></select>
</div>
<button type="submit" class="btn btn-small" id="zone-user-add">Add user</button>
</form>
</section>
<section class="card danger-zone" id="danger" aria-labelledby="danger-title">
<h2 id="danger-title">Danger zone</h2>
<p>Deleting the zone removes every record and every delegation of this zone. This cannot be undone.</p>
<form class="inline-form" id="zone-delete-form" novalidate>
<div class="field">
<label for="zone-delete-confirm">Type the zone name to confirm</label>
<input id="zone-delete-confirm" name="confirm" type="text" autocomplete="off" autocapitalize="none" spellcheck="false">
</div>
<button type="submit" class="btn btn-danger" id="zone-delete" disabled>Delete zone</button>
</form>
</section>
{{end}}
{{template "soa_dialog" .}}
{{template "record_dialog" .}}{{end}}
+23
View File
@@ -0,0 +1,23 @@
{{- /* SPDX-License-Identifier: GPL-2.0-or-later */ -}}
{{- /* Copyright (C) 2026 Bryan Joshua Pedini */ -}}
{{define "title"}}Zones{{end}}
{{define "content"}}<div class="page-head">
<h1>Zones</h1>
{{if .IsAdmin}}<button type="button" class="btn btn-primary" id="new-zone">New zone</button>
{{end}}</div>
<div class="toolbar">
<div class="field">
<label for="zone-search">Search zones</label>
<input id="zone-search" type="search" autocomplete="off" spellcheck="false">
</div>
</div>
<div class="table-wrap">
<table class="table" id="zones-table">
<thead>
<tr><th scope="col">Zone</th><th scope="col" class="num">Records</th><th scope="col">SOA serial</th><th scope="col">Problems</th></tr>
</thead>
<tbody id="zones-body"></tbody>
</table>
</div>
<p class="muted" id="zones-status" role="status">Loading zones...</p>
{{if .IsAdmin}}{{template "zone_create_dialog" .}}{{end}}{{end}}