Merge pull request #278 from nmav/ocserv
[project/luci.git] / applications / luci-ocserv / luasrc / view / ocserv_status.htm
1 <script type="text/javascript">//<![CDATA[
2
3         function ocserv_disconnect(idx) {
4                 XHR.get('<%=luci.dispatcher.build_url("admin", "services", "ocserv", "disconnect")%>/' + idx, null,
5                         function(x)
6                         {
7                                 var tb = document.getElementById('ocserv_status_table');
8                                 if (tb && (idx < tb.rows.length))
9                                         tb.rows[0].parentNode.removeChild(tb.rows[idx]);
10                         }
11                 );
12         }
13
14         XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "services", "ocserv", "status")%>', null,
15                 function(x, st)
16                 {
17                         var tb = document.getElementById('ocserv_status_table');
18                         if (st && tb)
19                         {
20                                 /* clear all rows */
21                                 while( tb.rows.length > 1 )
22                                         tb.deleteRow(1);
23
24                                 for( var i = 0; i < st.length; i++ )
25                                 {
26                                         var tr = tb.insertRow(-1);
27                                                 tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
28
29                                         tr.insertCell(-1).innerHTML = st[i].user;
30                                         tr.insertCell(-1).innerHTML = st[i].group;
31                                         tr.insertCell(-1).innerHTML = st[i].vpn_ip;
32                                         tr.insertCell(-1).innerHTML = st[i].ip;
33                                         tr.insertCell(-1).innerHTML = st[i].device;
34                                         tr.insertCell(-1).innerHTML = st[i].time;
35                                         tr.insertCell(-1).innerHTML = st[i].cipher;
36                                         tr.insertCell(-1).innerHTML = st[i].status;
37
38                                         tr.insertCell(-1).innerHTML = String.format(
39                                                 '<input class="cbi-button cbi-input-remove" type="button" value="<%:Disconnect%>" onclick="ocserv_disconnect(%d)" />',
40                                                         st[i].id
41                                         );
42                                 }
43
44                                 if( tb.rows.length == 1 )
45                                 {
46                                         var tr = tb.insertRow(-1);
47                                                 tr.className = 'cbi-section-table-row';
48
49                                         var td = tr.insertCell(-1);
50                                                 td.colSpan = 5;
51                                                 td.innerHTML = '<em><br /><%:There are no active users.%></em>';
52                                 }
53                         }
54                 }
55         );
56 //]]></script>
57
58 <fieldset class="cbi-section">
59         <legend><%:Active OpenConnect Users%></legend>
60         <table class="cbi-section-table" id="ocserv_status_table">
61                 <tr class="cbi-section-table-titles">
62                         <th class="cbi-section-table-cell"><%:User%></th>
63                         <th class="cbi-section-table-cell"><%:Group%></th>
64                         <th class="cbi-section-table-cell"><%:IP Address%></th>
65                         <th class="cbi-section-table-cell"><%:VPN IP Address%></th>
66                         <th class="cbi-section-table-cell"><%:Device%></th>
67                         <th class="cbi-section-table-cell"><%:Time%></th>
68                         <th class="cbi-section-table-cell"><%:Cipher%></th>
69                         <th class="cbi-section-table-cell"><%:Status%></th>
70                         <th class="cbi-section-table-cell">&#160;</th>
71                 </tr>
72                 <tr class="cbi-section-table-row">
73                         <td colspan="5"><em><br /><%:Collecting data...%></em></td>
74                 </tr>
75         </table>
76 </fieldset>