updated dash

This commit is contained in:
2026-05-17 14:12:06 +00:00
parent 317a7f3f13
commit 72c71bb95d
14 changed files with 369 additions and 93 deletions
+23
View File
@@ -8,6 +8,7 @@ import (
"io/fs"
"log"
"net/http"
"net/url"
"path"
"strings"
@@ -112,6 +113,28 @@ func buildFuncMap() template.FuncMap {
return template.FuncMap{
"inc": func(i int) int { return i + 1 },
"dec": func(i int) int { return i - 1 },
// alertsPageURL builds the prev/next link for the alerts page.
"alertsPageURL": func(f crowdsec.AlertFilter, page int, next bool, showUpdates bool) string {
p := page - 1
if next {
p = page + 1
}
q := url.Values{}
q.Set("page", fmt.Sprintf("%d", p))
if f.Scenario != "" {
q.Set("scenario", f.Scenario)
}
if f.IP != "" {
q.Set("ip", f.IP)
}
if f.Since != "" {
q.Set("since", f.Since)
}
if showUpdates {
q.Set("show_updates", "1")
}
return "/alerts?" + q.Encode()
},
// dict builds a map for passing multiple values to a sub-template.
// Usage: {{template "foo" dict "Key1" val1 "Key2" val2}}
"dict": func(pairs ...any) (map[string]any, error) {