applications: add luci-ahcp, support for the AHCP server package
[project/luci.git] / applications / luci-ahcp / luasrc / view / ahcp_status.htm
1 <script type="text/javascript">//<![CDATA[
2         var stxhr = new XHR();
3         var update_status = function() {
4                 stxhr.get('<%=luci.dispatcher.build_url("admin", "network", "ahcpd", "status")%>', null,
5                         function(x, st)
6                         {
7                                 var tb = document.getElementById('ahcpd_status_table');
8                                 var tx = document.getElementById('ahcpd_status_text');
9                                 if (st && tb && tx)
10                                 {
11                                         /* clear all rows */
12                                         while( tb.rows.length > 1 )
13                                                 tb.deleteRow(1);
14
15                                         for( var i = 0; i < st.leases.length; i++ )
16                                         {
17                                                 var tr = tb.insertRow(-1);
18                                                         tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
19
20                                                 tr.insertCell(-1).innerHTML = st.leases[i].addr;
21                                                 tr.insertCell(-1).innerHTML = String.format('%t', st.leases[i].age);
22                                         }
23
24                                         if( tb.rows.length == 1 )
25                                         {
26                                                 var tr = tb.insertRow(-1);
27                                                         tr.className = 'cbi-section-table-row';
28
29                                                 var td = tr.insertCell(-1);
30                                                         td.colSpan = 2;
31                                                         td.innerHTML = '<em><br /><%:There are no active leases.%></em>';
32                                         }
33
34                                         if( st.uid == '00:00:00:00:00:00:00:00' )
35                                                 tx.innerHTML = 'The AHCP Service is not running.';
36                                         else
37                                                 tx.innerHTML = String.format('The AHCP Service is running with ID %s.', st.uid);
38                                 }
39
40                                 window.setTimeout(update_status, 5000);
41                         }
42                 )
43         };
44
45         update_status();
46 //]]></script>
47
48 <fieldset class="cbi-section">
49         <legend><%:Active AHCP Leases%></legend>
50         <p id="ahcpd_status_text"></p>
51         <table class="cbi-section-table" id="ahcpd_status_table">
52                 <tr class="cbi-section-table-titles">
53                         <th class="cbi-section-table-cell"><%:Address%></th>
54                         <th class="cbi-section-table-cell"><%:Age%></th>
55                 </tr>
56                 <tr class="cbi-section-table-row">
57                         <td colspan="5"><em><br /><%:Collecting data...%></em></td>
58                 </tr>
59         </table>
60 </fieldset>