Module: check_mk
Branch: master
Commit: 3b06bfc45b27f8c157e732e47a24b8244db35bf8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3b06bfc45b27f8…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed May 9 11:36:14 2012 +0200
BI: boxed format remembers folding state now
---
ChangeLog | 1 +
web/htdocs/bi.css | 15 +++++--
web/htdocs/js/bi.js | 26 +++++++-----
web/plugins/views/bi.py | 106 +++++++++++++++++++++--------------------------
4 files changed, 74 insertions(+), 74 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ce4084a..176376f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -35,6 +35,7 @@
BI:
* FIX: make rotating folding arrows black (white was not visible)
* Display format 'boxes' now in all BI views available
+ * Display format 'boxes' now persists folding state
1.2.0b3:
Core:
diff --git a/web/htdocs/bi.css b/web/htdocs/bi.css
index 7960463..913b079 100644
--- a/web/htdocs/bi.css
+++ b/web/htdocs/bi.css
@@ -123,15 +123,22 @@ td.aggrtree_box {
}
.bibox_box {
border-width: 1px;
+ border-color: black;
+ border-style: solid;
margin: 0px 0px 0px 0px;
padding: 1px 3px;
}
-.bibox_box.noleaf {
- border: 1px solid black;
- box-shadow: 1px 1px 3px #000;
+.bibox_box.open.noleaf {
+ box-shadow: inset 0.5px 0.5px 3px #444;
+}
+.bibox_box.noleaf:hover {
+ border-style: dashed;
+}
+.bibox_box.closed.noleaf {
+ box-shadow: 0.5px 0.5px 3px #000;
}
.bibox_box.leaf {
- border-style: solid;
+ border-color: white;
}
.bibox {
padding: 0px;
diff --git a/web/htdocs/js/bi.js b/web/htdocs/js/bi.js
index 419af9b..345001a 100644
--- a/web/htdocs/js/bi.js
+++ b/web/htdocs/js/bi.js
@@ -22,7 +22,7 @@
// to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA 02110-1301 USA.
-function toggle_subtree(oImg)
+function bi_toggle_subtree(oImg)
{
var oSubtree = oImg.parentNode.childNodes[6];
var url = "bi_save_treestate.py?path=" + escape(oSubtree.id);
@@ -41,21 +41,24 @@ function toggle_subtree(oImg)
get_url(url);
}
-function toggle_bi_box(oDiv)
+function bi_toggle_box(oDiv)
{
- // oDiv.style.display = "none";
- if (oDiv.style.borderStyle != "dashed") {
- oDiv.style.boxShadow = "none";
- oDiv.style.borderStyle = "dashed";
- oDiv.style.BiBoxHidden = true;
+ var url = "bi_save_treestate.py?path=" + escape(oDiv.id);
+
+ if (oDiv.className.indexOf("open") >= 0) {
+ oDiv.className = oDiv.className.replace(/open/, "closed");
+ url += "&state=closed";
}
else {
- oDiv.style.boxShadow = "1px 1px 3px #000";
- oDiv.style.borderStyle = "solid";
- oDiv.style.BiBoxHidden = false;
+ oDiv.className = oDiv.className.replace(/closed/, "open");
+ url += "&state=open";
}
- // find child nodes that belong to this node
+ get_url(url); // persist current folding
+
+ // find child nodes that belong to this node and
+ // control visibility of those. Note: the BI child nodes
+ // are *no* child nodes in HTML but siblings!
var found = 0;
for (var i in oDiv.parentNode.childNodes) {
var onode = oDiv.parentNode.childNodes[i];
@@ -71,6 +74,7 @@ function toggle_bi_box(oDiv)
return;
}
}
+
}
diff --git a/web/plugins/views/bi.py b/web/plugins/views/bi.py
index 3b2c4a5..46b83e3 100644
--- a/web/plugins/views/bi.py
+++ b/web/plugins/views/bi.py
@@ -275,49 +275,7 @@ def filter_tree_only_problems(tree):
return state, assumed_state, node, new_subtrees
-def paint_aggr_tree_boxes(row):
- mousecode = \
- 'onmouseover="this.style.cursor=\'pointer\';" ' \
- 'onmouseout="this.style.cursor=\'auto\';" ' \
- 'onclick="toggle_bi_box(this);" '
-
- def render_subtree(tree, open, show_host, level):
- ret = ""
- if not open:
- state = tree[0]
- if len(tree) == 3:
- mc = ""
- else:
- mc = mousecode
- if len(tree) == 3:
- leaf = " leaf"
- else:
- leaf = " noleaf"
- ret = '<span %s class="bibox_box%s state%s">' % (mc,
leaf, state["state"])
- # ret += ">" * (level-1)
- if len(tree) == 3:
- ret += aggr_render_leaf(tree, show_host, bare = True) # .replace("
", " ")
- else:
- ret += tree[2]["title"].replace(" ",
" ")
- ret += '</span> '
- if len(tree) >= 4:
- ret += '<span class="bibox" style="%s">' %
(not open and "display: none;" or "")
- parts = []
- for node in tree[3]:
- ret += render_subtree(node, False, show_host, level+1)
- ret += '</span>'
- return ret
-
- tree = row["aggr_treestate"]
- if get_painter_option("aggr_onlyproblems") == "1":
- tree = filter_tree_only_problems(tree)
-
- affected_hosts = row["aggr_hosts"]
- htmlcode = render_subtree(tree, True, len(affected_hosts) > 1, 0)
- return "aggrtree_box", htmlcode
-
-
-def paint_aggr_tree_foldable(row, boxes=False):
+def paint_aggr_tree_foldable(row, boxes):
saved_expansion_level = bi.load_ex_level()
treestate = weblib.get_tree_states('bi')
expansion_level = int(get_painter_option("aggr_expand"))
@@ -329,22 +287,52 @@ def paint_aggr_tree_foldable(row, boxes=False):
mousecode = \
'onmouseover="this.style.cursor=\'pointer\';" ' \
'onmouseout="this.style.cursor=\'auto\';" ' \
- 'onclick="toggle_subtree(this);" '
-
+ 'onclick="bi_toggle_%s(this);" ' % (boxes and "box" or
"subtree")
def render_subtree(tree, path, show_host):
- if len(tree) == 3: # leaf
- return aggr_render_leaf(tree, show_host)
- else:
- h = '<span class=title>'
+ is_leaf = len(tree) == 3
+ path_id = "/".join(path)
+ is_open = treestate.get(path_id)
+ if is_open == None:
+ is_open = len(path) <= expansion_level
+
+ h = ""
+
+ state = tree[0]
+
+ # Variant: BI-Boxes
+ if boxes:
+ if is_leaf:
+ leaf = "leaf"
+ mc = ""
+ else:
+ leaf = "noleaf"
+ mc = mousecode
- path_id = "/".join(path)
- is_open = treestate.get(path_id)
- if is_open == None:
- is_open = len(path) <= expansion_level
+ h += '<span id="%d:%s" %s class="bibox_box %s %s
state%s">' % (
+ expansion_level, path_id, mc, leaf, is_open and "open" or
"closed", state["state"])
+ if is_leaf:
+ h += aggr_render_leaf(tree, show_host, bare = True) # .replace("
", " ")
+ else:
+ h += tree[2]["title"].replace(" ",
" ")
+ h += '</span> '
- is_empty = len(tree[3]) == 0
+ if not is_leaf:
+ h += '<span class="bibox" style="%s">'
% (not is_open and "display: none;" or "")
+ parts = []
+ for node in tree[3]:
+ new_path = path + [node[2]["title"]]
+ h += render_subtree(node, new_path, show_host)
+ h += '</span>'
+ return h
+
+ # Variant: foldable trees
+ else:
+ if is_leaf: # leaf
+ return aggr_render_leaf(tree, show_host, bare = boxes)
+ h += '<span class=title>'
+ is_empty = len(tree[3]) == 0
if is_empty:
style = ''
mc = ''
@@ -374,7 +362,7 @@ def paint_aggr_tree_foldable(row, boxes=False):
affected_hosts = row["aggr_hosts"]
htmlcode = render_subtree(tree, [tree[2]["title"]], len(affected_hosts)
> 1)
- return "aggrtree", htmlcode
+ return "aggrtree" + (boxes and "_box" or ""), htmlcode
def paint_aggr_tree_ltr(row, mirror):
@@ -433,13 +421,13 @@ def paint_aggr_tree_ltr(row, mirror):
def paint_aggregated_tree_state(row):
treetype = get_painter_option("aggr_treetype")
if treetype == "foldable":
- return paint_aggr_tree_foldable(row)
+ return paint_aggr_tree_foldable(row, boxes = False)
+ elif treetype == "boxes":
+ return paint_aggr_tree_foldable(row, boxes = True)
elif treetype == "bottom-up":
return paint_aggr_tree_ltr(row, False)
elif treetype == "top-down":
return paint_aggr_tree_ltr(row, True)
- elif treetype == "boxes":
- return paint_aggr_tree_boxes(row)
multisite_painters["aggr_treestate"] = {
"title" : _("Aggregation: complete tree"),
@@ -453,7 +441,7 @@ multisite_painters["aggr_treestate_boxed"] = {
"title" : _("Aggregation: simplistic boxed layout"),
"short" : _("Tree"),
"columns" : [ "aggr_treestate", "aggr_hosts" ],
- "paint" : paint_aggr_tree_boxes,
+ "paint" : lambda row: paint_aggr_tree_foldable(row, boxes=True),
}
# _____ _ _ _