luci-app-mwan3: remove duplicated code section
[project/luci.git] / applications / luci-app-mwan3 / luasrc / view / mwan / status_diagnostics.htm
1 <%#
2  Copyright 2014 Aedan Renner <chipdankly@gmail.com>
3  Copyright 2018 Florian Eckert <fe@dev.tdt.de>
4  Licensed to the public under the GNU General Public License v2.
5 -%>
6
7 <%+header%>
8
9 <ul class="cbi-tabmenu">
10         <li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/status/mwan/overview")%>"><%:Interface%></a></li>
11         <li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/status/mwan/detail")%>"><%:Detail%></a></li>
12         <li class="cbi-tab"><a href="<%=luci.dispatcher.build_url("admin/status/mwan/diagnostics")%>"><%:Diagnostics%></a></li>
13         <li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/status/mwan/troubleshooting")%>"><%:Troubleshooting%></a></li>
14 </ul>
15
16 <%
17         local uci = require "luci.model.uci"
18
19         local iface = {}
20
21         uci.cursor():foreach("mwan3", "interface",
22                 function (section)
23                         table.insert(iface, section[".name"])
24                 end
25         )
26 %>
27
28 <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
29 <script type="text/javascript">//<![CDATA[
30         var stxhr = new XHR();
31
32         function update_status(iface, task)
33         {
34                 var legend = document.getElementById('diag-rc-legend');
35                 var output = document.getElementById('diag-rc-output');
36
37                 output.innerHTML =
38                         '<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align: middle;" />' +
39                         "<%:Waiting for command to complete...%>"
40                 ;
41
42                 output.parentNode.style.display = 'block';
43                 output.style.display = 'inline';
44
45                 stxhr.post('<%=url('admin/status/mwan')%>/diagnostics_display' + '/' + iface + '/' + task, { token: '<%=token%>' },
46                         function(x)
47                         {
48                                 legend.style.display = 'none';
49                                 output.innerHTML = String.format('<pre>%h</pre>', x.responseText);
50                         }
51                 );
52         }
53 //]]></script>
54
55 <form method="post" action="<%=url('admin/network/diagnostics')%>">
56         <div class="cbi-map">
57                 <h2 name="content"><%:MWAN Status - Diagnostics%></h2>
58                 <%if not require("luci.sys").init.enabled("mwan3") then%>
59                 <div><strong><%:INFO: MWAN not running%></strong></div>
60                 <%end%>
61                 <fieldset class="cbi-section">
62                         <br />
63
64                         <div style="width:30%; float:left">
65                                 <label class="cbi-value-title"><%:Interface%></label>
66                                 <select name="iface" style="width:auto">
67                                         <% for _, z in ipairs(iface) do -%><option value="<%=z%>"><%=z%></option><%- end %>
68                                 </select>
69                         </div>
70
71                         <div style="width:30%; float:left">
72                                 <label class="cbi-value-title"><%:Task%></label>
73                                 <select name="task" style="width:auto">
74                                         <option value="ping_gateway"><%:Ping default gateway%></option>
75                                         <option value="ping_trackips"><%:Ping tracking IP%></option>
76                                         <option value="check_rules"><%:Check IP rules%></option>
77                                         <option value="check_routes"><%:Check routing table%></option>
78                                         <option value="hotplug_ifup"><%:Hotplug ifup%></option>
79                                         <option value="hotplug_ifdown"><%:Hotplug ifdown%></option>
80                                 </select>
81                         </div>
82
83                         <div style="width:30%; float:left">
84                                 <input type="button" value="<%:Execute%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.iface.value, this.form.task.value)"/>
85                         </div>
86                 </fieldset>
87         </div>
88         <fieldset class="cbi-section" style="display:none">
89                 <legend id="diag-rc-legend"><%:Collecting data...%></legend>
90                 <span id="diag-rc-output"></span>
91         </fieldset>
92 </form>
93
94 <%+footer%>