Module: check_mk
Branch: master
Commit: e3a53d31121eb0ea4fa61ac77f6b45e0165db1e0
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e3a53d31121eb0…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Fri Nov 25 15:45:08 2016 +0100
4095 new filter host auxiliary tags
---
.werks/4095 | 9 +++++++
ChangeLog | 1 +
web/plugins/visuals/filters.py | 57 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 67 insertions(+)
diff --git a/.werks/4095 b/.werks/4095
new file mode 100644
index 0000000..71087e0
--- /dev/null
+++ b/.werks/4095
@@ -0,0 +1,9 @@
+Title: new filter host auxiliary tags
+Level: 1
+Component: multisite
+Compatible: compat
+Version: 1.4.0i3
+Date: 1480085074
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index a023526..fe41b15 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -30,6 +30,7 @@
Multisite:
* 4070 Added a painter for the service check period
+ * 4095 new filter host auxiliary tags
* 3974 FIX: Sorting comments in hover menu of comments icon by time now
* 4040 FIX: Fix error in view about "No WATO folder ..." in case of host
imported via cmcdump...
* 4046 FIX: Repaired html rendering....
diff --git a/web/plugins/visuals/filters.py b/web/plugins/visuals/filters.py
index 23c685d..f360a17 100644
--- a/web/plugins/visuals/filters.py
+++ b/web/plugins/visuals/filters.py
@@ -1158,6 +1158,63 @@ class FilterHostTags(Filter):
declare_filter(302, FilterHostTags())
+
+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) ]
+
+ Filter.__init__(self,
+ name = 'host_auxtags',
+ title = _('Host Auxiliary Tags'),
+ info = 'host',
+ htmlvars = htmlvars,
+ link_columns = []
+ )
+
+ self.auxtags = config.wato_aux_tags
+
+
+ def display(self):
+ selection = []
+ for num in range(self.count):
+ html.sorted_select( '%s_%d' % (self.prefix, num),
+ [("", "")] + self.auxtags )
+
+
+ def host_auxtags_filter(self, tag):
+ return "Filter: custom_variables ~ TAGS (^|[ ])%s($|[ ])" %
lqencode(tag)
+
+
+ def filter(self, infoname):
+ headers = []
+
+ # Do not restrict to a certain number, because we'd like to link to this
+ # via an URL, e.g. from the virtual host tree snapin
+ num = 0
+ 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 ) )
+ num += 1
+
+ if headers:
+ return '\n'.join(headers) + '\n'
+ else:
+ return ''
+
+
+ def double_height(self):
+ return True
+
+
+
+declare_filter(302, FilterHostAuxTags())
+
+
+
class FilterStarred(FilterTristate):
def __init__(self, what):
self.what = what