add links for length of query for nodescanhistory view
Stephen Soltesz [Mon, 27 Jul 2009 16:19:22 +0000 (16:19 +0000)]
web/MonitorWeb/monitorweb/controllers.py
web/MonitorWeb/monitorweb/templates/nodescanhistory.kid

index 5fe87b1..0c80fee 100644 (file)
@@ -177,7 +177,25 @@ class Root(controllers.RootController, MonitorXmlrpcServer):
                flash("Welcome To MyOps!")
                return dict(now=time.ctime())
 
-       @expose(template="monitorweb.templates.nodelist")
+       @expose(template="monitorweb.templates.nodelist", allow_json=True)
+       def node3(self, filter=None):
+               nhquery = HistoryNodeRecord.query.all()
+               query = []
+               for nh in nhquery:
+                       if filter:
+                               if nh.status == filter:
+                                       query.append(nh)
+                       else:
+                               query.append(nh)
+
+               rquery=[]
+               for q in query:
+                       fb = FindbadNodeRecord.get_latest_by(hostname=q.hostname)
+                       rquery.append(fb)
+
+               return dict(now=time.ctime(), query=rquery)
+
+       @expose(template="monitorweb.templates.nodelist", allow_json=True)
        def node2(self, filter=None):
                nhquery = HistoryNodeRecord.query.all()
                query = []
@@ -407,7 +425,7 @@ class Root(controllers.RootController, MonitorXmlrpcServer):
        @expose(template="monitorweb.templates.nodescanhistory")
        def nodescanhistory(self, hostname=None, length=10):
                try: length = int(length)
-               except: length = 10
+               except: length = 21
 
                fbnode = FindbadNodeRecord.get_by(hostname=hostname)
                # TODO: add links for earlier history if desired.
@@ -418,7 +436,9 @@ class Root(controllers.RootController, MonitorXmlrpcServer):
                        agg = prep_node_for_display(node, pcuhash=None, preppcu=False, asofdate=node.timestamp)
                        query.append(agg)
 
-               return dict(query=query, hostname=hostname)
+               if 'length' in request.params: 
+                       del request.params['length']
+               return dict(query=query, hostname=hostname, params=request.params)
 
        @expose(template="monitorweb.templates.nodehistory")
        def nodehistory(self, hostname=None):
index 7e99d9d..03416e7 100644 (file)
@@ -1,9 +1,10 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <?python
-layout_params['page_title'] = "MyOps Node List"
+layout_params['page_title'] = "MyOps Node Scan History"
 from monitor.util import diff_time
 from time import mktime
 from links import *
+from cherrypy import request, response
 
 ?>
 <html py:layout="'sitemenu.kid'"
@@ -15,6 +16,17 @@ from links import *
   <script type="text/javascript">
     function nodelist_paginator(opts) { plekit_table_paginator(opts, "nodelist"); }
   </script>
+       <table width="100%">
+               <thead>
+                       <tr>
+                               <th><a href="${link('nodescanhistory', length=42, **params)}">Last Week</a></th>
+                               <th><a href="${link('nodescanhistory', length=180, **params)}">Last Month</a></th>
+                               <th><a href="${link('nodescanhistory', length=1000, **params)}">Last 1000</a></th>
+                       </tr>
+               </thead>
+               <tbody>
+               <tr>
+               <td colspan="5">
 
 <table id="nodelist" cellpadding="0" border="0" class="plekit_table sortable-onload-2 colstyle-alt no-arrow paginationcallback-nodelist_paginator max-pages-10 paginate-25">
   <thead>
@@ -70,6 +82,10 @@ from links import *
 
   </tbody>  
 </table>
+               </td>
+               </tr>
+               </tbody>
+       </table>
 
 </div>