Show the peer device/port in component connection columns
Add ConceptComponent.peer, returning the component on the other end of its cable (whichever termination isn't itself). Use it in the component tables' "Connection" column (Device > Port, both linked, mirroring NetBox's own link_peer style) instead of just linking to the cable object, and on the component detail page's "Connected to" row in place of the manual termination_a/b branch. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -115,8 +115,21 @@ class ConceptComponentTable(NetBoxTable):
|
||||
concept = tables.Column(accessor='device__concept', linkify=True, verbose_name=_('Concept'))
|
||||
component_type = columns.ChoiceFieldColumn()
|
||||
color = columns.ColorColumn()
|
||||
connection = tables.Column(
|
||||
accessor='cable', linkify=True, orderable=False, verbose_name=_('Connection'), empty_values=()
|
||||
connection = tables.TemplateColumn(
|
||||
template_code="""
|
||||
{% with peer=record.peer %}
|
||||
{% if peer %}
|
||||
<a href="{{ peer.device.get_absolute_url }}">{{ peer.device }}</a>
|
||||
<i class="mdi mdi-chevron-right"></i>
|
||||
<a href="{{ peer.get_absolute_url }}">{{ peer }}</a>
|
||||
{% else %}
|
||||
{{ ''|placeholder }}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
""",
|
||||
verbose_name=_('Connection'),
|
||||
orderable=False,
|
||||
empty_values=()
|
||||
)
|
||||
connect = tables.TemplateColumn(
|
||||
template_code="""
|
||||
@@ -139,9 +152,6 @@ class ConceptComponentTable(NetBoxTable):
|
||||
)
|
||||
default_columns = ('name', 'device', 'component_type', 'port_type', 'connection', 'connect')
|
||||
|
||||
def render_connection(self, value, record):
|
||||
return value if value else _('Not connected')
|
||||
|
||||
|
||||
class ConceptCableTable(NetBoxTable):
|
||||
id = tables.Column(linkify=True, verbose_name=_('ID'))
|
||||
|
||||
Reference in New Issue
Block a user