Module: check_mk
Branch: master
Commit: 64bbe4e8c0ed681c11512baed503c0b3c861788c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=64bbe4e8c0ed68…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Sep 2 16:32:08 2016 +0200
Cleaned up tree folding visualization of BI aggregations
---
web/htdocs/bi.css | 7 +------
web/htdocs/bi.py | 24 +++++++++++++-----------
web/htdocs/images/tree_black_90.png | Bin 333 -> 0 bytes
web/htdocs/js/checkmk.js | 15 ++++++++-------
web/plugins/views/bi.py | 3 ++-
5 files changed, 24 insertions(+), 25 deletions(-)
diff --git a/web/htdocs/bi.css b/web/htdocs/bi.css
index fe23099..bb02ca0 100644
--- a/web/htdocs/bi.css
+++ b/web/htdocs/bi.css
@@ -107,7 +107,7 @@ b.bullet {
background-repeat: repeat;
}
-.aggrtree img.opentree {
+.aggrtree img.treeangle {
width: 15px;
height: 15px;
margin-right: 2px;
@@ -115,11 +115,6 @@ b.bullet {
vertical-align:middle;
}
-.aggrtree img.opentree:hover {
- cursor: pointer;
-}
-
-
table.aggrtree {
border-collapse: collapse;
width: 100%;
diff --git a/web/htdocs/bi.py b/web/htdocs/bi.py
index 6700bdb..a3e1b47 100644
--- a/web/htdocs/bi.py
+++ b/web/htdocs/bi.py
@@ -1660,18 +1660,18 @@ def render_tree_foldable(row, boxes, omit_root, expansion_level,
only_problems,
h += '<span class=title>'
is_empty = len(tree[3]) == 0
if is_empty:
- style = ''
mc = ''
- elif is_open:
- style = ''
- mc = mousecode + 'src="images/tree_black_90.png" '
else:
- style = 'style="display: none" '
- mc = mousecode + 'src="images/tree_black_00.png" '
+ mc = mousecode
+
+ css_class = "open" if is_open else "closed"
- h += aggr_render_node(tree, tree[2]["title"], mc, show_host)
+ h += aggr_render_node(tree, tree[2]["title"], show_host,
+ mousecode=mc, img_class=css_class)
if not is_empty:
- h += '<ul id="%d:%s"
%sclass="subtree">' % (expansion_level or 0, path_id, style)
+ h += '<ul id="%d:%s" class="subtree
%s">' % \
+ (expansion_level or 0, path_id, css_class)
+
if not omit_content:
for node in tree[3]:
if not node[2].get("hidden"):
@@ -1701,7 +1701,7 @@ def render_tree_foldable(row, boxes, omit_root, expansion_level,
only_problems,
'</div>'
return "aggrtree" + (boxes and "_box" or ""), htmlcode
-def aggr_render_node(tree, title, mousecode, show_host):
+def aggr_render_node(tree, title, show_host, mousecode=None, img_class=None):
# Check if we have an assumed state: comparing assumed state (tree[1]) with state
(tree[0])
if tree[1] and tree[0] != tree[1]:
addclass = " " + _("assumed")
@@ -1729,7 +1729,9 @@ def aggr_render_node(tree, title, mousecode, show_host):
h = '<span class="content state state%d%s">%s</span>\n'
\
% (effective_state["state"], addclass,
render_bi_state(effective_state["state"]))
if mousecode:
- h += '<img class=opentree %s>' % mousecode
+ if img_class:
+ h += '<img src="images/tree_black_closed.png"
class="treeangle %s"%s>' % \
+ (img_class,
mousecode)
h += '<span class="content name" %s>%s</span>' %
(mousecode, title)
else:
h += title
@@ -1792,7 +1794,7 @@ def aggr_render_leaf(tree, show_host, bare = False):
if bare:
return content
else:
- return aggr_render_node(tree, content, None, show_host)
+ return aggr_render_node(tree, content, show_host)
def render_bi_state(state):
return { PENDING: _("PD"),
diff --git a/web/htdocs/images/tree_black_90.png b/web/htdocs/images/tree_black_90.png
deleted file mode 100644
index 58ae250..0000000
Binary files a/web/htdocs/images/tree_black_90.png and /dev/null differ
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index 8ebc74d..83470d4 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -2903,21 +2903,22 @@ function bi_toggle_subtree(oImg, lazy)
}
var oSubtree = oImg.parentNode.childNodes[6];
var url = "bi_save_treestate.py?path=" + encodeURIComponent(oSubtree.id);
- var do_open;
- if (oSubtree.style.display == "none") {
- oSubtree.style.display = "";
- url += "&state=open";
+ if (has_class(oImg, "closed")) {
+ change_class(oSubtree, "closed", "open");
toggle_folding(oImg, true);
+
+ url += "&state=open";
do_open = true;
}
else {
- oSubtree.style.display = "none";
- url += "&state=closed";
+ change_class(oSubtree, "open", "closed");
toggle_folding(oImg, false);
+
+ url += "&state=closed";
do_open = false;
}
- oSubtree = null;
+
if (lazy && do_open)
get_url(url, bi_update_tree, oImg);
else
diff --git a/web/plugins/views/bi.py b/web/plugins/views/bi.py
index 894ee0b..19772aa 100644
--- a/web/plugins/views/bi.py
+++ b/web/plugins/views/bi.py
@@ -268,7 +268,8 @@ def paint_aggr_tree_ltr(row, mirror):
for node in tree[3]:
if not node[2].get("hidden"):
leaves += gen_table(node, height - 1, show_host)
- h = '<div class="aggr tree">' + bi.aggr_render_node(tree,
tree[2]["title"], '', show_host) + "</div>"
+ h = '<div class="aggr tree">' \
+ + bi.aggr_render_node(tree, tree[2]["title"], show_host) +
"</div>"
if leaves:
leaves[0][2].append((len(leaves), h))
return leaves