Module: check_mk
Branch: master
Commit: 38c44fe19d11e80f5573c1e53558da141012775a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=38c44fe19d11e8…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Feb 16 15:18:15 2012 +0100
BI: new tree rendering painter using boxes
---
ChangeLog | 4 ++
web/htdocs/bi.css | 11 +++++++
web/htdocs/js/bi.js | 18 ++++++++++++
web/plugins/views/bi.py | 63 ++++++++++++++++++++++++++++++++++++++----
web/plugins/views/builtin.py | 31 ++++++++++++++++++++
5 files changed, 121 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d01304e..d226aad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -48,6 +48,10 @@
* check_bi_local.py: works now with cookie based authentication
* FIX: Fixed wrong redirection after login in some cases
+ BI:
+ * New column (painter) for simplistic box display of tree.
+ This is used in a view for a single hostgroup.
+
1.1.13i3:
Core, Setup, etc.:
* *_contactgroups lists: Single group rules are all appended. When a list
diff --git a/web/htdocs/bi.css b/web/htdocs/bi.css
index 1c90e5c..ed10992 100644
--- a/web/htdocs/bi.css
+++ b/web/htdocs/bi.css
@@ -119,3 +119,14 @@ table.aggrtree td.node {
}
+div.bibox_box {
+ border-style: solid;
+ border-width: 1px;
+ float: left;
+ margin: 1px 4px 1px 0px;
+ padding: 1px 3px;
+}
+div.bibox {
+ float: left;
+}
+
diff --git a/web/htdocs/js/bi.js b/web/htdocs/js/bi.js
index 1d3b594..ecfed96 100644
--- a/web/htdocs/js/bi.js
+++ b/web/htdocs/js/bi.js
@@ -41,6 +41,24 @@ function toggle_subtree(oImg)
get_url(url);
}
+function toggle_bi_box(oDiv)
+{
+ oDiv.style.display = "none";
+
+ // find child nodes that belong to this node
+ var found = false;
+ for (var i in oDiv.parentNode.childNodes) {
+ var onode = oDiv.parentNode.childNodes[i];
+ if (onode == oDiv)
+ found = true;
+ else if (found) {
+ onode.style.display = "";
+ return;
+ }
+ }
+}
+
+
function toggle_assumption(oImg, site, host, service)
{
// get current state
diff --git a/web/plugins/views/bi.py b/web/plugins/views/bi.py
index 56051e2..edf5ed5 100644
--- a/web/plugins/views/bi.py
+++ b/web/plugins/views/bi.py
@@ -147,7 +147,10 @@ multisite_painter_options["aggr_onlyproblems"] = {
multisite_painter_options["aggr_treetype"] = {
"title" : _("Type of tree layout"),
"default" : "foldable",
- "values" : [ ("foldable", "foldable"),
("bottom-up", "bottom up"), ("top-down", "top
down")]
+ "values" : [
+ ("foldable", "foldable"),
+ ("bottom-up", "bottom up"),
+ ("top-down", "top down")]
}
multisite_painter_options["aggr_wrap"] = {
@@ -186,10 +189,13 @@ def render_assume_icon(site, host, service):
current = str(ass).lower()
return u'<img state="%s" class=assumption %s
src="images/assume_%s.png">\n' % (current, mousecode, current)
-def aggr_render_leaf(tree, show_host):
+def aggr_render_leaf(tree, show_host, bare = False):
site, host = tree[2]["host"]
service = tree[2].get("service")
- content = u"" + render_assume_icon(site, host, service)
+ if bare:
+ content = u""
+ else:
+ content = u"" + render_assume_icon(site, host, service)
# Four cases:
# (1) zbghora17 . Host status (show_host == True, service == None)
@@ -211,7 +217,10 @@ def aggr_render_leaf(tree, show_host):
else:
content += '<a href="%s">%s</a>' % (service_url,
service)
- return aggr_render_node(tree, content, None, show_host)
+ if bare:
+ return content
+ else:
+ return aggr_render_node(tree, content, None, show_host)
def aggr_render_node(tree, title, mousecode, show_host):
state = tree[0]
@@ -259,7 +268,43 @@ def filter_tree_only_problems(tree):
return state, assumed_state, node, new_subtrees
-def paint_aggr_tree_foldable(row):
+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):
+ ret = ""
+ if not open:
+ state = tree[0]
+ if len(tree) == 3:
+ mc = ""
+ else:
+ mc = mousecode
+ ret = '<div %s class="bibox_box state%s">' % (mc,
state["state"])
+ if len(tree) == 3: # leaf
+ ret += aggr_render_leaf(tree, show_host, bare = True)
+ else:
+ ret += tree[2]["title"]
+ ret += '</div>'
+ if len(tree) >= 4:
+ ret += '<div class="bibox" style="%s">' %
(not open and "display: none;" or "")
+ parts = []
+ for node in tree[3]:
+ ret += render_subtree(node, False, show_host)
+ ret += '</div>'
+ 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)
+ return "aggrtree", htmlcode
+
+def paint_aggr_tree_foldable(row, boxes=False):
saved_expansion_level = bi.load_ex_level()
treestate = weblib.get_tree_states('bi')
expansion_level = int(get_painter_option("aggr_expand"))
@@ -378,7 +423,7 @@ def paint_aggregated_tree_state(row):
return paint_aggr_tree_foldable(row)
elif treetype == "bottom-up":
return paint_aggr_tree_ltr(row, False)
- else:
+ elif treetype == "top-down":
return paint_aggr_tree_ltr(row, True)
multisite_painters["aggr_treestate"] = {
@@ -389,6 +434,12 @@ multisite_painters["aggr_treestate"] = {
"paint" : paint_aggregated_tree_state,
}
+multisite_painters["aggr_treestate_boxed"] = {
+ "title" : _("Aggregation: simplistic boxed layout"),
+ "short" : _("Tree"),
+ "columns" : [ "aggr_treestate", "aggr_hosts" ],
+ "paint" : paint_aggr_tree_boxes,
+}
# _____ _ _ _
# | ___(_) | |_ ___ _ __ ___
diff --git a/web/plugins/views/builtin.py b/web/plugins/views/builtin.py
index c8bd2d9..a29bb55 100644
--- a/web/plugins/views/builtin.py
+++ b/web/plugins/views/builtin.py
@@ -2503,6 +2503,37 @@ multisite_builtin_views.update({
'topic': u'Business Intelligence',
'user_sortable': 'on'},
+# Hostgroup with boxed BIs for each host
+'aggr_hostgroup_boxed': {'browser_reload': 0,
+ 'column_headers': 'off',
+ 'datasource': 'bi_host_aggregations',
+ 'description': '',
+ 'group_painters': [('site_icon', None),
+ ('sitealias', 'sitehosts')],
+ 'hard_filters': [],
+ 'hard_filtervars': [],
+ 'hidden': True,
+ 'hide_filters': ['hostgroup'],
+ 'icon' : 'aggr',
+ 'layout': 'boxed',
+ 'linktitle': _('BI Boxes'),
+ 'mustsearch': False,
+ 'name': 'hostgroup',
+ 'num_columns': 2,
+ 'owner': 'admin',
+ 'painters': [('host_state', None),
+ ('host', 'host'),
+ ('host_icons', None),
+ ('alias', None),
+ ('aggr_treestate_boxed', None),
+ ],
+ 'play_sounds': False,
+ 'public': True,
+ 'show_filters': [],
+ 'sorters': [('site', False), ('site_host',
False)],
+ 'title': _('Hostgroup with BI state'),
+ 'topic': _('hidden')},
+
# +----------------------------------------------------------------------+
# | _ _ _ _ __ _ _ _ |