Module: check_mk
Branch: master
Commit: 25df498cdf22c95e012a5a71bd6ce2f08a5a8a89
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=25df498cdf22c9…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Fri Jan 12 10:16:26 2018 +0100
5613 Auxiliary tags: New column 'Tags using this auxiliary tag' shows related tag
group
Change-Id: I418aa24fd1d440a672569a702b078461099291cb
---
.werks/5613 | 10 ++++++++++
web/htdocs/wato.py | 20 +++++++++++++++-----
2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/.werks/5613 b/.werks/5613
new file mode 100644
index 0000000..5cdf184
--- /dev/null
+++ b/.werks/5613
@@ -0,0 +1,10 @@
+Title: Auxiliary tags: New column 'Tags using this auxiliary tag' shows related
tag group
+Level: 1
+Component: multisite
+Compatible: compat
+Edition: cre
+Version: 1.5.0i3
+Date: 1515748506
+Class: feature
+
+
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 3e4fe68..ad7fd76 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -11749,6 +11749,7 @@ class ModeHostTags(WatoMode, watolib.HosttagsConfiguration):
def __init__(self):
super(ModeHostTags, self).__init__()
self._hosttags, self._auxtags = self._load_hosttags()
+ self._effective_tag_groups = watolib.get_effective_tag_groups(self._hosttags)
def title(self):
@@ -11877,13 +11878,11 @@ class ModeHostTags(WatoMode, watolib.HosttagsConfiguration):
empty_text = _("You haven't defined any tag groups
yet."),
searchable = False, sortable = False)
- tag_groups = watolib.get_effective_tag_groups(self._hosttags)
-
- if not tag_groups:
+ if not self._effective_tag_groups:
table.end()
return
- for nr, entry in enumerate(tag_groups):
+ for nr, entry in enumerate(self._effective_tag_groups):
tag_id, title, choices = entry[:3] # fourth: tag dependency information
topic, title = map(_u, watolib.parse_hosttag_title(title))
table.row()
@@ -11898,7 +11897,7 @@ class ModeHostTags(WatoMode, watolib.HosttagsConfiguration):
else:
html.icon_button(make_action_link([("mode",
"hosttags"), ("_move", str(-nr))]),
_("Move this tag group one position up"),
"up")
- if nr == len(tag_groups) - 1:
+ if nr == len(self._effective_tag_groups) - 1:
html.empty_icon_button()
else:
html.icon_button(make_action_link([("mode",
"hosttags"), ("_move", str(nr))]),
@@ -11948,9 +11947,20 @@ class ModeHostTags(WatoMode, watolib.HosttagsConfiguration):
table.text_cell(_("Title"), _u(title))
table.text_cell(_("Topic"), _u(topic) or '')
+ table.text_cell(_("Tags using this auxiliary tag"),
+ ",
".join(self._get_tags_using_aux_tag(self._effective_tag_groups, tag_id)))
table.end()
+ def _get_tags_using_aux_tag(self, tag_groups, aux_tag):
+ used_tags = set()
+ for tag_def in tag_groups:
+ for entry in tag_def[2]:
+ if aux_tag in entry[-1]:
+ used_tags.add(tag_def[1].split("/")[-1])
+ return sorted(used_tags)
+
+
class ModeEditHosttagConfiguration(WatoMode):
def __init__(self):