feat: Aruba-style switch front panel on the device page

Switches show a Ports panel above the Device and Management cards: a dark
faceplate with every physical port as RJ45/SFP jack (odd on top, even
below, per stack member), a status view (link, free, disabled) and a VLAN
view with the label colours of the PDF, contrast-aware text, legend,
tooltips with peer and description, key figures and a link to the PDF
export. Texts follow the user's NetBox language. The panel is rendered
into the left column and moved to the top by a small script.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
MrBlakeandClaude Opus 5.5 committed 2026-10-30 10:03:07 +01:00
1 parent 7289c21684
commit b1ecbbbb75
10 files changed
+369 -5

No files matched your search

+24
View File
@@ -45,12 +45,36 @@ def collect_ports(interfaces):
description=interface.description,
peer=peer,
lag=interface.lag.name if interface.lag_id else "",
url=interface.get_absolute_url(),
virtual=interface.type in switch_ports.VIRTUAL_TYPES,
)
)
return ports
def switch_panel_context(request, device):
"""Front panel above the "Device" and "Management" cards, in the user's NetBox language."""
interfaces = (
Interface.objects.restrict(request.user, "view")
.filter(device=device)
.select_related("lag", "cable", "_path")
.order_by("_name")
)
ports = collect_ports(interfaces)
switch_ports.assign_vlan_colors(ports)
texts = switch_ports.PANEL_TEXTS[switch_port_pdf.language(translation.get_language())]
for port in ports:
if port.peer == switch_ports.MARKED_CONNECTED:
port.peer = texts["marked"]
port.state_text = texts[port.state]
return {
"groups": switch_ports.build_groups(ports),
"summary": switch_ports.summary(ports),
"legend": switch_ports.vlan_legend(ports),
"texts": texts,
}
def device_info(device):
rack = ""
if device.rack_id: