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

Naparuba naparuba at gmail.com
Tue Feb 28 22:14:45 UTC 2012


The following commit has been merged in the debian/master branch:
commit ea030c6bd2714140243ae36e19a3ef8a5618ff1a
Author: Naparuba <naparuba at gmail.com>
Date:   Wed Jan 18 16:06:01 2012 +0100

    Add : skonf : autocompletion for host tags.

diff --git a/shinken/daemons/skonfdaemon.py b/shinken/daemons/skonfdaemon.py
index c0ced78..9293d50 100644
--- a/shinken/daemons/skonfdaemon.py
+++ b/shinken/daemons/skonfdaemon.py
@@ -174,6 +174,8 @@ class Skonf(Daemon):
 
         self.workers = {}   # dict of active workers
 
+        self.host_templates = None
+
 
 
     # Use for adding things like broks
@@ -295,6 +297,9 @@ class Skonf(Daemon):
         self.conf.fill_default()
         
         # Remove templates from config
+        # SAVE TEMPLATES
+        self.host_templates = self.conf.hosts.templates
+        # Then clean for other parts
         self.conf.remove_templates()
 
         # We removed templates, and so we must recompute the
@@ -330,7 +335,6 @@ class Skonf(Daemon):
         # And link them
         self.conf.create_business_rules_dependencies()
 
-
         # Warn about useless parameters in Shinken
         if self.verify_only:
             self.conf.notice_about_useless_parameters()
diff --git a/shinken/webui/plugins/problems/htdocs/css/autocompleter.css b/shinken/webui/htdocs/css/autocompleter.css
similarity index 100%
rename from shinken/webui/plugins/problems/htdocs/css/autocompleter.css
rename to shinken/webui/htdocs/css/autocompleter.css
diff --git a/shinken/webui/plugins/problems/views/problems.tpl b/shinken/webui/plugins/problems/views/problems.tpl
index 62cb12a..205d964 100644
--- a/shinken/webui/plugins/problems/views/problems.tpl
+++ b/shinken/webui/plugins/problems/views/problems.tpl
@@ -7,7 +7,7 @@
 %top_right_banner_state = datamgr.get_overall_state()
 
 
-%rebase layout title='All problems', top_right_banner_state=top_right_banner_state, js=['problems/js/img_hovering.js', 'problems/js/accordion.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
+%rebase layout title='All problems', top_right_banner_state=top_right_banner_state, js=['problems/js/img_hovering.js', 'problems/js/accordion.js'], css=['problems/css/accordion.css', 'problems/css/pagenavi.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"
diff --git a/shinken/webui/plugins_skonf/lookup/lookup.py b/shinken/webui/plugins_skonf/lookup/lookup.py
index e46270e..cacbdfb 100644
--- a/shinken/webui/plugins_skonf/lookup/lookup.py
+++ b/shinken/webui/plugins_skonf/lookup/lookup.py
@@ -30,26 +30,32 @@ def lookup(name=''):
     return json.dumps(r)
 
 
-def lookup_post():
+def lookup_tag_post():
     app.response.content_type = 'application/json'
 
-    user = app.get_user_auth()
-    if not user:
-        return []
+#    user = app.get_user_auth()
+#    if not user:
+#        return []
 
     name = app.request.forms.get('value')
     if not name or len(name) < 3:
         print "Lookup POST %s too short, bail out" % name
         return []
 
-    hnames = (h.host_name for h in app.datamgr.get_hosts())
-    r  = [n for n in hnames if n.startswith(name)]
+    print "Lookup for", name
+    tags = set()
+    for h in app.host_templates.values():
+        print "Template", h
+        if hasattr(h, 'name'):
+            tags.add(h.name)
+    r  = [n for n in tags if n.startswith(name)]
+
+    print "RES", r
 
     return json.dumps(r)
 
 
 
-pages = {lookup : { 'routes' : ['/lookup/:name']},
-         lookup_post : { 'routes' : ['/lookup'] , 'method' : 'POST'}
+pages = {lookup_tag_post : { 'routes' : ['/lookup/tag'] , 'method' : 'POST'}
          }
 
diff --git a/shinken/webui/plugins_skonf/newhosts/views/newhosts_results.tpl b/shinken/webui/plugins_skonf/newhosts/views/newhosts_results.tpl
index fd0a517..5252616 100644
--- a/shinken/webui/plugins_skonf/newhosts/views/newhosts_results.tpl
+++ b/shinken/webui/plugins_skonf/newhosts/views/newhosts_results.tpl
@@ -1,5 +1,6 @@
 
 %rebase layout_skonf globals()
+
 <div> <h1> Discover your new hosts </h1> </div>
 
 <p>Here are the scans :</p>
@@ -11,4 +12,35 @@
 
 %for h in pending_hosts:
      <br/>{{h}}
-%end
\ No newline at end of file
+     <form method="get" id="host-{{h['host_name']}}" action="/add">
+       <span class="table">
+	 <span class="row">
+	   <span class="cell">
+	     <input name="tags" type="text" tabindex="1" value="{{h['use']}}" id="use-{{h['host_name']}}"/>
+	   </span>
+	   <span class="cell">
+	     <a tabindex="4" href="javascript: submitform()">
+	       <img src="/static/images/search.png" alt="search"/>
+	     </a>
+	   </span>
+	 </span>
+       </span>
+     </form>
+
+     %# " Add the auto copleter in the search input form"
+     <script type="text/javascript">
+       document.addEvent('domready', function() {
+         var tags = $("use-{{h['host_name']}}");
+ 
+         // Our instance for the element with id "use-"
+         new Autocompleter.Request.JSON(tags, '/lookup/tag', {
+            'indicatorClass': 'autocompleter-loading',
+            'minLength': 3,
+            'multiple': true,
+         });
+       
+       });
+     </script>
+
+
+%end
diff --git a/shinken/webui/views/layout.tpl b/shinken/webui/views/layout.tpl
index 43beb6d..9c85c86 100644
--- a/shinken/webui/views/layout.tpl
+++ b/shinken/webui/views/layout.tpl
@@ -31,6 +31,7 @@
       <link rel="stylesheet" type="text/css" href="/static/css/message.css" media="screen"/>
       <link rel="stylesheet" type="text/css" href="/static/css/multibox.css" media="screen"/>
       <link rel="stylesheet" type="text/css" href="/static/css/pulse.css" media="screen"/>
+      <link rel="stylesheet" type="text/css" href="/static/css/autocompleter.css" media="screen"/>
 
       %if user is not None:
         <link rel="stylesheet" type="text/css" href="/static/css/userinfo.css" media="screen"/>
diff --git a/shinken/webui/views/layout_skonf.tpl b/shinken/webui/views/layout_skonf.tpl
index fda5b40..187d441 100644
--- a/shinken/webui/views/layout_skonf.tpl
+++ b/shinken/webui/views/layout_skonf.tpl
@@ -31,6 +31,7 @@
       <link rel="stylesheet" type="text/css" href="/static/css/message.css" media="screen"/>
       <link rel="stylesheet" type="text/css" href="/static/css/multibox.css" media="screen"/>
       <link rel="stylesheet" type="text/css" href="/static/css/pulse.css" media="screen"/>
+      <link rel="stylesheet" type="text/css" href="/static/css/autocompleter.css" media="screen"/>
 
       %if user is not None:
         <link rel="stylesheet" type="text/css" href="/static/css/userinfo.css" media="screen"/>
@@ -56,6 +57,13 @@
       <script type="text/javascript" src="/static/js/multibox.js"></script>
       <script type="text/javascript" src="/static/js/deptree.js"></script>
 
+      %# Auto completer part
+      <script type="text/javascript" src="/static/js/autocompleter.js"></script>
+      <script type="text/javascript" src="/static/js/autocompleter.Request.js"></script>
+      <script type="text/javascript" src="/static/js/autocompleterObserver.js"></script>
+
+
+
       %if user is not None and print_header:
         <script type="text/javascript" src="/static/js/userinfo.js"></script>
       %end

-- 
UNNAMED PROJECT



More information about the Pkg-nagios-changes mailing list