monfront - enable jumping from groups to checks
This allows to view all the important checks for a group much easier.
This commit is contained in:
parent
bb48d9387b
commit
bef2cfa349
@ -37,6 +37,7 @@ type (
|
|||||||
Checks []check
|
Checks []check
|
||||||
CheckDetails *checkDetails
|
CheckDetails *checkDetails
|
||||||
Groups []group
|
Groups []group
|
||||||
|
Unhandled bool // set this flag when unhandled was called
|
||||||
}
|
}
|
||||||
|
|
||||||
MapEntry struct {
|
MapEntry struct {
|
||||||
@ -250,6 +251,7 @@ func checkAction(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func showChecks(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,
|
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,
|
ac.enabled, ac.notice, ac.next_time, ac.msg,
|
||||||
case when cn.check_id is null then false else true end as notify_enabled
|
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") {
|
if strings.HasPrefix(r.URL.Path, "/unhandled") {
|
||||||
where = append(where, `ac.states[1] > 0 and ac.acknowledged = false and ac.enabled = true`)
|
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 {
|
if search, found := r.URL.Query()["search"]; found {
|
||||||
idx += 1
|
idx += 1
|
||||||
@ -324,9 +327,7 @@ func showChecks(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
checks = append(checks, c)
|
checks = append(checks, c)
|
||||||
}
|
}
|
||||||
con := Context{
|
con.Checks = checks
|
||||||
Checks: checks,
|
|
||||||
}
|
|
||||||
if err := loadMappings(&con); err != nil {
|
if err := loadMappings(&con); err != nil {
|
||||||
con.Error = "could not load mapping data"
|
con.Error = "could not load mapping data"
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
@ -345,6 +346,7 @@ func showChecks(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func showGroups(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
|
query := `select groupid, groupname, nodeid, nodename, mapping_id, state
|
||||||
from (
|
from (
|
||||||
select g.id groupid, g.name groupname, n.id nodeid, n.name nodename, ac.mapping_id,
|
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`
|
where state = maxstate`
|
||||||
if strings.HasPrefix(r.URL.Path, "/unhandled") {
|
if strings.HasPrefix(r.URL.Path, "/unhandled") {
|
||||||
query += ` and state > 0`
|
query += ` and state > 0`
|
||||||
|
con.Unhandled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(r.URL.Path, "/unhandled") {
|
if strings.HasPrefix(r.URL.Path, "/unhandled") {
|
||||||
@ -387,9 +390,7 @@ func showGroups(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
groups = append(groups, g)
|
groups = append(groups, g)
|
||||||
}
|
}
|
||||||
con := Context{
|
con.Groups = groups
|
||||||
Groups: groups,
|
|
||||||
}
|
|
||||||
if err := loadMappings(&con); err != nil {
|
if err := loadMappings(&con); err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
w.Write([]byte("problem with the mappings"))
|
w.Write([]byte("problem with the mappings"))
|
||||||
@ -790,7 +791,7 @@ var (
|
|||||||
{{ range .Groups }}
|
{{ range .Groups }}
|
||||||
<tr>
|
<tr>
|
||||||
<td><input type="checkbox" name="nodes" value="{{ .NodeId }}" /></td>
|
<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><a href="/checks?node_id={{ .NodeId }}">{{ .NodeName }}</a></td>
|
||||||
<td class="state-{{ .MappingId }}-{{ .State }}">{{ (index $mapping .MappingId .State).Title }}</td>
|
<td class="state-{{ .MappingId }}-{{ .State }}">{{ (index $mapping .MappingId .State).Title }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
Loading…
Reference in New Issue
Block a user