Module: check_mk
Branch: master
Commit: 2b1a933a8cff293b6e4f2e43b8950b4c2af524fb
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2b1a933a8cff29…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Thu Sep 14 14:13:02 2017 +0200
5119 BI rules: 'Call a rule' in 'Child Node Generation' shows separated
pack and rule title
Change-Id: Ia078fa75c5c4cc9ab4d38a1ef24e7bffe636624b
---
.werks/5119 | 12 ++++++++++++
web/plugins/wato/bi.py | 30 ++++++++++++++++++++++--------
2 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/.werks/5119 b/.werks/5119
new file mode 100644
index 0000000..1418e5d
--- /dev/null
+++ b/.werks/5119
@@ -0,0 +1,12 @@
+Title: BI rules: 'Call a rule' in 'Child Node Generation' shows separated
pack and rule title
+Level: 1
+Component: bi
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1503597775
+Class: feature
+
+Previously within the above mentioned choices rule ID,
+pack title and rule title were merged into one.
+Separated them for better overview.
diff --git a/web/plugins/wato/bi.py b/web/plugins/wato/bi.py
index 9118c91..b2e1f60 100644
--- a/web/plugins/wato/bi.py
+++ b/web/plugins/wato/bi.py
@@ -66,7 +66,6 @@ class ModeBI(WatoMode):
self._user_contactgroups = userdb.contactgroups_of_user(config.user.id)
else:
self._user_contactgroups = None # meaning I am admin
- self._create_valuespecs()
# Most modes need a pack as context
if html.has_var("pack"):
@@ -78,6 +77,8 @@ class ModeBI(WatoMode):
self._pack_id = None
self._pack = None
+ self._create_valuespecs()
+
def title(self):
title = _("Business Intelligence")
@@ -390,10 +391,10 @@ class ModeBI(WatoMode):
def _allowed_rule_choices(self):
choices = []
- for pack_id, pack in sorted(self._packs.items()):
+ for pack_id, pack in sorted(self._packs.iteritems()):
if self.may_use_rules_in_pack(pack):
- for rule_id, rule in sorted(pack["rules"].items()):
- choices.append((rule_id, "%s - %s/%s" % (rule_id,
pack["title"], rule["title"])))
+ pack_choices = [(rule_id, rule["title"]) for rule_id, rule in
pack["rules"].iteritems()]
+ choices.append((pack_id, pack["title"],
DropdownChoice(choices=sorted(pack_choices))))
return choices
@@ -437,10 +438,14 @@ class ModeBI(WatoMode):
def _get_vs_call_rule(self):
return Tuple(
elements = [
- DropdownChoice(
- title = _("Rule:"),
- choices = self._allowed_rule_choices(),
- sorted = True,
+ Transform(CascadingDropdown(
+ title=_("Rule:"),
+ orientation="horizontal",
+ choices=self._allowed_rule_choices(),
+ sorted=True,
+ ),
+ back=self._transform_back_vs_call_rule,
+ forth=self._transform_forth_vs_call_rule,
),
ListOfStrings(
orientation = "horizontal",
@@ -452,6 +457,15 @@ class ModeBI(WatoMode):
)
+ def _transform_back_vs_call_rule(self, choice):
+ return choice[1]
+
+
+ def _transform_forth_vs_call_rule(self, choice):
+ pack = self.pack_containing_rule(choice)
+ return (pack['id'], choice)
+
+
def _get_vs_host_re(self):
host_re_help = _("Either an exact host name or a regular expression exactly
matching the host "
"name. Example: <tt>srv.*p</tt> will match
<tt>srv4711p</tt> but not <tt>xsrv4711p2</tt>. ")