From c3904645907d47050a6cfe2b9e1610e64744d7ad Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Tue, 3 Apr 2018 11:43:52 +0200 Subject: [PATCH 1/3] luci-app-mwan3: calculate max interface usage from mmx_mask value Show max interface value on interface page dependent on the mmx_mask value Signed-off-by: Florian Eckert --- .../luasrc/model/cbi/mwan/interface.lua | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/interface.lua b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/interface.lua index 14bf1384f7..556a4f7010 100644 --- a/applications/luci-app-mwan3/luasrc/model/cbi/mwan/interface.lua +++ b/applications/luci-app-mwan3/luasrc/model/cbi/mwan/interface.lua @@ -5,15 +5,15 @@ dsp = require "luci.dispatcher" -function interfaceWarnings(overview, count) +function interfaceWarnings(overview, count, iface_max) local warnings = "" - if count <= 250 then + if count <= iface_max then warnings = string.format("%s
", - translatef("There are currently %d of 250 supported interfaces configured", count) + translatef("There are currently %d of %d supported interfaces configured", count, iface_max) ) else warnings = string.format("%s
", - translatef("WARNING: %d interfaces are configured exceeding the maximum of 250!", count) + translatef("WARNING: %d interfaces are configured exceeding the maximum of %d!", count, iface_max) ) end @@ -103,7 +103,34 @@ function configCheck() end end ) - return overview, count + + -- calculate iface_max usage from firewall mmx_mask + function bit(p) + return 2 ^ (p - 1) + end + function hasbit(x, p) + return x % (p + p) >= p + end + function setbit(x, p) + return hasbit(x, p) and x or x + p + end + + local uci = require("uci").cursor(nil, "/var/state") + local mmx_mask = uci:get("mwan3", "globals", "mmx_mask") or "0x3F00" + local number = tonumber(mmx_mask, 16) + local bits = 0 + local iface_max = 0 + for i=1,16 do + if hasbit(number, bit(i)) then + bits = bits + 1 + iface_max = setbit( iface_max, bit(bits)) + end + end + + -- subtract blackhole, unreachable and default table from iface_max + iface_max = iface_max - 3 + + return overview, count, iface_max end m5 = Map("mwan3", translate("MWAN - Interfaces"), From cd1a979593ab90753cda98ac5fa69e23037758d7 Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Tue, 3 Apr 2018 13:16:44 +0200 Subject: [PATCH 2/3] luci-app-mwan3: remove diag-rc-legend field id On the material theme the "Collecting data" hint in the status pages was still present on the page even though the command was sucessfull executed. Remove the legend tag and move the info "Collecting data" to the "diag-rc-output" tag will solve this issue. Signed-off-by: Florian Eckert --- .../luasrc/view/mwan/overview_status_interface.htm | 3 ++- .../luci-app-mwan3/luasrc/view/mwan/status_detail.htm | 4 +--- .../luci-app-mwan3/luasrc/view/mwan/status_diagnostics.htm | 3 --- .../luci-app-mwan3/luasrc/view/mwan/status_interface.htm | 5 +++-- .../luasrc/view/mwan/status_troubleshooting.htm | 4 +--- 5 files changed, 7 insertions(+), 12 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 4ec0edf049..fcc1bcf69c 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 @@ -69,6 +69,7 @@ XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "status", "mwan", "interface_
<%:MWAN Interfaces%>
- <%:Loading%><%:Collecting data...%> + <%:Loading%> + <%:Collecting data...%>
diff --git a/applications/luci-app-mwan3/luasrc/view/mwan/status_detail.htm b/applications/luci-app-mwan3/luasrc/view/mwan/status_detail.htm index 70eac72520..bcc23beb31 100644 --- a/applications/luci-app-mwan3/luasrc/view/mwan/status_detail.htm +++ b/applications/luci-app-mwan3/luasrc/view/mwan/status_detail.htm @@ -18,9 +18,7 @@ XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "status", "mwan", "detailed_status")%>', null, function(x) { - var legend = document.getElementById('diag-rc-legend'); var output = document.getElementById('diag-rc-output'); - legend.style.display = 'none'; output.innerHTML = String.format('
%h
', x.responseText); } ); @@ -32,9 +30,9 @@
<%:INFO: MWAN not running%>
<%end%>
- <%:Collecting data...%> <%:Loading%> + <%:Collecting data...%>
diff --git a/applications/luci-app-mwan3/luasrc/view/mwan/status_diagnostics.htm b/applications/luci-app-mwan3/luasrc/view/mwan/status_diagnostics.htm index f1c5d8fd98..22f4734ddd 100644 --- a/applications/luci-app-mwan3/luasrc/view/mwan/status_diagnostics.htm +++ b/applications/luci-app-mwan3/luasrc/view/mwan/status_diagnostics.htm @@ -31,7 +31,6 @@ function update_status(iface, task) { - var legend = document.getElementById('diag-rc-legend'); var output = document.getElementById('diag-rc-output'); output.innerHTML = @@ -45,7 +44,6 @@ stxhr.post('<%=url('admin/status/mwan')%>/diagnostics_display' + '/' + iface + '/' + task, { token: '<%=token%>' }, function(x) { - legend.style.display = 'none'; output.innerHTML = String.format('
%h
', x.responseText); } ); @@ -86,7 +84,6 @@ diff --git a/applications/luci-app-mwan3/luasrc/view/mwan/status_interface.htm b/applications/luci-app-mwan3/luasrc/view/mwan/status_interface.htm index cb476967f9..4518bd6588 100644 --- a/applications/luci-app-mwan3/luasrc/view/mwan/status_interface.htm +++ b/applications/luci-app-mwan3/luasrc/view/mwan/status_interface.htm @@ -15,6 +15,7 @@ -<%+mwan/overview_status_interface%> - +
+ <%+mwan/overview_status_interface%> +
<%+footer%> diff --git a/applications/luci-app-mwan3/luasrc/view/mwan/status_troubleshooting.htm b/applications/luci-app-mwan3/luasrc/view/mwan/status_troubleshooting.htm index 77d009231e..f60e0da0aa 100644 --- a/applications/luci-app-mwan3/luasrc/view/mwan/status_troubleshooting.htm +++ b/applications/luci-app-mwan3/luasrc/view/mwan/status_troubleshooting.htm @@ -18,9 +18,7 @@ XHR.poll(15, '<%=luci.dispatcher.build_url("admin", "status", "mwan", "troubleshooting_display")%>', null, function(x) { - var legend = document.getElementById('diag-rc-legend'); var output = document.getElementById('diag-rc-output'); - legend.style.display = 'none'; output.innerHTML = String.format('
%h
', x.responseText); } ); @@ -32,9 +30,9 @@
<%:INFO: MWAN not running%>
<%end%>
- <%:Collecting data...%> <%:Loading%> + <%:Collecting data...%>
From dd637e4f46713f4e09e026d7f76bbd8e2614e4a0 Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Tue, 3 Apr 2018 13:21:49 +0200 Subject: [PATCH 3/3] luci-app-mwan3: remove unnecessary 'tracking active' hint Remove the unnecessary 'tracking active' hint from the status interface page. Signed-off-by: Florian Eckert --- .../luasrc/view/mwan/overview_status_interface.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 fcc1bcf69c..49d120c1ae 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 @@ -19,7 +19,7 @@ XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "status", "mwan", "interface_ switch (status.interfaces[iface].status) { case 'online': - state = '<%:Online (tracking active)%>'; + state = '<%:Online%>'; css = 'success'; break; case 'offline':