diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index e4454ee75..d3d455899 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -886,7 +886,7 @@ class DeviceView(View): ) # Console server ports - consoleserverports = ConsoleServerPort.objects.filter(device=device).select_related('connected_endpoint') + consoleserverports = ConsoleServerPort.objects.filter(device=device).select_related('connected_endpoint__device') # Power ports power_ports = natsorted( @@ -894,7 +894,7 @@ class DeviceView(View): ) # Power outlets - poweroutlets = PowerOutlet.objects.filter(device=device).select_related('connected_endpoint') + poweroutlets = PowerOutlet.objects.filter(device=device).select_related('connected_endpoint__device') # Interfaces interfaces = device.vc_interfaces.order_naturally( diff --git a/netbox/templates/dcim/device.html b/netbox/templates/dcim/device.html index 261b7e1f2..bbcbfaab1 100644 --- a/netbox/templates/dcim/device.html +++ b/netbox/templates/dcim/device.html @@ -527,6 +527,7 @@ Description Mode Connection + Cable @@ -590,6 +591,7 @@ {% endif %} Name Connection + Cable @@ -648,6 +650,7 @@ {% endif %} Name Connection + Cable diff --git a/netbox/templates/dcim/inc/cable_termination.html b/netbox/templates/dcim/inc/cable_termination.html index cc2ec60f5..8ff74b855 100644 --- a/netbox/templates/dcim/inc/cable_termination.html +++ b/netbox/templates/dcim/inc/cable_termination.html @@ -2,7 +2,7 @@ Device - {{ termination.device }} + {{ termination.device }} diff --git a/netbox/templates/dcim/inc/consoleport.html b/netbox/templates/dcim/inc/consoleport.html index e8c7c5b35..e948e1784 100644 --- a/netbox/templates/dcim/inc/consoleport.html +++ b/netbox/templates/dcim/inc/consoleport.html @@ -1,7 +1,11 @@ + + {# Name #} {{ cp }} + + {# Connection #} {% if cp.connected_endpoint %} {{ cp.connected_endpoint.device }} @@ -14,6 +18,17 @@ Not connected {% endif %} + + {# Cable #} + + {% with cable=cp.get_connected_cable %} + {% if cable %} + via {{ cable }} + {% endif %} + {% endwith %} + + + {# Actions #} {% if perms.dcim.change_consoleport %} {% if cp.connected_endpoint %} diff --git a/netbox/templates/dcim/inc/consoleserverport.html b/netbox/templates/dcim/inc/consoleserverport.html index 700e940dd..001590686 100644 --- a/netbox/templates/dcim/inc/consoleserverport.html +++ b/netbox/templates/dcim/inc/consoleserverport.html @@ -1,12 +1,18 @@ + + {# Checkbox #} {% if perms.dcim.change_consoleserverport or perms.dcim.delete_consoleserverport %} {% endif %} + + {# Name #} {{ csp }} + + {# Connection #} {% if csp.connected_endpoint %} {{ csp.connected_endpoint.device }} @@ -19,6 +25,20 @@ Not connected {% endif %} + + {# Cable #} + + {% with cable=csp.get_connected_cable %} + {% if cable %} + {{ cable }} + {% if cable.far_end != csp.connected_endpoint %} + to {{ cable.far_end.device }} {{ cable.far_end }} + {% endif %} + {% endif %} + {% endwith %} + + + {# Actions #} {% if perms.dcim.change_consoleserverport %} {% if csp.connected_endpoint %} diff --git a/netbox/templates/dcim/inc/frontport.html b/netbox/templates/dcim/inc/frontport.html index 38fd29b34..8086d57ee 100644 --- a/netbox/templates/dcim/inc/frontport.html +++ b/netbox/templates/dcim/inc/frontport.html @@ -1,34 +1,46 @@ - - {% if perms.dcim.change_frontport or perms.dcim.delete_frontport %} - - +{% with cable=frontport.get_connected_cable %} + + + {# Checkbox #} + {% if perms.dcim.change_frontport or perms.dcim.delete_frontport %} + + + + {% endif %} + + {# Name #} + + {{ frontport }} - {% endif %} - - {{ frontport }} - - {{ frontport.get_type_display }} - {{ frontport.rear_port }} - {{ frontport.rear_port_position }} - {% with cable=frontport.get_connected_cable %} + + {# Type #} + {{ frontport.get_type_display }} + + {# Rear port #} + {{ frontport.rear_port }} + {{ frontport.rear_port_position }} + + {# Cable #} {% if cable %} - {{ cable }} to {{ cable.far_end.device }} {{ cable.far_end }} + {{ cable }} to {{ cable.far_end.device }} {{ cable.far_end }} {% else %} Not connected {% endif %} - {% endwith %} - - {% if perms.dcim.change_frontport %} - - - - {% endif %} - {% if perms.dcim.delete_frontport %} - - - - {% endif %} - - + + {# Actions #} + + {% if perms.dcim.change_frontport %} + + + + {% endif %} + {% if perms.dcim.delete_frontport %} + + + + {% endif %} + + +{% endwith %} diff --git a/netbox/templates/dcim/inc/interface.html b/netbox/templates/dcim/inc/interface.html index 72a56f367..0dfb44bd6 100644 --- a/netbox/templates/dcim/inc/interface.html +++ b/netbox/templates/dcim/inc/interface.html @@ -69,6 +69,18 @@ {% endif %} + {# Cable #} + + {% with cable=iface.get_connected_cable %} + {% if cable %} + {{ cable }} + {% if cable.far_end != csp.connected_endpoint %} + to {{ cable.far_end.device }} {{ cable.far_end }} + {% endif %} + {% endif %} + {% endwith %} + + {# Buttons #} {% if show_graphs %} diff --git a/netbox/templates/dcim/inc/poweroutlet.html b/netbox/templates/dcim/inc/poweroutlet.html index 5081c1f6e..104908fd5 100644 --- a/netbox/templates/dcim/inc/poweroutlet.html +++ b/netbox/templates/dcim/inc/poweroutlet.html @@ -1,12 +1,18 @@ + + {# Checkbox #} {% if perms.dcim.change_poweroutlet or perms.dcim.delete_poweroutlet %} {% endif %} + + {# Name #} {{ po }} + + {# Connection #} {% if po.connected_endpoint %} {{ po.connected_endpoint.device }} @@ -19,6 +25,17 @@ Not connected {% endif %} + + {# Cable #} + + {% with cable=po.get_connected_cable %} + {% if cable %} + {{ cable }} + {% endif %} + {% endwith %} + + + {# Actions #} {% if perms.dcim.change_poweroutlet %} {% if po.connected_endpoint %} diff --git a/netbox/templates/dcim/inc/powerport.html b/netbox/templates/dcim/inc/powerport.html index 0d46c4ba9..cb77ce7de 100644 --- a/netbox/templates/dcim/inc/powerport.html +++ b/netbox/templates/dcim/inc/powerport.html @@ -1,7 +1,11 @@ + + {# Name #} {{ pp }} + + {# Connection #} {% if pp.connected_endpoint %} {{ pp.connected_endpoint.device }} @@ -14,6 +18,17 @@ Not connected {% endif %} + + {# Cable #} + + {% with cable=pp.get_connected_cable %} + {% if cable %} + via {{ cable }} + {% endif %} + {% endwith %} + + + {# Actions #} {% if perms.dcim.change_powerport %} {% if pp.connected_endpoint %} diff --git a/netbox/templates/dcim/inc/rearport.html b/netbox/templates/dcim/inc/rearport.html index aa130b883..ab7359939 100644 --- a/netbox/templates/dcim/inc/rearport.html +++ b/netbox/templates/dcim/inc/rearport.html @@ -1,33 +1,45 @@ - - {% if perms.dcim.change_rearport or perms.dcim.delete_rearport %} - - +{% with cable=rearport.get_connected_cable %} + + + {# Checkbox #} + {% if perms.dcim.change_rearport or perms.dcim.delete_rearport %} + + + + {% endif %} + + {# Name #} + + {{ rearport }} - {% endif %} - - {{ rearport }} - - {{ rearport.get_type_display }} - {{ rearport.positions }} - {% with cable=rearport.get_connected_cable %} + + {# Type #} + {{ rearport.get_type_display }} + + {# Positions #} + {{ rearport.positions }} + + {# Cable #} {% if cable %} - {{ cable }} to {{ cable.far_end.device }} {{ cable.far_end }} + {{ cable }} to {{ cable.far_end.device }} {{ cable.far_end }} {% else %} Not connected {% endif %} - {% endwith %} - - {% if perms.dcim.change_rearport %} - - - - {% endif %} - {% if perms.dcim.delete_rearport %} - - - - {% endif %} - - + + {# Actions #} + + {% if perms.dcim.change_rearport %} + + + + {% endif %} + {% if perms.dcim.delete_rearport %} + + + + {% endif %} + + +{% endwith %}