- use plekit tables
Barış Metin [Fri, 15 May 2009 14:07:52 +0000 (14:07 +0000)]
- depend on plewww-plekit
- fix nodeview in controlers.py although it seems that it's not used.

Monitor.spec
web/MonitorWeb/monitorweb/controllers.py
web/MonitorWeb/monitorweb/templates/node_template.kid
web/MonitorWeb/monitorweb/templates/nodelist.kid
web/MonitorWeb/monitorweb/templates/pculist.kid
web/MonitorWeb/monitorweb/templates/sitelist.kid
web/MonitorWeb/monitorweb/templates/sitemenu.kid

index 1843fe2..c9b71fc 100644 (file)
@@ -61,6 +61,7 @@ Requires: MySQL-python
 Requires: nmap
 Requires: rt3
 
+Requires: plewww-plekit
 #Requires: python-sqlalchemy
 #Requires: python-elixir
 #Requires: zabbix-client
@@ -246,6 +247,10 @@ chkconfig --add monitor-runlevelagent
 chkconfig monitor-runlevelagent on
 
 %changelog
+* Fri May 15 2009 Baris Metin <tmetin@sophia.inria.fr>
+- use plekit tables from plewww.
+- depend on plewww-plekit
+
 * Tue May 12 2009 Stephen Soltesz <soltesz@cs.princeton.edu> - Monitor-3.0-7
 - make docs a noop
 - fix for package name dependency
index 45c2a08..68f9d6a 100644 (file)
@@ -164,10 +164,10 @@ class Root(controllers.RootController, MonitorXmlrpcServer):
        def nodeview(self, hostname=None):
                nodequery=[]
                if hostname:
-                       for node in FindbadNodeRecord.get_latest_by(hostname=hostname):
-                               # NOTE: reformat some fields.
-                               prep_node_for_display(node)
-                               nodequery += [node]
+                        node = FindbadNodeRecord.get_latest_by(hostname=hostname)
+                        # NOTE: reformat some fields.
+                        prep_node_for_display(node)
+                        nodequery += [node]
 
                return self.pcuview(None, None, hostname) # dict(nodequery=nodequery)
 
index a9ab0e4..e067596 100644 (file)
@@ -7,9 +7,11 @@ from links import *
 <span xmlns:py="http://purl.org/kid/ns#">
        <span py:if="header is not None">
                <th>Site</th>
+                <th>Ping</th>
+                <th>SSH</th>
+                <th>Boot Status</th>
                <th>pcu</th>
                <th>Hostname</th>
-               <!--th>ssh</th-->
                <th>kernel</th>
                <th>last_contact</th>
        </span>
@@ -17,6 +19,9 @@ from links import *
                <td id="site-${node.site.status}">
                        <a href="${link('pcuview', loginbase=node.loginbase)}">${node.loginbase}</a>
                </td>
+                <td py:content="node.ping_status">ping</td>
+                <td py:content="node.ssh_status">ssh</td>
+                <td py:content="node.plc_node_stats['boot_state']">boot</td>
                <td width="20%" nowrap='true' align='center' id="status-${node.pcu_short_status}">
                        <div id="links">
                                <a class="info" py:if="'error' in node.pcu_short_status" 
index 53bbe5b..95624d9 100644 (file)
@@ -4,46 +4,70 @@ layout_params['page_title'] = "Monitor Node List"
 from monitor.util import diff_time
 from time import mktime
 from links import *
+
 ?>
 <html py:layout="'sitemenu.kid'"
       xmlns:py="http://purl.org/kid/ns#"
          xmlns:mochi="http://www.mochi.org">
 
-  <div py:match="item.tag == 'content'">
-       <table width="100%">
-               <thead>
-                       <tr>
-                               <th><a href="${link('node', filter='boot')}">Prod(${fc['boot']})</a></th>
-                               <th><a href="${link('node', filter='down')}">Down(${fc['down']})</a></th>
-                               <th><a href="${link('node', filter='monitordebug')}">Errors(${fc['debug']})</a></th>
-                               <th><a href="${link('node', filter='diagnose')}">Diagnose (${fc['diagnose']})</a></th>
-                               <th><a href="${link('node', filter='disabled')}">Disabled (${fc['disabled']})</a></th>
-                               <th><a href="${link('node', filter='neverboot')}">Never Booted(${fc['neverboot']})</a></th>
-                               <!--th><a href="${link('node', filter='pending')}">Pending Reply(${fc['pending']})</a></th-->
-                               <th><a href="${link('node', filter='all')}">All</a></th>
-                       </tr>
-               </thead>
-               <tbody>
-               <tr>
-               <td colspan="7">
-               <table id="sortable_table" class="datagrid" border="1" width="100%">
-                       <thead>
-                               <tr>
-                                       <th mochi:format="int"></th>
-                                       ${nodewidget.display(node=None, header=True)}
-                               </tr>
-                       </thead>
-                       <tbody>
-                               <tr py:for="i,node in enumerate(query)" class="${i%2 and 'odd' or 'even'}" >
-                                       <td></td>
-                                       ${nodewidget.display(node=node, header=None)}
-                               </tr>
-                       </tbody>
-               </table>
-               </td>
-               </tr>
-               </tbody>
-       </table>
-  </div>
+<div py:match="item.tag == 'content'">
+
+  <script type="text/javascript">
+    function nodelist_paginator(opts) { plekit_table_paginator(opts, "nodelist"); }
+  </script>
+
+  <center>
+  <b py:content="'BOOT-PROD: %d' % len([node for node in query if node.plc_node_stats['boot_state'] == 'boot'])"></b> | 
+  <b py:content="'BOOT-SAFEBOOT: %d' % len([node for node in query if node.plc_node_stats['boot_state'] == 'safeboot'])"></b> | 
+  <b py:content="'BOOT-REINSTALL: %d' % len([node for node in query if node.plc_node_stats['boot_state'] == 'reinstall'])"></b><br/>
+  </center>
+
+<table id="nodelist" cellpadding="0" border="0" class="plekit_table sortable-onload-0 rowstyle-alt colstyle-alt no-arrow paginationcallback-nodelist_paginator max-pages-10 paginate-25">
+  <thead>
+
+    <tr class='pagesize_area'><td class='pagesize_area' colspan='8'>
+        <form class='pagesize' action='satisfy_xhtml_validator'><fieldset>
+            <input class='pagesize_input' type='text' id="nodelist_pagesize" value='25'
+                   onkeyup='plekit_pagesize_set("nodelist","nodelist_pagesize", 25);' 
+                   size='3' maxlength='3' />                                                          
+            <label class='pagesize_label'> items/page </label>                                     
+            <img class='reset' src="/planetlab/icons/clear.png" alt="reset visible size"           
+                 onmousedown='plekit_pagesize_reset("nodelist","nodelist_pagesize", 25);' />
+    </fieldset></form></td></tr>                                                                        
+    
+    <tr class='search_area'><td class='search_area' colspan='8'>
+        <div class='search'><fieldset>
+            <label class='search_label'> Search </label>                 
+            <input class='search_input' type='text' id='nodelist_search' 
+                   onkeyup='plekit_table_filter("nodelist","nodelist_search","nodelist_search_and");'
+                   size='self.search_width' maxlength='256' />                                            
+            <label>and</label>                                                                        
+            <input id='nodelist_search_and' class='search_and'                                        
+                   type='checkbox' checked='checked'                                                      
+                   onchange='plekit_table_filter("nodelist","nodelist_search","nodelist_search_and");' />
+            <img class='reset' src="/planetlab/icons/clear.png" alt="reset search"
+                 onmousedown='plekit_table_filter_reset("nodelist","nodelist_search","nodelist_search_and");' />
+    </fieldset></div></td></tr>
+    
+    <tr>
+      <th class="sortable plekit_table">Site</th>
+      <th class="sortable plekit_table">Ping</th>
+      <th class="sortable plekit_table">SSH</th>
+      <th class="sortable plekit_table">Status</th>
+      <th class="sortable plekit_table">pcu</th>
+      <th class="sortable plekit_table">Hostname</th>
+      <th class="sortable plekit_table">kernel</th>
+      <th class="sortable plekit_table">last_contact</th>
+  </tr>
+  </thead>
+  <tbody>
+    <tr py:for="i,node in enumerate(query)" class="${i%2 and 'odd' or 'even'}" >
+      ${nodewidget.display(node=node, header=None)}
+    </tr>
+
+  </tbody>  
+</table>
+
+</div>
 
 </html>
index c06717d..a038532 100644 (file)
@@ -10,71 +10,84 @@ from links import *
          xmlns:mochi="http://www.mochi.org">
 
   <div py:match="item.tag == 'content'">
-       <table id="sub-table" width="100%">
-               <thead>
-                       <tr>
-                               <th><a href="${link('pcu', filter='ok')}">Ok(${fc['ok']})</a></th>
-                               <th><a href="${link('pcu', filter='Not_Run')}">Misconfigured(${fc['Not_Run']})</a></th>
-                               <th><a href="${link('pcu', filter='NetDown')}">Offline(${fc['NetDown']})</a></th>
-                               <th><a href="${link('pcu', filter='pending')}">Runtime Error(${fc['pending']})</a></th>
-                               <th><a href="${link('pcu', filter='all')}">All</a></th>
-                       </tr>
-               </thead>
-               <tbody>
-               <tr>
-               <td colspan="5">
-               <table id="sortable_table" class="datagrid" border="1" width="100%">
-                       <thead>
-                               <tr>
-                                       <th mochi:format="int"></th>
-                                       <th mochi:format="str">Site</th>
-                                       <th>PCU Name</th>
-                                       <th nowrap='true' >Port Status</th>
-                                       <th nowrap='true' width="80%">Test Results</th>
-                                       <th>Model</th>
-                                       <th>Nodes</th>
-                               </tr>
-                       </thead>
-                       <tbody>
-                               <tr py:for="i,node in enumerate(query)" class="${i%2 and 'odd' or 'even'}" >
-                                       <td></td>
-                                       <td nowrap='true'>
-                                               <div class='oneline'>
-                                               <a class='left' href="${link('pcuview', loginbase=node.loginbase)}">${node.loginbase}</a>
-                                               <a class='right' href="${plc_site_uri(node.loginbase)}">
-                                                       <img style='display: inline' border='0' src="static/images/extlink.gif" align='right'/></a>
-                                               </div>
-                                       </td>
-                                       <td nowrap='true'>
-                                               <div class='oneline'>
-                                               <a class='left' href="${link('pcuview', pcuid=node.plc_pcuid)}">${pcu_name(node.plc_pcu_stats)}</a>
-                                               <a class='right' href="${plc_pcu_uri_id(node.plc_pcu_stats['pcu_id'])}">
-                                                       <img style='display: inline' border='0' src="static/images/extlink.gif" align='right'/></a>
-                                               </div>
-                                       </td>
-                                       <td nowrap='true'>
-                                               <span py:for="port,state in node.ports" 
-                                               id="port${state}" py:content="'%s, ' % port">80</span>
-                                       </td>
-                                       <td width="20%" nowrap='true' align='center' id="status-${node.status}">
-                                               <div id="links">
-                                               <a class="info" py:if="'error' in node.status" 
-                                                       href="${link('pcuview', pcuid=node.plc_pcuid)}">
-                                                       Error<span><pre>${node.reboot_trial_status}</pre></span></a>
-                                               <a py:if="'error' not in node.status" 
-                                                       href="${link('pcuview', pcuid=node.plc_pcuid)}"
-                                                       py:content="node.status">Reboot Status</a>
-                                               </div>
-                                       </td>
-                                       <td py:content="node.plc_pcu_stats['model']"></td>
-                                       <td py:content="len(node.plc_pcu_stats['node_ids'])"></td>
-                               </tr>
-                       </tbody>
-               </table>
-               </td>
-               </tr>
-               </tbody>
-       </table>
+
+
+
+  <script type="text/javascript">
+    function pculist_paginator(opts) { plekit_table_paginator(opts, "pculist"); }
+  </script>
+
+<table id="pculist" cellpadding="0" border="0" class="plekit_table sortable-onload-0 rowstyle-alt colstyle-alt no-arrow paginationcallback-pculist_paginator max-pages-10 paginate-25">
+  <thead>
+
+    <tr class='pagesize_area'><td class='pagesize_area' colspan='5'>
+        <form class='pagesize' action='satisfy_xhtml_validator'><fieldset>
+            <input class='pagesize_input' type='text' id="pculist_pagesize" value='25'
+                   onkeyup='plekit_pagesize_set("pculist","pculist_pagesize", 25);' 
+                   size='3' maxlength='3' />                                                          
+            <label class='pagesize_label'> items/page </label>                                     
+            <img class='reset' src="/planetlab/icons/clear.png" alt="reset visible size"           
+                 onmousedown='plekit_pagesize_reset("pculist","pculist_pagesize", "pculist_search_and");' />
+    </fieldset></form></td></tr>                                                                        
+    
+    <tr class='search_area'><td class='search_area' colspan='5'>
+        <div class='search'><fieldset>
+            <label class='search_label'> Search </label>                 
+            <input class='search_input' type='text' id='pculist_search' 
+                   onkeyup='plekit_table_filter("pculist","pculist_search","pculist_search_and");'
+                   size='self.search_width' maxlength='256' />                                            
+            <label>and</label>                                                                        
+            <input id='pculist_search_and' class='search_and'                                        
+                   type='checkbox' checked='checked'                                                      
+                   onchange='plekit_table_filter("pculist","pculist_search","pculist_search_and");' />
+            <img class='reset' src="/planetlab/icons/clear.png" alt="reset search"
+                 onmousedown='plekit_table_filter_reset("pculist","pculist_search","pculist_search_and");' />
+    </fieldset></div></td></tr>
+    
+    <tr>
+      <th class="sortable plekit_table">Site</th>        
+      <th class="sortable plekit_table">PCU Name</th>         
+      <th class="sortable plekit_table">Port Status</th>    
+      <th class="sortable plekit_table">Test Results</th>      
+      <th class="sortable plekit_table">Model</th>
+      <th class="sortable plekit_table">Nodes</th>
+    </tr>
+  </thead>
+  <tbody>
+    <tr py:for="i,node in enumerate(query)" class="${i%2 and 'odd' or 'even'}" >
+      <td nowrap='true'>
+       <div class='oneline'>
+         <a class='left' href="${link('pcuview', loginbase=node.loginbase)}">${node.loginbase}</a>
+         <a class='right' href="${plc_site_uri(node.loginbase)}">
+           <img style='display: inline' border='0' src="static/images/extlink.gif" align='right'/></a>
+       </div>
+      </td>
+      <td nowrap='true'>
+       <div class='oneline'>
+         <a class='left' href="${link('pcuview', pcuid=node.plc_pcuid)}">${pcu_name(node.plc_pcu_stats)}</a>
+         <a class='right' href="${plc_pcu_uri_id(node.plc_pcu_stats['pcu_id'])}">
+           <img style='display: inline' border='0' src="static/images/extlink.gif" align='right'/></a>
+       </div>
+      </td>
+      <td nowrap='true'>
+       <span py:for="port,state in node.ports" 
+             id="port${state}" py:content="'%s, ' % port">80</span>
+      </td>
+      <td width="20%" nowrap='true' align='center' id="status-${node.status}">
+       <div id="links">
+         <a class="info" py:if="'error' in node.status" 
+            href="${link('pcuview', pcuid=node.plc_pcuid)}">
+           Error<span><pre>${node.reboot_trial_status}</pre></span></a>
+         <a py:if="'error' not in node.status" 
+            href="${link('pcuview', pcuid=node.plc_pcuid)}"
+            py:content="node.status">Reboot Status</a>
+       </div>
+      </td>
+      <td py:content="node.plc_pcu_stats['model']"></td>
+      <td py:content="len(node.plc_pcu_stats['node_ids'])"></td>
+    </tr>
+  </tbody>  
+</table>
   </div>
 
 </html>
index a2bac31..6f40828 100644 (file)
@@ -10,53 +10,66 @@ from links import *
          xmlns:mochi="http://www.mochi.org">
 
   <div py:match="item.tag == 'content'">
-       <table width="100%">
-               <thead>
-                       <tr>
-                               <th><a href="${link('site', filter='good')}">Compliant(${fc['good']})</a></th>
-                               <th><a href="${link('site', filter='down')}">Down(${fc['down']})</a></th>
-                               <th><a href="${link('site', filter='new')}">New Sites(${fc['new']})</a></th>
-                               <th><a href="${link('site', filter='pending')}">Disabled(${fc['pending']})</a></th>
-                               <th><a href="${link('site', filter='all')}">All(${fc['all']})</a></th>
-                       </tr>
-               </thead>
-               <tbody>
-               <tr>
-               <td colspan="5">
-               <table id="sortable_table" class="datagrid" border="1" width="100%">
-                       <thead>
-                               <tr>
-                                       <th></th>
-                                       <th>Site name</th>
-                                       <th>Enabled</th>
-                                       <th>Penalty</th>
-                                       <th mochi:format="int">Slices/Max</th>
-                                       <th mochi:format="int">Nodes/Total</th>
-                                       <th>Last Change</th>
-                               </tr>
-                       </thead>
-                       <tbody>
-                               <tr py:for="i,site in enumerate(query)" class="${i%2 and 'odd' or 'even'}" >
-                                       <td></td>
-                                       <td nowrap="true">
-                                               <div class='oneline'>
-                                               <a class='left' href="${link('pcuview', loginbase=site.loginbase)}">${site.loginbase}</a>
-                                               <a class='right' href="${plc_site_uri(site.loginbase)}">
-                                                       <img style='display: inline' border='0' src="static/images/extlink.gif" align='right'/></a>
-                                               </div>
-                                       </td>
-                                       <td py:content="site.enabled"></td>
-                                       <td id="site-${site.penalty_level}">${site.penalty_level}</td>
-                                       <td>${site.slices_used}/${site.slices_total}</td>
-                                       <td>${site.nodes_up} / ${site.nodes_total}</td>
-                                       <td id="site-${site.status}" py:content="diff_time(mktime(site.last_changed.timetuple()))"></td>
-                               </tr>
-                       </tbody>
-               </table>
-               </td>
-               </tr>
-               </tbody>
-       </table>
+
+
+  <script type="text/javascript">
+    function sitelist_paginator(opts) { plekit_table_paginator(opts, "sitelist"); }
+  </script>
+
+<table id="sitelist" cellpadding="0" border="0" class="plekit_table sortable-onload-0 rowstyle-alt colstyle-alt no-arrow paginationcallback-sitelist_paginator max-pages-10 paginate-25">
+  <thead>
+
+    <tr class='pagesize_area'><td class='pagesize_area' colspan='5'>
+        <form class='pagesize' action='satisfy_xhtml_validator'><fieldset>
+            <input class='pagesize_input' type='text' id="sitelist_pagesize" value='25'
+                   onkeyup='plekit_pagesize_set("sitelist","sitelist_pagesize", 25);' 
+                   size='3' maxlength='3' />                                                          
+            <label class='pagesize_label'> items/page </label>                                     
+            <img class='reset' src="/planetlab/icons/clear.png" alt="reset visible size"           
+                 onmousedown='plekit_pagesize_reset("sitelist","sitelist_pagesize", "sitelist_search_and");' />
+    </fieldset></form></td></tr>                                                                        
+    
+    <tr class='search_area'><td class='search_area' colspan='5'>
+        <div class='search'><fieldset>
+            <label class='search_label'> Search </label>                 
+            <input class='search_input' type='text' id='sitelist_search' 
+                   onkeyup='plekit_table_filter("sitelist","sitelist_search","sitelist_search_and");'
+                   size='self.search_width' maxlength='256' />                                            
+            <label>and</label>                                                                        
+            <input id='sitelist_search_and' class='search_and'                                        
+                   type='checkbox' checked='checked'                                                      
+                   onchange='plekit_table_filter("sitelist","sitelist_search","sitelist_search_and");' />
+            <img class='reset' src="/planetlab/icons/clear.png" alt="reset search"
+                 onmousedown='plekit_table_filter_reset("sitelist","sitelist_search","sitelist_search_and");' />
+    </fieldset></div></td></tr>
+    
+    <tr>
+      <th class="sortable plekit_table">Site Name</th>        
+      <th class="sortable plekit_table">Enabled</th>         
+      <th class="sortable plekit_table">Penalty</th>    
+      <th class="sortable plekit_table">Slices/Max</th>      
+      <th class="sortable plekit_table">Nodes/Total</th>
+      <th class="sortable plekit_table">Last Change</th>
+    </tr>
+  </thead>
+  <tbody>
+    <tr py:for="i,site in enumerate(query)" class="${i%2 and 'odd' or 'even'}" >
+      <td nowrap="true">
+       <div class='oneline'>
+         <a class='left' href="${link('pcuview', loginbase=site.loginbase)}">${site.loginbase}</a>
+         <a class='right' href="${plc_site_uri(site.loginbase)}">
+           <img style='display: inline' border='0' src="static/images/extlink.gif" align='right'/></a>
+       </div>
+      </td>
+      <td py:content="site.enabled"></td>
+      <td id="site-${site.penalty_level}">${site.penalty_level}</td>
+      <td>${site.slices_used}/${site.slices_total}</td>
+      <td>${site.nodes_up} / ${site.nodes_total}</td>
+      <td id="site-${site.status}" py:content="diff_time(mktime(site.last_changed.timetuple()))"></td>
+    </tr>
+  </tbody>  
+</table>
+
   </div>
 
 </html>
index 301e6ae..43d3c21 100644 (file)
@@ -4,7 +4,19 @@
     <title>${page_title}</title>
     <link href="static/css/style.css" type="text/css" rel="stylesheet" />
     <script type="text/javascript" src="tg_js/MochiKit.js"></script>
-    <script type="text/javascript" src="static/javascript/sortable_tables.js"></script>
+
+    <script type="text/javascript" src="/plekit/prototype/prototype.js"></script>
+
+    <script type="text/javascript" src="/plekit/tablesort/tablesort.js"></script>
+    <script type="text/javascript" src="/plekit/tablesort/customsort.js"></script>
+    <script type="text/javascript" src="/plekit/tablesort/paginate.js"></script>
+    <script type="text/javascript" src="/plekit/table/table.js"></script>
+    <link href="/plekit/table/table.css" rel="stylesheet" type="text/css" />
+
+    <script type="text/javascript" src="/plekit/niftycorner/niftycube.js"></script>
+    <script type="text/javascript" src="/plekit/niftycorner/nifty_init.js"></script>
+    <script type="text/javascript"> Event.observe(window,"load", nifty_init); </script>
+
 
        <!-- If in an iframe, then include this... -->
        <?python from monitor import config ?>