advanced_diagnostics.htm 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <%+header%>
  2. <ul class="cbi-tabmenu">
  3. <li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan/advanced/hotplugscript")%>"><%:Hotplug Script%></a></li>
  4. <li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan/advanced/mwanconfig")%>"><%:MWAN Config%></a></li>
  5. <li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan/advanced/networkconfig")%>"><%:Network Config%></a></li>
  6. <li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan/advanced/wirelessconfig")%>"><%:Wireless Config%></a></li>
  7. <li class="cbi-tab"><a href="<%=luci.dispatcher.build_url("admin/network/mwan/advanced/diagnostics")%>"><%:Diagnostics%></a></li>
  8. <li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan/advanced/troubleshooting")%>"><%:Troubleshooting%></a></li>
  9. </ul>
  10. <%
  11. local uci = require "luci.model.uci"
  12. interfaceNames = ""
  13. uci.cursor():foreach("mwan3", "interface",
  14. function (section)
  15. interfaceNames = interfaceNames .. section[".name"] .. " "
  16. end
  17. )
  18. %>
  19. <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
  20. <script type="text/javascript">//<![CDATA[
  21. var stxhr = new XHR();
  22. function update_status(tool, task, task_name)
  23. {
  24. var iface = document.getElementById('mwaniface').value;
  25. var output = document.getElementById('diag_output');
  26. if (tool == "service")
  27. {
  28. output.innerHTML =
  29. '<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="padding: 20px; vertical-align: middle;" /> ' +
  30. String.format("<%:Waiting for MWAN to %s...%>", task_name)
  31. ;
  32. }
  33. else
  34. {
  35. output.innerHTML =
  36. '<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="padding: 20px; vertical-align: middle;" /> ' +
  37. "<%:Waiting for diagnostic results...%>"
  38. ;
  39. }
  40. output.parentNode.style.display = 'block';
  41. output.style.display = 'inline';
  42. stxhr.get('<%=luci.dispatcher.build_url("admin", "network", "mwan", "advanced")%>/diagnostics_display' + '/' + iface + '/' + tool + '/' + task, null,
  43. function(x, mArray)
  44. {
  45. if (mArray.diagnostics)
  46. {
  47. output.innerHTML = String.format('<pre id="diag_output_css">%h</pre>', mArray.diagnostics[0]);
  48. }
  49. else
  50. {
  51. output.innerHTML = '<pre id="diag_output_css"><strong><%:No diagnostic results returned%></strong></pre>';
  52. }
  53. }
  54. );
  55. }
  56. //]]></script>
  57. <div id="mwan_diagnostics" class="cbi-map">
  58. <fieldset id="diag_select" class="cbi-section">
  59. <legend><%:MWAN Interface Diagnostics%></legend>
  60. <select id="mwaniface">
  61. <% for z in interfaceNames:gmatch("[^ ]+") do -%><option value="<%=z%>"><%=z%></option><%- end %>
  62. </select>
  63. <div id="buttoncss">
  64. <input type="button" value="<%:Ping default gateway%>" class="cbi-button cbi-button-apply" onclick="update_status('ping', 'gateway', null)" />
  65. <input type="button" value="<%:Ping tracking IP%>" class="cbi-button cbi-button-apply" onclick="update_status('ping', 'track_ip', null)" />
  66. <input type="button" value="<%:Check IP rules%>" class="cbi-button cbi-button-apply" onclick="update_status('rulechk', null, null)" />
  67. <input type="button" value="<%:Check routing table%>" class="cbi-button cbi-button-apply" onclick="update_status('routechk', null, null)" />
  68. <input type="button" value="<%:Hotplug ifup%>" class="cbi-button cbi-button-apply" onclick="update_status('hotplug', 'ifup', null)" />
  69. <input type="button" value="<%:Hotplug ifdown%>" class="cbi-button cbi-button-apply" onclick="update_status('hotplug', 'ifdown', null)" />
  70. </div>
  71. </fieldset>
  72. <fieldset id="diag_select" class="cbi-section">
  73. <legend><%:MWAN Service Control%></legend>
  74. <div id="buttoncss">
  75. <input type="button" value="<%:Restart MWAN%>" class="cbi-button cbi-button-apply" onclick="update_status('service', 'restart', '<%:restart%>')" />
  76. <input type="button" value="<%:Stop MWAN%>" class="cbi-button cbi-button-apply" onclick="update_status('service', 'stop', '<%:stop%>')" />
  77. <input type="button" value="<%:Start MWAN%>" class="cbi-button cbi-button-apply" onclick="update_status('service', 'start', '<%:start%>')" />
  78. </div>
  79. </fieldset>
  80. <fieldset class="cbi-section" style="display:none">
  81. <legend><%:Diagnostic Results%></legend>
  82. <div id="diag_output"></div>
  83. </fieldset>
  84. </div>
  85. <style type="text/css">
  86. #mwaniface {
  87. float: left;
  88. margin: 8px 20px 0px 0px;
  89. }
  90. #buttoncss {
  91. display: table;
  92. float: left;
  93. text-align: left;
  94. }
  95. .cbi-button {
  96. margin: 8px 20px 0px 0px;
  97. min-width: 153px;
  98. }
  99. #diag_output_css {
  100. padding: 20px;
  101. text-align: left;
  102. }
  103. </style>
  104. <%+footer%>