Device page: hovering a drawn NIC highlights its interface row, and back #64
No files matched your search
@@ -278,7 +278,9 @@ interface and port names, and LLDP neighbors.
|
||||
- **Hardware drawing** (hosts, modem, AP): a server shows the same front the rack page draws, from its
|
||||
cutsheet item's *Front drawing* (a ZimaBoard's NIC lights follow its interfaces), with where it sits
|
||||
("U5-U8, full depth", "Rear shelf (U22-U23), slot 1") linking to the rack page; Overview lists the
|
||||
location too. A host with no cutsheet item, or one with no Front drawing, shows no picture. The
|
||||
location too. On drawings that show NICs (the ZimaBoards' RJ45 jacks and ConnectX-3 SFP+ cage),
|
||||
hovering a port highlights its interface row and hovering a row rings its port; clicking a port
|
||||
(or Enter on it) opens that row. A host with no cutsheet item, or one with no Front drawing, shows no picture. The
|
||||
modem and AP use the drawings from the topology page.
|
||||
- **Interfaces / Ports**: one row each with state, speed, RX/TX rate, and neighbor, filterable.
|
||||
Expanding a host's row shows duplex, auto-negotiation, carrier changes, error and drop rates,
|
||||
|
||||
+69
-2
@@ -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')) {
|
||||
|
||||
+18
-5
@@ -265,6 +265,16 @@ function zimaRj45(x, y, link) {
|
||||
<rect class="zb-led" x="${x + 161}" y="${y + 9}" width="30" height="15" rx="2" style="fill:${link ? '#f2d13a' : '#77714a'}"/>`;
|
||||
}
|
||||
|
||||
// A NIC's socket as one hoverable part: the device page ties it to that interface's table row.
|
||||
// box is [x, y, w, h] for the highlight ring drawn around it.
|
||||
function nicPort(ctx, name, box, inner) {
|
||||
const n = (ctx.interfaces || []).find(i => i.name === name);
|
||||
const state = n ? (n.unused ? 'marked unused' : (n.up ? 'link up' : 'no link')) : 'not reported';
|
||||
const [x, y, w, h] = box;
|
||||
return `<g class="hw-port" data-iface="${lt.escHtml(name)}"><title>${lt.escHtml(`${name} · ${state}`)}</title>
|
||||
${inner}<rect class="hw-port-ring" x="${x - 8}" y="${y - 8}" width="${w + 16}" height="${h + 16}" rx="10"/></g>`;
|
||||
}
|
||||
|
||||
function zimaUsb(x, y) {
|
||||
return `<rect class="zb-shield" x="${x}" y="${y}" width="204" height="100" rx="5"/>
|
||||
<rect class="zb-hole" x="${x + 26}" y="${y + 20}" width="152" height="62" rx="2"/>
|
||||
@@ -298,7 +308,8 @@ function zimaFront(ctx) {
|
||||
<rect class="zb-shield" x="63" y="225" width="127" height="80" rx="6"/>
|
||||
<path class="zb-hole" d="M75 243 H178 V280 L163 293 H90 L75 280 Z"/>
|
||||
<rect class="zb-dp-pins" x="92" y="262" width="69" height="9" rx="1"/>
|
||||
${zimaRj45(213, 47, link(0))}${zimaRj45(443, 47, link(1))}
|
||||
${nicPort(ctx, ZIMA_NICS.rj45[0], [213, 47, 207, 143], zimaRj45(213, 47, link(0)))}
|
||||
${nicPort(ctx, ZIMA_NICS.rj45[1], [443, 47, 207, 143], zimaRj45(443, 47, link(1)))}
|
||||
${zimaUsb(216, 205)}${zimaUsb(443, 205)}
|
||||
<rect class="zb-dc" x="678" y="177" width="132" height="130" rx="8"/>
|
||||
<rect class="zb-dc-face" x="690" y="189" width="108" height="106" rx="6"/>
|
||||
@@ -314,7 +325,7 @@ function zimaFront(ctx) {
|
||||
// The round dot on the cage is Gandalf's link mark (like the cutsheet marks), not an LED on the card.
|
||||
const CX3_PX = 572;
|
||||
|
||||
function cx3Card(up) {
|
||||
function cx3Card(up, port) {
|
||||
return `
|
||||
<rect class="cx-part" x="40" y="314" width="70" height="22" rx="2"/>
|
||||
<rect class="cx-part" x="150" y="314" width="40" height="16" rx="2"/>
|
||||
@@ -323,17 +334,19 @@ function cx3Card(up) {
|
||||
<rect class="cx-pcb-edge" x="0" y="296" width="${CX3_PX}" height="4"/>
|
||||
<rect class="cx-heatsink" x="110" y="232" width="210" height="64" rx="3"/>
|
||||
${Array.from({ length: 9 }, (_, i) => `<rect class="cx-fin" x="${120 + i * 22}" y="232" width="9" height="64"/>`).join('')}
|
||||
<rect class="cx-cage" x="380" y="190" width="150" height="106" rx="4"/>
|
||||
${port(`<rect class="cx-cage" x="380" y="190" width="150" height="106" rx="4"/>
|
||||
<rect class="cx-cage-lip" x="380" y="190" width="150" height="10" rx="3"/>
|
||||
<rect class="cx-plug" x="392" y="206" width="126" height="80" rx="5"/>
|
||||
<rect class="cx-boot" x="410" y="220" width="90" height="52" rx="10"/>
|
||||
<circle class="cx-cable" cx="455" cy="246" r="20"/>
|
||||
<path class="cx-tab" d="M441 286 V392 Q441 404 455 404 Q469 404 469 392 V286"/>
|
||||
<circle class="cx-link" cx="520" cy="200" r="13" style="fill:${up ? '#3ad16b' : '#e0312b'}"><title>Gandalf: SFP+ link ${up ? 'up' : 'down'}</title></circle>`;
|
||||
<circle class="cx-link" cx="520" cy="200" r="13" style="fill:${up ? '#3ad16b' : '#e0312b'}"/>`)}`;
|
||||
}
|
||||
|
||||
function zimaCx3Front(ctx) {
|
||||
return `${cx3Card(zimaNic(ctx, (ctx.interfaces || []).map(i => i.name).find(n => ZIMA_NICS.slot.test(n)) || 'enp1s0'))}
|
||||
const name = (ctx.interfaces || []).map(i => i.name).find(n => ZIMA_NICS.slot.test(n)) || 'enp1s0';
|
||||
const port = inner => nicPort(ctx, name, [380, 190, 150, 214], inner);
|
||||
return `${cx3Card(zimaNic(ctx, name), port)}
|
||||
<g transform="translate(${CX3_PX} 0)">${zimaFront(ctx)}</g>`;
|
||||
}
|
||||
|
||||
|
||||
@@ -947,6 +947,12 @@ tr.device-row.is-selected { background: var(--bg-tertiary); box-shadow: inset 3p
|
||||
.hw-art { margin: 0 auto; padding: 16px; box-sizing: content-box; }
|
||||
.hw-box { width: 100%; }
|
||||
.hw-box svg { display: block; width: 100%; height: 100%; }
|
||||
/* A NIC in a drawing: its ring lights with the matching table row (device.js setHotIface) */
|
||||
.hw-port-ring { fill: none; stroke: transparent; stroke-width: 6; pointer-events: none; }
|
||||
.device-chassis .hw-port { cursor: pointer; outline: none; }
|
||||
.device-chassis .hw-port.is-hot .hw-port-ring { stroke: var(--terminal-cyan, #0ff); filter: drop-shadow(0 0 6px var(--terminal-cyan, #0ff)); }
|
||||
.device-chassis .hw-port:focus-visible .hw-port-ring { stroke: var(--amber); }
|
||||
tr.device-row.is-linked { background: var(--bg-tertiary); box-shadow: inset 3px 0 0 var(--terminal-cyan, #0ff); }
|
||||
.hw-specs { margin: 0; padding: 0 16px 12px; font-size: .72em; color: var(--text-muted); text-align: center; }
|
||||
.chassis-meta .device-link { font-size: inherit; }
|
||||
|
||||
|
||||
Reference in new issue
Block a user