diff --git a/netbox/project-static/css/base.css b/netbox/project-static/css/base.css index 6ae37bdf1..f80b134cd 100644 --- a/netbox/project-static/css/base.css +++ b/netbox/project-static/css/base.css @@ -487,3 +487,8 @@ td .progress { textarea { font-family: Consolas, Lucida Console, monospace; } + +/* Dividers between path elements */ +span.path-element + span.path-element:before { + content: ' ➞ '; +} diff --git a/netbox/templates/dcim/inc/interface.html b/netbox/templates/dcim/inc/interface.html index 424f487a8..15cd6552e 100644 --- a/netbox/templates/dcim/inc/interface.html +++ b/netbox/templates/dcim/inc/interface.html @@ -72,58 +72,71 @@ Virtual interface {% elif iface.is_wireless %} Wireless interface - {% elif iface.connected_endpoint.name %} - {# Connected to an Interface #} - - - {{ iface.connected_endpoint.device }} - - - - - - {{ iface.connected_endpoint }} - - - - {% elif iface.connected_endpoint.term_side %} - {# Connected to a CircuitTermination #} - {% with iface.connected_endpoint.get_peer_termination as peer_termination %} - {% if peer_termination %} - {% if peer_termination.connected_endpoint %} - - - {{ peer_termination.connected_endpoint.device }} -
- via - - {{ iface.connected_endpoint.circuit.provider }} - {{ iface.connected_endpoint.circuit }} - - - - - {{ peer_termination.connected_endpoint }} - - {% else %} - - - {{ peer_termination.site }} + {% elif iface.connected_endpoint %} + {% with endpoint=iface.connected_endpoint previous_endpoint=iface.via_endpoints|last %} + {% if endpoint.positions and previous_endpoint.rear_port_position %} + {# RearPort has positions, FrontPort has rear port position #} + {# Ending at a rear port isn't interesting if we know the front port #} + + + {{ previous_endpoint.device }} + + {% with path=iface.via_endpoints|slice:":-1" %} + {% include "dcim/inc/interface_path.html" %} + {% endwith %} + + + + {{ previous_endpoint.name }} + + + {% elif endpoint.name and endpoint.device %} + {# Interface, FrontPort and RearPort have a name and a device #} + + + {{ endpoint.device }} + + {% with path=iface.via_endpoints %} + {% include "dcim/inc/interface_path.html" %} + {% endwith %} + + + {% if endpoint.get_type_display %} + + + {{ endpoint.name }} + - via - - {{ iface.connected_endpoint.circuit.provider }} - {{ iface.connected_endpoint.circuit }} + {% else %} + + {{ endpoint.name }} - - {% endif %} + {% endif %} + + {% elif endpoint.circuit %} + {# CircuitTermination has a circuit #} + + {% if endpoint.circuit == previous_endpoint.circuit %} + {# We have the remote endpoint, show the remote site #} + + {{ endpoint.site }} + + {% else %} + {# We have the local endpoint, show the circuit #} + + + {{ endpoint.circuit.provider }} + {{ endpoint.circuit.cid }} + + {% endif %} + + {% with path=iface.via_endpoints %} + {% include "dcim/inc/interface_path.html" %} + {% endwith %} + {% else %} - - - {{ iface.connected_endpoint.circuit.provider }} - {{ iface.connected_endpoint.circuit }} - + Unknown endpoint type {% endif %} {% endwith %} diff --git a/netbox/templates/dcim/inc/interface_path.html b/netbox/templates/dcim/inc/interface_path.html new file mode 100644 index 000000000..063f6b030 --- /dev/null +++ b/netbox/templates/dcim/inc/interface_path.html @@ -0,0 +1,26 @@ +{% if path %} +
+ + via + {% for endpoint in path %} + {% ifchanged %} + {% if endpoint.positions %} + {# Don't show RearPort #} + {% elif endpoint.rear_port_position %} + + + {{ endpoint.device }} + + {{ endpoint.name }} + + {% elif endpoint.circuit %} + + + {{ endpoint.circuit }} + + + {% endif %} + {% endifchanged %} + {% endfor %} + +{% endif %}