Module: check_mk
Branch: master
Commit: 1dd9b283dbd43ee85217ac2b35ee125c54b02a58
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1dd9b283dbd43e…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Sep 27 13:51:47 2018 +0200
6726 FIX Fixed duplicate view names in "link to" dropdown in view editor
When editing the view a painter should link to, the list contained some
duplicate names. The user often had to trial and error to select the
correct view. The titles now contain a category prefix and also include
the internal view ID which is used to identify the views.
Change-Id: I7db892e46eda415e4d3a9c1632533b1430c91909
---
.werks/6726 | 14 ++++++++++++++
cmk/gui/views.py | 36 ++++++++++++++++++++++++++++++------
2 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/.werks/6726 b/.werks/6726
new file mode 100644
index 0000000..35d0ed9
--- /dev/null
+++ b/.werks/6726
@@ -0,0 +1,14 @@
+Title: Fixed duplicate view names in "link to" dropdown in view editor
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1538048999
+
+When editing the view a painter should link to, the list contained some
+duplicate names. The user often had to trial and error to select the
+correct view. The titles now contain a category prefix and also include
+the internal view ID which is used to identify the views.
diff --git a/cmk/gui/views.py b/cmk/gui/views.py
index 6067a10..5de3ca9 100644
--- a/cmk/gui/views.py
+++ b/cmk/gui/views.py
@@ -163,7 +163,7 @@ def load_plugins(force):
config.declare_permission_section("view", _("Multisite Views"), do_sort = True)
for name, view in multisite_builtin_views.items():
config.declare_permission("view.%s" % name,
- format_view_title(view),
+ format_view_title(name, view),
"%s - %s" % (name, _u(view["description"])),
config.builtin_role_ids)
@@ -383,15 +383,39 @@ def view_choices(only_with_hidden = False):
choices = [("", "")]
for name, view in available_views.items():
if not only_with_hidden or view['single_infos']:
- title = format_view_title(view)
+ title = format_view_title(name, view)
choices.append(("%s" % name, title))
return choices
-def format_view_title(view):
+def format_view_title(name, view):
+ title_parts = []
+
if view.get('mobile', False):
- return _('Mobile: ') + _u(view["title"])
- else:
- return _u(view["title"])
+ title_parts.append(_('Mobile'))
+
+ # Don't use the data source title because it does not really look good here
+ datasource = multisite_datasources[view["datasource"]]
+ infos = datasource["infos"]
+ if "event" in infos:
+ title_parts.append(_("Event Console"))
+ elif view["datasource"].startswith("inv"):
+ title_parts.append(_("HW/SW inventory"))
+ elif "aggr" in infos:
+ title_parts.append(_("BI"))
+ elif "log" in infos:
+ title_parts.append(_("Log"))
+ elif "service" in infos:
+ title_parts.append(_("Services"))
+ elif "host" in infos:
+ title_parts.append(_("Hosts"))
+ elif "hostgroup" in infos:
+ title_parts.append(_("Hostgroups"))
+ elif "servicegroup" in infos:
+ title_parts.append(_("Servicegroups"))
+
+ title_parts.append("%s (%s)" % (_u(view["title"]), name))
+
+ return " - ".join(title_parts)
def view_editor_options():
return [