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 09bb6c3e..db4cecaf 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 @@ -150,6 +150,11 @@ <%:Wireless 2.4 GHz%><%= statistics('clients/wifi24') %> <%:Wireless 5 GHz%><%= statistics('clients/wifi5') %> +

<%: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 de3f86b2..7a87b875 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 a=JSON.parse(document.body.getAttribute("data-translations"));function i(t,e){return t.toFixed(e).replace(/\./,a["."])}function o(t,e){e--;for(var n=t;10<=n&&0e[0]||t[1]e[1]?1:0});var e=t[0][2];return e&&!/^fe80:/i.test(e)?e:void 0}}return t.wireless&&((s=a.insertCell()).textContent="-",s.setAttribute("data-label",i.children[Object.keys(g).length+1].textContent),(d=a.insertCell()).textContent="-",d.setAttribute("data-label",i.children[Object.keys(g).length+2].textContent),(u=a.insertCell()).textContent="-",u.setAttribute("data-label",i.children[Object.keys(g).length+3].textContent),l=E(n),t.signalgraph.addSignal(l)),a.onmouseenter=function(){a.classList.add("highlight"),l&&(l.highlight=!0)},a.onmouseleave=function(){a.classList.remove("highlight"),l&&(l.highlight=!1)},p(),{get_hostname:function(){return f.textContent},update_nodeinfo:function(t){var e,n,r,i,a,o,c,s,u=C(t.network.addresses);if(u){if("span"===f.nodeName.toLowerCase()){var l=f;f=document.createElement("a"),l.parentNode.replaceChild(f,l)}f.href="http://["+u+"]/"}if(f.textContent=t.hostname,y&&t.location){var h=(e=y.latitude,n=y.longitude,r=t.location.latitude,i=t.location.longitude,a=Math.PI/180,o=(r*=a)-(e*=a),c=(i*=a)-(n*=a),s=Math.sin(o/2)*Math.sin(o/2)+Math.sin(c/2)*Math.sin(c/2)*Math.cos(e)*Math.cos(r),2*Math.asin(Math.sqrt(s))*6372.8);d.textContent=Math.round(1e3*h)+" m"}p()},update_mesh:function(n){Object.keys(g).forEach(function(t){var e=g[t];e.td.textContent=n[t]+e.suffix}),p()},update_wifi:function(t){s.textContent=t.signal,u.textContent=Math.round(t.inactive/1e3)+" s",a.classList.toggle("inactive",200Channel "+(2484===(t=t.frequency)?14:2412<=t&&t<=2472?(t-2407)/5:5160<=t&&t<=5885?(t-5e3)/5:"unknown"),e.appendChild(n),i.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"),i=l(o,e),e=l(a,e);try{var r=s[n](e,i,c);void 0!==r&&(t.textContent=r)}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 i=document.createElement("canvas"),r=i.getContext("2d"),a=null;return{canvas:i,highlight:!1,resize:function(t,e){try{r.getImageData(0,0,t,e)}catch(t){}i.width=t,i.height=e},draw:function(t,e){e=e(a);r.clearRect(t,0,5,i.height),e&&(t=t,e=e,r.beginPath(),r.fillStyle=n,r.arc(t,e,1.2,0,2*Math.PI,!1),r.closePath(),r.fill())},set:function(t){a=t}}}function h(){var c=-100,s=0,n=0,i=[],l=document.createElement("canvas");l.className="signalgraph",l.height=200;var u=l.getContext("2d");function t(){l.width=l.clientWidth,i.forEach(function(t){t.resize(l.width,l.height)})}function r(){var e;0!==l.clientWidth&&(l.width!==l.clientWidth&&t(),u.clearRect(0,0,l.width,l.height),e=!1,i.forEach(function(t){t.highlight&&(e=!0)}),u.save(),i.forEach(function(t){e&&(u.globalAlpha=.2),t.highlight&&(u.globalAlpha=1),t.draw(n,function(t){return e=t,n=c,i=s,t=l.height,(1-(e-n)/(i-n))*t;var e,n,i}),u.drawImage(t.canvas,0,0)}),u.restore(),u.save(),u.beginPath(),u.strokeStyle="rgba(255, 180, 0, 0.15)",u.lineWidth=5,u.moveTo(n+2.5,0),u.lineTo(n+2.5,l.height),u.stroke(),function(){var t=Math.floor(l.height/40);u.save(),u.lineWidth=.5,u.strokeStyle="rgba(0, 0, 0, 0.25)",u.fillStyle="rgba(0, 0, 0, 0.5)",u.textAlign="end",u.textBaseline="bottom",u.beginPath();for(var e,n,i,r=0;re[0]||t[1]e[1]?1:0});t=t[0][2];return t&&!/^fe80:/i.test(t)?t:void 0}}return t.wireless&&((g=o.insertCell()).textContent="-",g.setAttribute("data-label",a.children[Object.keys(l).length+1].textContent),(v=o.insertCell()).textContent="-",v.setAttribute("data-label",a.children[Object.keys(l).length+2].textContent),(m=o.insertCell()).textContent="-",m.setAttribute("data-label",a.children[Object.keys(l).length+3].textContent),p=A(n),t.signalgraph.addSignal(p)),o.onmouseenter=function(){o.classList.add("highlight"),p&&(p.highlight=!0)},o.onmouseleave=function(){o.classList.remove("highlight"),p&&(p.highlight=!1)},y(),{get_hostname:function(){return s.textContent},update_nodeinfo:function(t){var e,n,i,r,a=w(t.network.addresses);a&&("span"===s.nodeName.toLowerCase()&&(r=s,s=document.createElement("a"),r.parentNode.replaceChild(s,r)),s.href="http://["+a+"]/"),s.textContent=t.hostname,x&&t.location&&(e=x.latitude,n=x.longitude,i=t.location.latitude,r=t.location.longitude,a=Math.PI/180,t=(i*=a)-(e*=a),n=(r*=a)-(n*=a),i=Math.sin(t/2)*Math.sin(t/2)+Math.sin(n/2)*Math.sin(n/2)*Math.cos(e)*Math.cos(i),i=6372.8*(2*Math.asin(Math.sqrt(i))),v.textContent=Math.round(1e3*i)+" m"),y()},update_mesh:function(n){Object.keys(l).forEach(function(t){var e=l[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",o.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) { @@ -233,6 +275,11 @@ } catch (e) { console.error(e); } + try { + update_radios(data.wireless); + } catch (e) { + console.error(e); + } }) function haversine(lat1, lon1, lat2, lon2) {