within any rule configuration which can be used for visual recognition
Message-ID: <5a61e2a2.MdeedJfGKQ99lz3e%si(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.5 6/20/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: 966cc5a68374a5c77d1dc559188faa1a140a0813
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=966cc5a68374a5…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed Jan 10 10:10:45 2018 +0100
5611 BI rule: Icons can be added below 'Aggregation functions' within any rule
configuration which can be used for visual recognition
Change-Id: I79d2692eb7586c135e1dfd085b173e3c76eaa14c
---
.werks/5611 | 10 ++++++++++
web/htdocs/bi.py | 13 ++++++++++---
web/plugins/wato/bi.py | 14 +++++++++++---
3 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/.werks/5611 b/.werks/5611
new file mode 100644
index 0000000..97a89e9
--- /dev/null
+++ b/.werks/5611
@@ -0,0 +1,10 @@
+Title: BI rule: Icons can be added below 'Aggregation functions' within any rule
configuration which can be used for visual recognition
+Level: 1
+Component: bi
+Compatible: compat
+Edition: cre
+Version: 1.5.0i3
+Date: 1515575152
+Class: feature
+
+
diff --git a/web/htdocs/bi.py b/web/htdocs/bi.py
index 356a77c..56344b6 100644
--- a/web/htdocs/bi.py
+++ b/web/htdocs/bi.py
@@ -1966,6 +1966,7 @@ def compile_aggregation_rule(aggr_type, rule, args, lvl):
nodes = rule.get("nodes", [])
state_messages = rule.get("state_messages")
docu_url = rule.get("docu_url")
+ icon = rule.get("icon")
if lvl == 50:
raise MKConfigError(_("<b>BI depth limit reached</b>: "
@@ -2076,6 +2077,9 @@ def compile_aggregation_rule(aggr_type, rule, args, lvl):
if docu_url:
aggregation["docu_url"] = docu_url
+ if icon:
+ aggregation["icon"] = icon
+
# Handle REMAINING references, if we are a root node
if lvl == 0:
for hostspec, ref, placeholder in g_remaining_refs:
@@ -2810,9 +2814,9 @@ def compute_output_message(effective_state, rule):
str_state = str(effective_state["state"])
if str_state in rule.get("state_messages", {}):
output.append(html.attrencode(rule["state_messages"][str_state]))
-
return ", ".join(output)
+
def render_tree_json(row):
expansion_level = int(html.var("expansion_level", 999))
@@ -3073,6 +3077,8 @@ 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('icon'):
+ html.write(html.render_icon(tree[2]['icon']))
if tree[2].get("docu_url"):
html.icon_button(tree[2]["docu_url"], _("Context
information about this rule"),
"url", target="_blank")
@@ -3678,12 +3684,13 @@ def _convert_legacy_aggregation_rule(rule):
# Since version 1.4.0b4
# - werk 4460 introduced 'state_messages'.
# Since version 1.5.0i3
- # - werk 5617 introduced 'docu_url'
+ # - werk 5617 introduced 'docu_url' and
+ # - werk introduced 'icon'.
# 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", "docu_url"], rule))
+ "state_messages", "docu_url",
"icon"], rule))
raise MKConfigError(_("<b>Invalid BI aggregation rule</b>: "
"Aggregation rules must contain at least four elements:
"
diff --git a/web/plugins/wato/bi.py b/web/plugins/wato/bi.py
index ecc1324..5d578e5 100644
--- a/web/plugins/wato/bi.py
+++ b/web/plugins/wato/bi.py
@@ -1393,7 +1393,13 @@ class ModeBIRules(ModeBI):
table.text_cell(_("Level"), level or "",
css="number")
table.text_cell(_("ID"), html.render_a(rule_id, edit_url))
table.text_cell(_("Parameters"), "
".join(rule["params"]))
- table.text_cell(_("Title"), rule["title"])
+
+ if rule.get('icon'):
+ title = html.render_icon(rule["icon"]) +
rule["title"]
+ else:
+ title = rule["title"]
+ table.text_cell(_("Title"), title)
+
table.text_cell(_("Aggregation"),
"/".join([rule["aggregation"][0]] + map(str,
rule["aggregation"][1])))
table.text_cell(_("Nodes"), len(rule["nodes"]),
css="number")
table.cell(_("Used by"))
@@ -1405,6 +1411,7 @@ class ModeBIRules(ModeBI):
html.a(self.aggregation_title(aggregation), href=aggr_url)
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()
@@ -1801,7 +1808,8 @@ class ModeBIEditRule(ModeBI):
"check plugins."),
label = _("Add messages")
)
- )
+ ),
+ ("icon", IconSelector(title=_("Icon"))),
]
return Dictionary(
@@ -1812,7 +1820,7 @@ class ModeBIEditRule(ModeBI):
headers = [
( _("Rule Properties"), [ "id",
"title", "docu_url", "comment", "params",
"disabled" ]),
( _("Child Node Generation"), [ "nodes" ] ),
- ( _("Aggregation Function"), [ "aggregation",
"state_messages" ], ),
+ ( _("Aggregation Function"), [ "aggregation",
"state_messages", "icon" ], ),
]
)