a26371a26addbf4e86b5a9071dad718dc4f07519
[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 <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
18 <script type="text/javascript">//<![CDATA[
19         var stxhr = new XHR();
20
21         function update_status(field)
22         {
23                 var tool = field.name;
24                 var addr = field.value;
25
26                 var legend = document.getElementById('diag-rc-legend');
27                 var output = document.getElementById('diag-rc-output');
28
29                 if (legend && output)
30                 {
31                         output.innerHTML =
32                                 '<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
33                                 '<%:Waiting for router...%>'
34                         ;
35
36                         legend.style.display = null;
37                         legend.parentNode.style.display = 'block';
38
39                         stxhr.get('<%=luci.dispatcher.build_url("admin", "network")%>/diag_' + tool + '/' + addr, null,
40                                 function(x)
41                                 {
42                                         if (x.responseText)
43                                         {
44                                                 legend.style.display = 'none';
45                                                 output.innerHTML = String.format('<pre>%h</pre>', x.responseText);
46                                         }
47                                         else
48                                         {
49                                                 legend.style.display = 'none';
50                                                 output.innerHTML = '<span class="error"><%:Bad address specified!%></span>';
51                                         }
52                                 }
53                         );
54                 }
55         }
56 //]]></script>
57
58 <form method="post" action="<%=pcdata(luci.http.getenv("REQUEST_URI"))%>">
59         <div class="cbi-map">
60                 <h2><a id="content" name="content"><%:Diagnostics%></a></h2>
61
62                 <fieldset class="cbi-section">
63                         <legend><%:Network Utilities%></legend>
64
65                         <br />
66
67                         <div style="width:30%; float:left; text-align:center">
68                                 <input style="width: 50%" type="text" value="openwrt.org" name="ping" />
69                                 <input type="button" value="Ping" class="cbi-button cbi-button-apply" onclick="update_status(this.form.ping)" />
70                         </div>
71
72                         <div style="width:30%; float:left; text-align:center">
73                                 <input style="width: 50%" type="text" value="openwrt.org" name="traceroute" />
74                                 <input type="button" value="Traceroute" class="cbi-button cbi-button-apply" onclick="update_status(this.form.traceroute)" />
75                         </div>
76
77                         <div style="width:30%; float:left; text-align:center">
78                                 <input style="width: 50%" type="text" value="openwrt.org" name="nslookup" />
79                                 <input type="button" value="Nslookup" class="cbi-button cbi-button-apply" onclick="update_status(this.form.nslookup)" />
80                         </div>
81
82                         <br style="clear:both" /><br />
83
84                 </fieldset>
85         </div>
86
87         <fieldset class="cbi-section" style="display:none">
88                 <legend id="diag-rc-legend"><%:Collecting data...%></legend>
89                 <span id="diag-rc-output"></span>
90         </fieldset>
91 </form>
92
93 <%+footer%>