[Pkg-nagios-changes] [SCM] UNNAMED PROJECT branch, debian/master, updated. 810edbdd3feedbfe37f4a65bee50b57b2f60fa2a

Naparuba naparuba at gmail.com
Tue Feb 28 22:05:55 UTC 2012


The following commit has been merged in the debian/master branch:
commit 9ef26a27c6696f8c6580bd4fc30bee6c803b108f
Author: Naparuba <naparuba at gmail.com>
Date:   Wed Nov 16 14:47:14 2011 +0100

    Add : perfometer image hovering with the graph module like PNP.

diff --git a/etc/shinken-specific.cfg b/etc/shinken-specific.cfg
index bf675b2..afcc9ae 100644
--- a/etc/shinken-specific.cfg
+++ b/etc/shinken-specific.cfg
@@ -375,6 +375,7 @@ define module{
  module_type  pnp_webui
  uri 	      http://YOURSERVERNAME/pnp4nagios/   ; put the real PNP uri here. YOURSERVERNAME will be changed
                                               ; bu the localname of the server
+
 }
 
 # send into GLPI DB
diff --git a/shinken/webui/plugins/problems/htdocs/css/img_hovering.css b/shinken/webui/plugins/problems/htdocs/css/img_hovering.css
new file mode 100644
index 0000000..6b85315
--- /dev/null
+++ b/shinken/webui/plugins/problems/htdocs/css/img_hovering.css
@@ -0,0 +1,4 @@
+#img_hover{
+    position : absolute;
+    z-index : 10;
+}
\ No newline at end of file
diff --git a/shinken/webui/plugins/problems/htdocs/js/img_hovering.js b/shinken/webui/plugins/problems/htdocs/js/img_hovering.js
new file mode 100644
index 0000000..e77ef6e
--- /dev/null
+++ b/shinken/webui/plugins/problems/htdocs/js/img_hovering.js
@@ -0,0 +1,97 @@
+/*Copyright (C) 2009-2011 :
+     Gabes Jean, naparuba at gmail.com
+     Gerhard Lausser, Gerhard.Lausser at consol.de
+     Gregory Starck, g.starck at gmail.com
+     Hartmut Goebel, h.goebel at goebel-consult.de
+     Andreas Karfusehr, andreas at karfusehr.de
+ 
+ This file is part of Shinken.
+ 
+ Shinken is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+ 
+ Shinken is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU Affero General Public License for more details.
+ 
+ You should have received a copy of the GNU Affero General Public License
+ along with Shinken.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+/* We want to be able to add image hovering in perfdata
+   so we need the position of the mouse and make apears a div with
+   the image in it */
+
+var mouse_abs_x = 0;
+var mouse_abs_y = 0;
+
+function create_img(src, alt){
+    var img = document.createElement("img");
+
+    // If we got problem with the image, bail out the
+    // print/ WARNING : BEFORE set src!
+    img.onerror = function() {
+	img.hide()
+    };
+    img.src = src;
+    img.alt = alt;
+
+    return img;
+}
+
+// First we look for the img_hover div and we add it
+// the image, and we set it in the good place
+function display_hover_img(src, alt){
+    var img = create_img(src, alt);
+    var div = $('img_hover');
+
+    var pagesize = document.documentElement.clientWidth;
+    var pagehigth = document.documentElement.clientHeight;
+
+    // We remove the previous image in it
+    div.innerHTML = '';
+
+    // If we are too much on the left, put the image a bit
+    // before so we are sure it fill on the page without
+    // slide. same for hight
+    var pos_x = mouse_abs_x;
+    if(pagesize - pos_x < 600){
+	pos_x = pagesize - 600;
+    }
+
+    // By default we are a bit lower than the mouse
+    var pos_y = mouse_abs_y + 20;
+
+    // If too low, go higher. We use the relative y position here
+    if(pagehigth - event.clientY < 200){
+        pos_y = pos_y - 300;
+    }
+
+    // Ok, let apply our positions!
+    div.style.left = pos_x +'px';
+    div.style.top = pos_y +'px';
+    
+    // And add our image, then make the div appears
+    // magically
+    div.appendChild(img);
+    div.fade('in');
+}
+
+// when we go out the hover item, we must hide the
+// img div, and remove the image in it
+function hide_hover_img(){
+    var div = $('img_hover');
+    div.fade('out');
+}
+
+// When we move, we save our mouse position
+window.addEvent('domready', function(){
+    document.onmousemove = function(e){
+	mouse_abs_x = e.pageX;
+	mouse_abs_y = e.pageY;
+    };
+});
diff --git a/shinken/webui/plugins/problems/views/problems.tpl b/shinken/webui/plugins/problems/views/problems.tpl
index a572344..74562d2 100644
--- a/shinken/webui/plugins/problems/views/problems.tpl
+++ b/shinken/webui/plugins/problems/views/problems.tpl
@@ -1,11 +1,13 @@
 
+%import time
+%now = time.time()
 %helper = app.helper
 %datamgr = app.datamgr
 
 %top_right_banner_state = datamgr.get_overall_state()
 
 
-%rebase layout title='All problems', top_right_banner_state=top_right_banner_state, js=['problems/js/accordion.js', 'problems/js/autocompleter.js', 'problems/js/autocompleter.Request.js', 'problems/js/autocompleterObserver.js'], css=['problems/css/accordion.css', 'problems/css/pagenavi.css', 'problems/css/autocompleter.css', 'problems/css/perfometer.css'], refresh=True, menu_part='/'+page, user=user
+%rebase layout title='All problems', top_right_banner_state=top_right_banner_state, js=['problems/js/img_hovering.js', 'problems/js/accordion.js', 'problems/js/autocompleter.js', 'problems/js/autocompleter.Request.js', 'problems/js/autocompleterObserver.js'], css=['problems/css/accordion.css', 'problems/css/pagenavi.css', 'problems/css/autocompleter.css', 'problems/css/perfometer.css', 'problems/css/img_hovering.css'], refresh=True, menu_part='/'+page, user=user
 
 
 %# " If the auth got problem, we bail out"
@@ -227,7 +229,12 @@ document.addEvent('domready', function() {
 		      <td class="tdBorderTop tdBorderLeft tdCriticity" style="width:450px;"> {{pb.output}} </td>
                    %end
 		%end
-		<td class="perfometer">
+		%graphs = app.get_graph_uris(pb, now- 4*3600 , now)
+		%onmouse_code = ''
+		%if len(graphs) > 0:
+		      %onmouse_code = 'onmouseover="display_hover_img(\'%s\',\'\');" onmouseout="hide_hover_img();" ' % graphs[0]['img_src']
+		%end
+		<td class="perfometer" {{!onmouse_code}}>
 		  {{!helper.get_perfometer(pb)}}
 		</td>
 		<td class="tdBorderLeft tdCriticity opacity_hover shortdesc" style="max-width:20px;" onclick="show_detail('{{pb.get_full_name()}}')"> <img src="/static/images/expand.png" alt="expand" /> </td>
@@ -324,3 +331,6 @@ document.addEvent('domready', function() {
 </div>
 
 <div class="clear"></div>
+
+%# """ This div is an image container and will move hover the perfometer with mouse hovering """
+<div id="img_hover"></div>

-- 
UNNAMED PROJECT



More information about the Pkg-nagios-changes mailing list