ocserv_status.htm 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 + 1 < tb.childNodes.length))
  8. tb.removeChild(tb.childNodes[idx + 1]);
  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.firstElementChild !== tb.lastElementChild)
  20. tb.removeChild(tb.lastElementChild);
  21. for (var i = 0; i < st.length; i++)
  22. {
  23. tb.appendChild(E('<div class="tr cbi-section-table-row cbi-rowstyle-%d">'.format((i % 2) + 1), [
  24. E('<div class="td">', st[i].user),
  25. E('<div class="td">', st[i].group),
  26. E('<div class="td">', st[i].vpn_ip),
  27. E('<div class="td">', st[i].ip),
  28. E('<div class="td">', st[i].device),
  29. E('<div class="td">', st[i].time),
  30. E('<div class="td">', st[i].cipher),
  31. E('<div class="td">', st[i].status),
  32. E('<div class="td">',
  33. E('<input class="cbi-button cbi-input-remove" type="button" value="<%:Disconnect%>" onclick="ocserv_disconnect(%d)" />'
  34. .format(st[i].id)))
  35. ]));
  36. }
  37. if (tb.firstElementChild === tb.lastElementChild)
  38. tb.appendChild(E('<div class="tr cbi-section-table-row"><div class="td"><em><br /><%:There are no active users.%></em></div></div>'));
  39. }
  40. }
  41. );
  42. //]]></script>
  43. <fieldset class="cbi-section">
  44. <legend><%:Active OpenConnect Users%></legend>
  45. <div class="table cbi-section-table" id="ocserv_status_table">
  46. <div class="tr cbi-section-table-titles">
  47. <div class="th cbi-section-table-cell"><%:User%></div>
  48. <div class="th cbi-section-table-cell"><%:Group%></div>
  49. <div class="th cbi-section-table-cell"><%:IP Address%></div>
  50. <div class="th cbi-section-table-cell"><%:VPN IP Address%></div>
  51. <div class="th cbi-section-table-cell"><%:Device%></div>
  52. <div class="th cbi-section-table-cell"><%:Time%></div>
  53. <div class="th cbi-section-table-cell"><%:Cipher%></div>
  54. <div class="th cbi-section-table-cell"><%:Status%></div>
  55. <div class="th cbi-section-table-cell">&#160;</div>
  56. </div>
  57. <div class="tr cbi-section-table-row">
  58. <div class="td" colspan="5"><em><br /><%:Collecting data...%></em></div>
  59. </div>
  60. </div>
  61. </fieldset>