From aff501bebc99c405130c7414941e6f039d2fdf9d Mon Sep 17 00:00:00 2001 From: Gibheer Date: Thu, 24 Jan 2019 15:37:43 +0100 Subject: monfront - add select all This commit adds a select all function to select all rows of a list to mark them all. This could be used to send a refresh to all these checks or acknowledge them or whatever. Also the referrer handling in checkAction() was moved to the start so that even with an error the same thing happens. --- cmd/monfront/main.go | 68 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/cmd/monfront/main.go b/cmd/monfront/main.go index ac9de17..3f71727 100644 --- a/cmd/monfront/main.go +++ b/cmd/monfront/main.go @@ -154,10 +154,15 @@ func checkAction(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "could not parse parameters: %s", err) return } + ref, found := r.Header["Referer"] + if found { + w.Header()["Location"] = ref + } else { + w.Header()["Location"] = []string{"/"} + } checks := r.PostForm["checks"] action := r.PostForm["action"] if len(action) == 0 || action[0] == "" || len(checks) == 0 { - w.Header()["Location"] = []string{"/"} w.WriteHeader(http.StatusSeeOther) return } @@ -216,7 +221,6 @@ func checkAction(w http.ResponseWriter, r *http.Request) { log.Printf("could not adjust checks %#v: %s", checks, err) return } - w.Header()["Location"] = []string{"/"} w.WriteHeader(http.StatusSeeOther) return default: @@ -236,12 +240,6 @@ func checkAction(w http.ResponseWriter, r *http.Request) { log.Printf("could not adjust checks %#v: %s", checks, err) return } - ref, found := r.Header["Referer"] - if found { - w.Header()["Location"] = ref - } else { - w.Header()["Location"] = []string{"/"} - } w.WriteHeader(http.StatusSeeOther) return } @@ -639,35 +637,61 @@ var ( {{ if .Error }}
{{ .Error }}
{{ end }}`, "footer": ``, "checklist": `{{ template "header" . }}
@@ -693,7 +717,7 @@ var ( - + {{ $current := "" }} {{ $mapping := .Mappings }} -- cgit v1.2.3-70-g09d2
hoststatusnext checkmessage
hoststatusnext checkmessage