monfront - add link to list checks from a group
This commit is contained in:
parent
c9a990513a
commit
bb48d9387b
@ -129,9 +129,14 @@ func main() {
|
|||||||
for k, val := range Templates {
|
for k, val := range Templates {
|
||||||
template.Must(tmpl.New(k).Parse(val))
|
template.Must(tmpl.New(k).Parse(val))
|
||||||
}
|
}
|
||||||
|
for k, val := range AdminTemplates {
|
||||||
|
template.Must(tmpl.New("admin-" + k).Parse(val))
|
||||||
|
}
|
||||||
Tmpl = tmpl
|
Tmpl = tmpl
|
||||||
|
|
||||||
http.HandleFunc("/", showChecks)
|
http.HandleFunc("/", showChecks)
|
||||||
|
http.HandleFunc("/admin/", showAdmin)
|
||||||
|
http.HandleFunc("/admin/action", adminAction)
|
||||||
http.HandleFunc("/static/", showStatic)
|
http.HandleFunc("/static/", showStatic)
|
||||||
http.HandleFunc("/check", showCheck)
|
http.HandleFunc("/check", showCheck)
|
||||||
http.HandleFunc("/checks", showChecks)
|
http.HandleFunc("/checks", showChecks)
|
||||||
@ -254,11 +259,17 @@ func showChecks(w http.ResponseWriter, r *http.Request) {
|
|||||||
join commands co on c.command_id = co.id
|
join commands co on c.command_id = co.id
|
||||||
left join ( select distinct check_id from checks_notify where enabled = true) cn on c.id = cn.check_id`
|
left join ( select distinct check_id from checks_notify where enabled = true) cn on c.id = cn.check_id`
|
||||||
where := []string{}
|
where := []string{}
|
||||||
|
idx := 0
|
||||||
|
params := []interface{}{}
|
||||||
|
if id, found := r.URL.Query()["group_id"]; found {
|
||||||
|
query += ` join nodes_groups ng on n.id = ng.node_id`
|
||||||
|
idx += 1
|
||||||
|
where = append(where, fmt.Sprintf(`ng.group_id = $%d::int`, idx))
|
||||||
|
params = append(params, id[0])
|
||||||
|
}
|
||||||
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`)
|
||||||
}
|
}
|
||||||
idx := 0
|
|
||||||
params := []interface{}{}
|
|
||||||
if search, found := r.URL.Query()["search"]; found {
|
if search, found := r.URL.Query()["search"]; found {
|
||||||
idx += 1
|
idx += 1
|
||||||
// Add the search for nodes. As hostnames or FQDNs are really weird, the
|
// Add the search for nodes. As hostnames or FQDNs are really weird, the
|
||||||
@ -473,7 +484,7 @@ func showCheck(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func returnError(status int, con Context, w http.ResponseWriter) {
|
func returnError(status int, con interface{}, w http.ResponseWriter) {
|
||||||
w.Header()["Content-Type"] = []string{"text/html"}
|
w.Header()["Content-Type"] = []string{"text/html"}
|
||||||
w.WriteHeader(status)
|
w.WriteHeader(status)
|
||||||
if err := Tmpl.ExecuteTemplate(w, "error", con); err != nil {
|
if err := Tmpl.ExecuteTemplate(w, "error", con); err != nil {
|
||||||
@ -597,6 +608,7 @@ var (
|
|||||||
.mute { background-image: url(/static/icon-mute); }
|
.mute { background-image: url(/static/icon-mute); }
|
||||||
.detail > div { display: grid; grid-template-columns: 25% auto; }
|
.detail > div { display: grid; grid-template-columns: 25% auto; }
|
||||||
.detail > div:hover { background: #dfdfdf; }
|
.detail > div:hover { background: #dfdfdf; }
|
||||||
|
.error { padding: 0.5em; background: #ffc6c6; border: 1px solid red; }
|
||||||
/* state background colors */
|
/* state background colors */
|
||||||
{{ range $mapId, $mapping := .Mappings -}}
|
{{ range $mapId, $mapping := .Mappings -}}
|
||||||
{{ range $target, $val := $mapping -}}
|
{{ range $target, $val := $mapping -}}
|
||||||
@ -610,8 +622,14 @@ var (
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav id="mainmenu">
|
<nav id="mainmenu">
|
||||||
|
<ul>
|
||||||
|
<li class="submenu">
|
||||||
|
<span class="header">main</span>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="/">home</a></li>
|
<li><a href="/">home</a></li>
|
||||||
|
<li><a href="/admin">admin</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
<li class="submenu">
|
<li class="submenu">
|
||||||
<span class="header">all</span>
|
<span class="header">all</span>
|
||||||
<ul>
|
<ul>
|
||||||
@ -772,7 +790,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 }}{{ .Name }}{{ end }}</td>
|
<td>{{ if ne $current .Name }}{{ $current = .Name }}<a href="/checks?group_id={{ .NodeId }}">{{ .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