mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
fx status
This commit is contained in:
parent
e83013d8fc
commit
f08f66c14e
3 changed files with 60 additions and 19 deletions
|
@ -43,7 +43,7 @@ function server_add()
|
|||
serversnb = serversnb + 1
|
||||
end
|
||||
ucic:set("openmptcprouter",server,"disabled",openmptcprouter_vps_disabled)
|
||||
ucic:set("openmptcprouter",server,"ip",server_ip)
|
||||
ucic:set_list("openmptcprouter",server,"ip",server_ip)
|
||||
ucic:set("openmptcprouter",server,"port","65500")
|
||||
ucic:save("openmptcprouter")
|
||||
end
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
<div class="cbi-value">
|
||||
<label class="cbi-value-title" for="server_ip"><%:Server IP%></label>
|
||||
<div class="cbi-value-field">
|
||||
<input name="<%=servername%>.server_ip" id="<%=servername%>.server_ip" placeholder="<%:Server IP%>" class="cbi-input-text" value="<%=uci:get("openmptcprouter",servername,"ip")%>" data-optional="false">
|
||||
<input name="<%=servername%>.server_ip" id="<%=servername%>.server_ip" placeholder="<%:Server IP%>" class="cbi-input-text" value="<%=uci:get_list("openmptcprouter",servername,"ip")[1]%>" data-optional="false">
|
||||
<div class="cbi-value-description">
|
||||
<%:Server IP%>
|
||||
</div>
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
<%+header%>
|
||||
<%
|
||||
local ucic = luci.model.uci.cursor()
|
||||
local menuentry = ucic:get("openmptcprouter","settings","menu") or "status"
|
||||
local menuentry = "status"
|
||||
local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openmptcprouter.png"
|
||||
%>
|
||||
<link rel="stylesheet" type="text/css" href="<%=resource%>/status/css/wanstatus.css?v=git-20"/>
|
||||
|
@ -897,21 +897,23 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
|
|||
<script type="text/javascript">//<![CDATA[
|
||||
|
||||
function stringToColour(str) {
|
||||
if(str == "wan")
|
||||
if(str == "total")
|
||||
return "OrangeRed";
|
||||
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);
|
||||
|
@ -1102,6 +1104,7 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
|
|||
var data_tx_peak = 0;
|
||||
|
||||
var data = {};
|
||||
var pre_itf = "";
|
||||
|
||||
for(var itf in dataarray)
|
||||
{
|
||||
|
@ -1114,7 +1117,15 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
|
|||
// Create a new polygon to draw the bandwith
|
||||
var dnline = Gdn.createElementNS('http://www.w3.org/2000/svg', 'polyline');
|
||||
dnline.setAttributeNS(null, 'id', 'rx_' + itf);
|
||||
dnline.setAttributeNS(null, 'style', 'fill:' + color + ';fill-opacity:0.4;stroke:black;stroke-width:0.1');
|
||||
if (itf != "total")
|
||||
{
|
||||
dnline.setAttributeNS(null, 'style', 'fill:' + color + ';fill-opacity:0.4;stroke:black;stroke-width:0.1');
|
||||
}
|
||||
else
|
||||
{
|
||||
//dnline.setAttributeNS(null, 'style', 'fill: none;stroke:OrangeRed;stroke-width:1');
|
||||
dnline.setAttributeNS(null, 'style', 'fill: none;stroke:none');
|
||||
}
|
||||
Gdn.getElementById('rx').parentNode.appendChild(dnline);
|
||||
|
||||
dnPolygons[itf] = Gdn.getElementById('rx_' + itf);
|
||||
|
@ -1127,11 +1138,18 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
|
|||
|
||||
// Create legend for this connextion
|
||||
var table = document.getElementById('download_stats');
|
||||
var tr = table.insertRow();
|
||||
if (pre_itf == "total")
|
||||
{
|
||||
var tr = table.insertRow(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
var tr = table.insertRow();
|
||||
}
|
||||
tr.setAttribute('id', itf + '_download');
|
||||
// Create cells of the table
|
||||
var itflabel = tr.insertCell(0);
|
||||
// Crete itf legend
|
||||
// Create itf legend
|
||||
var strong = document.createElement('strong')
|
||||
strong.appendChild(document.createTextNode(itf));
|
||||
strong.setAttribute('style', 'border-bottom:2px solid ' + color);
|
||||
|
@ -1155,7 +1173,15 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
|
|||
{
|
||||
var upline = Gup.createElementNS('http://www.w3.org/2000/svg', 'polyline');
|
||||
upline.setAttributeNS(null, 'id', 'tx_' + itf);
|
||||
upline.setAttributeNS(null, 'style', 'fill:' + color + ';fill-opacity:0.4;stroke:black;stroke-width:0.1');
|
||||
if (itf != "total")
|
||||
{
|
||||
upline.setAttributeNS(null, 'style', 'fill:' + color + ';fill-opacity:0.4;stroke:black;stroke-width:0.1');
|
||||
}
|
||||
else
|
||||
{
|
||||
//upline.setAttributeNS(null, 'style', 'fill:none;stroke:OrangeRed;stroke-width:1');
|
||||
upline.setAttributeNS(null, 'style', 'fill:none;stroke:none');
|
||||
}
|
||||
Gup.getElementById('tx').parentNode.appendChild(upline);
|
||||
|
||||
upPolygons[itf] = Gup.getElementById('tx_' + itf);
|
||||
|
@ -1168,7 +1194,14 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
|
|||
|
||||
// Create legend for this connextion
|
||||
var table = document.getElementById('upload_stats');
|
||||
var tr = table.insertRow();
|
||||
if (pre_itf == "total")
|
||||
{
|
||||
var tr = table.insertRow(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
var tr = table.insertRow();
|
||||
}
|
||||
tr.setAttribute('id', itf + '_upload');
|
||||
// Create cells of the table
|
||||
var itflabel = tr.insertCell(0);
|
||||
|
@ -1190,8 +1223,8 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
|
|||
var itfpeak = tr.insertCell(6);
|
||||
itfpeak.setAttribute('id', itf + '_upload_peak');
|
||||
itfpeak.appendChild(document.createTextNode('0 <%:kbit/s%> (0 <%:kB/s%>)'));
|
||||
|
||||
}
|
||||
if (pre_itf != "total") pre_itf = itf;
|
||||
}
|
||||
|
||||
var dnsma = {};
|
||||
|
@ -1258,11 +1291,15 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
|
|||
{
|
||||
var rx_bot=0;
|
||||
var tx_bot=0;
|
||||
if (itf != "total")
|
||||
{
|
||||
for(var j=0; j < toadditf.length; j++)
|
||||
{
|
||||
if (toadditf[j] == "total") continue;
|
||||
rx_bot += dndata[toadditf[j]][i];
|
||||
tx_bot += updata[toadditf[j]][i];
|
||||
}
|
||||
}
|
||||
// set upline of the interface
|
||||
uplineDnl[itf][i] = dndata[itf][i] + rx_bot;
|
||||
data_rx_peak = Math.max(data_rx_peak, dndata[itf][i]);
|
||||
|
@ -1282,8 +1319,11 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
|
|||
}
|
||||
if(toadditf.length)
|
||||
{
|
||||
if (toadditf[toadditf.length-1] != "total")
|
||||
{
|
||||
downlineDnl[itf][i] = uplineDnl[toadditf[toadditf.length-1]][i];
|
||||
downlineUpl[itf][i] = uplineUpl[toadditf[toadditf.length-1]][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1324,6 +1364,7 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
|
|||
|
||||
for (var itf in uplineDnl)
|
||||
{
|
||||
if (itf == "total") continue;
|
||||
var y_rx = 0;
|
||||
var y_tx = 0;
|
||||
|
||||
|
@ -1394,7 +1435,7 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
|
|||
if (typeof dntopline != "object")
|
||||
{
|
||||
dntopline = Gdn.getElementById('rx');
|
||||
dntopline.setAttributeNS(null, 'style', 'stroke:DimGray;stroke-width:1;stroke-linecap="round";fill:;fill-opacity:0;');
|
||||
dntopline.setAttributeNS(null, 'style', 'stroke:DimGray;stroke-width:0;stroke-linecap="round";fill:;fill-opacity:0;');
|
||||
/* Move line on top */
|
||||
var father = dntopline.parentNode;
|
||||
father.removeChild(dntopline);
|
||||
|
@ -1403,7 +1444,7 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
|
|||
if (typeof uptopline != "object")
|
||||
{
|
||||
uptopline = Gup.getElementById('tx');
|
||||
uptopline.setAttributeNS(null, 'style', 'stroke:DimGray;stroke-width:1;stroke-linecap="round";fill:;fill-opacity:0;');
|
||||
uptopline.setAttributeNS(null, 'style', 'stroke:DimGray;stroke-width:0;stroke-linecap="round";fill:;fill-opacity:0;');
|
||||
/* Move line on top */
|
||||
var father = uptopline.parentNode;
|
||||
father.removeChild(uptopline);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue