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