Skip to content

Commit 97e4e9f

Browse files
committed
Fix partial-connection indicator leaking across stack members
applyPortStatus() used a global querySelectorAll which matched the same stylename (e.g. gigabitethernet0-35) in every chassis panel simultaneously. For a virtual chassis, GigabitEthernet1/0/35 and GigabitEthernet2/0/35 both derive the same stylename, so a partially-connected port on one member incorrectly highlighted the same port position on all other members. Fix: add a device field to each portData entry (the ports_chassis key) and scope querySelectorAll to the matching #dv-svg-wrapper-{device} div, falling back to a global search only when the wrapper is not found.
1 parent 5d1f39e commit 97e4e9f

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

netbox_device_view/templates/netbox_device_view/deviceview.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
{% for device, interfaces in ports_chassis.items %}
114114
{% for int in interfaces %}
115115
{
116+
device: "{{ device }}",
116117
stylename: "{{ int.stylename }}",
117118
url: "{{ int.get_absolute_url }}trace/",
118119
name: "{{ int.name|escapejs }}",
@@ -130,7 +131,10 @@
130131

131132
function applyPortStatus() {
132133
portData.forEach(function (p) {
133-
var groups = document.querySelectorAll(".dv-port." + CSS.escape(p.stylename));
134+
var wrapper = document.getElementById("dv-svg-wrapper-" + p.device);
135+
var groups = wrapper
136+
? wrapper.querySelectorAll(".dv-port." + CSS.escape(p.stylename))
137+
: document.querySelectorAll(".dv-port." + CSS.escape(p.stylename));
134138
groups.forEach(function (g) {
135139
var rect = g.querySelector(".dv-port-rect");
136140

netbox_device_view/templates/netbox_device_view/ports.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ <h2 class="card-header">Deviceview {{ object.name }}</h2>
110110
{% for switch, interfaces in ports_chassis.items %}
111111
{% for int in interfaces %}
112112
{
113+
device: "{{ switch }}",
113114
stylename: "{{ int.stylename }}",
114115
url: "{{ int.get_absolute_url }}trace/",
115116
name: "{{ int.name|escapejs }}",
@@ -127,7 +128,10 @@ <h2 class="card-header">Deviceview {{ object.name }}</h2>
127128

128129
function applyPortStatus() {
129130
portData.forEach(function (p) {
130-
var groups = document.querySelectorAll(".dv-port." + CSS.escape(p.stylename));
131+
var wrapper = document.getElementById("dv-svg-wrapper-" + p.device);
132+
var groups = wrapper
133+
? wrapper.querySelectorAll(".dv-port." + CSS.escape(p.stylename))
134+
: document.querySelectorAll(".dv-port." + CSS.escape(p.stylename));
131135
groups.forEach(function (g) {
132136
var rect = g.querySelector(".dv-port-rect");
133137
if (p.cableNoColor) {

0 commit comments

Comments
 (0)