diff --git a/html/main.js b/html/main.js index 6e8bceb..9c48581 100644 --- a/html/main.js +++ b/html/main.js @@ -100,7 +100,6 @@ function update() { } } else { pAdvertised[n] = parseInt(p.adv, 2); - console.log("Advertised " + n + " entry " + p.adv + " is now " + pAdvertised[n]); } iHTML += ""; tt.innerHTML = iHTML; diff --git a/html/ports.html b/html/ports.html index 6b15e50..84fe41e 100644 --- a/html/ports.html +++ b/html/ports.html @@ -11,7 +11,10 @@

Port Configuration

- + +
Port Current Link SpeedSelected Speed Set SpeedSet DuplexApply
Port Current Link SpeedSet SpeedDisabledApply
+

Configure Maximum Frame Size (MTU) forwarded at Port

+
diff --git a/html/ports.js b/html/ports.js index 2c6ebf2..3548bac 100644 --- a/html/ports.js +++ b/html/ports.js @@ -1,20 +1,19 @@ var mtus = new Int16Array(10); +var clicked = new Int8Array(10); function createPortTable() { var tbl = document.getElementById('speedtable'); if (tbl.rows.length <= 2 && numPorts) { clearInterval(pTableInterval); const sSelect = ''; - const dSelect = ''; + const dSwitch = '' for (let i = 1; i <= numPorts; i++) { if (pIsSFP[i-1]) continue; @@ -22,9 +21,9 @@ function createPortTable() { const tr = tbl.insertRow(); let td = tr.insertCell(); td.appendChild(document.createTextNode(`Port ${i}`)); td = tr.insertCell(); td.innerHTML = linkS[pState[i] + 1]; - td = tr.insertCell(); td.innerHTML = "Unknown"; td = tr.insertCell(); td.innerHTML = sSelect.replaceAll("speed_sel", "speed_sel_" + i); - td = tr.insertCell(); td.innerHTML = dSelect.replaceAll("duplex_sel", "duplex_sel_" + i); + td = tr.insertCell(); td.innerHTML = dSwitch.replaceAll("disable_port", "disable_port_" + i) + .replace("portOnOff()", "portOnOff(" + i + ")"); var button = ''; td = tr.insertCell(); td.innerHTML = button; @@ -69,57 +68,39 @@ function updatePortTable() { if (pIsSFP[i-1]) continue; tbl.rows[i].cells[1].innerHTML = `${linkS[pState[i-1]+1]}`; - var td = tbl.rows[i].cells[2]; - var adv = pAdvertised[i-1]; - switch(pAdvertised[i-1]) { - case 0x20: - td.innerHTML = "2.5GBit Full Duplex"; break; - case 0x10: - td.innerHTML = "1000MBit Full Duplex"; break; - case 0x2f: - td.innerHTML = "AUTO"; break; - case 0xc: - td.innerHTML = "100MBit"; break; - case 8: - td.innerHTML = "100MBit Full Duplex"; break; - case 4: - td.innerHTML = "100MBit Half Duplex"; break; - case 3: - td.innerHTML = "10MBit"; break; - case 2: - td.innerHTML = "10MBit Full Duplex"; break; - case 1: - td.innerHTML = "10MBit Half Duplex"; break; - default: - td.innerHTML = "None"; break; - } + if (!clicked[i] && pState[i - 1] < 0) { + document.getElementById('speed_sel_' + i).disabled = true; + document.getElementById('disable_port_' + i).checked = true; + } } } async function applySpeed(port) { var speed = document.getElementById('speed_sel_' + port).value; - var duplex = document.getElementById('duplex_sel_' + port).value; - var cmd = "port " + port + " " + speed; - console.log("port " + port, ", speed: " + speed, ", duplex: ", duplex); + var disabled = document.getElementById('disable_port_' + port).checked; + var cmd = "port " + port + " "; + if (!disabled) + cmd = cmd + speed; + else + cmd = cmd + "off"; + console.log("CMD: " + cmd); try { const response = await fetch('/cmd', { method: 'POST', body: cmd }); console.log('Completed!', response); - if (duplex != "any") { - cmd = "port " + port + " duplex " + duplex; - const response = await fetch('/cmd', { - method: 'POST', - body: cmd - }); - console.log('Completed!', response); - } } catch(err) { console.error(`Error: ${err}`); } } +async function portOnOff(p) { + var disabled = document.getElementById('disable_port_' + p).checked; + document.getElementById('speed_sel_' + p).disabled = disabled; + clicked[p] = 1; +} + async function applyMTU(port) { var mtu = document.getElementById('mtu_sel_' + port).value; var cmd = "mtu " + port + " " + mtu;