diff options
author | Gibheer <gibheer+git@zero-knowledge.org> | 2019-03-08 15:18:12 +0100 |
---|---|---|
committer | Gibheer <gibheer+git@zero-knowledge.org> | 2019-03-08 15:18:12 +0100 |
commit | bef2cfa349615d2dd61c6426df9a7587a8b519e4 (patch) | |
tree | 8adcbe9da21d7aa053187585b3139a209a3aa577 | |
parent | bb48d9387be746339dd34d7aa24c314e10cfe14f (diff) |
monfront - enable jumping from groups to checks
This allows to view all the important checks for a group much easier.
-rw-r--r-- | cmd/monfront/main.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/cmd/monfront/main.go b/cmd/monfront/main.go index c471ef1..b8ba1de 100644 --- a/cmd/monfront/main.go +++ b/cmd/monfront/main.go @@ -37,6 +37,7 @@ type ( Checks []check CheckDetails *checkDetails Groups []group + Unhandled bool // set this flag when unhandled was called } MapEntry struct { @@ -250,6 +251,7 @@ func checkAction(w http.ResponseWriter, r *http.Request) { } func showChecks(w http.ResponseWriter, r *http.Request) { + con := Context{} query := `select c.id, n.id, n.name, co.name, ac.mapping_id, ac.states[1] as state, ac.enabled, ac.notice, ac.next_time, ac.msg, case when cn.check_id is null then false else true end as notify_enabled @@ -269,6 +271,7 @@ func showChecks(w http.ResponseWriter, r *http.Request) { } if strings.HasPrefix(r.URL.Path, "/unhandled") { where = append(where, `ac.states[1] > 0 and ac.acknowledged = false and ac.enabled = true`) + con.Unhandled = true } if search, found := r.URL.Query()["search"]; found { idx += 1 @@ -324,9 +327,7 @@ func showChecks(w http.ResponseWriter, r *http.Request) { } checks = append(checks, c) } - con := Context{ - Checks: checks, - } + con.Checks = checks if err := loadMappings(&con); err != nil { con.Error = "could not load mapping data" w.WriteHeader(http.StatusInternalServerError) @@ -345,6 +346,7 @@ func showChecks(w http.ResponseWriter, r *http.Request) { } func showGroups(w http.ResponseWriter, r *http.Request) { + con := Context{} query := `select groupid, groupname, nodeid, nodename, mapping_id, state from ( select g.id groupid, g.name groupname, n.id nodeid, n.name nodename, ac.mapping_id, @@ -359,6 +361,7 @@ func showGroups(w http.ResponseWriter, r *http.Request) { where state = maxstate` if strings.HasPrefix(r.URL.Path, "/unhandled") { query += ` and state > 0` + con.Unhandled = true } if strings.HasPrefix(r.URL.Path, "/unhandled") { @@ -387,9 +390,7 @@ func showGroups(w http.ResponseWriter, r *http.Request) { } groups = append(groups, g) } - con := Context{ - Groups: groups, - } + con.Groups = groups if err := loadMappings(&con); err != nil { w.WriteHeader(http.StatusInternalServerError) w.Write([]byte("problem with the mappings")) @@ -790,7 +791,7 @@ var ( {{ range .Groups }} <tr> <td><input type="checkbox" name="nodes" value="{{ .NodeId }}" /></td> - <td>{{ if ne $current .Name }}{{ $current = .Name }}<a href="/checks?group_id={{ .NodeId }}">{{ .Name }}</a>{{ end }}</td> + <td>{{ if ne $current .Name }}{{ $current = .Name }}<a href="{{ if $.Unhandled }}/unhandled{{ end }}/checks?group_id={{ .GroupId }}">{{ .Name }}</a>{{ end }}</td> <td><a href="/checks?node_id={{ .NodeId }}">{{ .NodeName }}</a></td> <td class="state-{{ .MappingId }}-{{ .State }}">{{ (index $mapping .MappingId .State).Title }}</td> </tr> |