The cluster's settings edited on the portal, by administrators

/admin/settings edits the document llmgw ctl config edit opens: checked as a
control plane would load it, refused when made from a version since replaced
(the edit kept), its history viewed and rolled back as a new version, every
change audited by size and never by contents, since it can hold webhook
secrets. Administrators only; in English and Turkish.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-08 17:23:13 +02:00
1 parent 6bc6a67fb0
commit 659f20dc9a
17 files changed
+494 -13

No files matched your search

+6 -1
View File
@@ -813,8 +813,13 @@ Labels, fabrics, engines, heartbeat and supervisor settings move to the
store per node and reach the agent over its stream; a change to the file is
noticed and the agent restarts itself.
### E4. Web settings page (S)
### E4. Web settings page (S) — done 2026-10-08 (branch `settings-e`)
The same document, edited on /admin/settings, for whoever has no terminal.
Built: administrators only (staff roles get 404: webhook secrets), checked by
the same function as PUT /api/v1/settings, made from a base version or
refused on a newer one (the edit kept in the editor), history with view and
roll back as a new version, audit with the size not the body, English and
Turkish, a Settings link in the menu.
---
+10
View File
@@ -24,6 +24,16 @@ is only released once its **exit criterion** is met, not when its code lands.
Until v1.0.0 the minor version is the breaking one: configuration formats and Go
APIs change between minors without a deprecation period.
## Unreleased
### Added
- **The cluster's settings on the portal** (BACKLOG E4): `/admin/settings`
for administrators. It edits the document `llmgw ctl config edit` opens:
checked as a control plane would load it, refused when made from a
version since replaced, with the history to view and roll back. Changes
are audited by size, never by contents.
## v0.14.0 — 2026-10-08
Knowledge bases: a company's documents, put in by people from their own
+8 -2
View File
@@ -258,8 +258,14 @@ llmgw ctl config history # who changed what, when, and why
llmgw ctl config rollback 4 # back to version 4, as a new version
```
or on the console's **Settings** screen. A change is checked before it is
kept — one that would not load is refused — and recorded in the audit log.
or on the console's **Settings** screen, or in a browser on the portal's
**Settings** page (`/admin/settings`, for administrators only: the document
can hold webhook secrets). The page edits the same document, lists its
history, and puts an earlier version back. A change is checked before it is
kept, so one that would not load is refused. A change made from a version
someone else has replaced since is refused too, rather than overwriting
theirs. Every change is recorded in the audit log, with the document's size
but not its contents.
Guardrails change live; anything else has every control plane start again on
the new settings, the standbys first and the leader half a minute later, so
one of them is always serving. Engines keep running through it.
+2
View File
@@ -382,6 +382,8 @@ func newServerCmd() *cobra.Command {
// machine's own keys before it is kept.
api.SetSettings(&adminapi.Settings{Store: st, LocalKeys: config.LocalKeys(),
Check: func(body []byte) error { return checkClusterSettings(configPath, body) }})
// And the same document on the portal, for administrators.
rt.SetSettingsCheck(func(body []byte) error { return checkClusterSettings(configPath, body) }, config.LocalKeys())
}
// Catalog changes need somewhere to persist, so this is wired
// only when there is a store. Without one, the endpoints say so
+3
View File
@@ -247,6 +247,9 @@ func (r *Router) Handler() http.Handler {
if r.store != nil && r.guardLibrary != nil {
pages.RegisterAdminGuard(mux, r.store, r.guardLibrary)
}
if r.store != nil && r.settingsCheck != nil {
pages.RegisterAdminSettings(mux, r.store, r.settingsCheck, r.settingsLocal)
}
pages.Register(mux)
// The docs portal, with the menu of whoever is signed in, and only to
// them when the site asked for that.
+11
View File
@@ -177,6 +177,10 @@ type Router struct {
// collections for kbDefaultTTL.
kbDefMu sync.Mutex
kbDefCache map[string]kbDefaultEntry
// settingsCheck and settingsLocal mount the portal's settings page.
settingsCheck func([]byte) error
settingsLocal []string
}
// SetClusterView gives the router the data the /admin page renders.
@@ -200,6 +204,13 @@ func (r *Router) SetGuard(g guard.Guard) { r.guard = g }
// SetGuardLibrary is the policies the guard was built from, for the pages.
func (r *Router) SetGuardLibrary(c func() guard.Config) { r.guardLibrary = c }
// SetSettingsCheck enables the portal's settings page: check says whether a
// document would load as the cluster's settings beside this machine's own
// server.yaml, and local are the keys that file keeps.
func (r *Router) SetSettingsCheck(check func([]byte) error, local []string) {
r.settingsCheck, r.settingsLocal = check, local
}
// SetStopped refuses, or again serves, every request for a model.
func (r *Router) SetStopped(stopped bool) { r.stopped.Store(stopped) }
+3 -1
View File
@@ -90,7 +90,9 @@ type AccountPages struct {
audit audit.Sink
// hasGuard is set when /admin/guard is registered, and guardLibrary
// with it: the policies in force, whose judges the mirror page serves.
hasGuard bool
hasGuard bool
// hasSettings is set when /admin/settings is registered.
hasSettings bool
guardLibrary func() guard.Config
// guardFor names the guardrail policies in force for someone, and
// whether they keep nothing; nil when there are none.
+174
View File
@@ -0,0 +1,174 @@
package web
import (
"context"
"errors"
"net/http"
"strconv"
"strings"
"gitea.mynodes.xyz/ilker/llmgw/internal/store"
)
// The cluster's settings, edited in the browser (BACKLOG E4): the document
// `llmgw ctl config edit` opens, for whoever has no terminal on a control
// plane. The same rules hold here as there — a version is checked as a
// control plane would load it before it is kept, it is made from the newest
// version or refused, and every change is in force on every control plane
// within seconds and in the audit log.
// SettingsAdmin is where the cluster's settings are kept.
type SettingsAdmin interface {
ClusterSettings(ctx context.Context) (store.SettingsVersion, error)
ClusterSettingsAt(ctx context.Context, version int64) (store.SettingsVersion, error)
ClusterSettingsHistory(ctx context.Context, limit int) ([]store.SettingsVersion, error)
PutClusterSettings(ctx context.Context, base int64, body, by, note string) (int64, error)
}
type settingsPageData struct {
Nav Nav
Version string
CSRF string
// Current is the version in force; Shown the one in the editor, which
// is an earlier one when ?version= asked for it.
Current, Shown store.SettingsVersion
Earlier bool
// Body is what the editor holds: the version shown, or what was sent
// and refused, so a refusal does not lose the edit.
Body string
Note string
History []settingsRow
LocalKeys []string
Notice string
Error string
}
type settingsRow struct {
Version int64
At, By string
Note string
InForce bool
Selected bool
}
// RegisterAdminSettings mounts /admin/settings, for administrators only:
// the settings hold webhook addresses and the like, so even reading them is
// not every staff role's.
func (p *AccountPages) RegisterAdminSettings(mux *http.ServeMux, s SettingsAdmin, check func([]byte) error, localKeys []string) {
p.hasSettings = true
page := func(w http.ResponseWriter, r *http.Request, admin store.User, d settingsPageData) {
ctx, l := r.Context(), langOf(r)
d.Nav, d.Version, d.CSRF, d.LocalKeys = p.navFor(r, admin, "settings"), p.version, csrfFor(r), localKeys
cur, err := s.ClusterSettings(ctx)
if err != nil {
d.Error = l.Err(err)
}
d.Current = cur
if d.Shown.Version == 0 {
d.Shown = cur
}
d.Earlier = d.Shown.Version != cur.Version
if d.Body == "" {
d.Body = d.Shown.Body
}
if hist, err := s.ClusterSettingsHistory(ctx, 30); err == nil {
for _, v := range hist {
d.History = append(d.History, settingsRow{Version: v.Version, At: l.Date(v.At.UTC()) + " " + v.At.UTC().Format("15:04"),
By: v.By, Note: v.Note, InForce: v.Version == cur.Version, Selected: v.Version == d.Shown.Version})
}
}
noStore(w)
render(w, r, "admin_settings", d)
}
adminsOnly := func(next func(w http.ResponseWriter, r *http.Request, admin store.User)) http.HandlerFunc {
return p.adminOnly(func(w http.ResponseWriter, r *http.Request, admin store.User) {
if !admin.IsAdmin {
http.NotFound(w, r)
return
}
if r.Method == http.MethodPost {
sess, _, _ := p.session(r)
if !p.accounts.CheckCSRF(sess, r.FormValue("csrf")) {
http.Error(w, "bad request", http.StatusBadRequest)
return
}
}
next(w, r, admin)
})
}
mux.HandleFunc("GET /admin/settings", adminsOnly(func(w http.ResponseWriter, r *http.Request, admin store.User) {
var d settingsPageData
if q := r.URL.Query().Get("version"); q != "" {
n, err := strconv.ParseInt(q, 10, 64)
if v, verr := s.ClusterSettingsAt(r.Context(), n); err == nil && verr == nil && v.Version != 0 {
d.Shown = v
} else {
d.Error = langOf(r).T("settings.err.no_version")
}
}
page(w, r, admin, d)
}))
mux.HandleFunc("POST /admin/settings", adminsOnly(func(w http.ResponseWriter, r *http.Request, admin store.User) {
l := langOf(r)
body := strings.ReplaceAll(r.FormValue("body"), "\r\n", "\n")
note := strings.TrimSpace(r.FormValue("note"))
base, _ := strconv.ParseInt(r.FormValue("base"), 10, 64)
// The audit line records the form; the document can hold webhook
// secrets, so it records the document's size, not the document.
r.PostForm.Set("body", "("+strconv.Itoa(len(body))+" bytes)")
refuse := func(msg string) {
noteAudit(r, "cluster settings", "", msg)
page(w, r, admin, settingsPageData{Body: body, Note: note, Error: msg})
}
if cur, err := s.ClusterSettings(r.Context()); err == nil && cur.Body == body {
refuse(l.T("settings.err.unchanged"))
return
}
if err := check([]byte(body)); err != nil {
refuse(l.T("settings.err.invalid") + " " + err.Error())
return
}
n, err := s.PutClusterSettings(r.Context(), base, body, admin.Email, note)
switch {
case errors.Is(err, store.ErrSettingsChanged):
refuse(l.T("settings.err.changed"))
return
case err != nil:
refuse(l.Err(err))
return
}
noteAudit(r, "cluster settings", "version "+strconv.FormatInt(n, 10), "")
page(w, r, admin, settingsPageData{Notice: l.T("settings.saved", n)})
}))
mux.HandleFunc("POST /admin/settings/rollback", adminsOnly(func(w http.ResponseWriter, r *http.Request, admin store.User) {
l := langOf(r)
n, _ := strconv.ParseInt(r.FormValue("version"), 10, 64)
old, err := s.ClusterSettingsAt(r.Context(), n)
if err != nil || old.Version == 0 {
page(w, r, admin, settingsPageData{Error: l.T("settings.err.no_version")})
return
}
cur, err := s.ClusterSettings(r.Context())
if err != nil {
page(w, r, admin, settingsPageData{Error: l.Err(err)})
return
}
if err := check([]byte(old.Body)); err != nil {
// A version kept before a change to server.yaml may no longer
// load beside it; refused here rather than breaking the cluster.
noteAudit(r, "cluster settings", "", err.Error())
page(w, r, admin, settingsPageData{Error: l.T("settings.err.invalid") + " " + err.Error()})
return
}
v, err := s.PutClusterSettings(r.Context(), cur.Version, old.Body, admin.Email, "back to version "+strconv.FormatInt(n, 10))
if err != nil {
page(w, r, admin, settingsPageData{Error: l.Err(err)})
return
}
noteAudit(r, "cluster settings", "version "+strconv.FormatInt(v, 10)+" from "+strconv.FormatInt(n, 10), "")
page(w, r, admin, settingsPageData{Notice: l.T("settings.rolled_back", n, v)})
}))
}
+143
View File
@@ -0,0 +1,143 @@
package web
import (
"context"
"errors"
"io"
"log/slog"
"net/http"
"net/url"
"strings"
"testing"
"time"
"gitea.mynodes.xyz/ilker/llmgw/internal/store"
)
type fakeSettings struct{ versions []store.SettingsVersion }
func (f *fakeSettings) ClusterSettings(context.Context) (store.SettingsVersion, error) {
if len(f.versions) == 0 {
return store.SettingsVersion{}, nil
}
return f.versions[len(f.versions)-1], nil
}
func (f *fakeSettings) ClusterSettingsAt(_ context.Context, v int64) (store.SettingsVersion, error) {
for _, s := range f.versions {
if s.Version == v {
return s, nil
}
}
return store.SettingsVersion{}, nil
}
func (f *fakeSettings) ClusterSettingsHistory(context.Context, int) ([]store.SettingsVersion, error) {
out := make([]store.SettingsVersion, len(f.versions))
for i, v := range f.versions {
out[len(f.versions)-1-i] = v
}
return out, nil
}
func (f *fakeSettings) PutClusterSettings(_ context.Context, base int64, body, by, note string) (int64, error) {
cur, _ := f.ClusterSettings(context.Background())
if base != cur.Version {
return 0, store.ErrSettingsChanged
}
n := cur.Version + 1
f.versions = append(f.versions, store.SettingsVersion{Version: n, Body: body, By: by, Note: note, At: time.Now()})
return n, nil
}
type auditSink struct{ events []store.AuditEvent }
func (a *auditSink) WriteAudit(_ context.Context, e store.AuditEvent) error {
a.events = append(a.events, e)
return nil
}
func clusterSettingsPage(t *testing.T, user store.User) (*http.ServeMux, *fakeSettings, *auditSink) {
t.Helper()
s := &fakeSettings{versions: []store.SettingsVersion{{Version: 1, Body: "guard:\n enabled: true\n", By: "init", At: time.Now()}}}
p := NewAccountPages(fakeAccounts{user: user}, nil, nil, "v0", slog.New(slog.NewTextHandler(io.Discard, nil)))
sink := &auditSink{}
p.SetAudit(sink)
mux := http.NewServeMux()
p.RegisterAdminSettings(mux, s, func(b []byte) error {
if strings.Contains(string(b), "bogus") {
return errors.New("unknown key bogus")
}
return nil
}, []string{"listen", "store"})
return mux, s, sink
}
func TestTheSettingsPageIsForAdministratorsOnly(t *testing.T) {
for _, u := range []store.User{
{ID: "u1", Email: "v@example.com", Role: store.RoleViewer},
{ID: "u2", Email: "o@example.com", Role: store.RoleOperator},
{ID: "u3", Email: "b@example.com", Role: store.RoleBilling},
} {
mux, _, _ := clusterSettingsPage(t, u)
if w := mirrorGet(t, mux, "/admin/settings"); w.Code != http.StatusNotFound {
t.Errorf("%s saw the settings: %d", u.Role, w.Code)
}
}
mux, _, _ := clusterSettingsPage(t, store.User{ID: "a", Email: "a@example.com", IsAdmin: true})
body := mirrorGet(t, mux, "/admin/settings").Body.String()
for _, want := range []string{"guard:\n enabled: true", "Version 1, in force", "<code>listen</code>", `href="/admin/settings" aria-current="page"`} {
if !strings.Contains(body, want) {
t.Errorf("no %q in:\n%s", want, body)
}
}
}
func TestSettingsAreCheckedAppliedAndRolledBack(t *testing.T) {
mux, s, sink := clusterSettingsPage(t, store.User{ID: "a", Email: "a@example.com", IsAdmin: true})
post := func(form url.Values) string {
form.Set("csrf", "tok")
return mirrorPost(t, mux, "/admin/settings", form).Body.String()
}
// Refused: does not load. The edit stays in the editor; nothing kept.
body := post(url.Values{"base": {"1"}, "body": {"bogus: 1\n"}})
if !strings.Contains(body, "unknown key bogus") || !strings.Contains(body, "bogus: 1") || len(s.versions) != 1 {
t.Errorf("an invalid document: %d versions\n%s", len(s.versions), body)
}
// Applied, with its note and who.
body = post(url.Values{"base": {"1"}, "body": {"guard:\r\n enabled: false\r\n"}, "note": {"maintenance"}})
if !strings.Contains(body, "Version 2 is in force") || len(s.versions) != 2 ||
s.versions[1].Body != "guard:\n enabled: false\n" || s.versions[1].By != "a@example.com" || s.versions[1].Note != "maintenance" {
t.Errorf("applying: %+v\n%s", s.versions, body)
}
// Made from a version no longer the newest: refused, not overwritten.
body = post(url.Values{"base": {"1"}, "body": {"guard:\n enabled: true\n x: 1\n"}})
if !strings.Contains(body, "someone changed the settings") || len(s.versions) != 2 {
t.Errorf("a stale edit: %d versions\n%s", len(s.versions), body)
}
// An earlier version is shown, and put back as a new one.
if body := mirrorGet(t, mux, "/admin/settings?version=1").Body.String(); !strings.Contains(body, "Put version 1 back in force") {
t.Errorf("viewing version 1:\n%s", body)
}
w := mirrorPost(t, mux, "/admin/settings/rollback", url.Values{"csrf": {"tok"}, "version": {"1"}})
if len(s.versions) != 3 || s.versions[2].Body != s.versions[0].Body || !strings.Contains(w.Body.String(), "as version 3") {
t.Errorf("rollback: %+v\n%s", s.versions, w.Body.String())
}
// Without the CSRF token, nothing.
if w := mirrorPost(t, mux, "/admin/settings", url.Values{"base": {"3"}, "body": {"a: 1\n"}}); w.Code != http.StatusBadRequest || len(s.versions) != 3 {
t.Errorf("no token: %d", w.Code)
}
// Audited, without the document itself: it can hold secrets.
var saw bool
for _, e := range sink.events {
if strings.Contains(e.Detail, "enabled") {
t.Errorf("the document is in the audit log: %+v", e)
}
if e.Action == "POST /admin/settings" && strings.Contains(e.Detail, "version 2") {
saw = true
}
}
if !saw {
t.Errorf("no audit line for version 2: %+v", sink.events)
}
}
+2 -1
View File
@@ -10,5 +10,6 @@
"nav.chat": "Chat",
"nav.account": "Account",
"nav.sign_out": "Sign out",
"nav.docs": "Docs"
"nav.docs": "Docs",
"nav.settings": "Settings"
}
+28
View File
@@ -0,0 +1,28 @@
{
"settings.title": "Settings",
"settings.sub": "The cluster's settings: everything that is not one machine's own, the same on every control plane, in force within seconds of a change. <code>llmgw ctl config edit</code> edits the same document.",
"settings.current": "Version %d, in force",
"settings.earlier": "Version %d",
"settings.earlier_sub": "An earlier version; version %d is in force. Rolling back keeps this one as a new version, so nothing is lost.",
"settings.rollback": "Put version %d back in force",
"settings.back_to_current": "back to the version in force",
"settings.local_keys": "Not here, because each machine's server.yaml keeps them:",
"settings.note": "Why",
"settings.note_hint": "kept with the version, for whoever reads the history",
"settings.save": "Check and apply",
"settings.save_hint": "Checked as a control plane would load it before it is kept; a change made since this page was opened is not overwritten.",
"settings.saved": "Version %d is in force; every control plane applies it within seconds.",
"settings.rolled_back": "Version %d's settings are back in force, as version %d.",
"settings.history": "History",
"settings.col.version": "Version",
"settings.col.at": "When",
"settings.col.by": "By",
"settings.col.note": "Why",
"settings.in_force": "in force",
"settings.view": "view",
"settings.no_history": "No versions yet.",
"settings.err.unchanged": "Nothing was changed.",
"settings.err.invalid": "Not applied: a control plane could not load it.",
"settings.err.changed": "Not applied: someone changed the settings since this page was opened. Your edit is below; compare it with the version now in force and apply it again.",
"settings.err.no_version": "There is no such version."
}
+2 -1
View File
@@ -10,5 +10,6 @@
"nav.chat": "Sohbet",
"nav.account": "Hesap",
"nav.sign_out": "Çıkış yap",
"nav.docs": "Belgeler"
"nav.docs": "Belgeler",
"nav.settings": "Ayarlar"
}
+28
View File
@@ -0,0 +1,28 @@
{
"settings.title": "Ayarlar",
"settings.sub": "Kümenin ayarları: tek bir makineye ait olmayan her şey; her kontrol düzleminde aynı, değiştikten saniyeler sonra yürürlükte. <code>llmgw ctl config edit</code> aynı belgeyi düzenler.",
"settings.current": "Sürüm %d, yürürlükte",
"settings.earlier": "Sürüm %d",
"settings.earlier_sub": "Önceki bir sürüm; yürürlükte olan sürüm %d. Geri almak bunu yeni bir sürüm olarak kaydeder, hiçbir şey kaybolmaz.",
"settings.rollback": "%d numaralı sürümü yeniden yürürlüğe koy",
"settings.back_to_current": "yürürlükteki sürüme dön",
"settings.local_keys": "Burada değil, çünkü her makinenin kendi server.yaml dosyası tutar:",
"settings.note": "Neden",
"settings.note_hint": "sürümle birlikte saklanır, geçmişi okuyacak kişi için",
"settings.save": "Denetle ve uygula",
"settings.save_hint": "Saklanmadan önce bir kontrol düzleminin yükleyeceği gibi denetlenir; bu sayfa açıldıktan sonra yapılmış bir değişikliğin üzerine yazılmaz.",
"settings.saved": "%d numaralı sürüm yürürlükte; her kontrol düzlemi saniyeler içinde uygular.",
"settings.rolled_back": "%d numaralı sürümün ayarları yeniden yürürlükte; yeni sürüm numarası %d.",
"settings.history": "Geçmiş",
"settings.col.version": "Sürüm",
"settings.col.at": "Ne zaman",
"settings.col.by": "Kim",
"settings.col.note": "Neden",
"settings.in_force": "yürürlükte",
"settings.view": "görüntüle",
"settings.no_history": "Henüz sürüm yok.",
"settings.err.unchanged": "Hiçbir şey değiştirilmedi.",
"settings.err.invalid": "Uygulanmadı: bir kontrol düzlemi bunu yükleyemezdi.",
"settings.err.changed": "Uygulanmadı: bu sayfa açıldıktan sonra biri ayarları değiştirdi. Düzenlemeniz aşağıda; yürürlükteki sürümle karşılaştırıp yeniden uygulayın.",
"settings.err.no_version": "Böyle bir sürüm yok."
}
+11 -7
View File
@@ -26,6 +26,9 @@ type Nav struct {
Mirror, Quotas bool
// Guard is whether the guardrails page was mounted.
Guard bool
// Settings offers the cluster's settings: mounted, and to an
// administrator only.
Settings bool
// CSRF signs the sign-out form.
CSRF string
// Org offers the organization page: to an administrator, and to anyone
@@ -38,13 +41,14 @@ type navKey struct{}
// navFor builds the menu for a signed-in person.
func (p *AccountPages) navFor(r *http.Request, user store.User, current string) Nav {
n := Nav{
Current: current,
Admin: user.Staff(),
Role: user.StaffRole(),
Mirror: p.hasMirror,
Quotas: p.hasQuotas,
Guard: p.hasGuard,
CSRF: csrfFor(r),
Current: current,
Admin: user.Staff(),
Role: user.StaffRole(),
Mirror: p.hasMirror,
Quotas: p.hasQuotas,
Guard: p.hasGuard,
Settings: p.hasSettings && user.IsAdmin,
CSRF: csrfFor(r),
}
// Only when there is an organization to show: a link that leads to "there
// are none" on every page is noise.
+10
View File
@@ -905,3 +905,13 @@ a.sel-link.small { font-size: .78rem; color: var(--muted); margin-left: .4rem; }
/* The language switcher at the foot of every page. */
.langs a { color: var(--muted); }
.langs b { font-weight: 600; }
/* The cluster's settings, edited as the YAML document they are. */
.settings-form textarea, pre.settings-body {
width: 100%; box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: .85rem; line-height: 1.4; padding: .6rem .7rem; border: 1px solid var(--line);
border-radius: 6px; background: var(--card); color: var(--fg); tab-size: 2; overflow-x: auto;
}
.settings-form label { display: block; margin: .8rem 0; }
.settings-form input[type=text] { width: 100%; box-sizing: border-box; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@@ -0,0 +1,50 @@
{{define "admin_settings"}}<!doctype html>
<html lang="{{lang}}"><head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>{{t "settings.title"}} · llmgw</title><link rel="stylesheet" href="{{stylesheet}}">
</head><body><div class="wrap">
<header>
<h1>{{t "settings.title"}}</h1>
<p class="sub">{{th "settings.sub"}}</p>
{{template "nav" .Nav}}
</header>
{{if .Error}}<p class="error" role="alert">{{.Error}}</p>{{end}}
{{if .Notice}}<p class="ok" role="status">{{.Notice}}</p>{{end}}
{{if .Earlier}}
<h2>{{t "settings.earlier" .Shown.Version}}</h2>
<p class="sub">{{t "settings.earlier_sub" .Current.Version}}</p>
<pre class="settings-body">{{.Body}}</pre>
<form method="post" action="/admin/settings/rollback">
<input type="hidden" name="csrf" value="{{.CSRF}}">
<input type="hidden" name="version" value="{{.Shown.Version}}">
<button type="submit">{{t "settings.rollback" .Shown.Version}}</button>
<a href="/admin/settings">{{t "settings.back_to_current"}}</a>
</form>
{{else}}
<h2>{{t "settings.current" .Current.Version}}</h2>
{{if .LocalKeys}}<p class="sub">{{t "settings.local_keys"}} {{range $i, $k := .LocalKeys}}{{if $i}}, {{end}}<code>{{$k}}</code>{{end}}.</p>{{end}}
<form method="post" action="/admin/settings" class="settings-form">
<input type="hidden" name="csrf" value="{{.CSRF}}">
<input type="hidden" name="base" value="{{.Current.Version}}">
<label for="settings-body" class="sr-only">{{t "settings.title"}}</label>
<textarea id="settings-body" name="body" rows="30" spellcheck="false" class="mono">{{.Body}}</textarea>
<label>{{t "settings.note"}} <span class="opt">{{t "settings.note_hint"}}</span>
<input type="text" name="note" value="{{.Note}}" maxlength="200"></label>
<button type="submit">{{t "settings.save"}}</button>
<p class="sub">{{t "settings.save_hint"}}</p>
</form>
{{end}}
<h2>{{t "settings.history"}}</h2>
{{if .History}}
<table class="rows">
<tr><th class="num">{{t "settings.col.version"}}</th><th>{{t "settings.col.at"}}</th><th>{{t "settings.col.by"}}</th><th>{{t "settings.col.note"}}</th><th></th></tr>
{{range .History}}<tr{{if .Selected}} aria-current="true"{{end}}>
<td class="num">{{.Version}}</td><td>{{.At}}</td><td>{{.By}}</td><td>{{.Note}}</td>
<td>{{if .InForce}}<strong>{{t "settings.in_force"}}</strong>{{else}}<a href="/admin/settings?version={{.Version}}">{{t "settings.view"}}</a>{{end}}</td>
</tr>{{end}}
</table>
{{else}}<p class="sub">{{t "settings.no_history"}}</p>{{end}}
<footer>llmgw {{.Version}}</footer>
</div></body></html>{{end}}
+3
View File
@@ -20,6 +20,9 @@
{{- if .Guard}}
<a href="/admin/guard"{{if eq .Current "guard"}} aria-current="page"{{end}}>{{t "nav.guard"}}</a>
{{- end}}
{{- if .Settings}}
<a href="/admin/settings"{{if eq .Current "settings"}} aria-current="page"{{end}}>{{t "nav.settings"}}</a>
{{- end}}
{{- /* An organization is a panel of the people page for an administrator;
/org is the managers' view, and leads an administrator there. */}}
<span class="menu-gap" aria-hidden="true"></span>