Merge remote branch 'remotes/origin/Teaman-IPTraffic' into Teaman-ND
[tomato.git] / release / src / router / www / status-devices.asp
blob0f85f2cb3857be9621ca9fa4e3f7609a763fa67b
1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0//EN'>
2 <!--
3 Tomato GUI
4 Copyright (C) 2006-2010 Jonathan Zarate
5 http://www.polarcloud.com/tomato/
7 Tomato VLAN GUI
8 Copyright (C) 2011 Augusto Bott
9 http://code.google.com/p/tomato-sdhc-vlan/
11 For use with Tomato Firmware only.
12 No part of this file may be used without permission.
13 -->
14 <html>
15 <head>
16 <meta http-equiv='content-type' content='text/html;charset=utf-8'>
17 <meta name='robots' content='noindex,nofollow'>
18 <title>[<% ident(); %>] Status: Device List</title>
19 <link rel='stylesheet' type='text/css' href='tomato.css'>
20 <% css(); %>
21 <script type='text/javascript' src='tomato.js'></script>
23 <!-- / / / -->
25 <style type='text/css'>
26 #dev-grid .co1 {
27 width: 9%;
29 #dev-grid .co2 {
30 width: 18%;
32 #dev-grid .co3 {
33 width: 14%;
35 #dev-grid .co4 {
36 width: 21%;
38 #dev-grid .co5 {
39 width: 8%;
40 text-align: right;
42 #dev-grid .co6 {
43 width: 8%;
44 text-align: center;
46 #dev-grid .co7 {
47 width: 9%;
48 text-align: right;
50 #dev-grid .co8 {
51 width: 13%;
52 text-align: right;
54 #dev-grid .header {
55 text-align: left;
57 </style>
59 <script type='text/javascript' src='debug.js'></script>
61 <script type='text/javascript' src='wireless.jsx?_http_id=<% nv(http_id); %>'></script>
62 <script type='text/javascript'>
64 ipp = '<% lipp(); %>.';
65 //<% nvram('lan_ifname,wl_ifname,wl_mode,wl_radio'); %>
66 // <% devlist(); %>
68 list = [];
70 function find(mac, ip)
72 var e, i;
74 mac = mac.toUpperCase();
75 for (i = list.length - 1; i >= 0; --i) {
76 e = list[i];
77 if (((e.mac == mac) && ((e.ip == ip) || (e.ip == '') || (ip == null))) ||
78 ((e.mac == '00:00:00:00:00:00') && (e.ip == ip))) {
79 return e;
82 return null;
85 function get(mac, ip)
87 var e, i;
89 mac = mac.toUpperCase();
90 if ((e = find(mac, ip)) != null) {
91 if (ip) e.ip = ip;
92 return e;
95 e = {
96 mac: mac,
97 ip: ip || '',
98 ifname: '',
99 unit: 0,
100 name: '',
101 rssi: '',
102 txrx: '',
103 lease: ''
105 list.push(e);
107 return e;
111 var xob = null;
113 function _deleteLease(ip)
115 form.submitHidden('dhcpd.cgi', { remove: ip });
118 function deleteLease(a, ip)
120 if (xob) return;
121 if ((xob = new XmlHttp()) == null) {
122 _deleteLease(ip);
123 return;
126 a = E(a);
127 a.innerHTML = 'deleting...';
129 xob.onCompleted = function(text, xml) {
130 a.innerHTML = '...';
131 xob = null;
133 xob.onError = function() {
134 _deleteLease(ip);
137 xob.post('dhcpd.cgi', 'remove=' + ip);
140 function addStatic(n)
142 var e = list[n];
143 cookie.set('addstatic', [e.mac, e.ip, e.name.split(',')[0]].join(','), 1);
144 location.href = 'basic-static.asp';
147 function addWF(n)
149 var e = list[n];
150 cookie.set('addmac', [e.mac, e.name.split(',')[0]].join(','), 1);
151 location.href = 'basic-wfilter.asp';
155 var ref = new TomatoRefresh('update.cgi', 'exec=devlist', 0, 'status_devices_refresh');
157 ref.refresh = function(text)
159 eval(text);
160 dg.removeAllData();
161 dg.populate();
162 dg.resort();
163 for (var uidx = 0; uidx < wl_ifaces.length; ++uidx) {
164 if (wl_sunit(uidx)<0)
165 E("noise"+uidx).innerHTML = wlnoise[uidx];
170 var dg = new TomatoGrid();
172 dg.sortCompare = function(a, b) {
173 var col = this.sortColumn;
174 var ra = a.getRowData();
175 var rb = b.getRowData();
176 var r;
178 switch (col) {
179 case 2:
180 r = cmpIP(ra.ip, rb.ip);
181 break;
182 case 4:
183 r = cmpInt(ra.rssi, rb.rssi);
184 break;
185 case 5:
186 r = cmpInt(ra.qual, rb.qual);
187 break;
188 default:
189 r = cmpText(a.cells[col].innerHTML, b.cells[col].innerHTML);
191 if (r == 0) {
192 r = cmpIP(ra.ip, rb.ip);
193 if (r == 0) r = cmpText(ra.ifname, rb.ifname);
195 return this.sortAscending ? r : -r;
198 dg.populate = function()
200 var i, j;
201 var a, b, c, e;
203 list = [];
205 for (i = 0; i < list.length; ++i) {
206 list[i].ip = '';
207 list[i].ifname = '';
208 list[i].unit = 0;
209 list[i].name = '';
210 list[i].rssi = '';
211 list[i].txrx = '';
212 list[i].lease = '';
215 for (i = dhcpd_lease.length - 1; i >= 0; --i) {
216 a = dhcpd_lease[i];
217 e = get(a[2], a[1]);
218 e.lease = '<small><a href="javascript:deleteLease(\'L' + i + '\',\'' + a[1] + '\')" title="Delete Lease" id="L' + i + '">' + a[3] + '</a></small>';
219 e.name = a[0];
220 e.ifname = nvram.lan_ifname;
223 for (i = wldev.length - 1; i >= 0; --i) {
224 a = wldev[i];
225 if (a[0].indexOf('wds') == 0) {
226 e = get(a[1], '-');
228 else {
229 e = get(a[1], null);
231 e.ifname = a[0];
232 e.unit = a[6] * 1;
233 e.rssi = a[2];
235 if ((a[3] > 1000) || (a[4] > 1000))
236 e.txrx = ((a[3] > 1000) ? Math.round(a[3] / 1000) : '-') + ' / ' + ((a[4] > 1000) ? Math.round(a[4] / 1000) : '-'); //+ '<br><small>Mbps</small>';
239 for (i = arplist.length - 1; i >= 0; --i) {
240 a = arplist[i];
242 if ((e = get(a[1], a[0])) != null) {
243 if (e.ifname == '') e.ifname = a[2];
247 for (i = dhcpd_static.length - 1; i >= 0; --i) {
248 a = dhcpd_static[i].split('<');
249 if (a.length < 3) continue;
251 if (a[1].indexOf('.') == -1) a[1] = (ipp + a[1]);
253 c = a[0].split(',');
254 for (j = c.length - 1; j >= 0; --j) {
255 if ((e = find(c[j], a[1])) != null) break;
257 if (j < 0) continue;
259 if (e.name == '') {
260 e.name = a[2];
262 else {
263 b = e.name.toLowerCase();
264 c = a[2].toLowerCase();
265 if ((b.indexOf(c) == -1) && (c.indexOf(b) == -1)) {
266 if (e.name != '') e.name += ', ';
267 e.name += a[2];
272 for (i = list.length - 1; i >= 0; --i) {
273 e = list[i];
275 b = e.mac;
276 if (e.mac.match(/^(..):(..):(..)/)) {
277 b += '<br><small>' +
278 '<a href="http://standards.ieee.org/cgi-bin/ouisearch?' + RegExp.$1 + '-' + RegExp.$2 + '-' + RegExp.$3 + '" target="_new" title="OUI Search">[oui]</a> ' +
279 '<a href="javascript:addStatic(' + i + ')" title="Static Lease...">[static]</a>';
281 if (e.rssi != '') {
282 b += ' <a href="javascript:addWF(' + i + ')" title="Wireless Filter...">[wfilter]</a>';
284 b += '</small>';
286 else {
287 b = '';
290 var ifidx = wl_uidx(e.unit);
291 if ((e.rssi !== '') && (ifidx >= 0) && (wlnoise[ifidx] < 0)) {
292 e.qual = MAX(e.rssi - wlnoise[ifidx], 0);
294 else {
295 e.qual = -1;
298 this.insert(-1, e, [
299 e.ifname, b, (e.ip == '-') ? '' : e.ip, e.name,
300 (e.rssi != 0) ? e.rssi + ' <small>dBm</small>' : '',
301 (e.qual < 0) ? '' : '<small>' + e.qual + '</small> <img src="bar' + MIN(MAX(Math.floor(e.qual / 10), 1), 6) + '.gif">',
302 e.txrx, e.lease], false);
306 dg.setup = function()
308 this.init('dev-grid', 'sort');
309 this.headerSet(['Interface', 'MAC Address', 'IP Address', 'Name', 'RSSI &nbsp; &nbsp; ', 'Quality', 'TX/RX Rate&nbsp;', 'Lease &nbsp; &nbsp; ']);
310 this.populate();
311 this.sort(2);
314 function earlyInit()
316 dg.setup();
319 function init()
321 dg.recolor();
322 ref.initPage(3000, 3);
324 </script>
325 </head>
326 <body onload='init()'>
327 <table id='container' cellspacing=0>
328 <tr><td colspan=2 id='header'>
329 <div class='title'>Tomato</div>
330 <div class='version'>Version <% version(); %></div>
331 </td></tr>
332 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
333 <td id='content'>
334 <div id='ident'><% ident(); %></div>
336 <!-- / / / -->
338 <div class='section-title'>Device List</div>
339 <div class='section'>
340 <table id='dev-grid' class='tomato-grid' cellspacing=0></table>
342 <script type='text/javascript'>
343 f = [];
344 for (var uidx = 0; uidx < wl_ifaces.length; ++uidx) {
345 var u = wl_unit(uidx);
346 if (nvram['wl'+u+'_radio'] == '1') {
347 if (wl_sunit(uidx)<0) {
348 var a = '';
349 if ((nvram['wl'+u+'_mode'] == 'ap') || (nvram['wl'+u+'_mode'] == 'wds'))
350 a = '&nbsp;&nbsp;&nbsp; <input type="button" value="Measure" onclick="javascript:window.location=\'wlmnoise.cgi?_http_id=' + nvram.http_id + '&_wl_unit=' + u +'\'">';
351 f.push( { title: '<b>Noise Floor (' + wl_ifaces[uidx][0] + ')&nbsp;:</b>',
352 prefix: '<span id="noise'+uidx+'">',
353 custom: wlnoise[uidx],
354 suffix: '</span>&nbsp;<small>dBm</small>' + a } );
358 createFieldTable('', f);
359 </script>
361 </div>
363 <!-- / / / -->
365 </td></tr>
366 <tr><td id='footer' colspan=2><script type='text/javascript'>genStdRefresh(1,1,'ref.toggle()');</script></td></tr>
367 </table>
368 <script type='text/javascript'>earlyInit();</script>
369 </body>
370 </html>