Module: check_mk
Branch: master
Commit: a0cafd2a87fb90a7b64419b5607dc58d73e36a65
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a0cafd2a87fb90…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed Jan 17 11:48:15 2018 +0100
5617 BI rule: Documentation-URL is configurable within 'Rule Properties'
Change-Id: I36f6cad69cd345111476145e12f72eb08a01c9b0
---
.werks/5617 | 10 ++++++++++
web/htdocs/bi.py | 13 ++++++++++++-
web/htdocs/wato.py | 2 +-
web/plugins/wato/bi.py | 12 ++++++++++++
4 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/.werks/5617 b/.werks/5617
new file mode 100644
index 0000000..79f9ff0
--- /dev/null
+++ b/.werks/5617
@@ -0,0 +1,10 @@
+Title: BI rule: Documentation-URL is configurable within 'Rule Properties'
+Level: 1
+Component: bi
+Compatible: compat
+Edition: cre
+Version: 1.5.0i3
+Date: 1516046491
+Class: feature
+
+
diff --git a/web/htdocs/bi.py b/web/htdocs/bi.py
index 73e2864..356a77c 100644
--- a/web/htdocs/bi.py
+++ b/web/htdocs/bi.py
@@ -1965,6 +1965,7 @@ def compile_aggregation_rule(aggr_type, rule, args, lvl):
funcname = rule.get("aggregation", "worst")
nodes = rule.get("nodes", [])
state_messages = rule.get("state_messages")
+ docu_url = rule.get("docu_url")
if lvl == 50:
raise MKConfigError(_("<b>BI depth limit reached</b>: "
@@ -2072,6 +2073,9 @@ def compile_aggregation_rule(aggr_type, rule, args, lvl):
if state_messages:
aggregation["state_messages"] = state_messages
+ if docu_url:
+ aggregation["docu_url"] = docu_url
+
# Handle REMAINING references, if we are a root node
if lvl == 0:
for hostspec, ref, placeholder in g_remaining_refs:
@@ -3069,6 +3073,10 @@ class FoldableTreeRendererTree(FoldableTreeRenderer):
css_class = "open" if self._is_open(path) else "closed"
with self._show_node(tree, show_host, mousecode=mc, img_class=css_class):
+ if tree[2].get("docu_url"):
+ html.icon_button(tree[2]["docu_url"], _("Context
information about this rule"),
+ "url", target="_blank")
+ html.write(" ")
html.write_text(tree[2]["title"])
if not is_empty:
@@ -3669,10 +3677,13 @@ def _convert_legacy_aggregation_rule(rule):
# Rule has at least four entries.
# Since version 1.4.0b4
# - werk 4460 introduced 'state_messages'.
+ # Since version 1.5.0i3
+ # - werk 5617 introduced 'docu_url'
# zip function:
# The returned list is truncated in length to the length of the
# shortest argument sequence.
- return dict(zip(["title", "params", "aggregation",
"nodes", "state_messages"], rule))
+ return dict(zip(["title", "params", "aggregation",
"nodes",
+ "state_messages", "docu_url"], rule))
raise MKConfigError(_("<b>Invalid BI aggregation rule</b>: "
"Aggregation rules must contain at least four elements:
"
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index ad7fd76..4982c96 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -17348,7 +17348,7 @@ def rule_option_elements(disabling=True):
( "comment", RuleComment()),
( "docu_url",
TextAscii(
- title = _("Documentation-URL"),
+ title = _("Documentation URL"),
help = HTML(_("An optional URL pointing to documentation or any other
page. This will be displayed "
"as an icon <img class=icon
src='images/button_url.png'> and open a new page when clicked. "
"You can use either global URLs (beginning with
<tt>http://</tt>), absolute local urls "
diff --git a/web/plugins/wato/bi.py b/web/plugins/wato/bi.py
index 048918c..ecc1324 100644
--- a/web/plugins/wato/bi.py
+++ b/web/plugins/wato/bi.py
@@ -1406,6 +1406,7 @@ class ModeBIRules(ModeBI):
html.br()
have_this.add(aggr_id)
table.text_cell(_("Comment"), rule.get("comment",
""))
+ table.text_cell(_("Documentation URL"),
rule.get("docu_url", ""))
table.end()
@@ -1727,6 +1728,17 @@ class ModeBIEditRule(ModeBI):
rows = 4,
),
),
+ ( "docu_url",
+ TextAscii(
+ title = _("Documentation URL"),
+ help = HTML(_("An optional URL pointing to documentation or any
other page. This will be "
+ "displayed as an icon <img class=icon
src='images/button_url.png'> and open "
+ "a new page when clicked. You can use either global
URLs (beginning with "
+ "<tt>http://</tt>), absolute local urls
(beginning with <tt>/</tt>) or relative "
+ "URLs (that are relative to
<tt>check_mk/</tt>).")),
+ size = 80,
+ ),
+ ),
( "params",
ListOfStrings(
title = _("Parameters"),