monfront - make fake groups in frontend

It would have been nice to use rowgrouping for the node name, but
somehow it wasn't easy to get the rowcount. So this should do for now.
This commit is contained in:
Gibheer 2018-12-10 09:34:45 +01:00
parent 40e744cd6a
commit 6c2bea5365

View File

@ -172,7 +172,9 @@ func showChecks(w http.ResponseWriter, r *http.Request) {
} }
checks = append(checks, c) checks = append(checks, c)
} }
tmpl, err := template.New("checklist").Parse(TmplCheckList) tmpl := template.New("checklist")
tmpl.Funcs(Funcs)
tmpl, err = tmpl.Parse(TmplCheckList)
if err != nil { if err != nil {
w.WriteHeader(http.StatusInternalServerError) w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte("problems with a template")) w.Write([]byte("problems with a template"))
@ -318,10 +320,11 @@ var (
<table> <table>
<thead><tr><th></th><th>host</th><th>status</th><th>next check</th><th>message</th></tr></thead> <thead><tr><th></th><th>host</th><th>status</th><th>next check</th><th>message</th></tr></thead>
<tbody> <tbody>
{{ $current := "" }}
{{ range . }} {{ range . }}
<tr> <tr>
<td><input type="checkbox" name="checks" value="{{ .CheckID }}" /></td> <td><input type="checkbox" name="checks" value="{{ .CheckID }}" /></td>
<td>{{ .NodeName }}</td> <td>{{ if ne $current .NodeName }}{{ $current = .NodeName }}{{ .NodeName }}{{ end }}</td>
<td class="state-{{ .State }}">{{ .CommandName }} - {{ .State }}</td> <td class="state-{{ .State }}">{{ .CommandName }} - {{ .State }}</td>
<td>{{ .NextTime.Format "2006.01.02 15:04:05" }}</td> <td>{{ .NextTime.Format "2006.01.02 15:04:05" }}</td>
<td><pre>{{ .Msg }}</pre></td> <td><pre>{{ .Msg }}</pre></td>
@ -334,4 +337,7 @@ var (
</body> </body>
</html>` </html>`
TmplUnhandledGroups = `TODO` TmplUnhandledGroups = `TODO`
Funcs = template.FuncMap{
"sub": func(base, amount int) int { return base - amount },
}
) )