summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-mwan3/luasrc/view
diff options
context:
space:
mode:
authorFlorian Eckert <fe@dev.tdt.de>2018-12-21 10:00:26 +0100
committerFlorian Eckert <fe@dev.tdt.de>2018-12-21 10:33:21 +0100
commitf9b634f95b06d2618a3742089cd64e80da0149fd (patch)
tree9ba64ed46ea170d7c1ba30422277344556e19623 /applications/luci-app-mwan3/luasrc/view
parent77af204dea8c7872ed6a695ddb155fbe77a4a4dd (diff)
luci-app-mwan3: add uptime/downtime to status page
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
Diffstat (limited to 'applications/luci-app-mwan3/luasrc/view')
-rw-r--r--applications/luci-app-mwan3/luasrc/view/mwan/overview_status_interface.htm26
1 files changed, 25 insertions, 1 deletions
diff --git a/applications/luci-app-mwan3/luasrc/view/mwan/overview_status_interface.htm b/applications/luci-app-mwan3/luasrc/view/mwan/overview_status_interface.htm
index 259f3c975..2e7b490f4 100644
--- a/applications/luci-app-mwan3/luasrc/view/mwan/overview_status_interface.htm
+++ b/applications/luci-app-mwan3/luasrc/view/mwan/overview_status_interface.htm
@@ -5,6 +5,17 @@
-%>
<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,
function(x, status)
{
@@ -15,15 +26,24 @@ XHR.poll(-1, '<%=luci.dispatcher.build_url("admin", "status", "mwan", "interface
for ( var iface in status.interfaces)
{
var state = '';
- var css = ''
+ var css = '';
+ var time = '';
switch (status.interfaces[iface].status)
{
case 'online':
state = '<%:Online%>';
+ time = String.format(
+ '<div><strong>Uptime: </strong>%s</div>',
+ secondsToString(status.interfaces[iface].uptime)
+ );
css = 'success';
break;
case 'offline':
state = '<%:Offline%>';
+ time = String.format(
+ '<div><strong>Downtime: </strong>%s</div>',
+ secondsToString(status.interfaces[iface].downtime)
+ );
css = 'danger';
break;
default:
@@ -43,6 +63,10 @@ XHR.poll(-1, '<%=luci.dispatcher.build_url("admin", "status", "mwan", "interface
'<div><strong>Status: </strong>%s</div>',
state
);
+ if (time)
+ {
+ statusview += time;
+ }
statusview += '</div>'
}
statusDiv.innerHTML = statusview;