Moving lldp cmd parsing to be above the is_sfp check to take precedence

Needed to increase buffer size for this to send app.js

The logical port status is what is returned in the array, for
non-sequential systems we need to map through physToLog rather
than just subtracting 1

physToLog is 1 based! not 0; also fixing up typecasts

Reimplementing using an array of objects to represent ports.
The previous approach of a bitmask of logical ports, was just too
simple on devices such as the SWGT024_V2_0_MANAGED which has
gaps in the port assignments.
This commit is contained in:
Rob Emery committed 2026-10-10 09:51:33 +01:00
1 parent 9b2bd7f1b8
commit dda873a633
5 files changed
+53 -35

No files matched your search

+8 -18
View File
@@ -1843,36 +1843,26 @@ function lldpLoad(){
return getJSON("/lldp.json").then(function(s){
$("lldp_en").checked=s.on;
var tb=$("lldp_table").tBodies[0];tb.innerHTML="";
if(tb.rows.length!==S.n){
tb.innerHTML="";
for(var i=0;i<S.n;i++)(function(i){
var tr=tb.insertRow();
tr.insertCell();
tr.insertCell();
tr.insertCell();
})(i);
}
S.ports.forEach(function(p){
var r=tb.rows[p.portNum-1];
if(!r)return;
r.cells[0].textContent=p.portNum+(p.isSFP?" (SFP)":"");
r.cells[1].textContent=p.name||"";
byPort(s.portStatus).forEach(function(p){
var tr=tb.insertRow();
tr.insertCell().textContent=p.portNum;
tr.insertCell().textContent=p.name;
var sw=h("label",{class:"switch"},[
h("input",{type:"checkbox",onchange:function(){
postCmd("port "+p.portNum+" lldp "+(this.checked?"permit":"block"))
.then(function(){setTimeout(lldpLoad,300)}).catch(function(){});
}}),h("i")]);
sw.firstChild.checked=s.port_status[p.portNum-1];
r.cells[2].appendChild(sw);
sw.firstChild.checked=p.enabled;
tr.insertCell().appendChild(sw);
});
}).catch(function(e){console.log("ERROR!"); console.log(e)});
});
}
$("lldp_en").addEventListener("change",function(){
var el=this;
postCmd("lldp "+(el.checked?"on":"off")).catch(function(){el.checked=!el.checked});
});
tabHooks.lldp={enter:needPorts(lldpLoad)};
tabHooks.lldp={enter:lldpLoad};
function eeeFlags(bits){
var b=parseInt(bits,2);