mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
Add EEE html page
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<script src="/ports.js"></script>
|
||||||
|
<script src="/main.js"></script>
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
<title>FreeSwitchOS Port Statistics</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<nav id="sidebar"></nav>
|
||||||
|
<div style="margin-left:16%;padding:1px 16px;height:1000px;">
|
||||||
|
<div id="ports"></div>
|
||||||
|
<h1>EEE Status</h1>
|
||||||
|
<table id="eeetable">
|
||||||
|
<tr> <th> </th> <th colspan="3"> Advertising </th> <th colspan="3">Link-Partner advertises</th> <th></th></tr>
|
||||||
|
<tr> <th>Port</th> <th>2.5G</th> <th>1G</th> <th>100M</th> <th>2.5G</th> <th>1G</th> <th>100M</th> <th>Active?</th></tr>
|
||||||
|
</table>
|
||||||
|
<div>
|
||||||
|
<input style="width:20%;padding: 8px 16px;margin-top: 2em;margin-right: 3em;" id="eee_enable" onclick="eeeSub(0, 1);" type="button" value="Enable EEE">
|
||||||
|
<input style="width:20%;padding: 8px 16px;margin-top: 2em;" id="eee_enable" onclick="eeeSub(0, 0);" type="button" value="Disable EEE">
|
||||||
|
</div>
|
||||||
|
<script src="/eee.js"></script>
|
||||||
|
<script src="/eee_sub.js"></script>
|
||||||
|
</div>
|
||||||
|
<script src="/navigation.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
function createEEE() {
|
||||||
|
var tbl = document.getElementById('eeetable');
|
||||||
|
if (tbl.rows.length <= 2) {
|
||||||
|
console.log("CREATING TABLE ", tbl.rows.length);
|
||||||
|
for (let i = 2; i < 8; i++) {
|
||||||
|
console.log("Table row: " + i + "pState: " + pState[i-2]);
|
||||||
|
const tr = tbl.insertRow();
|
||||||
|
let td = tr.insertCell(); td.appendChild(document.createTextNode(`Port ${i-1}`));
|
||||||
|
for (let j = 0; j < 7; j++) {
|
||||||
|
td = tr.insertCell(); td.appendChild(document.createTextNode(" "));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getEEE() {
|
||||||
|
var xhttp = new XMLHttpRequest();
|
||||||
|
xhttp.onreadystatechange = function() {
|
||||||
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
|
const s = JSON.parse(xhttp.responseText);
|
||||||
|
console.log("EEE: ", JSON.stringify(s));
|
||||||
|
var tbl = document.getElementById('eeetable');
|
||||||
|
if (tbl.rows.length > 2) {
|
||||||
|
for (let i = 2; i < 8; i++) {
|
||||||
|
p = s[i-2];
|
||||||
|
let n = p.portNum;
|
||||||
|
console.log("Table Update row: " + i + " portNum is " + n + ", pState is " + pState[i-2]);
|
||||||
|
let tr = tbl.rows[n+1];
|
||||||
|
if (!p.isSFP) {
|
||||||
|
let eee = parseInt(p.eee,2); let lp = parseInt(p.eee_lp,2);
|
||||||
|
tr.cells[1].innerHTML = `${eee&4?"ON":"OFF"}`; tr.cells[2].innerHTML = `${eee&2?"ON":"OFF"}`; tr.cells[3].innerHTML = `${eee&1?"ON":"OFF"}`;
|
||||||
|
tr.cells[4].innerHTML = `${lp&4?"ON":"OFF"}`; tr.cells[5].innerHTML = `${lp&2?"ON":"OFF"}`; tr.cells[6].innerHTML = `${lp&1?"ON":"OFF"}`;
|
||||||
|
tr.cells[7].innerHTML = `${p.active}`;
|
||||||
|
tr.classList.toggle('disabled', pState[i-2] < 0); tr.classList.toggle('isNOK', !p.active); tr.classList.toggle('isOK', p.active);
|
||||||
|
}
|
||||||
|
tr.classList.toggle('isSFP', p.isSFP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhttp.open("GET", "/eee.json", true);
|
||||||
|
xhttp.send();
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener("load", function() {
|
||||||
|
const iCount = setInterval(getEEE, 1000);
|
||||||
|
});
|
||||||
|
const stat = setInterval(createEEE, 500);
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
async function eeeSub(port, enable) {
|
||||||
|
var cmd = "eee ";
|
||||||
|
if (enable)
|
||||||
|
cmd = cmd + "on";
|
||||||
|
else
|
||||||
|
cmd = cmd + "off";
|
||||||
|
console.log("eeeSub port " + port, ", value " + enable);
|
||||||
|
try {
|
||||||
|
const response = await fetch('/cmd', {
|
||||||
|
method: 'POST',
|
||||||
|
body: cmd
|
||||||
|
});
|
||||||
|
console.log('Completed!', response);
|
||||||
|
} catch(err) {
|
||||||
|
console.error(`Error: ${err}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user