Device page: hovering a drawn NIC highlights its interface row, and back
Lint / JS (eslint) (push) Successful in 16s
Lint / Python (flake8) (push) Successful in 1m38s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Test / Python Tests (pytest) (push) Successful in 1m40s
Lint / JS (eslint) (pull_request) Successful in 28s
Lint / Python (flake8) (pull_request) Successful in 1m21s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (push) Successful in 1m43s
Security / Python Security (bandit) (pull_request) Successful in 1m37s
Test / Python Tests (pytest) (pull_request) Successful in 1m38s

The ZimaBoard drawing's RJ45 jacks and the ConnectX-3 SFP+ cage are now
ports tied to their interface: hover or focus one to ring it and highlight
its table row (and the other way round); click or Enter opens that row.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-25 14:06:14 -05:00
1 parent f636d29c9f
commit 0fa9229c06
4 files changed
+96 -8

No files matched your search

+69 -2
View File
@@ -11,6 +11,7 @@ const _openRows = new Set(); // survives auto-refresh
let _filter = 'all';
let _query = '';
let _device = null;
let _hotIface = null; // the interface hovered in the drawing or the table
// ── Formatting ───────────────────────────────────────────────────────
function fmtSpeed(mbps) {
@@ -190,7 +191,7 @@ function renderTable(rows) {
? (r.neighbor.name ? `<a class="device-link" href="${esc(deviceUrl(r.neighbor.name))}">${esc(r.neighbor.name)}</a>` : esc(r.neighbor.chassis || r.neighbor.port || ''))
: '-';
return `
<tr class="device-row${r.unused ? ' device-row--unused' : (r.up ? '' : ' device-row--down')}"${isPorts ? ` data-port-idx="${esc(r.num)}"` : ''}>
<tr class="device-row${r.unused ? ' device-row--unused' : (r.up ? '' : ' device-row--down')}${!isPorts && r.id === _hotIface ? ' is-linked' : ''}"${isPorts ? ` data-port-idx="${esc(r.num)}"` : ` data-iface="${esc(r.id)}"`}>
<td><button type="button" class="device-row-toggle" data-row="${esc(r.id)}"${isPorts ? '' : ` aria-expanded="${open}"`} aria-label="Details for ${esc(r.label)}">${open ? '▾' : '▸'}</button></td>
<td><span class="dot-${r.unused ? 'unused' : (r.up ? 'up' : 'down')}"></span></td>
<td class="device-row-name">${r.num !== undefined ? `<span class="port-badge port-badge-num">#${esc(r.num)}</span> ` : ''}${esc(r.label)}<div class="device-row-sub">${esc(r.sub)}</div></td>
@@ -401,6 +402,59 @@ function hardwareHtml(d, art) {
</div>`;
}
// ── Drawing <-> table: a NIC drawn in the picture and its row light up together ──
function setHotIface(name) {
if (name === _hotIface) return;
_hotIface = name;
document.querySelectorAll('#device-chassis .hw-port').forEach(el => el.classList.toggle('is-hot', el.dataset.iface === name));
document.querySelectorAll('tr.device-row[data-iface]').forEach(el => el.classList.toggle('is-linked', el.dataset.iface === name));
}
// Clicking a drawn port opens its row and brings it into view
function openIfaceRow(name) {
const row = () => [...document.querySelectorAll('tr.device-row[data-iface]')].find(el => el.dataset.iface === name);
if (!row()) {
lt.toast.info(`${name} is not in the interface list`);
return;
}
if (_filter !== 'all' || _query) {
// A filter that hides the row would make the click look like it did nothing
_filter = 'all';
_query = '';
document.getElementById('device-table-search').value = '';
document.querySelectorAll('[data-device-filter]').forEach(p => {
const on = p.dataset.deviceFilter === 'all';
p.classList.toggle('active', on);
p.setAttribute('aria-pressed', String(on));
});
}
_openRows.add(name);
renderInterfaces();
const el = row();
if (el) {
el.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
el.querySelector('.device-row-toggle').focus({ preventScroll: true });
}
}
function hotFrom(e) {
const port = e.target.closest('#device-chassis .hw-port');
if (port) return port.dataset.iface;
const row = e.target.closest('tr.device-row[data-iface], tr.device-row-detail');
if (!row) return null;
return row.dataset.iface || (row.previousElementSibling && row.previousElementSibling.dataset.iface) || null;
}
document.addEventListener('mouseover', e => setHotIface(hotFrom(e)));
document.addEventListener('focusin', e => setHotIface(hotFrom(e)));
document.addEventListener('keydown', e => {
const port = e.target.closest && e.target.closest('#device-chassis .hw-port');
if (port && (e.key === 'Enter' || e.key === ' ')) {
e.preventDefault();
openIfaceRow(port.dataset.iface);
}
});
// ── Inventory (HomeBox) link ────────────────────────────────────────────
function inventoryActions(d) {
const inv = d.inventory || {};
@@ -489,7 +543,15 @@ function render(d) {
document.getElementById('device-inspector').classList.toggle('has-chassis', hasChassis);
updateInterfaceSection(currentRows(), d.ports ? 'Ports' : 'Interfaces', hasChassis);
if (hasFaceplate) renderPortInspector(d);
else if (art) document.getElementById('device-chassis').innerHTML = hardwareHtml(d, art);
else if (art) {
document.getElementById('device-chassis').innerHTML = hardwareHtml(d, art);
document.querySelectorAll('#device-chassis .hw-port').forEach(el => {
el.setAttribute('tabindex', '0');
el.setAttribute('role', 'button');
el.setAttribute('aria-label', `${el.querySelector('title').textContent}: show in the interface list`);
el.classList.toggle('is-hot', el.dataset.iface === _hotIface);
});
}
// A drawing has no ports to open, so the port panel takes no room beside it
document.getElementById('inspector-panel').style.display = hasFaceplate ? '' : 'none';
renderInterfaces();
@@ -516,6 +578,11 @@ async function loadDevice() {
}
document.addEventListener('click', e => {
const drawn = e.target.closest('#device-chassis .hw-port');
if (drawn) {
openIfaceRow(drawn.dataset.iface);
return;
}
// Switch and router rows open the shared port panel, except when following a link
const portRow = e.target.closest('tr.device-row[data-port-idx]');
if (portRow && !e.target.closest('a')) {