luci-app-mwan3: add uptime/downtime to status page
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
parent
77af204dea
commit
f9b634f95b
1 changed files with 25 additions and 1 deletions
|
@ -5,6 +5,17 @@
|
||||||
-%>
|
-%>
|
||||||
|
|
||||||
<script type="text/javascript">//<![CDATA[
|
<script type="text/javascript">//<![CDATA[
|
||||||
|
|
||||||
|
function secondsToString(time) {
|
||||||
|
var seconds = parseInt(time, 10);
|
||||||
|
|
||||||
|
var hrs = Math.floor(seconds / 3600);
|
||||||
|
seconds -= hrs*3600;
|
||||||
|
var mnts = Math.floor(seconds / 60);
|
||||||
|
seconds -= mnts*60;
|
||||||
|
return String.format("%sh:%sm:%ss", hrs, mnts, seconds);
|
||||||
|
}
|
||||||
|
|
||||||
XHR.poll(-1, '<%=luci.dispatcher.build_url("admin", "status", "mwan", "interface_status")%>', null,
|
XHR.poll(-1, '<%=luci.dispatcher.build_url("admin", "status", "mwan", "interface_status")%>', null,
|
||||||
function(x, status)
|
function(x, status)
|
||||||
{
|
{
|
||||||
|
@ -15,15 +26,24 @@ XHR.poll(-1, '<%=luci.dispatcher.build_url("admin", "status", "mwan", "interface
|
||||||
for ( var iface in status.interfaces)
|
for ( var iface in status.interfaces)
|
||||||
{
|
{
|
||||||
var state = '';
|
var state = '';
|
||||||
var css = ''
|
var css = '';
|
||||||
|
var time = '';
|
||||||
switch (status.interfaces[iface].status)
|
switch (status.interfaces[iface].status)
|
||||||
{
|
{
|
||||||
case 'online':
|
case 'online':
|
||||||
state = '<%:Online%>';
|
state = '<%:Online%>';
|
||||||
|
time = String.format(
|
||||||
|
'<div><strong>Uptime: </strong>%s</div>',
|
||||||
|
secondsToString(status.interfaces[iface].uptime)
|
||||||
|
);
|
||||||
css = 'success';
|
css = 'success';
|
||||||
break;
|
break;
|
||||||
case 'offline':
|
case 'offline':
|
||||||
state = '<%:Offline%>';
|
state = '<%:Offline%>';
|
||||||
|
time = String.format(
|
||||||
|
'<div><strong>Downtime: </strong>%s</div>',
|
||||||
|
secondsToString(status.interfaces[iface].downtime)
|
||||||
|
);
|
||||||
css = 'danger';
|
css = 'danger';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -43,6 +63,10 @@ XHR.poll(-1, '<%=luci.dispatcher.build_url("admin", "status", "mwan", "interface
|
||||||
'<div><strong>Status: </strong>%s</div>',
|
'<div><strong>Status: </strong>%s</div>',
|
||||||
state
|
state
|
||||||
);
|
);
|
||||||
|
if (time)
|
||||||
|
{
|
||||||
|
statusview += time;
|
||||||
|
}
|
||||||
statusview += '</div>'
|
statusview += '</div>'
|
||||||
}
|
}
|
||||||
statusDiv.innerHTML = statusview;
|
statusDiv.innerHTML = statusview;
|
||||||
|
|
Loading…
Reference in a new issue