ocserv_status.htm 2.4 KB

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