Skip to content

Commit 5c1a5d8

Browse files
committed
feat: click navigates to port detail; tooltip adds Trace link
Both the CSS grid and SVG rendering paths now navigate to the port detail page on click. A 'Trace' link is added to the hover tooltip so the trace view remains one click away.
1 parent a0a81c2 commit 5c1a5d8

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

netbox_device_view/templates/netbox_device_view/deviceview.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
>
5656
{% for int in interfaces %}
5757
<a
58-
href="{{int.get_absolute_url}}trace/"
58+
href="{{int.get_absolute_url}}"
5959
class="device-view-port
6060
{% if cable_colors == "on" and int.cable.color == "" or cable_colors == "on" and int.cable == None %}
6161
nocolor
@@ -81,6 +81,7 @@
8181
{% endif %}
8282
{% endfor %}
8383
{% endif %}
84+
<hr><a href='{{int.get_absolute_url}}trace/'>Trace</a>
8485
"
8586
style="grid-area: {{ int.stylename }}{% if cable_colors == 'on' and int.cable.color != '' %}; background-color: #{{ int.cable.color }}{% endif %}"
8687
data-bs-toggle="tooltip"
@@ -115,7 +116,8 @@
115116
{
116117
device: "{{ device }}",
117118
stylename: "{{ int.stylename }}",
118-
url: "{{ int.get_absolute_url }}trace/",
119+
detailUrl: "{{ int.get_absolute_url }}",
120+
traceUrl: "{{ int.get_absolute_url }}trace/",
119121
name: "{{ int.name|escapejs }}",
120122
enabled: {% if int.enabled or int.is_port %}true{% else %}false{% endif %},
121123
connected: {% if int.connected_endpoints|length > 0 or int.is_port and int.link_peers|length > 0 %}true{% else %}false{% endif %},
@@ -165,14 +167,15 @@
165167

166168
g.setAttribute("role", "link");
167169
g.style.cursor = "pointer";
168-
g.addEventListener("click", function () { window.location.href = p.url; });
170+
g.addEventListener("click", function () { window.location.href = p.detailUrl; });
169171
g.addEventListener("keydown", function (e) {
170-
if (e.key === "Enter" || e.key === " ") { window.location.href = p.url; }
172+
if (e.key === "Enter" || e.key === " ") { window.location.href = p.detailUrl; }
171173
});
172174

173175
var title = p.name;
174176
var peers = p.connectedEndpoints.length > 0 ? p.connectedEndpoints : p.linkPeers;
175177
if (peers.length > 0) { title += "<hr>" + peers.join("<br>"); }
178+
title += '<hr><a href="' + p.traceUrl + '">Trace</a>';
176179
g.setAttribute("data-bs-html", "true");
177180
g.setAttribute("data-bs-custom-class", "device-view-tooltip");
178181
g.setAttribute("title", title);

0 commit comments

Comments
 (0)