mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
ports: show the SFP port in the table, and read the right link state
The port table skipped every SFP port outright, so on a SWTGW218AS the uplink simply was not there. Of the seven columns only Set Speed is meaningless for a module: the name, the link speed and the devices behind the port all are worth showing, and the name in particular was accepted on another page and then never displayed anywhere. The MTU table further down the same page has always drawn the port, so the page disagreed with itself. Give an SFP port its row and leave the three control cells empty. Whether speed and disable should work for a module is a separate question and untested, so this does not offer a button for it. The link state was read one port too far. main.js fills pState by portNum - 1, updatePortTable() reads pState[i-1], and createPortTable() read pState[i], so every row started out showing the next port's link speed until the first refresh corrected it. On the last copper port that meant showing the uplink's speed. Feeding the real status.json of a nine port switch through both versions: expected 7 7 7 1 7 1 7 7 6 before 7 7 1 7 1 7 7 6 after 7 7 7 1 7 1 7 7 6 Dropping the skip also removes a trap rather than papering over it. updatePortTable() addresses rows as tbl.rows[i], which only lined up with port i because the SFP port happens to be last on this board. With a module in the middle every row after it would have been off by one.
This commit is contained in:
1 parent
8a7b146892
commit
38b8e38c04
1 file changed
+6
-7
+6
-7
@@ -14,15 +14,16 @@ function createPortTable() {
|
||||
+ '</select>';
|
||||
const dSwitch = '<input type="checkbox" id="disable_port" onchange="portOnOff();">'
|
||||
for (let i = 1; i <= numPorts; i++) {
|
||||
if (pIsSFP[i-1])
|
||||
continue;
|
||||
console.log("Table row: " + i + "pState: " + pState[i-2]);
|
||||
const tr = tbl.insertRow();
|
||||
let td = tr.insertCell(); td.appendChild(document.createTextNode(t('common_port') + i));
|
||||
let portName = portNames[physToLogPort[i-1]] || '';
|
||||
td = tr.insertCell(); td.appendChild(document.createTextNode(portName));
|
||||
td = tr.insertCell(); td.innerHTML = linkText(pState[i] + 1);
|
||||
td = tr.insertCell(); td.innerHTML = linkText(pState[i-1] + 1);
|
||||
tr.insertCell(); // filled by devRender()
|
||||
if (pIsSFP[i-1]) {
|
||||
tr.insertCell(); tr.insertCell(); tr.insertCell();
|
||||
continue;
|
||||
}
|
||||
td = tr.insertCell(); td.innerHTML = sSelect.replaceAll("speed_sel", "speed_sel_" + i);
|
||||
td = tr.insertCell(); td.innerHTML = dSwitch.replaceAll("disable_port", "disable_port_" + i)
|
||||
.replace("portOnOff()", "portOnOff(" + i + ")");
|
||||
@@ -67,9 +68,9 @@ function updatePortTable() {
|
||||
if (tbl.rows.length <= 2 || !numPorts)
|
||||
return;
|
||||
for (let i = 1; i <= numPorts ; i++) {
|
||||
tbl.rows[i].cells[2].innerHTML = linkText(pState[i-1]+1);
|
||||
if (pIsSFP[i-1])
|
||||
continue;
|
||||
tbl.rows[i].cells[2].innerHTML = linkText(pState[i-1]+1);
|
||||
if (!clicked[i] && pState[i - 1] < 0) {
|
||||
document.getElementById('speed_sel_' + i).disabled = true;
|
||||
document.getElementById('disable_port_' + i).checked = true;
|
||||
@@ -133,8 +134,6 @@ function devRender(entries) {
|
||||
perPort[e.port].push(e.mac);
|
||||
}
|
||||
for (let i = 1; i <= numPorts; i++) {
|
||||
if (pIsSFP[i-1])
|
||||
continue;
|
||||
var cell = tbl.rows[i].cells[3];
|
||||
var macs = perPort[i] || [];
|
||||
if (macs.length == 1) {
|
||||
|
||||
Reference in new issue
Block a user