diff --git a/cmd/mavweb/dash.html b/cmd/mavweb/dash.html index 594867f..699c9f3 100644 --- a/cmd/mavweb/dash.html +++ b/cmd/mavweb/dash.html @@ -8,7 +8,9 @@ .pending{color:#fc6}.acted{color:#6c6}.ignored{color:#888}.snoozed{color:#c9f} .pres{color:#6c6}.away{color:#888} .updated{color:#666;font-size:.85rem;margin-top:-.5rem;margin-bottom:1rem} + nav a{color:#8cf;margin-right:1rem;font-size:.85rem} +
{{.Presence.Bucket}} — score {{printf "%.2f" .Presence.Score}} ({{ago .Presence.Updated}})
{{len .Facts}} facts shown (newest first)
+| when | kind | key | value | source | conf |
|---|---|---|---|---|---|
| {{if .VoidsID}}⨯ voided{{end}}{{.Ts.Format "2006-01-02 15:04"}} | +{{.Kind}} | +{{.Key}} | +{{.Value}} | +{{.Source}} | +{{printf "%.2f" .Confidence}} | +
none enabled.
{{end}} ` +var historyTmpl = template.Must(template.New("history").Parse(historyHTML)) + +func handleHistory(w http.ResponseWriter, r *http.Request, core ipc.CoreAPI) { + if core == nil { + http.Error(w, "history disabled (no -core)", http.StatusServiceUnavailable) + return + } + ctx := r.Context() + facts, err := core.RecentFacts(ctx, 200) + if err != nil { + log.Printf("history: %v", err) + http.Error(w, "core read failed", http.StatusBadGateway) + return + } + w.Header().Set("Content-Type", "text/html; charset=utf-8") + if err := historyTmpl.Execute(w, struct { + Facts []ipc.Fact + }{facts}); err != nil { + log.Printf("history render: %v", err) + } +} + // handleTools serves the enable surface (GET) and applies an enable (POST). // POST fields: name, cmd (space-separated argv), destructive (checkbox). cmd is // whitespace-split — argv with embedded spaces isn't supported (ponytail: no