Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
.dv-port.bg-success .dv-port-rect { fill: #198754; }
.dv-port.bg-secondary .dv-port-rect { fill: #6c757d; }
.dv-port.bg-danger .dv-port-rect { fill: #dc3545; }
/* Partial connection: cable attached but far-end has no device */
.dv-port.bg-warning .dv-port-rect { fill: #ffc107; }

/* Cable colour override — applied inline via JS (style attribute on .dv-port) */
/* No rule needed; the JS sets fill on .dv-port-rect directly */
Expand All @@ -85,6 +87,15 @@
fill: url(#dv-nocolor-pattern);
}

/* Partial connection dot overlay — small warning circle in the top-right corner.
Always rendered on top of the port rect, visible even in cable colour mode. */
.dv-partial-dot {
fill: #ffc107;
stroke: #333;
stroke-width: 0.5;
pointer-events: none;
}

/* ── Structural elements ───────────────────────────────────────────────────── */

.dv-spacer {
Expand Down
14 changes: 14 additions & 0 deletions netbox_device_view/templates/netbox_device_view/deviceview.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
name: "{{ int.name|escapejs }}",
enabled: {% if int.enabled or int.is_port %}true{% else %}false{% endif %},
connected: {% if int.connected_endpoints|length > 0 or int.is_port and int.link_peers|length > 0 %}true{% else %}false{% endif %},
partiallyConnected: {% if int.link_peers|length > 0 and int.connected_endpoints|length == 0 %}true{% else %}false{% endif %},
cableColor: "{% if cable_colors == 'on' and int.cable.color != '' %}{{ int.cable.color }}{% endif %}",
cableNoColor: {% if cable_colors == "on" and int.cable.color == "" or cable_colors == "on" and int.cable == None %}true{% else %}false{% endif %},
connectedEndpoints: [{% for ce in int.connected_endpoints %}"{{ ce.device }} | {{ ce.name }}"{% if not forloop.last %},{% endif %}{% endfor %}],
Expand All @@ -139,12 +140,25 @@
if (rect) rect.setAttribute("fill", "#" + p.cableColor);
} else if (p.connected) {
g.classList.add("bg-success");
} else if (p.partiallyConnected) {
g.classList.add("bg-warning");
} else if (p.enabled) {
g.classList.add("bg-secondary");
} else {
g.classList.add("bg-danger");
}

// Always show a small warning dot for partially connected ports,
// even when cable color mode overrides the fill colour.
if (p.partiallyConnected && rect) {
var dot = document.createElementNS("http://www.w3.org/2000/svg", "circle");
dot.setAttribute("class", "dv-partial-dot");
dot.setAttribute("cx", parseFloat(rect.getAttribute("x")) + parseFloat(rect.getAttribute("width")) - 3);
dot.setAttribute("cy", parseFloat(rect.getAttribute("y")) + 3);
dot.setAttribute("r", "2.5");
g.appendChild(dot);
}

g.setAttribute("role", "link");
g.style.cursor = "pointer";
g.addEventListener("click", function () { window.location.href = p.url; });
Expand Down
15 changes: 15 additions & 0 deletions netbox_device_view/templates/netbox_device_view/ports.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ <h2 class="card-header">Deviceview {{ object.name }}</h2>
name: "{{ int.name|escapejs }}",
enabled: {% if int.enabled or int.is_port %}true{% else %}false{% endif %},
connected: {% if int.connected_endpoints|length > 0 or int.is_port and int.link_peers|length > 0 %}true{% else %}false{% endif %},
partiallyConnected: {% if int.link_peers|length > 0 and int.connected_endpoints|length == 0 %}true{% else %}false{% endif %},
cableColor: "{% if cable_colors == 'on' and int.cable.color != '' %}{{ int.cable.color }}{% endif %}",
cableNoColor: {% if cable_colors == "on" and int.cable.color == "" or cable_colors == "on" and int.cable == None %}true{% else %}false{% endif %},
connectedEndpoints: [{% for ce in int.connected_endpoints %}"{{ ce.device }} | {{ ce.name }}"{% if not forloop.last %},{% endif %}{% endfor %}],
Expand All @@ -135,11 +136,25 @@ <h2 class="card-header">Deviceview {{ object.name }}</h2>
if (rect) rect.setAttribute("fill", "#" + p.cableColor);
} else if (p.connected) {
g.classList.add("bg-success");
} else if (p.partiallyConnected) {
g.classList.add("bg-warning");
} else if (p.enabled) {
g.classList.add("bg-secondary");
} else {
g.classList.add("bg-danger");
}

// Always show a small warning dot for partially connected ports,
// even when cable color mode overrides the fill colour.
if (p.partiallyConnected && rect) {
var dot = document.createElementNS("http://www.w3.org/2000/svg", "circle");
dot.setAttribute("class", "dv-partial-dot");
dot.setAttribute("cx", parseFloat(rect.getAttribute("x")) + parseFloat(rect.getAttribute("width")) - 3);
dot.setAttribute("cy", parseFloat(rect.getAttribute("y")) + 3);
dot.setAttribute("r", "2.5");
g.appendChild(dot);
}

g.setAttribute("role", "link");
g.style.cursor = "pointer";
g.addEventListener("click", function () { window.location.href = p.url; });
Expand Down
Loading