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