From f0e99530811c5e3508054caebfb6291995fdcd5b Mon Sep 17 00:00:00 2001 From: bloqaudio Date: Thu, 3 Sep 2026 14:33:07 -0500 Subject: [PATCH] web: hide the L2 delete button for the CPU entry and drop a deleted row The firmware now refuses to delete the switch's own entry, so the button on the CPU row can only fail; leave it out. When a delete succeeds, remove the entry from the cached table and repaint instead of leaving the stale row until the next refresh. --- html/l2.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/html/l2.js b/html/l2.js index 2011c655..3d41d89a 100644 --- a/html/l2.js +++ b/html/l2.js @@ -52,8 +52,10 @@ function delL2(idx) { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { - var s = JSON.parse(xhttp.responseText); - console.log("Entry deletion result: ", s.result); + if (JSON.parse(xhttp.responseText).result == 1) { + l2All = l2All.filter(function(e) { return e.idx != idx; }); + renderL2(); + } } }; xhttp.open("GET", "/l2_del.json?idx=" + idx, true); @@ -116,6 +118,13 @@ function fillL2(s) renderL2(); } +function delL2Button(e) +{ + if (e.port == 'CPU') + return ''; + return ''; +} + function paintL2(tbl, s) { console.log("L2: ", JSON.stringify(s)); @@ -127,14 +136,14 @@ function paintL2(tbl, s) tbl.rows[i+1].cells[1].innerHTML = `${e.mac}`; tbl.rows[i+1].cells[2].innerHTML = `${e.vlan}`; tbl.rows[i+1].cells[3].innerHTML = `${e.type}`; - tbl.rows[i+1].cells[4].innerHTML = ''; + tbl.rows[i+1].cells[4].innerHTML = delL2Button(e); } else { const tr = tbl.insertRow(); let td = tr.insertCell(); td.innerHTML = `${e.port}`; td = tr.insertCell(); td.innerHTML = `${e.mac}`; td = tr.insertCell(); td.innerHTML = `${e.vlan}`; td = tr.insertCell(); td.innerHTML = `${e.type}`; - td = tr.insertCell(); td.innerHTML = ''; + td = tr.insertCell(); td.innerHTML = delL2Button(e); } } for (let i = tbl.rows.length - 1; i > s.length; i--)