luci-0.11: merge r9571 - r9622
[project/luci.git] / modules / admin-full / luasrc / view / admin_network / diagnostics.htm
1 <%#
2 LuCI - Lua Configuration Interface
3 Copyright 2010 Jo-Philipp Wich <xm@subsignal.org>
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 $Id$
12
13 -%>
14
15 <%+header%>
16
17 <%
18 local fs = require "nixio.fs"
19 local has_ping6 = fs.access("/bin/ping6") or fs.access("/usr/bin/ping6")
20 local has_traceroute6 = fs.access("/usr/bin/traceroute6")
21 %>
22
23 <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
24 <script type="text/javascript">//<![CDATA[
25 var stxhr = new XHR();
26
27 function update_status(field, proto)
28 {
29 var tool = field.name;
30 var addr = field.value;
31 var protocol = proto ? "6" : "";
32
33 var legend = document.getElementById('diag-rc-legend');
34 var output = document.getElementById('diag-rc-output');
35
36 if (legend && output)
37 {
38 output.innerHTML =
39 '<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
40 '<%:Waiting for command to complete...%>'
41 ;
42
43 legend.parentNode.style.display = 'block';
44 legend.style.display = 'inline';
45
46 stxhr.get('<%=luci.dispatcher.build_url("admin", "network")%>/diag_' + tool + protocol + '/' + addr, null,
47 function(x)
48 {
49 if (x.responseText)
50 {
51 legend.style.display = 'none';
52 output.innerHTML = String.format('<pre>%h</pre>', x.responseText);
53 }
54 else
55 {
56 legend.style.display = 'none';
57 output.innerHTML = '<span class="error"><%:Bad address specified!%></span>';
58 }
59 }
60 );
61 }
62 }
63 //]]></script>
64
65 <form method="post" action="<%=pcdata(luci.http.getenv("REQUEST_URI"))%>">
66 <div class="cbi-map">
67 <h2><a id="content" name="content"><%:Diagnostics%></a></h2>
68
69 <fieldset class="cbi-section">
70 <legend><%:Network Utilities%></legend>
71
72 <br />
73
74 <div style="width:30%; float:left">
75 <input style="margin: 5px 0" type="text" value="openwrt.org" name="ping" /><br />
76 <% if has_ping6 then %>
77 <select name="ping_proto" style="width:auto">
78 <option value="" selected="selected"><%:IPv4%></option>
79 <option value="6"><%:IPv6%></option>
80 </select>
81 <input type="button" value="<%:Ping%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.ping, this.form.ping_proto.selectedIndex)" />
82 <% else %>
83 <input type="button" value="<%:Ping%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.ping)" />
84 <% end %>
85 </div>
86
87 <div style="width:33%; float:left">
88 <input style="margin: 5px 0" type="text" value="openwrt.org" name="traceroute" /><br />
89 <% if has_traceroute6 then %>
90 <select name="traceroute_proto" style="width:auto">
91 <option value="" selected="selected"><%:IPv4%></option>
92 <option value="6"><%:IPv6%></option>
93 </select>
94 <input type="button" value="<%:Traceroute%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.traceroute, this.form.traceroute_proto.selectedIndex)" />
95 <% else %>
96 <input type="button" value="<%:Traceroute%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.traceroute)" />
97 <% end %>
98 <% if not has_traceroute6 then %>
99 <p>&#160;</p>
100 <p><%:Install iputils-traceroute6 for IPv6 traceroute%></p>
101 <% end %>
102 </div>
103
104 <div style="width:33%; float:left;">
105 <input style="margin: 5px 0" type="text" value="openwrt.org" name="nslookup" /><br />
106 <input type="button" value="<%:Nslookup%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.nslookup)" />
107 </div>
108
109 <br style="clear:both" /><br />
110
111 </fieldset>
112 </div>
113
114 <fieldset class="cbi-section" style="display:none">
115 <legend id="diag-rc-legend"><%:Collecting data...%></legend>
116 <span id="diag-rc-output"></span>
117 </fieldset>
118 </form>
119
120 <%+footer%>