Merge pull request #1652 from TDT-AG/pr/20180301-luci-app-mwan3-fix-status-page

luci-app-mwan3: fix status pages
This commit is contained in:
Hannu Nyman 2018-03-02 23:31:56 +02:00 committed by GitHub
commit 2913111ffe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 133 deletions

View file

@ -93,7 +93,7 @@ function configCheck()
local trackingNumber = uci:get("mwan3", iface, "track_ip") local trackingNumber = uci:get("mwan3", iface, "track_ip")
overview[iface]["tracking"] = 0 overview[iface]["tracking"] = 0
if #trackingNumber > 0 then if trackingNumber and #trackingNumber > 0 then
overview[iface]["tracking"] = #trackingNumber overview[iface]["tracking"] = #trackingNumber
overview[iface]["reliability"] = false overview[iface]["reliability"] = false
local reliabilityNumber = tonumber(uci:get("mwan3", iface, "reliability")) local reliabilityNumber = tonumber(uci:get("mwan3", iface, "reliability"))

View file

@ -15,30 +15,27 @@ XHR.poll(5, '<%=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 = '';
switch (status.interfaces[iface].status) switch (status.interfaces[iface].status)
{ {
case 'online': case 'online':
state = '<%:Online (tracking active)%>'; state = '<%:Online (tracking active)%>';
css = 'wanon';
break; break;
case 'notMonitored': case 'notMonitored':
state = '<%:Online (tracking off)%>'; state = '<%:Online (tracking off)%>';
css = 'wanon';
break; break;
case 'offline': case 'offline':
state = '<%:Offline%>'; state = '<%:Offline%>';
css = 'wanoff';
break; break;
default: default:
state = '<%:Disabled%>'; state = '<%:Disabled%>';
css = 'wanoff';
break; break;
} }
statusview += String.format( statusview += String.format(
'<span class="%s"><strong>%s</strong><br />%s</span>', '<div><strong>Interface: </strong>%s</div>',
css, iface
iface, );
statusview += String.format(
'<div><strong>Status: </strong>%s</div></br></br>',
state state
); );
} }
@ -53,36 +50,8 @@ XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "status", "mwan", "interface_
//]]></script> //]]></script>
<fieldset id="interface_field" class="cbi-section"> <fieldset id="interface_field" class="cbi-section">
<legend><%:MWAN Interface Live Status%></legend> <legend><%:MWAN Interfaces%></legend>
<div id="mwan_status_text"><img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /><%:Collecting data...%></div> <div id="mwan_status_text">
<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /><%:Collecting data...%>
</div>
</fieldset> </fieldset>
<style type="text/css">
.container { /* container for entire page. fixes bootstrap theme's ridiculously small page width */
max-width: 1044px;
}
#mwan_status_text {
display: table;
font-size: 14px;
margin: auto;
max-width: 1044px;
min-width: 246px;
width: 100%;
}
.wanon {
background-color: rgb(144, 240, 144);
}
.wanoff {
background-color: rgb(240, 144, 144);
}
.wanon, .wanoff {
border-radius: 60px;
box-shadow: 0px 2px 5px -3px;
float: left;
margin: 8px 3px 0px 3px;
min-height: 30px;
min-width: 235px;
padding: 5px 10px 8px 10px;
text-align: center;
}
</style>

View file

@ -14,98 +14,7 @@
</ul> </ul>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script> <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<script type="text/javascript">//<![CDATA[
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "status", "mwan", "interface_status")%>', null,
function(x, status)
{
var legend = document.getElementById('diag-rc-legend');
var statusDiv = document.getElementById('diag-rc-output');
legend.style.display = 'none';
if (status.interfaces)
{
var statusview = '';
for ( var iface in status.interfaces)
{
var state = '';
var css = '';
switch (status.interfaces[iface].status)
{
case 'online':
state = '<%:Online (tracking active)%>';
css = 'wanon';
break;
case 'notMonitored':
state = '<%:Online (tracking off)%>';
css = 'wanon';
break;
case 'offline':
state = '<%:Offline%>';
css = 'wanoff';
break;
default:
state = '<%:Disabled%>';
css = 'wanoff';
break;
}
statusview += String.format(
'<span class="%s"><strong>%s</strong><br />%s</span>',
css,
iface,
state
);
}
statusDiv.innerHTML = statusview;
}
else
{
statusDiv.innerHTML = '<strong><%:No MWAN interfaces found%></strong>';
}
}
);
//]]></script>
<div class="cbi-map"> <%+mwan/overview_status_interface%>
<h2 name="content"><%:MWAN Status - Interface%></h2>
<%if not require("luci.sys").init.enabled("mwan3") then%>
<div><strong><%:INFO: MWAN not running%></strong></div>
<%end%>
<fieldset class="cbi-section">
<legend id="diag-rc-legend"><%:Collecting data...%></legend>
<span id="diag-rc-output">
<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align: middle;" />
</span>
</fieldset>
</div>
<style type="text/css">
#mwan_status_text {
display: table;
font-size: 14px;
margin: auto;
max-width: 1044px;
min-width: 246px;
width: 100%;
}
.wanon {
background-color: rgb(144, 240, 144);
}
.wanoff {
background-color: rgb(240, 144, 144);
}
.wanon, .wanoff {
border-radius: 60px;
box-shadow: 0px 2px 5px -3px;
float: left;
margin: 8px 3px 0px 3px;
min-height: 30px;
min-width: 235px;
padding: 5px 10px 8px 10px;
text-align: center;
}
#mwan_statuslog_text {
padding: 20px;
text-align: left;
}
</style>
<%+footer%> <%+footer%>