Module: check_mk
Branch: master
Commit: 7bb32b05a1612c510609b0db95b09de01e9a8bf7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7bb32b05a1612c…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Dec 6 17:01:19 2011 +0100
FIX: BI - Assuming host states is possible again (exception: list index "3")
---
ChangeLog | 3 ++
web/htdocs/bi.py | 9 ++++++
web/htdocs/js/bi.js | 71 +++++++++++++++++++++++++++++++++++++++++++++
web/htdocs/js/check_mk.js | 48 +-----------------------------
web/htdocs/views.py | 3 +-
5 files changed, 86 insertions(+), 48 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2eea0be..9b88627 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -50,6 +50,9 @@
* Add Snapin page: show previews of all snapins
* New (hidden) button for reloading a snapin (left to the close button)
+ BI:
+ * FIX: Assuming host states is possible again (exception: list index "3")
+
WATO:
* Evolved to full featured monitoring configuration tool!
* Major internal code cleanup
diff --git a/web/htdocs/bi.py b/web/htdocs/bi.py
index c50dada..2679473 100644
--- a/web/htdocs/bi.py
+++ b/web/htdocs/bi.py
@@ -1085,3 +1085,12 @@ def is_part_of_aggregation(what, site, host, service):
else:
return (site, host, service) in g_user_cache["affected_services"]
+def get_state_name(node):
+ if node[1]['type'] == NT_LEAF:
+ if 'service' in node[1]:
+ return service_state_names[node[0]['state']]
+ else:
+ return host_state_names[node[0]['state']]
+ else:
+ # FIXME: Und wenn ein Hoststatus zum Summary-Status wird?
+ return service_state_names[node[0]['state']]
diff --git a/web/htdocs/js/bi.js b/web/htdocs/js/bi.js
new file mode 100644
index 0000000..93f1eaa
--- /dev/null
+++ b/web/htdocs/js/bi.js
@@ -0,0 +1,71 @@
+// +------------------------------------------------------------------+
+// | ____ _ _ __ __ _ __ |
+// | / ___| |__ ___ ___| | __ | \/ | |/ / |
+// | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+// | | |___| | | | __/ (__| < | | | | . \ |
+// | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+// | |
+// | Copyright Mathias Kettner 2011 mk(a)mathias-kettner.de |
+// +------------------------------------------------------------------+
+//
+// This file is part of Check_MK.
+// The official homepage is at
http://mathias-kettner.de/check_mk.
+//
+// check_mk is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation in version 2. check_mk is distributed
+// in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+// out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+// PARTICULAR PURPOSE. See the GNU General Public License for more de-
+// ails. You should have received a copy of the GNU General Public
+// License along with GNU Make; see the file COPYING. If not, write
+// to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+// Boston, MA 02110-1301 USA.
+
+function toggle_subtree(oImg)
+{
+ var oSubtree = oImg.parentNode.childNodes[6];
+ var url = "bi_save_treestate.py?path=" + escape(oSubtree.id);
+
+ if (oSubtree.style.display == "none") {
+ oSubtree.style.display = "";
+ url += "&state=open";
+ toggle_folding(oImg, 1);
+ }
+ else {
+ oSubtree.style.display = "none";
+ url += "&state=closed";
+ toggle_folding(oImg, 0);
+ }
+ oSubtree = null;
+ get_url(url);
+}
+
+function toggle_assumption(oImg, site, host, service)
+{
+ // get current state
+ var current = oImg.src;
+ while (current.indexOf('/') > -1)
+ current = current.substr(current.indexOf('/') + 1);
+ current = current.substr(7);
+ current = current.substr(0, current.length - 4);
+ if (current == 'none')
+ current = '1';
+ else if (current == '3')
+ current = '0'
+ else if (current == '0')
+ current = 'none'
+ else if (current == '2' && service == '')
+ current = 'none'
+ else
+ current = parseInt(current) + 1;
+
+ var url = "bi_set_assumption.py?site=" + encodeURIComponent(site)
+ + '&host=' + encodeURIComponent(host);
+ if (service) {
+ url += '&service=' + encodeURIComponent(service);
+ }
+ url += '&state=' + current;
+ oImg.src = "images/assume_" + current + ".png";
+ get_url(url);
+}
diff --git a/web/htdocs/js/check_mk.js b/web/htdocs/js/check_mk.js
index 605d7dd..732208e 100644
--- a/web/htdocs/js/check_mk.js
+++ b/web/htdocs/js/check_mk.js
@@ -759,7 +759,7 @@ function handleReload(url) {
}
// --------------------------------------------------------------------------
-// BI
+// Folding
// --------------------------------------------------------------------------
//
var fold_steps = [ 0, 10, 10, 15, 20, 30, 40, 55, 80 ];
@@ -811,24 +811,6 @@ function toggle_tree_state(tree, name, oContainer) {
oContainer = null;
}
-function toggle_subtree(oImg)
-{
- var oSubtree = oImg.parentNode.childNodes[6];
- var url = "bi_save_treestate.py?path=" + escape(oSubtree.id);
-
- if (oSubtree.style.display == "none") {
- oSubtree.style.display = "";
- url += "&state=open";
- toggle_folding(oImg, 1);
- }
- else {
- oSubtree.style.display = "none";
- url += "&state=closed";
- toggle_folding(oImg, 0);
- }
- oSubtree = null;
- get_url(url);
-}
function toggle_foldable_container(treename, id) {
var oImg = document.getElementById('treeimg.' + treename + '.' +
id);
@@ -839,34 +821,6 @@ function toggle_foldable_container(treename, id) {
oBox = null;
}
-// TODO: Why is this not in a bi.js?
-function toggle_assumption(oImg, site, host, service)
-{
- // get current state
- var current = oImg.src;
- while (current.indexOf('/') > -1)
- current = current.substr(current.indexOf('/') + 1);
- current = current.substr(7);
- current = current.substr(0, current.length - 4);
- if (current == 'none')
- current = '1';
- else if (current == '3')
- current = '0'
- else if (current == '0')
- current = 'none'
- else
- current = parseInt(current) + 1;
-
- var url = "bi_set_assumption.py?site=" + encodeURIComponent(site)
- + '&host=' + encodeURIComponent(host);
- if (service) {
- url += '&service=' + encodeURIComponent(service);
- }
- url += '&state=' + current;
- oImg.src = "images/assume_" + current + ".png";
- get_url(url);
-}
-
/*
* +----------------------------------------------------------------------+
* | ____ _ _ |
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 6bb22d0..14af06b 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -1295,7 +1295,8 @@ def render_view(view, rows, datasource, group_painters, painters,
if show_heading:
# Show/Hide the header with page title, MK logo, etc.
if 'H' in display_options:
- html.body_start(view_title(view),
stylesheets=["pages","views","status","bi"])
+ # FIXME: view/layout/module related stylesheets/javascripts e.g. in case of
BI?
+ html.body_start(view_title(view),
stylesheets=["pages","views","status","bi"],
javascripts=['bi'])
if 'T' in display_options:
html.top_heading(view_title(view))