runtime.htm 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <%#
  2. Copyright 2018 Dirk Brenken (dev@brenken.org)
  3. This is free software, licensed under the Apache License, Version 2.0
  4. -%>
  5. <%+banip/banip_css%>
  6. <script type="text/javascript">
  7. //<![CDATA[
  8. function status_update(json)
  9. {
  10. var btn1 = document.getElementById("btn1");
  11. var btn1_running = document.getElementById("btn1_running");
  12. var view = document.getElementById("value_1");
  13. var input = json.data.status;
  14. btn1.value = "<%:Refresh%>";
  15. btn1.name = "do_refresh";
  16. view.innerHTML = input || "-";
  17. if (input != "running")
  18. {
  19. btn1.disabled = false;
  20. running(btn1_running, 0);
  21. }
  22. view = document.getElementById("value_2");
  23. input = json.data.version;
  24. view.innerHTML = input || "-";
  25. view = document.getElementById("value_3");
  26. input = json.data.fetch_info;
  27. view.innerHTML = input || "-";
  28. view = document.getElementById("value_4");
  29. input = json.data.ipset_info;
  30. view.innerHTML = input || "-";
  31. view = document.getElementById("value_5");
  32. input = json.data.last_run;
  33. view.innerHTML = input || "-";
  34. }
  35. function btn_action(action)
  36. {
  37. var btn1 = document.getElementById("btn1");
  38. var btn1_running = document.getElementById("btn1_running");
  39. btn1.disabled = true;
  40. running(btn1_running, 1);
  41. new XHR.get('<%=luci.dispatcher.build_url("admin", "services", "banip")%>/action/' + action.name, null,
  42. function(x)
  43. {
  44. if (!x)
  45. {
  46. return;
  47. }
  48. });
  49. }
  50. function running(element, state)
  51. {
  52. if (state === 1)
  53. {
  54. var running_html = '<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" width="16" height="16" style="vertical-align:middle" />';
  55. element.innerHTML = running_html;
  56. }
  57. else
  58. {
  59. element.innerHTML = '';
  60. }
  61. }
  62. XHR.get('<%=luci.dispatcher.build_url("admin", "services", "banip", "status")%>', null,
  63. function(x, json_info)
  64. {
  65. if (!x || !json_info)
  66. {
  67. return;
  68. }
  69. status_update(json_info)
  70. });
  71. XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "services", "banip", "status")%>', null,
  72. function(x, json_info)
  73. {
  74. if (!x || !json_info)
  75. {
  76. return;
  77. }
  78. status_update(json_info)
  79. });
  80. //]]>
  81. </script>
  82. <h3><%:Runtime Information%></h3>
  83. <div class="cbi-value" id="status_1">
  84. <label class="cbi-value-title" for="status_1"><%:banIP Status%></label>
  85. <div class="cbi-value-field">
  86. <span class="runtime" id="value_1">-</span>
  87. </div>
  88. </div>
  89. <div class="cbi-value" id="status_2">
  90. <label class="cbi-value-title" for="status_2"><%:banIP Version%></label>
  91. <div class="cbi-value-field">
  92. <span class="runtime" id="value_2">-</span>
  93. </div>
  94. </div>
  95. <div class="cbi-value" id="status_3">
  96. <label class="cbi-value-title" for="status_3"><%:Download Utility (SSL Library)%></label>
  97. <div class="cbi-value-field">
  98. <span class="runtime" id="value_3">-</span>
  99. </div>
  100. </div>
  101. <div class="cbi-value" id="status_4">
  102. <label class="cbi-value-title" for="status_4"><%:IPSet Information%></label>
  103. <div class="cbi-value-field">
  104. <span class="runtime" id="value_4">-</span>
  105. </div>
  106. </div>
  107. <div class="cbi-value" id="status_5">
  108. <label class="cbi-value-title" for="status_5"><%:Last Run%></label>
  109. <div class="cbi-value-field">
  110. <span class="runtime" id="value_5">-</span>
  111. </div>
  112. </div>
  113. <hr />
  114. <div class="cbi-value" id="button_1">
  115. <label class="cbi-value-title" for="button_1"><%:Refresh IPSets%></label>
  116. <div class="cbi-value-field">
  117. <input class="cbi-button cbi-button-apply" id="btn1" type="button" name="do_refresh" value="<%:Refresh%>" onclick="btn_action(this)" />
  118. <span id="btn1_running" class="btn_running"></span>
  119. </div>
  120. </div>