aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/monfront/filter.go21
-rw-r--r--cmd/monfront/templates/checkfilter.html7
2 files changed, 28 insertions, 0 deletions
diff --git a/cmd/monfront/filter.go b/cmd/monfront/filter.go
index bd82c91..968cb36 100644
--- a/cmd/monfront/filter.go
+++ b/cmd/monfront/filter.go
@@ -64,6 +64,18 @@ func (f *filter) filterChecks(c *Context) {
}
f.Add("ac.mapping_id", "=", val[0], "int")
f.Vals[arg] = val[0]
+ case "mute":
+ if val[0] == "" {
+ continue
+ }
+ isNull := false
+ if val[0] == "true" {
+ isNull = true
+ f.Vals[arg] = "true"
+ } else if val[0] == "false" {
+ f.Vals[arg] = "false"
+ }
+ f.AddNull("cn.check_id", isNull)
}
}
}
@@ -75,6 +87,14 @@ func (f *filter) Add(field, op string, arg interface{}, castTo string) {
f.params = append(f.params, arg)
}
+func (f *filter) AddNull(field string, isNull bool) {
+ check := "is not null"
+ if isNull {
+ check = "is null"
+ }
+ f.where = append(f.where, fmt.Sprintf("%s %s", field, check))
+}
+
// AddSpecial lets you add a special where clause comparison where you can
// wrap the argument in whatevery you like.
//
@@ -82,6 +102,7 @@ func (f *filter) Add(field, op string, arg interface{}, castTo string) {
// in the query string.
//
// Example:
+//
// AddSpecial("foo", "=", "to_tsvector('english', $%d), search)
func (f *filter) AddSpecial(field, op, special string, arg interface{}) {
f.idx += 1
diff --git a/cmd/monfront/templates/checkfilter.html b/cmd/monfront/templates/checkfilter.html
index f86ce3c..f04427b 100644
--- a/cmd/monfront/templates/checkfilter.html
+++ b/cmd/monfront/templates/checkfilter.html
@@ -39,6 +39,13 @@
</select>
</div>
<div class="option">
+ <select id="filter-mute" name="filter-mute">
+ <option value="">filter muted</option>
+ <option value="true" {{ if eq "true" (index .Filter.Vals "mute") }}selected{{ end }}>muted</option>
+ <option value="false" {{ if eq "false" (index .Filter.Vals "mute") }}selected{{ end }}>unmuted</option>
+ </select>
+ </div>
+ <div class="option">
<input name="filter-search" placeholder="hostname" value="{{ .Filter.Vals.search }}" />
</div>
<div class="option">