From 97e27a0bcf5eb9c388a05f73dc13867ef8703e4c Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 8 Nov 2010 22:40:04 +0000 Subject: [PATCH] modules/admin-full: properly handle disabled radios in live overview --- .../luasrc/controller/admin/network.lua | 6 +- .../view/admin_network/wifi_overview.htm | 57 +++++++++++++------ 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/modules/admin-full/luasrc/controller/admin/network.lua b/modules/admin-full/luasrc/controller/admin/network.lua index b9d9d845e..b271e20d2 100644 --- a/modules/admin-full/luasrc/controller/admin/network.lua +++ b/modules/admin-full/luasrc/controller/admin/network.lua @@ -224,14 +224,15 @@ end function wifi_status() local path = luci.dispatcher.context.requestpath + local arp = luci.sys.net.arptable() local rv = { } local dev for dev in path[#path]:gmatch("[%w%.%-]+") do + local j = { id = dev } local iw = luci.sys.wifi.getiwinfo(dev) if iw then local f - local j = { id = dev } for _, f in ipairs({ "channel", "frequency", "txpower", "bitrate", "signal", "noise", "quality", "quality_max", "mode", "ssid", "bssid", "country", @@ -239,9 +240,8 @@ function wifi_status() }) do j[f] = iw[f] end - - rv[#rv+1] = j end + rv[#rv+1] = j end if #rv > 0 then diff --git a/modules/admin-full/luasrc/view/admin_network/wifi_overview.htm b/modules/admin-full/luasrc/view/admin_network/wifi_overview.htm index 20f0e8d6e..218e47bb2 100644 --- a/modules/admin-full/luasrc/view/admin_network/wifi_overview.htm +++ b/modules/admin-full/luasrc/view/admin_network/wifi_overview.htm @@ -109,11 +109,14 @@ $Id$ while (assoctable.rows.length > 1) assoctable.rows[1].parentNode.removeChild(assoctable.rows[1]); + var devup = { }; + for( var i = 0; i < st.length; i++ ) { var iw = st[i]; + var is_assoc = (iw.bssid && iw.channel); var p = (100 / iw.quality_max * iw.quality); - var q = (iw.bssid && iw.channel) ? p : -1; + var q = is_assoc ? p : -1; var icon; if (q < 0) @@ -129,6 +132,9 @@ $Id$ else icon = "<%=resource%>/icons/signal-75-100.png"; + if (!devup[wifidevs[iw.id]]) + devup[wifidevs[iw.id]] = is_assoc; + var sig = document.getElementById(iw.id + '-iw-signal'); if (sig) sig.innerHTML = String.format( @@ -138,24 +144,34 @@ $Id$ var info = document.getElementById(iw.id + '-iw-status'); if (info) - info.innerHTML = String.format( - '<%:SSID%>: %s | ' + - '<%:Mode%>: %s
' + - '<%:BSSID%>: %s | ' + - '<%:Encryption%>: %s', - iw.ssid, iw.mode, iw.bssid, - iw.encryption ? iw.encryption.description : '<%:None%>' - ); + { + if (is_assoc) + info.innerHTML = String.format( + '<%:SSID%>: %s | ' + + '<%:Mode%>: %s
' + + '<%:BSSID%>: %s | ' + + '<%:Encryption%>: %s', + iw.ssid, iw.mode, iw.bssid, + iw.encryption ? iw.encryption.description : '<%:None%>' + ); + else + info.innerHTML = '<%:Wireless is disabled or not associated%>'; + } var dev = document.getElementById(wifidevs[iw.id] + '-iw-devinfo'); if (dev) - dev.innerHTML = String.format( - '<%:Channel%>: %s (%s GHz) | ' + - '<%:Bitrate%>: %s Mb/s', - iw.channel ? iw.channel : '?', - iw.frequency ? iw.frequency / 1000 : '?', - iw.bitrate ? iw.bitrate / 1000 : '?' - ); + { + if (is_assoc) + dev.innerHTML = String.format( + '<%:Channel%>: %s (%s GHz) | ' + + '<%:Bitrate%>: %s Mb/s', + iw.channel ? iw.channel : '?', + iw.frequency ? iw.frequency / 1000 : '?', + iw.bitrate ? iw.bitrate / 1000 : '?' + ); + else + dev.innerHTML = ''; + } if (assoctable) { @@ -218,6 +234,13 @@ $Id$ assoctable.rows[0].parentNode.appendChild(tr); } + + for (var dev in devup) + { + var img = document.getElementById(dev + '-iw-upstate'); + if (img) + img.src = '<%=resource%>/icons/wifi' + (devup[dev] ? '' : '_disabled') + '.png'; + } } } ) @@ -236,7 +259,7 @@ $Id$ - +
.png" style="float:left; margin-right:10px" /> <%=guess_wifi_hw(dev:name())%> (<%=dev:name()%>)
-- 2.25.1