1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Display label in MPTCP bandwidth graph

This commit is contained in:
Ycarus (Yannick Chabanois) 2020-10-22 14:33:02 +02:00
parent f01302b6f8
commit cc501a5e0a
2 changed files with 26 additions and 13 deletions

View file

@ -58,6 +58,7 @@ function multipath_bandwidth()
uci:foreach("network", "interface", function(s)
local intname = s[".name"]
local label = s["label"]
local dev = get_device(intname)
if dev == "" then
dev = get_device(s["ifname"])
@ -75,9 +76,17 @@ function multipath_bandwidth()
local bwc = luci.sys.exec("luci-bwc -i %q 2>/dev/null" % dev) or ""
if bwc ~= nil then
--result[dev] = "[" .. string.gsub(bwc, '[\r\n]', '') .. "]"
result[intname] = "[" .. string.gsub(bwc, '[\r\n]', '') .. "]"
if label ~= nil then
result[intname .. " (" .. label .. ")" ] = "[" .. string.gsub(bwc, '[\r\n]', '') .. "]"
else
result[intname] = "[" .. string.gsub(bwc, '[\r\n]', '') .. "]"
end
else
result[intname] = "[]"
if label ~= nil then
result[intname .. " (" .. label .. ")" ] = "[]"
else
result[intname] = "[]"
end
end
end
end

View file

@ -59,21 +59,21 @@
function stringToColour(str) {
if(str == "total")
return "OrangeRed";
if(str == "wan")
if(str.substring(0, 4) == "wan")
return "FireBrick";
if(str == "wan1")
if(str.substring(0, 4) == "wan1")
return "DeepSkyBlue";
if(str == "wan2")
if(str.substring(0, 4) == "wan2")
return "SeaGreen";
if(str == "wan3")
if(str.substring(0, 4) == "wan3")
return "PaleGreen";
if(str == "wan4")
if(str.substring(0, 4) == "wan4")
return "PowderBlue";
if(str == "wan5")
if(str.substring(0, 4) == "wan5")
return "Salmon";
if(str == "wan6")
if(str.substring(0, 4) == "wan6")
return "LightGreen";
if(str == "wan7")
if(str.substring(0, 4) == "wan7")
return "PaleTurquoise";
// Generate a color folowing the name
Math.seedrandom(str);
@ -893,9 +893,13 @@ window.setTimeout(function()
<ul class="cbi-tabmenu">
<% for _, dev in ipairs(devices) do
local ifname = get_device(dev)
%>
<li class="cbi-tab<%= ifname == curifname and "" or "-disabled" %>"><a href="?dev=<%=pcdata(get_device(dev))%>"><%=pcdata(dev)%></a></li>
local label = uci:get("network",dev,"label")
if label ~= nil then
%>
<li class="cbi-tab<%= ifname == curifname and "" or "-disabled" %>"><a href="?dev=<%=pcdata(get_device(dev))%>"><%=label%></a></li>
<% else %>
<li class="cbi-tab<%= ifname == curifname and "" or "-disabled" %>"><a href="?dev=<%=pcdata(get_device(dev))%>"><%=pcdata(dev)%></a></li>
<% end %>
<% end %>
</ul>