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

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


The following commit has been merged in the debian/master branch:
commit 03e212e30ad5ff9fa27fe38e25704fd7117d31ba
Author: Naparuba <naparuba at gmail.com>
Date:   Mon Jan 23 16:51:25 2012 +0100

    Enh : skonfui, change validate host form in an ajax way.

diff --git a/shinken/webui/htdocs/images/spinner.gif b/shinken/webui/htdocs/images/spinner.gif
new file mode 100644
index 0000000..88fac73
Binary files /dev/null and b/shinken/webui/htdocs/images/spinner.gif differ
diff --git a/shinken/webui/plugins_skonf/newhosts/htdocs/css/results.css b/shinken/webui/plugins_skonf/newhosts/htdocs/css/results.css
index 53ce220..1c6a0fe 100644
--- a/shinken/webui/plugins_skonf/newhosts/htdocs/css/results.css
+++ b/shinken/webui/plugins_skonf/newhosts/htdocs/css/results.css
@@ -8,4 +8,10 @@
 .form_button_image {
     width : 48px;
     height : 48px;
+}
+
+
+.log_result.ajax-loading {
+    padding: 20px 0;
+    background: url(/static/images/spinner.gif) no-repeat center;
 }
\ No newline at end of file
diff --git a/shinken/webui/plugins_skonf/newhosts/htdocs/js/results.js b/shinken/webui/plugins_skonf/newhosts/htdocs/js/results.js
index aedc93c..197dc19 100644
--- a/shinken/webui/plugins_skonf/newhosts/htdocs/js/results.js
+++ b/shinken/webui/plugins_skonf/newhosts/htdocs/js/results.js
@@ -25,5 +25,43 @@
 
 
 function validatehostform(name) {
-    document.forms[name].submit();
+    //var form = document.forms[name];//.submit();
+
+    var form = $("form-"+name);
+    //alert("submit" + name);
+    /**
+     * This empties the log and shows the spinning indicator
+     */
+    var log = $("res-"+name).empty().addClass('ajax-loading');
+
+    new Request({
+        method: form.method,
+        url: form.action+"toto",
+        onSuccess: function(responseText, responseXML) {
+            log.removeClass('ajax-loading');
+            log.set('text', 'text goes here');
+	    div_res = $("good-result-"+name);
+	    new Fx.Slide(div_res).show();
+	    div_res.highlight('#ddf');
+        },
+	onFailure: function(responseText, responseXML) {
+            log.removeClass('ajax-loading');
+            log.set('text', 'ajax finished');
+	    div_res = $("bad-result-"+name);
+	    new Fx.Slide(div_res).show();
+	    div_res.highlight('#ddf');
+        }
+
+    }).send(form.toQueryString());
 }
+
+
+
+
+/* We Hide all results divs */
+window.addEvent('domready', function(){
+    var res = $$('.div-result');
+	 res.each(function(el){
+	     new Fx.Slide(el).hide();
+	 });
+});
diff --git a/shinken/webui/plugins_skonf/newhosts/views/newhosts_results.tpl b/shinken/webui/plugins_skonf/newhosts/views/newhosts_results.tpl
index 640cdde..80d47a9 100644
--- a/shinken/webui/plugins_skonf/newhosts/views/newhosts_results.tpl
+++ b/shinken/webui/plugins_skonf/newhosts/views/newhosts_results.tpl
@@ -11,6 +11,7 @@
 <p>Here are the results :</p>
 
 %for h in pending_hosts:
+     %hname = h['host_name']
      <div id="host-{{h['host_name']}}" class="grid_10 discovered_host">
      <br/>{{h}}
      <form method="post" id="form-{{h['host_name']}}" action="/newhosts/validatehost">
@@ -26,19 +27,33 @@
 	     <input name="tags" type="text" tabindex="2" value="{{h['use']}}" id="form-use-{{h['host_name']}}"/>
 	   </span>
 	   <span class="cell">
-	     <a tabindex="4" href='javascript: validatehostform("form-{{h['host_name']}}")'>
+	     <a tabindex="4" href='javascript: validatehostform("{{h['host_name']}}")'>
 	       <img class='form_button_image' src="/static/images/big_ack.png" alt="Validate"/>
 	     </a>
 	   </span>
+	   <input type="submit" value="GO">
+	   <div id="res-{{h['host_name']}}" class="log_result">
+	     <h3>Ajax Response</h3>
+	   </div>
 	 </span>
        </span>
      </form>
 
+     <div id="good-result-{{hname}}" class='div-result'>
+       OK, the host {{hname}} was added succesfuly.
+       <img class='form_button_image' src="/static/images/big_ack.png" alt="OK"/>
+     </div>
+     <div id="bad-result-{{hname}}" class='div-result'>
+       ERROR : the host {{hname}} was not added succesfuly.
+       <img class='form_button_image' src="/static/images/bomb.png" alt="Error"/>
+     </div>
+
+
      %# " Add the auto copleter in the search input form"
      <script type="text/javascript">
        document.addEvent('domready', function() {
          var tags = $("form-use-{{h['host_name']}}");
- 
+       
          // Our instance for the element with id "use-"
          new Autocompleter.Request.JSON(tags, '/lookup/tag', {
             'indicatorClass': 'autocompleter-loading',

-- 
UNNAMED PROJECT



More information about the Pkg-nagios-changes mailing list