Staff roles (viewer, operator, billing) and the console's Audit view
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
f8fcecd640
commit
b60cf45adf
19 files changed
+352
-24
No files matched your search
@@ -0,0 +1,47 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gitea.mynodes.xyz/ilker/llmgw/internal/store"
|
||||
)
|
||||
|
||||
// The audit view: who changed what, newest first — the same as `llmgw ctl
|
||||
// audit`.
|
||||
|
||||
func (m consoleModel) auditPanel(pw int) (string, string, string) {
|
||||
keys := "→ or Enter open · ↑↓ choose · Q leave"
|
||||
if m.inPanel {
|
||||
keys = "↑↓ row · Enter what it was given · ← back · Q leave"
|
||||
}
|
||||
head := "\n " + sDim.Render("Every change through ctl, this console and the /admin pages, the last week.") + "\n\n"
|
||||
var rows [][]string
|
||||
for _, e := range m.data.audit {
|
||||
status := strconv.Itoa(e.Status)
|
||||
if e.Status >= 400 {
|
||||
status = sBad.Render(status)
|
||||
}
|
||||
rows = append(rows, []string{ageShort(e.At), e.Actor, e.Source, e.Action, dash(e.Target), status})
|
||||
}
|
||||
if len(rows) == 0 {
|
||||
return "Audit", head + " " + sDim.Render("Nothing changed in the last week, or this control plane has no store."), keys
|
||||
}
|
||||
return "Audit", head + table([]string{"WHEN", "WHO", "VIA", "WHAT", "TARGET", "STATUS"}, rows, m.row, pw, m.inPanel), keys
|
||||
}
|
||||
|
||||
// auditDialog is one change in full.
|
||||
func auditDialog(e store.AuditEvent) (string, string) {
|
||||
var b strings.Builder
|
||||
fmt.Fprintf(&b, "%s, by %s through %s\nstatus %d\n", e.At.Format(time.DateTime), e.Actor, e.Source, e.Status)
|
||||
if e.Target != "" {
|
||||
fmt.Fprintf(&b, "target %s\n", e.Target)
|
||||
}
|
||||
if e.Detail != "" && e.Detail != "{}" {
|
||||
fmt.Fprintf(&b, "\n%s\n", wrap(e.Detail, 80, ""))
|
||||
}
|
||||
b.WriteString("\n" + sDim.Render("any key"))
|
||||
return e.Action, b.String()
|
||||
}
|
||||
Reference in new issue
Block a user