Module: check_mk
Branch: master
Commit: 1a5da1b1bd347a238a36a5a1faac040c41522df8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1a5da1b1bd347a…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Mon Mar 12 17:24:07 2018 +0100
5750 Add negate button to the Host Auxiliary Tags filter
Change-Id: I31974318e3349e2ce27f7ab8620f97b7574aa3a3
---
.werks/5750 | 10 ++++++++++
web/htdocs/views.css | 2 ++
web/plugins/visuals/filters.py | 19 +++++++++++++------
3 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/.werks/5750 b/.werks/5750
new file mode 100644
index 0000000..e319366
--- /dev/null
+++ b/.werks/5750
@@ -0,0 +1,10 @@
+Title: Add negate button to the Host Auxiliary Tags filter
+Level: 1
+Component: multisite
+Compatible: compat
+Edition: cre
+Version: 1.5.0i4
+Date: 1520871739
+Class: feature
+
+
diff --git a/web/htdocs/views.css b/web/htdocs/views.css
index 3669055..3614dc0 100644
--- a/web/htdocs/views.css
+++ b/web/htdocs/views.css
@@ -116,6 +116,8 @@ div.floatfilter.double .content {
div.floatfilter .content > select {
width: 300px;
}
+
+div.floatfilter .content > select.neg,
div.floatfilter .content > select#opthost_group,
div.floatfilter .content > select#optservice_contact_group,
div.floatfilter .content > select#opthost_contact_group,
diff --git a/web/plugins/visuals/filters.py b/web/plugins/visuals/filters.py
index 3002855..dd63735 100644
--- a/web/plugins/visuals/filters.py
+++ b/web/plugins/visuals/filters.py
@@ -1194,8 +1194,10 @@ class FilterHostAuxTags(Filter):
def __init__(self):
self.count = 3
self.prefix = 'host_auxtags'
- htmlvars = [ "%s_%d" % (self.prefix, num)
- for num in range(self.count) ]
+ htmlvars = []
+ for num in range(self.count):
+ htmlvars.append("%s_%d" % (self.prefix, num))
+ htmlvars.append("%s_%d_neg" % (self.prefix, num))
Filter.__init__(self,
name = 'host_auxtags',
@@ -1211,11 +1213,14 @@ class FilterHostAuxTags(Filter):
def display(self):
selection = []
for num in range(self.count):
- html.dropdown('%s_%d' % (self.prefix, num), [("",
"")] + self.auxtags, sorted=True)
+ html.dropdown('%s_%d' % (self.prefix, num), [("",
"")] + self.auxtags, sorted=True, class_='neg')
+ html.open_nobr()
+ html.checkbox('%s_%d_neg' % (self.prefix, num), False,
label=_("negate"))
+ html.close_nobr()
- def host_auxtags_filter(self, tag):
- return "Filter: host_custom_variables ~ TAGS (^|[ ])%s($|[ ])" %
lqencode(tag)
+ def host_auxtags_filter(self, tag, negate):
+ return "Filter: host_custom_variables %s~ TAGS (^|[ ])%s($|[ ])" %
(negate, lqencode(tag))
def filter(self, infoname):
@@ -1227,7 +1232,9 @@ class FilterHostAuxTags(Filter):
while html.has_var( '%s_%d' % (self.prefix, num) ):
this_tag = html.var( '%s_%d' % (self.prefix, num) )
if this_tag:
- headers.append( self.host_auxtags_filter( this_tag ) )
+ negate = ("!" if html.get_checkbox('%s_%d_neg' %
(self.prefix, num))
+ else "")
+ headers.append(self.host_auxtags_filter(this_tag, negate))
num += 1
if headers: