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
|
serversnb = serversnb + 1
|
||||||
end
|
end
|
||||||
ucic:set("openmptcprouter",server,"disabled",openmptcprouter_vps_disabled)
|
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:set("openmptcprouter",server,"port","65500")
|
||||||
ucic:save("openmptcprouter")
|
ucic:save("openmptcprouter")
|
||||||
end
|
end
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
<div class="cbi-value">
|
<div class="cbi-value">
|
||||||
<label class="cbi-value-title" for="server_ip"><%:Server IP%></label>
|
<label class="cbi-value-title" for="server_ip"><%:Server IP%></label>
|
||||||
<div class="cbi-value-field">
|
<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">
|
<div class="cbi-value-description">
|
||||||
<%:Server IP%>
|
<%:Server IP%>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
<%+header%>
|
<%+header%>
|
||||||
<%
|
<%
|
||||||
local ucic = luci.model.uci.cursor()
|
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"
|
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"/>
|
<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[
|
<script type="text/javascript">//<![CDATA[
|
||||||
|
|
||||||
function stringToColour(str) {
|
function stringToColour(str) {
|
||||||
if(str == "wan")
|
if(str == "total")
|
||||||
|
return "OrangeRed";
|
||||||
|
if(str.substring(0,4) == "wan")
|
||||||
return "FireBrick";
|
return "FireBrick";
|
||||||
if(str == "wan1")
|
if(str.substring(0,4) == "wan1")
|
||||||
return "DeepSkyBlue";
|
return "DeepSkyBlue";
|
||||||
if(str == "wan2")
|
if(str.substring(0,4) == "wan2")
|
||||||
return "SeaGreen";
|
return "SeaGreen";
|
||||||
if(str == "wan3")
|
if(str.substring(0,4) == "wan3")
|
||||||
return "PaleGreen";
|
return "PaleGreen";
|
||||||
if(str == "wan4")
|
if(str.substring(0,4) == "wan4")
|
||||||
return "PowderBlue";
|
return "PowderBlue";
|
||||||
if(str == "wan5")
|
if(str.substring(0,4) == "wan5")
|
||||||
return "Salmon";
|
return "Salmon";
|
||||||
if(str == "wan6")
|
if(str.substring(0,4) == "wan6")
|
||||||
return "LightGreen";
|
return "LightGreen";
|
||||||
if(str == "wan7")
|
if(str.substring(0,4) == "wan7")
|
||||||
return "PaleTurquoise";
|
return "PaleTurquoise";
|
||||||
// Generate a color folowing the name
|
// Generate a color folowing the name
|
||||||
Math.seedrandom(str);
|
Math.seedrandom(str);
|
||||||
|
@ -1102,6 +1104,7 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
|
||||||
var data_tx_peak = 0;
|
var data_tx_peak = 0;
|
||||||
|
|
||||||
var data = {};
|
var data = {};
|
||||||
|
var pre_itf = "";
|
||||||
|
|
||||||
for(var itf in dataarray)
|
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
|
// Create a new polygon to draw the bandwith
|
||||||
var dnline = Gdn.createElementNS('http://www.w3.org/2000/svg', 'polyline');
|
var dnline = Gdn.createElementNS('http://www.w3.org/2000/svg', 'polyline');
|
||||||
dnline.setAttributeNS(null, 'id', 'rx_' + itf);
|
dnline.setAttributeNS(null, 'id', 'rx_' + itf);
|
||||||
|
if (itf != "total")
|
||||||
|
{
|
||||||
dnline.setAttributeNS(null, 'style', 'fill:' + color + ';fill-opacity:0.4;stroke:black;stroke-width:0.1');
|
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);
|
Gdn.getElementById('rx').parentNode.appendChild(dnline);
|
||||||
|
|
||||||
dnPolygons[itf] = Gdn.getElementById('rx_' + itf);
|
dnPolygons[itf] = Gdn.getElementById('rx_' + itf);
|
||||||
|
@ -1127,11 +1138,18 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
|
||||||
|
|
||||||
// Create legend for this connextion
|
// Create legend for this connextion
|
||||||
var table = document.getElementById('download_stats');
|
var table = document.getElementById('download_stats');
|
||||||
|
if (pre_itf == "total")
|
||||||
|
{
|
||||||
|
var tr = table.insertRow(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
var tr = table.insertRow();
|
var tr = table.insertRow();
|
||||||
|
}
|
||||||
tr.setAttribute('id', itf + '_download');
|
tr.setAttribute('id', itf + '_download');
|
||||||
// Create cells of the table
|
// Create cells of the table
|
||||||
var itflabel = tr.insertCell(0);
|
var itflabel = tr.insertCell(0);
|
||||||
// Crete itf legend
|
// Create itf legend
|
||||||
var strong = document.createElement('strong')
|
var strong = document.createElement('strong')
|
||||||
strong.appendChild(document.createTextNode(itf));
|
strong.appendChild(document.createTextNode(itf));
|
||||||
strong.setAttribute('style', 'border-bottom:2px solid ' + color);
|
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');
|
var upline = Gup.createElementNS('http://www.w3.org/2000/svg', 'polyline');
|
||||||
upline.setAttributeNS(null, 'id', 'tx_' + itf);
|
upline.setAttributeNS(null, 'id', 'tx_' + itf);
|
||||||
|
if (itf != "total")
|
||||||
|
{
|
||||||
upline.setAttributeNS(null, 'style', 'fill:' + color + ';fill-opacity:0.4;stroke:black;stroke-width:0.1');
|
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);
|
Gup.getElementById('tx').parentNode.appendChild(upline);
|
||||||
|
|
||||||
upPolygons[itf] = Gup.getElementById('tx_' + itf);
|
upPolygons[itf] = Gup.getElementById('tx_' + itf);
|
||||||
|
@ -1168,7 +1194,14 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
|
||||||
|
|
||||||
// Create legend for this connextion
|
// Create legend for this connextion
|
||||||
var table = document.getElementById('upload_stats');
|
var table = document.getElementById('upload_stats');
|
||||||
|
if (pre_itf == "total")
|
||||||
|
{
|
||||||
|
var tr = table.insertRow(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
var tr = table.insertRow();
|
var tr = table.insertRow();
|
||||||
|
}
|
||||||
tr.setAttribute('id', itf + '_upload');
|
tr.setAttribute('id', itf + '_upload');
|
||||||
// Create cells of the table
|
// Create cells of the table
|
||||||
var itflabel = tr.insertCell(0);
|
var itflabel = tr.insertCell(0);
|
||||||
|
@ -1190,8 +1223,8 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
|
||||||
var itfpeak = tr.insertCell(6);
|
var itfpeak = tr.insertCell(6);
|
||||||
itfpeak.setAttribute('id', itf + '_upload_peak');
|
itfpeak.setAttribute('id', itf + '_upload_peak');
|
||||||
itfpeak.appendChild(document.createTextNode('0 <%:kbit/s%> (0 <%:kB/s%>)'));
|
itfpeak.appendChild(document.createTextNode('0 <%:kbit/s%> (0 <%:kB/s%>)'));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if (pre_itf != "total") pre_itf = itf;
|
||||||
}
|
}
|
||||||
|
|
||||||
var dnsma = {};
|
var dnsma = {};
|
||||||
|
@ -1258,11 +1291,15 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
|
||||||
{
|
{
|
||||||
var rx_bot=0;
|
var rx_bot=0;
|
||||||
var tx_bot=0;
|
var tx_bot=0;
|
||||||
|
if (itf != "total")
|
||||||
|
{
|
||||||
for(var j=0; j < toadditf.length; j++)
|
for(var j=0; j < toadditf.length; j++)
|
||||||
{
|
{
|
||||||
|
if (toadditf[j] == "total") continue;
|
||||||
rx_bot += dndata[toadditf[j]][i];
|
rx_bot += dndata[toadditf[j]][i];
|
||||||
tx_bot += updata[toadditf[j]][i];
|
tx_bot += updata[toadditf[j]][i];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// set upline of the interface
|
// set upline of the interface
|
||||||
uplineDnl[itf][i] = dndata[itf][i] + rx_bot;
|
uplineDnl[itf][i] = dndata[itf][i] + rx_bot;
|
||||||
data_rx_peak = Math.max(data_rx_peak, dndata[itf][i]);
|
data_rx_peak = Math.max(data_rx_peak, dndata[itf][i]);
|
||||||
|
@ -1281,11 +1318,14 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
|
||||||
data_tx_avg = updata[itf][i];
|
data_tx_avg = updata[itf][i];
|
||||||
}
|
}
|
||||||
if(toadditf.length)
|
if(toadditf.length)
|
||||||
|
{
|
||||||
|
if (toadditf[toadditf.length-1] != "total")
|
||||||
{
|
{
|
||||||
downlineDnl[itf][i] = uplineDnl[toadditf[toadditf.length-1]][i];
|
downlineDnl[itf][i] = uplineDnl[toadditf[toadditf.length-1]][i];
|
||||||
downlineUpl[itf][i] = uplineUpl[toadditf[toadditf.length-1]][i];
|
downlineUpl[itf][i] = uplineUpl[toadditf[toadditf.length-1]][i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
toadditf.push(itf);
|
toadditf.push(itf);
|
||||||
|
|
||||||
|
@ -1324,6 +1364,7 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
|
||||||
|
|
||||||
for (var itf in uplineDnl)
|
for (var itf in uplineDnl)
|
||||||
{
|
{
|
||||||
|
if (itf == "total") continue;
|
||||||
var y_rx = 0;
|
var y_rx = 0;
|
||||||
var y_tx = 0;
|
var y_tx = 0;
|
||||||
|
|
||||||
|
@ -1394,7 +1435,7 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
|
||||||
if (typeof dntopline != "object")
|
if (typeof dntopline != "object")
|
||||||
{
|
{
|
||||||
dntopline = Gdn.getElementById('rx');
|
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 */
|
/* Move line on top */
|
||||||
var father = dntopline.parentNode;
|
var father = dntopline.parentNode;
|
||||||
father.removeChild(dntopline);
|
father.removeChild(dntopline);
|
||||||
|
@ -1403,7 +1444,7 @@ local statuslogo = ucic:get("openmptcprouter","settings","statuslogo") or "openm
|
||||||
if (typeof uptopline != "object")
|
if (typeof uptopline != "object")
|
||||||
{
|
{
|
||||||
uptopline = Gup.getElementById('tx');
|
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 */
|
/* Move line on top */
|
||||||
var father = uptopline.parentNode;
|
var father = uptopline.parentNode;
|
||||||
father.removeChild(uptopline);
|
father.removeChild(uptopline);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue