Merge pull request #501 from LuttyYang/master
[project/luci.git] / modules / luci-mod-admin-full / luasrc / view / admin_status / index.htm
1 <%#
2  Copyright 2008 Steven Barth <steven@midlink.org>
3  Copyright 2008-2011 Jo-Philipp Wich <jow@openwrt.org>
4  Licensed to the public under the Apache License 2.0.
5 -%>
6
7 <%
8         local fs = require "nixio.fs"
9         local util = require "luci.util"
10         local stat = require "luci.tools.status"
11         local ver = require "luci.version"
12
13         local has_ipv6 = fs.access("/proc/net/ipv6_route")
14         local has_dhcp = fs.access("/etc/config/dhcp")
15         local has_wifi = ((fs.stat("/etc/config/wireless", "size") or 0) > 0)
16
17         local sysinfo = luci.util.ubus("system", "info") or { }
18         local boardinfo = luci.util.ubus("system", "board") or { }
19         local unameinfo = nixio.uname() or { }
20
21         local meminfo = sysinfo.memory or {
22                 total = 0,
23                 free = 0,
24                 buffered = 0,
25                 shared = 0
26         }
27
28         local swapinfo = sysinfo.swap or {
29                 total = 0,
30                 free = 0
31         }
32
33         local has_dsl = fs.access("/etc/init.d/dsl_control")
34
35         if luci.http.formvalue("status") == "1" then
36                 local ntm = require "luci.model.network".init()
37                 local wan = ntm:get_wannet()
38                 local wan6 = ntm:get_wan6net()
39
40                 local conn_count = tonumber((
41                         luci.sys.exec("wc -l /proc/net/nf_conntrack") or
42                         luci.sys.exec("wc -l /proc/net/ip_conntrack") or
43                         ""):match("%d+")) or 0
44
45                 local conn_max = tonumber((
46                         luci.sys.exec("sysctl net.nf_conntrack_max") or
47                         luci.sys.exec("sysctl net.ipv4.netfilter.ip_conntrack_max") or
48                         ""):match("%d+")) or 4096
49
50                 local rv = {
51                         uptime     = sysinfo.uptime or 0,
52                         localtime  = os.date(),
53                         loadavg    = sysinfo.load or { 0, 0, 0 },
54                         memory     = meminfo,
55                         swap       = swapinfo,
56                         connmax    = conn_max,
57                         conncount  = conn_count,
58                         leases     = stat.dhcp_leases(),
59                         leases6    = stat.dhcp6_leases(),
60                         wifinets   = stat.wifi_networks()
61                 }
62
63                 if wan then
64                         rv.wan = {
65                                 ipaddr  = wan:ipaddr(),
66                                 gwaddr  = wan:gwaddr(),
67                                 netmask = wan:netmask(),
68                                 dns     = wan:dnsaddrs(),
69                                 expires = wan:expires(),
70                                 uptime  = wan:uptime(),
71                                 proto   = wan:proto(),
72                                 ifname  = wan:ifname(),
73                                 link    = wan:adminlink()
74                         }
75                 end
76
77                 if wan6 then
78                         rv.wan6 = {
79                                 ip6addr = wan6:ip6addr(),
80                                 gw6addr = wan6:gw6addr(),
81                                 dns     = wan6:dns6addrs(),
82                                 uptime  = wan6:uptime(),
83                                 ifname  = wan6:ifname(),
84                                 link    = wan6:adminlink()
85                         }
86                 end
87
88                 if has_dsl then
89                         local dsl_stat = luci.sys.exec("/etc/init.d/dsl_control lucistat")
90                         local dsl_func = loadstring(dsl_stat)
91                         if dsl_func then
92                                 rv.dsl = dsl_func()
93                         end
94                 end
95
96                 luci.http.prepare_content("application/json")
97                 luci.http.write_json(rv)
98
99                 return
100         end
101 -%>
102
103 <%+header%>
104
105 <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
106 <script type="text/javascript">//<![CDATA[
107         function progressbar(v, m)
108         {
109                 var vn = parseInt(v) || 0;
110                 var mn = parseInt(m) || 100;
111                 var pc = Math.floor((100 / mn) * vn);
112
113                 return String.format(
114                         '<div style="width:200px; position:relative; border:1px solid #999999">' +
115                                 '<div style="background-color:#CCCCCC; width:%d%%; height:15px">' +
116                                         '<div style="position:absolute; left:0; top:0; text-align:center; width:100%%; color:#000000">' +
117                                                 '<small>%s / %s (%d%%)</small>' +
118                                         '</div>' +
119                                 '</div>' +
120                         '</div>', pc, v, m, pc
121                 );
122         }
123
124         var wifidevs = <%=luci.http.write_json(netdevs)%>;
125         var arptable = <%=luci.http.write_json(arpcache)%>;
126
127         XHR.poll(5, '<%=REQUEST_URI%>', { status: 1 },
128                 function(x, info)
129                 {
130                         var si = document.getElementById('wan4_i');
131                         var ss = document.getElementById('wan4_s');
132                         var ifc = info.wan;
133
134                         if (ifc && ifc.ifname && ifc.proto != 'none')
135                         {
136                                 var s = String.format(
137                                         '<strong><%:Type%>: </strong>%s<br />' +
138                                         '<strong><%:Address%>: </strong>%s<br />' +
139                                         '<strong><%:Netmask%>: </strong>%s<br />' +
140                                         '<strong><%:Gateway%>: </strong>%s<br />',
141                                                 ifc.proto,
142                                                 (ifc.ipaddr) ? ifc.ipaddr : '0.0.0.0',
143                                                 (ifc.netmask && ifc.netmask != ifc.ipaddr) ? ifc.netmask : '255.255.255.255',
144                                                 (ifc.gwaddr) ? ifc.gwaddr : '0.0.0.0'
145                                 );
146
147                                 for (var i = 0; i < ifc.dns.length; i++)
148                                 {
149                                         s += String.format(
150                                                 '<strong><%:DNS%> %d: </strong>%s<br />',
151                                                 i + 1, ifc.dns[i]
152                                         );
153                                 }
154
155                                 if (ifc.expires > -1)
156                                 {
157                                         s += String.format(
158                                                 '<strong><%:Expires%>: </strong>%t<br />',
159                                                 ifc.expires
160                                         );
161                                 }
162
163                                 if (ifc.uptime > 0)
164                                 {
165                                         s += String.format(
166                                                 '<strong><%:Connected%>: </strong>%t<br />',
167                                                 ifc.uptime
168                                         );
169                                 }
170
171                                 ss.innerHTML = String.format('<small>%s</small>', s);
172                                 si.innerHTML = String.format(
173                                         '<img src="<%=resource%>/icons/ethernet.png" />' +
174                                         '<br /><small><a href="%s">%s</a></small>',
175                                                 ifc.link, ifc.ifname
176                                 );
177                         }
178                         else
179                         {
180                                 si.innerHTML = '<img src="<%=resource%>/icons/ethernet_disabled.png" /><br /><small>?</small>';
181                                 ss.innerHTML = '<em><%:Not connected%></em>';
182                         }
183
184                         <% if has_ipv6 then %>
185                         var si6 = document.getElementById('wan6_i');
186                         var ss6 = document.getElementById('wan6_s');
187                         var ifc6 = info.wan6;
188
189                         if (ifc6 && ifc6.ifname && ifc6.proto != 'none')
190                         {
191                                 var s = String.format(
192                                         '<strong><%:Address%>: </strong>%s<br />' +
193                                         '<strong><%:Gateway%>: </strong>%s<br />',
194                                                 (ifc6.ip6addr) ? ifc6.ip6addr : '::',
195                                                 (ifc6.gw6addr) ? ifc6.gw6addr : '::'
196                                 );
197
198                                 for (var i = 0; i < ifc6.dns.length; i++)
199                                 {
200                                         s += String.format(
201                                                 '<strong><%:DNS%> %d: </strong>%s<br />',
202                                                 i + 1, ifc6.dns[i]
203                                         );
204                                 }
205
206                                 if (ifc6.uptime > 0)
207                                 {
208                                         s += String.format(
209                                                 '<strong><%:Connected%>: </strong>%t<br />',
210                                                 ifc6.uptime
211                                         );
212                                 }
213
214                                 ss6.innerHTML = String.format('<small>%s</small>', s);
215                                 si6.innerHTML = String.format(
216                                         '<img src="<%=resource%>/icons/ethernet.png" />' +
217                                         '<br /><small><a href="%s">%s</a></small>',
218                                                 ifc6.link, ifc6.ifname
219                                 );
220                         }
221                         else
222                         {
223                                 si6.innerHTML = '<img src="<%=resource%>/icons/ethernet_disabled.png" /><br /><small>?</small>';
224                                 ss6.innerHTML = '<em><%:Not connected%></em>';
225                         }
226                         <% end %>
227
228                         <% if has_dsl then %>
229                                 var dsl_i = document.getElementById('dsl_i');
230                                 var dsl_s = document.getElementById('dsl_s');
231
232                                 var s = String.format(
233                                         '<strong><%:Status%>: </strong>%s<br />' +
234                                         '<strong><%:Line State%>: </strong>%s [0x%x]<br />' +
235                                         '<strong><%:Line Speed%>: </strong>%s/s / %s/s<br />' +
236                                         '<strong><%:Line Attenuation%>: </strong>%s dB / %s dB<br />' +
237                                         '<strong><%:Noise Margin%>: </strong>%s dB / %s dB<br />',
238                                                 info.dsl.line_state, info.dsl.line_state_detail,
239                                                 info.dsl.line_state_num,
240                                                 info.dsl.data_rate_down_s, info.dsl.data_rate_up_s,
241                                                 info.dsl.line_attenuation_down, info.dsl.line_attenuation_up,
242                                                 info.dsl.noise_margin_down, info.dsl.noise_margin_up
243                                 );
244
245                                 dsl_s.innerHTML = String.format('<small>%s</small>', s);
246                                 dsl_i.innerHTML = String.format(
247                                         '<img src="<%=resource%>/icons/ethernet.png" />' +
248                                         '<br /><small>ADSL</small>'
249                                 );
250                         <% end %>
251
252                         <% if has_dhcp then %>
253                         var ls = document.getElementById('lease_status_table');
254                         if (ls)
255                         {
256                                 /* clear all rows */
257                                 while( ls.rows.length > 1 )
258                                         ls.rows[0].parentNode.deleteRow(1);
259
260                                 for( var i = 0; i < info.leases.length; i++ )
261                                 {
262                                         var timestr;
263
264                                         if (info.leases[i].expires <= 0)
265                                                 timestr = '<em><%:expired%></em>';
266                                         else
267                                                 timestr = String.format('%t', info.leases[i].expires);
268
269                                         var tr = ls.rows[0].parentNode.insertRow(-1);
270                                                 tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
271
272                                         tr.insertCell(-1).innerHTML = info.leases[i].hostname ? info.leases[i].hostname : '?';
273                                         tr.insertCell(-1).innerHTML = info.leases[i].ipaddr;
274                                         tr.insertCell(-1).innerHTML = info.leases[i].macaddr;
275                                         tr.insertCell(-1).innerHTML = timestr;
276                                 }
277
278                                 if( ls.rows.length == 1 )
279                                 {
280                                         var tr = ls.rows[0].parentNode.insertRow(-1);
281                                                 tr.className = 'cbi-section-table-row';
282
283                                         var td = tr.insertCell(-1);
284                                                 td.colSpan = 4;
285                                                 td.innerHTML = '<em><br /><%:There are no active leases.%></em>';
286                                 }
287                         }
288
289                         var ls6 = document.getElementById('lease6_status_table');
290                         if (ls6 && info.leases6)
291                         {
292                                 ls6.parentNode.style.display = 'block';
293
294                                 /* clear all rows */
295                                 while( ls6.rows.length > 1 )
296                                         ls6.rows[0].parentNode.deleteRow(1);
297
298                                 for( var i = 0; i < info.leases6.length; i++ )
299                                 {
300                                         var timestr;
301
302                                         if (info.leases6[i].expires <= 0)
303                                                 timestr = '<em><%:expired%></em>';
304                                         else
305                                                 timestr = String.format('%t', info.leases6[i].expires);
306
307                                         var tr = ls6.rows[0].parentNode.insertRow(-1);
308                                                 tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
309
310                                         tr.insertCell(-1).innerHTML = info.leases6[i].hostname ? info.leases6[i].hostname : '?';
311                                         tr.insertCell(-1).innerHTML = info.leases6[i].ip6addr;
312                                         tr.insertCell(-1).innerHTML = info.leases6[i].duid;
313                                         tr.insertCell(-1).innerHTML = timestr;
314                                 }
315
316                                 if( ls6.rows.length == 1 )
317                                 {
318                                         var tr = ls6.rows[0].parentNode.insertRow(-1);
319                                                 tr.className = 'cbi-section-table-row';
320
321                                         var td = tr.insertCell(-1);
322                                                 td.colSpan = 4;
323                                                 td.innerHTML = '<em><br /><%:There are no active leases.%></em>';
324                                 }
325                         }
326                         <% end %>
327
328                         <% if has_wifi then %>
329                         var assoclist = [ ];
330
331                         var ws = document.getElementById('wifi_status_table');
332                         if (ws)
333                         {
334                                 var wsbody = ws.rows[0].parentNode;
335                                 while (ws.rows.length > 0)
336                                         wsbody.deleteRow(0);
337
338                                 for (var didx = 0; didx < info.wifinets.length; didx++)
339                                 {
340                                         var dev = info.wifinets[didx];
341
342                                         var tr = wsbody.insertRow(-1);
343                                         var td;
344
345                                         td = tr.insertCell(-1);
346                                         td.width     = "33%";
347                                         td.innerHTML = dev.name;
348                                         td.style.verticalAlign = "top";
349
350                                         td = tr.insertCell(-1);
351
352                                         var s = '';
353
354                                         for (var nidx = 0; nidx < dev.networks.length; nidx++)
355                                         {
356                                                 var net = dev.networks[nidx];
357                                                 var is_assoc = (net.bssid != '00:00:00:00:00:00' && net.channel && !net.disabled);
358
359                                                 var icon;
360                                                 if (!is_assoc)
361                                                         icon = "<%=resource%>/icons/signal-none.png";
362                                                 else if (net.quality == 0)
363                                                         icon = "<%=resource%>/icons/signal-0.png";
364                                                 else if (net.quality < 25)
365                                                         icon = "<%=resource%>/icons/signal-0-25.png";
366                                                 else if (net.quality < 50)
367                                                         icon = "<%=resource%>/icons/signal-25-50.png";
368                                                 else if (net.quality < 75)
369                                                         icon = "<%=resource%>/icons/signal-50-75.png";
370                                                 else
371                                                         icon = "<%=resource%>/icons/signal-75-100.png";
372
373                                                 s += String.format(
374                                                         '<table><tr><td style="text-align:center; width:32px; padding:3px">' +
375                                                                 '<img src="%s" title="<%:Signal%>: %d dBm / <%:Noise%>: %d dBm" />' +
376                                                                 '<br /><small>%d%%</small>' +
377                                                         '</td><td style="text-align:left; padding:3px"><small>' +
378                                                                 '<strong><%:SSID%>:</strong> <a href="%s">%h</a><br />' +
379                                                                 '<strong><%:Mode%>:</strong> %s<br />' +
380                                                                 '<strong><%:Channel%>:</strong> %d (%.3f <%:GHz%>)<br />' +
381                                                                 '<strong><%:Bitrate%>:</strong> %s <%:Mbit/s%><br />',
382                                                                 icon, net.signal, net.noise,
383                                                                 net.quality,
384                                                                 net.link, net.ssid,
385                                                                 net.mode,
386                                                                 net.channel, net.frequency,
387                                                                 net.bitrate || '?'
388                                                 );
389
390                                                 if (is_assoc)
391                                                 {
392                                                         s += String.format(
393                                                                 '<strong><%:BSSID%>:</strong> %s<br />' +
394                                                                 '<strong><%:Encryption%>:</strong> %s',
395                                                                         net.bssid,
396                                                                         net.encryption
397                                                         );
398                                                 }
399                                                 else
400                                                 {
401                                                         s += '<em><%:Wireless is disabled or not associated%></em>';
402                                                 }
403
404                                                 s += '</small></td></tr></table>';
405
406                                                 for (var bssid in net.assoclist)
407                                                 {
408                                                         assoclist.push({
409                                                                 bssid:    bssid,
410                                                                 signal:   net.assoclist[bssid].signal,
411                                                                 noise:    net.assoclist[bssid].noise,
412                                                                 rx_rate:  net.assoclist[bssid].rx_rate,
413                                                                 rx_mcs:   net.assoclist[bssid].rx_mcs,
414                                                                 rx_40mhz: net.assoclist[bssid].rx_40mhz,
415                                                                 tx_rate:  net.assoclist[bssid].tx_rate,
416                                                                 tx_mcs:   net.assoclist[bssid].tx_mcs,
417                                                                 tx_40mhz: net.assoclist[bssid].tx_40mhz,
418                                                                 link:     net.link,
419                                                                 name:     net.name
420                                                         });
421                                                 }
422                                         }
423
424                                         if (!s)
425                                                 s = '<em><%:No information available%></em>';
426
427                                         td.innerHTML = s;
428                                 }
429                         }
430
431                         var ac = document.getElementById('wifi_assoc_table');
432                         if (ac)
433                         {
434                                 /* clear all rows */
435                                 while( ac.rows.length > 1 )
436                                         ac.rows[0].parentNode.deleteRow(1);
437
438                                 assoclist.sort(function(a, b) {
439                                         return (a.name == b.name)
440                                                 ? (a.bssid < b.bssid)
441                                                 : (a.name  > b.name )
442                                         ;
443                                 });
444
445                                 for( var i = 0; i < assoclist.length; i++ )
446                                 {
447                                         var tr = ac.rows[0].parentNode.insertRow(-1);
448                                                 tr.className = 'cbi-section-table-row cbi-rowstyle-' + (1 + (i % 2));
449
450                                         var icon;
451                                         var q = (-1 * (assoclist[i].noise - assoclist[i].signal)) / 5;
452                                         if (q < 1)
453                                                 icon = "<%=resource%>/icons/signal-0.png";
454                                         else if (q < 2)
455                                                 icon = "<%=resource%>/icons/signal-0-25.png";
456                                         else if (q < 3)
457                                                 icon = "<%=resource%>/icons/signal-25-50.png";
458                                         else if (q < 4)
459                                                 icon = "<%=resource%>/icons/signal-50-75.png";
460                                         else
461                                                 icon = "<%=resource%>/icons/signal-75-100.png";
462
463                                         tr.insertCell(-1).innerHTML = String.format(
464                                                 '<img src="%s" title="<%:Signal%>: %d <%:dBm%> / <%:Noise%>: %d <%:dBm%>" />',
465                                                 icon, assoclist[i].signal, assoclist[i].noise
466                                         );
467
468                                         tr.insertCell(-1).innerHTML = assoclist[i].bssid;
469
470                                         tr.insertCell(-1).innerHTML = String.format(
471                                                 '<a href="%s">%s</a>',
472                                                         assoclist[i].link,
473                                                         '%h'.format(assoclist[i].name).nobr()
474                                         );
475
476                                         tr.insertCell(-1).innerHTML = String.format('%d <%:dBm%>', assoclist[i].signal).nobr();
477                                         tr.insertCell(-1).innerHTML = String.format('%d <%:dBm%>', assoclist[i].noise).nobr();
478
479                                         tr.insertCell(-1).innerHTML = (assoclist[i].rx_mcs > -1)
480                                                 ? String.format('%.1f <%:Mbit/s%>, MCS %d, %d<%:MHz%>', assoclist[i].rx_rate / 1000, assoclist[i].rx_mcs, assoclist[i].rx_40mhz ? 40 : 20).nobr()
481                                                 : String.format('%.1f <%:Mbit/s%>', assoclist[i].rx_rate / 1000).nobr()
482                                         ;
483
484                                         tr.insertCell(-1).innerHTML = (assoclist[i].tx_mcs > -1)
485                                                 ? String.format('%.1f <%:Mbit/s%>, MCS %d, %d<%:MHz%>', assoclist[i].tx_rate / 1000, assoclist[i].tx_mcs, assoclist[i].tx_40mhz ? 40 : 20).nobr()
486                                                 : String.format('%.1f <%:Mbit/s%>', assoclist[i].tx_rate / 1000).nobr()
487                                         ;
488                                 }
489
490                                 if (ac.rows.length == 1)
491                                 {
492                                         var tr = ac.rows[0].parentNode.insertRow(-1);
493                                                 tr.className = 'cbi-section-table-row';
494
495                                         var td = tr.insertCell(-1);
496                                                 td.colSpan = 7;
497                                                 td.innerHTML = '<br /><em><%:No information available%></em>';
498                                 }
499                         }
500                         <% end %>
501
502                         var e;
503
504                         if (e = document.getElementById('localtime'))
505                                 e.innerHTML = info.localtime;
506
507                         if (e = document.getElementById('uptime'))
508                                 e.innerHTML = String.format('%t', info.uptime);
509
510                         if (e = document.getElementById('loadavg'))
511                                 e.innerHTML = String.format(
512                                         '%.02f, %.02f, %.02f',
513                                         info.loadavg[0] / 65535.0,
514                                         info.loadavg[1] / 65535.0,
515                                         info.loadavg[2] / 65535.0
516                                 );
517
518                         if (e = document.getElementById('memtotal'))
519                                 e.innerHTML = progressbar(
520                                         ((info.memory.free + info.memory.buffered) / 1024) + " <%:kB%>",
521                                         (info.memory.total / 1024) + " <%:kB%>"
522                                 );
523
524                         if (e = document.getElementById('memfree'))
525                                 e.innerHTML = progressbar(
526                                         (info.memory.free / 1024) + " <%:kB%>",
527                                         (info.memory.total / 1024) + " <%:kB%>"
528                                 );
529
530                         if (e = document.getElementById('membuff'))
531                                 e.innerHTML = progressbar(
532                                         (info.memory.buffered / 1024) + " <%:kB%>",
533                                         (info.memory.total / 1024) + " <%:kB%>"
534                                 );
535
536                         if (e = document.getElementById('swaptotal'))
537                                 e.innerHTML = progressbar(
538                                         (info.swap.free / 1024) + " <%:kB%>",
539                                         (info.swap.total / 1024) + " <%:kB%>"
540                                 );
541
542                         if (e = document.getElementById('swapfree'))
543                                 e.innerHTML = progressbar(
544                                         (info.swap.free / 1024) + " <%:kB%>",
545                                         (info.swap.total / 1024) + " <%:kB%>"
546                                 );
547
548                         if (e = document.getElementById('conns'))
549                                 e.innerHTML = progressbar(info.conncount, info.connmax);
550
551                 }
552         );
553 //]]></script>
554
555 <h2><a id="content" name="content"><%:Status%></a></h2>
556
557 <fieldset class="cbi-section">
558         <legend><%:System%></legend>
559
560         <table width="100%" cellspacing="10">
561                 <tr><td width="33%"><%:Hostname%></td><td><%=luci.sys.hostname() or "?"%></td></tr>
562                 <tr><td width="33%"><%:Model%></td><td><%=pcdata(boardinfo.model or boardinfo.system or "?")%></td></tr>
563                 <tr><td width="33%"><%:Firmware Version%></td><td>
564                         <%=pcdata(ver.distname)%> <%=pcdata(ver.distversion)%> /
565                         <%=pcdata(ver.luciname)%> (<%=pcdata(ver.luciversion)%>)
566                 </td></tr>
567                 <tr><td width="33%"><%:Kernel Version%></td><td><%=unameinfo.release or "?"%></td></tr>
568                 <tr><td width="33%"><%:Local Time%></td><td id="localtime">-</td></tr>
569                 <tr><td width="33%"><%:Uptime%></td><td id="uptime">-</td></tr>
570                 <tr><td width="33%"><%:Load Average%></td><td id="loadavg">-</td></tr>
571         </table>
572 </fieldset>
573
574 <fieldset class="cbi-section">
575         <legend><%:Memory%></legend>
576
577         <table width="100%" cellspacing="10">
578                 <tr><td width="33%"><%:Total Available%></td><td id="memtotal">-</td></tr>
579                 <tr><td width="33%"><%:Free%></td><td id="memfree">-</td></tr>
580                 <tr><td width="33%"><%:Buffered%></td><td id="membuff">-</td></tr>
581         </table>
582 </fieldset>
583
584 <% if swapinfo.total > 0 then %>
585 <fieldset class="cbi-section">
586         <legend><%:Swap%></legend>
587
588         <table width="100%" cellspacing="10">
589                 <tr><td width="33%"><%:Total Available%></td><td id="swaptotal">-</td></tr>
590                 <tr><td width="33%"><%:Free%></td><td id="swapfree">-</td></tr>
591         </table>
592 </fieldset>
593 <% end %>
594
595 <fieldset class="cbi-section">
596         <legend><%:Network%></legend>
597
598         <table width="100%" cellspacing="10">
599                 <tr><td width="33%" style="vertical-align:top"><%:IPv4 WAN Status%></td><td>
600                         <table><tr>
601                                 <td id="wan4_i" style="width:16px; text-align:center; padding:3px"><img src="<%=resource%>/icons/ethernet_disabled.png" /><br /><small>?</small></td>
602                                 <td id="wan4_s" style="vertical-align:middle; padding: 3px"><em><%:Collecting data...%></em></td>
603                         </tr></table>
604                 </td></tr>
605                 <% if has_ipv6 then %>
606                 <tr><td width="33%" style="vertical-align:top"><%:IPv6 WAN Status%></td><td>
607                         <table><tr>
608                                 <td id="wan6_i" style="width:16px; text-align:center; padding:3px"><img src="<%=resource%>/icons/ethernet_disabled.png" /><br /><small>?</small></td>
609                                 <td id="wan6_s" style="vertical-align:middle; padding: 3px"><em><%:Collecting data...%></em></td>
610                         </tr></table>
611                 </td></tr>
612                 <% end %>
613                 <tr><td width="33%"><%:Active Connections%></td><td id="conns">-</td></tr>
614         </table>
615 </fieldset>
616
617 <% if has_dhcp then %>
618 <fieldset class="cbi-section">
619         <legend><%:DHCP Leases%></legend>
620
621         <table class="cbi-section-table" id="lease_status_table">
622                 <tr class="cbi-section-table-titles">
623                         <th class="cbi-section-table-cell"><%:Hostname%></th>
624                         <th class="cbi-section-table-cell"><%:IPv4-Address%></th>
625                         <th class="cbi-section-table-cell"><%:MAC-Address%></th>
626                         <th class="cbi-section-table-cell"><%:Leasetime remaining%></th>
627                 </tr>
628                 <tr class="cbi-section-table-row">
629                         <td colspan="4"><em><br /><%:Collecting data...%></em></td>
630                 </tr>
631         </table>
632 </fieldset>
633
634 <fieldset class="cbi-section" style="display:none">
635         <legend><%:DHCPv6 Leases%></legend>
636
637         <table class="cbi-section-table" id="lease6_status_table">
638                 <tr class="cbi-section-table-titles">
639                         <th class="cbi-section-table-cell"><%:Hostname%></th>
640                         <th class="cbi-section-table-cell"><%:IPv6-Address%></th>
641                         <th class="cbi-section-table-cell"><%:DUID%></th>
642                         <th class="cbi-section-table-cell"><%:Leasetime remaining%></th>
643                 </tr>
644                 <tr class="cbi-section-table-row">
645                         <td colspan="4"><em><br /><%:Collecting data...%></em></td>
646                 </tr>
647         </table>
648 </fieldset>
649 <% end %>
650
651 <% if has_dsl then %>
652 <fieldset class="cbi-section">
653        <legend><%:ADSL%></legend>
654        <table width="100%" cellspacing="10">
655                <tr><td width="33%" style="vertical-align:top"><%:ADSL Status%></td><td>
656                        <table><tr>
657                                <td id="dsl_i" style="width:16px; text-align:center; padding:3px"><img src="<%=resource%>/icons/ethernet_disabled.png" /><br /><small>?</small></td>
658                                <td id="dsl_s" style="vertical-align:middle; padding: 3px"><em><%:Collecting data...%></em></td>
659                        </tr></table>
660                </td></tr>
661        </table>
662 </fieldset>
663 <% end %>
664
665 <% if has_wifi then %>
666 <fieldset class="cbi-section">
667         <legend><%:Wireless%></legend>
668
669         <table id="wifi_status_table" width="100%" cellspacing="10">
670                 <tr><td><em><%:Collecting data...%></em></td></tr>
671         </table>
672 </fieldset>
673
674 <fieldset class="cbi-section">
675         <legend><%:Associated Stations%></legend>
676
677         <table class="cbi-section-table" id="wifi_assoc_table">
678                 <tr class="cbi-section-table-titles">
679                         <th class="cbi-section-table-cell">&#160;</th>
680                         <th class="cbi-section-table-cell"><%:MAC-Address%></th>
681                         <th class="cbi-section-table-cell"><%:Network%></th>
682                         <th class="cbi-section-table-cell"><%:Signal%></th>
683                         <th class="cbi-section-table-cell"><%:Noise%></th>
684                         <th class="cbi-section-table-cell"><%:RX Rate%></th>
685                         <th class="cbi-section-table-cell"><%:TX Rate%></th>
686                 </tr>
687                 <tr class="cbi-section-table-row">
688                         <td colspan="7"><em><br /><%:Collecting data...%></em></td>
689                 </tr>
690         </table>
691 </fieldset>
692 <% end %>
693
694 <%-
695         local incdir = util.libpath() .. "/view/admin_status/index/"
696         if fs.access(incdir) then
697                 local inc
698                 for inc in fs.dir(incdir) do
699                         if inc:match("%.htm$") then
700                                 include("admin_status/index/" .. inc:gsub("%.htm$", ""))
701                         end
702                 end
703         end
704 -%>
705
706 <%+footer%>