Add in-app edit UI for dashboard config

A web editor at /edit for managing pages and widgets without hand-editing YAML:

- Page list and per-page widget views with breadcrumb navigation
- Add/delete pages, add/delete/reorder widgets within a column
- Per-widget textarea editor with curated starter templates, widget-specific
  help (example, full field reference, link to upstream docs), and inline
  error rendering that preserves the user's edits on validation failure
- Pre-save validation via newConfigFromYAML; atomic temp+rename writes with
  .bak backup; YAML edits go through yaml.Node so comments and unresolved
  ${env:X}/${secret:X} tokens survive round-trips
- Auth gate: editing requires auth.users to be configured, or
  admin.allow-without-auth: true as an explicit opt-in for trusted networks
- Pencil button on the dashboard near the theme picker for quick access
- Admin views read fresh from disk so the list updates immediately after
  saves rather than lagging the fsnotify watcher

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
uhlwoogi
2026-04-30 14:12:18 +00:00
co-authored by Claude Opus 4.7
parent 6c5b7a3f4c
commit 2e198a19b4
12 changed files with 1468 additions and 107 deletions
+40
View File
@@ -0,0 +1,40 @@
{{- template "document.html" . }}
{{- define "document-title" }}Edit - {{ .App.Config.Branding.AppName }}{{ end }}
{{- define "document-body" }}
<div class="flex flex-column body-content">
<main class="content-bounds" style="padding-block: 2rem;">
<h1 class="size-h1 margin-bottom-15">Edit</h1>
<p class="color-subdue margin-bottom-25">
Editing <code>{{ .App.ConfigPath }}</code>. Changes take effect via hot-reload.
</p>
<h2 class="size-h2 margin-bottom-10">Pages</h2>
<ul class="list list-gap-10 margin-bottom-25">
{{- range .Pages }}
<li class="flex items-center gap-10">
<div class="grow">
<a class="color-primary" href="{{ $.App.Config.Server.BaseURL }}/edit/pages/{{ .Slug }}">
{{ .Title }}
</a>
<span class="color-subdue"> — {{ .WidgetCount }} widget{{ if ne .WidgetCount 1 }}s{{ end }}</span>
<div class="color-subdue size-h5">/{{ .Slug }}</div>
</div>
<form method="post" action="{{ $.App.Config.Server.BaseURL }}/edit/api/pages/{{ .Slug }}/delete"
onsubmit="return confirm('Delete page &quot;{{ .Title }}&quot; and all its widgets?');">
<button type="submit" class="color-negative">Delete</button>
</form>
</li>
{{- end }}
</ul>
<h3 class="size-h3 margin-bottom-10">Add a page</h3>
<form method="post" action="{{ .App.Config.Server.BaseURL }}/edit/api/pages" class="flex gap-10 items-center">
<input type="text" name="title" required placeholder="Page title" class="input grow">
<button type="submit">Add page</button>
</form>
</main>
{{ template "footer.html" . }}
</div>
{{- end }}