Module: check_mk
Branch: master
Commit: 734a4992ed1442a5d5a92bf42aa618bbd9939228
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=734a4992ed1442…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Tue Jun 28 11:11:45 2016 +0200
3148 FIX fixed Edit View/Dashlet Dialogs offering non-sensical filter choices
This is actually two separate but similar bugfixes:
When editing a dashlet that represented a view, the search/context filter offered all
possible
filter choices even when they made no sense for the data visualised.
Also, when editing a aggregation group view (and potentially other views), the filter
list
offered the same filter option (aggregation group) twice, with different semantics,
causing
exceptions if either one of these options was used.
---
.werks/3148 | 15 +++++++++++
ChangeLog | 1 +
web/htdocs/dashboard.py | 10 +++++--
web/htdocs/visuals.py | 69 ++++++++++++++++++++++++-----------------------
4 files changed, 60 insertions(+), 35 deletions(-)
diff --git a/.werks/3148 b/.werks/3148
new file mode 100644
index 0000000..d23da64
--- /dev/null
+++ b/.werks/3148
@@ -0,0 +1,15 @@
+Title: fixed Edit View/Dashlet Dialogs offering non-sensical filter choices
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.4.0i1
+Date: 1467104831
+
+This is actually two separate but similar bugfixes:
+When editing a dashlet that represented a view, the search/context filter offered all
possible
+filter choices even when they made no sense for the data visualised.
+Also, when editing a aggregation group view (and potentially other views), the filter
list
+offered the same filter option (aggregation group) twice, with different semantics,
causing
+exceptions if either one of these options was used.
diff --git a/ChangeLog b/ChangeLog
index a757976..aec3261 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -368,6 +368,7 @@
* 3627 FIX: fixed double graphs of database size
* 3586 FIX: Fixed file locking issues (rare and random errors that settings file
could not be loaded)
* 2239 FIX: Fixed exception in WATO snapins Folders, Tree of folders and Virtual Host
Tree...
+ * 3148 FIX: fixed Edit View/Dashlet Dialogs offering non-sensical filter choices...
WATO:
* 3244 WATO BI Module: swap order of aggregation function and child node
selection...
diff --git a/web/htdocs/dashboard.py b/web/htdocs/dashboard.py
index 06f3fec..76a5628 100644
--- a/web/htdocs/dashboard.py
+++ b/web/htdocs/dashboard.py
@@ -1055,8 +1055,14 @@ def page_edit_dashlet():
],
)
- context_specs = visuals.get_context_specs(dashlet,
- info_handler=lambda dashlet:
dashlet_types[dashlet['type']].get('infos'))
+ def dashlet_info_handler(dashlet):
+ if dashlet['type'] == 'view':
+ import views
+ return views.get_view_infos(dashlet)
+ else:
+ return dashlet_types[dashlet['type']].get('infos')
+
+ context_specs = visuals.get_context_specs(dashlet,
info_handler=dashlet_info_handler)
vs_type = None
params = dashlet_type.get('parameters')
diff --git a/web/htdocs/visuals.py b/web/htdocs/visuals.py
index 911b110..b21e795 100644
--- a/web/htdocs/visuals.py
+++ b/web/htdocs/visuals.py
@@ -497,43 +497,44 @@ def page_create_visual(what, info_keys, next_url = None):
def get_context_specs(visual, info_handler):
context_specs = []
info_keys = info_handler and info_handler(visual) or infos.keys()
- for info_key in info_keys:
- info = infos[info_key]
- if info_key in visual['single_infos']:
- params = info['single_spec']
- optional = True
- isopen = True
- vs = Dictionary(
- title = info['title'],
- # render = 'form',
- form_isopen = isopen,
- optional_keys = optional,
- elements = params,
- )
- else:
- filter_list = VisualFilterList([info_key], title=info['title'])
- filter_names = filter_list.filter_names()
+ single_info_keys = [key for key in info_keys if key in
visual['single_infos']]
+ multi_info_keys = [key for key in info_keys if key not in single_info_keys]
+
+ def visual_spec_single(info_key):
+ info = infos[info_key]
+ params = info['single_spec']
+ optional = True
+ isopen = True
+ return Dictionary(
+ title = info['title'],
+ # render = 'form',
+ form_isopen = isopen,
+ optional_keys = optional,
+ elements = params,
+ )
+
+ def visual_spec_multi(info_key):
+ info = infos[info_key]
+ filter_list = VisualFilterList([info_key], title=info['title'],
ignore=set(single_info_keys))
+ filter_names = filter_list.filter_names()
- if not filter_names:
- continue # Skip infos which have no filters available
+ if not filter_names:
+ return [] # Skip infos which have no filters available
- params = [
- ('filters', filter_list),
- ]
- optional = None
- # Make it open by default when at least one filter is used
- isopen = bool([ fn for fn in visual.get('context', {}).keys()
- if fn in filter_names ])
- vs = filter_list
+ params = [
+ ('filters', filter_list),
+ ]
+ optional = None
+ # Make it open by default when at least one filter is used
+ isopen = bool([ fn for fn in visual.get('context', {}).keys()
+ if fn in filter_names ])
+ return filter_list
+ # single infos first, the rest afterwards
+ return [(info_key, visual_spec_single(info_key)) for info_key in single_info_keys]
+\
+ [(info_key, visual_spec_multi(info_key)) for info_key in multi_info_keys]
- # Single info context specifications should be listed first
- if info_key in visual['single_infos']:
- context_specs.insert(0, (info_key, vs))
- else:
- context_specs.append((info_key, vs))
- return context_specs
def process_context_specs(context_specs):
context = {}
@@ -1116,13 +1117,15 @@ class VisualFilterList(ListOfMultiple):
def __init__(self, infos, **kwargs):
self._infos = infos
+ ignore = kwargs.get("ignore", set())
+
# First get all filters useful for the infos, then create VisualFilter
# valuespecs from them and then sort them
fspecs = {}
self._filters = {}
for info in self._infos:
for fname, filter in filters_allowed_for_info(info).items():
- if fname not in fspecs:
+ if fname not in fspecs and fname not in ignore:
fspecs[fname] = VisualFilter(fname,
title = filter.title,
)