Module: check_mk
Branch: master
Commit: e797583e48b624691fd5322057150044466e4ce6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e797583e48b624…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Apr 21 15:06:30 2011 +0200
BI: handle new flag HIDDEN
---
web/htdocs/bi.py | 8 +++++---
web/plugins/views/bi.py | 12 ++++++------
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/web/htdocs/bi.py b/web/htdocs/bi.py
index 61b1445..fae5fba 100644
--- a/web/htdocs/bi.py
+++ b/web/htdocs/bi.py
@@ -65,7 +65,7 @@ SITE_SEP = '#'
# "host" : host spec for leaf node,
# "service" : service name for leaf node, missing if HOST_STATE
# "title" : title in case of rule nodes
-# "hide" : True if hidden
+# "hidden" : True if hidden
# "func" : Name of aggregation function for rule nodes
# "nodes" : List of subnodes for rule nodes
# }
@@ -311,11 +311,13 @@ def render_forest():
def render_tree(node, indent = ""):
h = ""
if node["type"] == NT_LEAF: # leaf node
- h += indent + "S/H/S: %s/%s/%s\n" % (node["host"][0],
node["host"][1], node.get("service"))
+ h += indent + "S/H/S: %s/%s/%s%s\n" % (node["host"][0],
node["host"][1], node.get("service"),
+ node.get("hidden") == True and " (hidden)" or
"")
else:
h += indent + "Aggregation:\n"
indent += " "
h += indent + "Description: %s\n" % node["title"]
+ h += indent + "Hidden: %s\n" % (node.get("hidden") ==
True and "yes" or "no")
h += indent + "Needed Hosts: %s\n" % "
".join([("%s/%s" % h_s) for h_s in node["reqhosts"]])
h += indent + "Aggregation: %s\n" % node["func"]
h += indent + "Nodes:\n"
@@ -450,7 +452,7 @@ def compile_aggregation_rule(rule, args, lvl = 0):
new_elements = compile_rule_node(rule_parts + (rule_args,), lvl + 1)
if hidden:
- for element in elements:
+ for element in new_elements:
element["hidden"] = True
elements += new_elements
diff --git a/web/plugins/views/bi.py b/web/plugins/views/bi.py
index a16edd0..868f7ad 100644
--- a/web/plugins/views/bi.py
+++ b/web/plugins/views/bi.py
@@ -219,6 +219,7 @@ def filter_tree_only_problems(tree):
return state, assumed_state, node, new_subtrees
+
def paint_aggr_tree_foldable(row):
saved_expansion_level, treestate = bi.load_treestate()
expansion_level = int(get_painter_option("aggr_expand"))
@@ -261,11 +262,9 @@ def paint_aggr_tree_foldable(row):
for node in tree[3]:
estate = node[1] != None and node[1] or node[0]
- if "title" not in node[2]:
- html.write("%r"%(node,))
-
- new_path = path + [node[2]["title"]]
- h += '<li>' + render_subtree(node, new_path, show_host)
+ '</li>\n'
+ if not node[2].get("hidden"):
+ new_path = path + [node[2]["title"]]
+ h += '<li>' + render_subtree(node, new_path,
show_host) + '</li>\n'
h += '</ul>'
return h + '</span>\n'
@@ -298,7 +297,8 @@ def paint_aggr_tree_ltr(row, mirror):
def gen_node(tree, height, show_host):
leaves = []
for node in tree[3]:
- leaves += gen_table(node, height - 1, show_host)
+ if not node[2].get("hidden"):
+ leaves += gen_table(node, height - 1, show_host)
h = '<div class="aggr tree">' + aggr_render_node(tree,
tree[2]["title"], '', show_host) + "</div>"
if leaves:
leaves[0][2].append((len(leaves), h))