Module: check_mk
Branch: master
Commit: 76d8095cb399144fe1c10444314c6e596d478000
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=76d8095cb39914…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Jul 17 11:21:47 2017 +0200
View editor: Prefix painter/sorter choices with related info titles
Change-Id: Id69407125a6af2146579c3a5159cdf135d3e1629
---
web/htdocs/views.py | 30 +++++++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 4ca2962..934bd6a 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -1215,7 +1215,7 @@ def view_editor_specs(ds_name, general_properties=True):
elements = [
DropdownChoice(
title = _('Column'),
- choices = [ (name, p["title"]) for name, p
+ choices = [ (name, get_painter_title_for_choices(p)) for
name, p
in sorters_of_datasource(ds_name).items() ],
sorted = True,
no_preselect = True,
@@ -2411,13 +2411,20 @@ def allowed_for_datasource(collection, datasourcename):
allowed = {}
for name, item in collection.items():
- columns = get_painter_columns(item)
- infos_needed = set([ c.split("_", 1)[0] for c in columns if c !=
"site" and c not in add_columns])
+ infos_needed = infos_needed_by_painter(item, add_columns)
if len(infos_needed.difference(infos_available)) == 0:
allowed[name] = item
return allowed
+def infos_needed_by_painter(painter, add_columns=None):
+ if add_columns is None:
+ add_columns = []
+
+ columns = get_painter_columns(painter)
+ return set([ c.split("_", 1)[0] for c in columns if c != "site"
and c not in add_columns])
+
+
# Returns either the valuespec of the painter parameters or None
def get_painter_params_valuespec(painter):
if "params" not in painter:
@@ -2433,16 +2440,29 @@ def painter_choices(painters, add_params=False):
choices = []
for name, painter in painters.items():
+ title = get_painter_title_for_choices(painter)
+
# Add the optional valuespec for painter parameters
if add_params and "params" in painter:
vs_params = get_painter_params_valuespec(painter)
- choices.append((name, painter["title"], vs_params))
+ choices.append((name, title, vs_params))
else:
- choices.append((name, painter["title"]))
+ choices.append((name, title))
return sorted(choices, key=lambda x: x[1])
+def get_painter_title_for_choices(painter):
+ info_title = "/".join([ visuals.infos[info_name]["title_plural"]
for info_name
+ in sorted(infos_needed_by_painter(painter)) ])
+
+ # TODO: Cleanup the special case for sites. How? Add an info for it?
+ if painter["columns"] == ["site"]:
+ info_title = _("Site")
+
+ return "%s: %s" % (info_title, painter["title"])
+
+
def painter_choices_with_params(painters):
return painter_choices(painters, add_params=True)