Module: check_mk
Branch: master
Commit: b089424b9056c5e783221ecda95e9380e7cd2eed
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b089424b9056c5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Sat Mar 9 15:28:12 2013 +0100
Dashboards can now be configured to be reloaded on resizing
(automatically adds width/height url parameters)
---
ChangeLog | 2 ++
web/htdocs/dashboard.py | 15 +++++++++++++--
web/htdocs/js/dashboard.js | 17 +++++++++++++++++
web/plugins/dashboard/builtin.py | 16 ++++++++++++++++
4 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c12d58d..723cc7b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -18,6 +18,8 @@
correctly even for multisite related settings
* perfometer: Bit values now using base of 1000
* ADD: check_disk_smb pnp-template
+ * Dashboards can now be configured to be reloaded on resizing
+ (automatically adds width/height url parameters)
Event Console:
* New rule feature: automatically delete event after actions
diff --git a/web/htdocs/dashboard.py b/web/htdocs/dashboard.py
index d124a60..d270fcc 100644
--- a/web/htdocs/dashboard.py
+++ b/web/htdocs/dashboard.py
@@ -213,16 +213,27 @@ def render_dashlet(nr, dashlet, wato_folder):
if "view" in dashlet:
dashlet["iframe"] =
"view.py?view_name=%s&_display_options=HRSIXL&_body_class=dashlet" %
dashlet["view"]
+ if dashlet.get("reload_on_resize"):
+ dashlet["onload"] = "dashlet_add_dimensions('dashlet_%d',
this)" % nr
+
# The content is rendered only if it is fixed. In the
# other cases the initial (re)-size will paint the content.
if "content" in dashlet: # fixed content
html.write(dashlet["content"])
elif "iframe" in dashlet: # fixed content containing iframe
+ if not dashlet.get("reload_on_resize"):
+ url = add_wato_folder_to_url(dashlet["iframe"], wato_folder)
+ else:
+ url = 'about:blank'
+
# Fix of iPad >:-P
html.write('<div style="width: 100%; height: 100%;
-webkit-overflow-scrolling:touch; overflow: auto;">')
- html.write('<iframe allowTransparency="true"
frameborder="0" width="100%%" height="100%%"
src="%s"></iframe>' %
- add_wato_folder_to_url(dashlet["iframe"], wato_folder))
+ html.write('<iframe id="dashlet_iframe_%d"
allowTransparency="true" frameborder="0" width="100%%"
'
+ 'height="100%%" src="%s">
</iframe>' % (nr, url))
html.write('</div>')
+ if dashlet.get("reload_on_resize"):
+ html.javascript('reload_on_resize["%d"] = "%s"'
%
+ (nr, add_wato_folder_to_url(dashlet["iframe"],
wato_folder)))
html.write("</div></div>\n")
# Here comes the brain stuff: An intelligent liquid layout algorithm.
diff --git a/web/htdocs/js/dashboard.js b/web/htdocs/js/dashboard.js
index f0b9a75..43d1338 100644
--- a/web/htdocs/js/dashboard.js
+++ b/web/htdocs/js/dashboard.js
@@ -22,6 +22,9 @@
// to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA 02110-1301 USA.
+// snapin ids and urls
+var reload_on_resize = {};
+
function resize_dashlets(id, code)
{
var resize_info = eval(code);
@@ -102,6 +105,14 @@ function resize_dashlets(id, code)
if (netto_height > 0)
oDash.style.height = netto_height + "px";
}
+
+ if (typeof reload_on_resize[d_number] != 'undefined') {
+ var base_url = reload_on_resize[d_number];
+ var iframe = document.getElementById("dashlet_iframe_" +
d_number);
+ iframe.src = base_url + '&width=' + oDash.clientWidth
+ + '&height=' + oDash.clientHeight;
+ iframe = null;
+ }
}
oDash = null;
}
@@ -158,3 +169,9 @@ function update_dashlet(id, code) {
obj = null;
}
}
+
+//function dashlet_open_with_dimensions(id, url) {
+// var dashlet = document.getElementById('dashlet_' + id);
+// alert(dashlet.clientWidth);
+// //iframe.src = url + '&width=' + iframe.clientWidth +
'&height=' + iframe.clientHeight;
+//}
diff --git a/web/plugins/dashboard/builtin.py b/web/plugins/dashboard/builtin.py
index ad0fef6..dc942ff 100644
--- a/web/plugins/dashboard/builtin.py
+++ b/web/plugins/dashboard/builtin.py
@@ -68,3 +68,19 @@ builtin_dashboards["main"] = {
},
]
}
+
+builtin_dashboards["topology"] = {
+ "title" : _("Network Topology"),
+ "dashlets" : [
+ {
+ "title" : "Topology of Site " +
defaults.omd_site,
+ "iframe" : defaults.url_prefix +
'nagvis/frontend/nagvis-js/index.php?' + \
+
'mod=Map&header_template=default&header_menu=0&label_show=1' + \
+
'&sources=automap&act=view&backend_id=' + defaults.omd_site + \
+
'&render_mode=undirected&url_target=main',
+ "reload_on_resize" : True,
+ "position" : (1, 0),
+ "size" : (GROW, GROW),
+ },
+ ]
+}