diff --git a/package/gluon-status-page/files/lib/gluon/status-page/view/status-page.html b/package/gluon-status-page/files/lib/gluon/status-page/view/status-page.html
index f3392eb4..bdce64fb 100644
--- a/package/gluon-status-page/files/lib/gluon/status-page/view/status-page.html
+++ b/package/gluon-status-page/files/lib/gluon/status-page/view/status-page.html
@@ -29,17 +29,31 @@
local mesh = get_mesh()
- local function get_interfaces()
- local uconn = ubus.connect()
- if not uconn then
- error('failed to connect to ubus')
- end
+ local function get_interfaces(uconn)
local interfaces = util.get_mesh_devices(uconn)
- ubus.close(uconn)
table.sort(interfaces)
return interfaces
end
+ local function get_radios(uconn)
+ local radios = uconn:call("network.wireless", "status", {})
+ local ret = {}
+
+ for radio, info in pairs(radios) do
+ if info.up then
+ table.insert(ret, {
+ name = radio,
+ channel = info.config.channel,
+ })
+ end
+ end
+
+ table.sort(ret, function(a, b)
+ return a.name < b.name
+ end)
+ return ret
+ end
+
local function is_wireless(iface)
while true do
local pattern = '/sys/class/net/' .. iface .. '/lower_*'
@@ -52,7 +66,15 @@
return unistd.access('/sys/class/net/' .. iface .. '/wireless') ~= nil
end
- local interfaces = get_interfaces()
+ local uconn = ubus.connect()
+ if not uconn then
+ error('failed to connect to ubus')
+ end
+
+ local interfaces = get_interfaces(uconn)
+ local radios = get_radios(uconn)
+
+ ubus.close(uconn)
local function sorted(t)
t = {unpack(t)}
@@ -66,12 +88,17 @@
local function formatBits(bits)
local units = {[0]='', 'k', 'M', 'G'}
+ local unit = 0
- local pow = math.floor(math.log(math.max(math.abs(bits), 1)) / math.log(1000))
- local known_pow = math.min(pow, #units)
+ for i = 1, #units do
+ if math.abs(bits) < 1000 then
+ break
+ end
+ unit = i
+ bits = bits / 1000
+ end
- local significand = bits/(1000^known_pow)
- return string.format('%g %sbit', significand, units[known_pow])
+ return string.format('%g %sbit', bits, units[unit])
end
local function statistics(key, format)
@@ -190,11 +217,17 @@
<%:Wireless 2.4 GHz%> | <%= statistics('clients/wifi24') %> |
<%:Wireless 5 GHz%> | <%= statistics('clients/wifi5') %> |
-
+ <% if radios[1] then -%>
<%:Radios%>
-
+
+ <% for _, radio in ipairs(radios) do -%>
+
+ <%| radio.name %> |
+ <%| translatef('Channel %u', radio.channel) %> |
+
+ <%- end %>
-
+ <%- end %>
<%:Traffic%>
diff --git a/package/gluon-status-page/files/lib/gluon/status-page/www/static/status-page.js b/package/gluon-status-page/files/lib/gluon/status-page/www/static/status-page.js
index 5be175f8..9c082278 100644
--- a/package/gluon-status-page/files/lib/gluon/status-page/www/static/status-page.js
+++ b/package/gluon-status-page/files/lib/gluon/status-page/www/static/status-page.js
@@ -1 +1 @@
-"use strict";!function(){var i=JSON.parse(document.body.getAttribute("data-translations"));function r(t,e){return t.toFixed(e).replace(/\./,i["."])}function a(t,e){e--;for(var n=t;10<=n&&0Channel "+(2484===(t=t.frequency)?14:2412<=t&&t<=2472?(t-2407)/5:5160<=t&&t<=5885?(t-5e3)/5:"unknown"),e.appendChild(n),r.appendChild(e)})}else e.style.display="none"}var n=document.querySelectorAll("[data-statistics]");d("/cgi-bin/dyn/statistics",function(a,o){var c=a.uptime-o.uptime;n.forEach(function(t){var e=t.getAttribute("data-statistics"),n=t.getAttribute("data-format"),r=s(o,e),e=s(a,e);try{var i=l[n](e,r,c);switch(typeof i){case"string":t.textContent=i;break;case"object":t.lastChild&&t.removeChild(t.lastChild),t.appendChild(i)}}catch(t){console.error(t)}});try{t(a.mesh_vpn)}catch(t){console.error(t)}try{e(a.wireless)}catch(t){console.error(t)}});var c={};function A(n){var r=document.createElement("canvas"),i=r.getContext("2d"),a=null;return{canvas:r,highlight:!1,resize:function(t,e){try{i.getImageData(0,0,t,e)}catch(t){}r.width=t,r.height=e},draw:function(t,e){e=e(a);i.clearRect(t,0,5,r.height),e&&(t=t,e=e,i.beginPath(),i.fillStyle=n,i.arc(t,e,1.2,0,2*Math.PI,!1),i.closePath(),i.fill())},set:function(t){a=t}}}function h(){var i=-100,a=0,n=0,r=[],o=document.createElement("canvas");o.className="signalgraph",o.height=200;var c=o.getContext("2d");function t(){o.width=o.clientWidth,r.forEach(function(t){t.resize(o.width,o.height)})}function l(){var e;0!==o.clientWidth&&(o.width!==o.clientWidth&&t(),c.clearRect(0,0,o.width,o.height),e=!1,r.forEach(function(t){t.highlight&&(e=!0)}),c.save(),r.forEach(function(t){e&&(c.globalAlpha=.2),t.highlight&&(c.globalAlpha=1),t.draw(n,function(t){return e=o.height,(1-(t-i)/(a-i))*e;var e}),c.drawImage(t.canvas,0,0)}),c.restore(),c.save(),c.beginPath(),c.strokeStyle="rgba(255, 180, 0, 0.15)",c.lineWidth=5,c.moveTo(n+2.5,0),c.lineTo(n+2.5,o.height),c.stroke(),function(){var t=Math.floor(o.height/40);c.save(),c.lineWidth=.5,c.strokeStyle="rgba(0, 0, 0, 0.25)",c.fillStyle="rgba(0, 0, 0, 0.5)",c.textAlign="end",c.textBaseline="bottom",c.beginPath();for(var e=0;ee[0]||t[1]e[1]?1:0});t=t[0][2];return t&&!/^fe80:/i.test(t)?t:void 0}}return t.wireless&&((g=a.insertCell()).textContent="-",g.setAttribute("data-label",i.children[Object.keys(s).length+1].textContent),(p=a.insertCell()).textContent="-",p.setAttribute("data-label",i.children[Object.keys(s).length+2].textContent),(m=a.insertCell()).textContent="-",m.setAttribute("data-label",i.children[Object.keys(s).length+3].textContent),v=A(e),t.signalgraph.addSignal(v)),a.onmouseenter=function(){a.classList.add("highlight"),v&&(v.highlight=!0)},a.onmouseleave=function(){a.classList.remove("highlight"),v&&(v.highlight=!1)},y(),{get_hostname:function(){return l.textContent},get_addr:function(){return o},update_nodeinfo:function(t){var e,n,r,i,a;(o=w(t.network.addresses))&&("span"===l.nodeName.toLowerCase()&&(a=l,l=document.createElement("a"),a.parentNode.replaceChild(l,a)),l.href="http://["+o+"]/"),l.textContent=t.hostname,x&&t.location&&(e=x.latitude,n=x.longitude,r=t.location.latitude,i=t.location.longitude,a=Math.PI/180,t=(r*=a)-(e*=a),n=(i*=a)-(n*=a),r=Math.sin(t/2)*Math.sin(t/2)+Math.sin(n/2)*Math.sin(n/2)*Math.cos(e)*Math.cos(r),r=6372.8*(2*Math.asin(Math.sqrt(r))),p.textContent=Math.round(1e3*r)+" m"),y()},update_mesh:function(n){Object.keys(s).forEach(function(t){var e=s[t];e.td.textContent=n[t]+e.suffix}),y()},update_wifi:function(t){g.textContent=t.signal,m.textContent=Math.round(t.inactive/1e3)+" s",a.classList.toggle("inactive",200e[0]?-1:t[1]e[1]?1:0});var e=t[0][2];return e&&!/^fe80:/i.test(e)?e:void 0}}return t.wireless&&((c=i.insertCell()).textContent="-",c.setAttribute("data-label",r.children[Object.keys(g).length+1].textContent),(f=i.insertCell()).textContent="-",f.setAttribute("data-label",r.children[Object.keys(g).length+2].textContent),(u=i.insertCell()).textContent="-",u.setAttribute("data-label",r.children[Object.keys(g).length+3].textContent),s=E(e),t.signalgraph.addSignal(s)),i.onmouseenter=function(){i.classList.add("highlight"),s&&(s.highlight=!0)},i.onmouseleave=function(){i.classList.remove("highlight"),s&&(s.highlight=!1)},m(),{get_hostname:function(){return h.textContent},get_addr:function(){return d},update_nodeinfo:function(t){if(d=C(t.network.addresses)){if("span"===h.nodeName.toLowerCase()){var e=h;h=document.createElement("a"),e.parentNode.replaceChild(h,e)}h.href="http://["+d+"]/"}if(h.textContent=t.hostname,y&&t.location){var n=(r=y.latitude,i=y.longitude,a=t.location.latitude,o=t.location.longitude,c=Math.PI/180,u=(a*=c)-(r*=c),s=(o*=c)-(i*=c),l=Math.sin(u/2)*Math.sin(u/2)+Math.sin(s/2)*Math.sin(s/2)*Math.cos(r)*Math.cos(a),2*Math.asin(Math.sqrt(l))*6372.8);f.textContent=Math.round(1e3*n)+" m"}var r,i,a,o,c,u,s,l;m()},update_mesh:function(n){Object.keys(g).forEach(function(t){var e=g[t];e.td.textContent=n[t]+e.suffix}),m()},update_wifi:function(t){c.textContent=t.signal,u.textContent=Math.round(t.inactive/1e3)+" s",i.classList.toggle("inactive",200Channel " + channel(radio.frequency);
- tr.appendChild(td);
-
- table.appendChild(tr);
- });
- }
-
var statisticsElems = document.querySelectorAll('[data-statistics]');
add_event_source('/cgi-bin/dyn/statistics', function(data, dataPrev) {
@@ -274,14 +230,13 @@
try {
var format_result = formats[format](value, valuePrev, diff);
switch (typeof format_result) {
- case "string":
- elem.textContent = format_result;
- break;
case "object":
if (elem.lastChild)
elem.removeChild(elem.lastChild);
elem.appendChild(format_result);
break;
+ default:
+ elem.textContent = format_result;
}
} catch (e) {
console.error(e);
@@ -293,11 +248,6 @@
} catch (e) {
console.error(e);
}
- try {
- update_radios(data.wireless);
- } catch (e) {
- console.error(e);
- }
})
function haversine(lat1, lon1, lat2, lon2) {