Module: check_mk
Branch: master
Commit: ed701a11f021c9aab85ce989f94c62a825c4cf35
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ed701a11f021c9…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed Nov 30 11:12:45 2016 +0100
fixed filter
---
web/htdocs/htmllib.py | 4 +++-
web/plugins/visuals/filters.py | 17 ++++++++++-------
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 97e6c0b..d8ccdc7 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -1846,7 +1846,9 @@ class html(DeprecationWrapper):
self.form_vars.append(varname)
- def sorted_select(self, varname, choices, deflt="", onchange=None, attrs =
{}):
+ def sorted_select(self, varname, choices, deflt="", onchange=None, attrs =
None):
+ if attrs is None:
+ attrs = {}
# Sort according to display texts, not keys
sorted = choices[:]
sorted.sort(lambda a,b: cmp(a[1].lower(), b[1].lower()))
diff --git a/web/plugins/visuals/filters.py b/web/plugins/visuals/filters.py
index be1771e..60a9d3c 100644
--- a/web/plugins/visuals/filters.py
+++ b/web/plugins/visuals/filters.py
@@ -1218,15 +1218,18 @@ declare_filter(302, FilterHostAuxTags())
# choices = [ (value, "readable"), .. ]
class FilterCustomVarChoice(Filter):
def __init__(self, name, title, info, custom_var, choices):
- Filter.__init__(self, name, title, info, [ name ], [])
self.custom_var = custom_var
self.choices = choices
- self.lower_bound_varname = "%s_lower" % self.name
- self.upper_bound_varname = "%s_upper" % self.name
+ self.lower_bound_varname = "%s_lower" % name
+ self.upper_bound_varname = "%s_upper" % name
+
+ Filter.__init__( self, name, title, info,
+ [ self.lower_bound_varname,
+ self.upper_bound_varname, ], [] )
def _prepare_choices(self):
- return map( lambda x: ( x[0], "%s - %s" % (x[0], x[1]) ), self.choices
)
+ return map( lambda x: ( str(x[0]), "%s - %s" % (x[0], x[1]) ),
self.choices )
def display(self):
@@ -1242,14 +1245,14 @@ class FilterCustomVarChoice(Filter):
upper_bound = html.var(self.upper_bound_varname)
if lower_bound and upper_bound:
- filterline = "Filter: %s_custom_variable_names = %s\n" % \
+ filterline = "Filter: %s_custom_variable_names >= %s\n" % \
( self.info, self.custom_var )
filterline_values = []
for value, readable in self.choices:
if value >= int(lower_bound) and value <= int(upper_bound):
- filterline_values.append( "Filter: custom_variable_values >=
%s" % \
- lqencode(str(value)) )
+ filterline_values.append( "Filter: %s_custom_variable_values
>= %s" % \
+ (self.info, lqencode(str(value))) )
filterline += "%s\n" % "\n".join( filterline_values )
len_filterline_values = len(filterline_values)