diff --git a/netbox/circuits/ui/panels.py b/netbox/circuits/ui/panels.py index e8d6cf9bb..2ad39bca7 100644 --- a/netbox/circuits/ui/panels.py +++ b/netbox/circuits/ui/panels.py @@ -58,6 +58,26 @@ class CircuitGroupAssignmentsPanel(panels.ObjectsTablePanel): ) +class CircuitTerminationPanel(panels.ObjectAttributesPanel): + title = _('Circuit Termination') + circuit = attrs.RelatedObjectAttr('circuit', linkify=True) + provider = attrs.RelatedObjectAttr('circuit.provider', linkify=True) + termination = attrs.GenericForeignKeyAttr('termination', linkify=True, label=_('Termination point')) + connection = attrs.TemplatedAttr( + 'pk', + template_name='circuits/circuit_termination/attrs/connection.html', + label=_('Connection'), + ) + speed = attrs.TemplatedAttr( + 'port_speed', + template_name='circuits/circuit_termination/attrs/speed.html', + label=_('Speed'), + ) + xconnect_id = attrs.TextAttr('xconnect_id', label=_('Cross-Connect'), style='font-monospace') + pp_info = attrs.TextAttr('pp_info', label=_('Patch Panel/Port')) + description = attrs.TextAttr('description') + + class CircuitGroupPanel(panels.OrganizationalObjectPanel): tenant = attrs.RelatedObjectAttr('tenant', linkify=True, grouped_by='group') diff --git a/netbox/circuits/views.py b/netbox/circuits/views.py index ddb4ef358..d65c2a468 100644 --- a/netbox/circuits/views.py +++ b/netbox/circuits/views.py @@ -8,7 +8,6 @@ from netbox.ui import actions, layout from netbox.ui.panels import ( CommentsPanel, ObjectsTablePanel, - Panel, RelatedObjectsPanel, ) from netbox.views import generic @@ -508,10 +507,7 @@ class CircuitTerminationView(generic.ObjectView): queryset = CircuitTermination.objects.all() layout = layout.SimpleLayout( left_panels=[ - Panel( - template_name='circuits/panels/circuit_termination.html', - title=_('Circuit Termination'), - ) + panels.CircuitTerminationPanel(), ], right_panels=[ CustomFieldsPanel(), diff --git a/netbox/templates/circuits/circuit_termination/attrs/connection.html b/netbox/templates/circuits/circuit_termination/attrs/connection.html new file mode 100644 index 000000000..0a60f9a41 --- /dev/null +++ b/netbox/templates/circuits/circuit_termination/attrs/connection.html @@ -0,0 +1,48 @@ +{% load helpers i18n %} +{% if object.mark_connected %} +
+ + {% trans "Marked as connected" %} +
+{% elif object.cable %} +
+ {{ object.cable }} {% trans "to" %} + {% for peer in object.link_peers %} + {% if peer.device %} + {{ peer.device|linkify }}
+ {% elif peer.circuit %} + {{ peer.circuit|linkify }}
+ {% endif %} + {{ peer|linkify }}{% if not forloop.last %},{% endif %} + {% endfor %} +
+
+ + {% trans "Trace" %} + + {% if perms.dcim.change_cable %} + + {% trans "Edit" %} + + {% endif %} + {% if perms.dcim.delete_cable %} + + {% trans "Disconnect" %} + + {% endif %} +
+{% elif perms.dcim.add_cable %} + +{% else %} + {{ ''|placeholder }} +{% endif %} diff --git a/netbox/templates/circuits/circuit_termination/attrs/speed.html b/netbox/templates/circuits/circuit_termination/attrs/speed.html new file mode 100644 index 000000000..015ba4aeb --- /dev/null +++ b/netbox/templates/circuits/circuit_termination/attrs/speed.html @@ -0,0 +1,8 @@ +{% load helpers i18n %} +{% if object.upstream_speed %} + {{ object.port_speed|humanize_speed }} + + {{ object.upstream_speed|humanize_speed }} +{% else %} + {{ object.port_speed|humanize_speed }} +{% endif %} diff --git a/netbox/templates/circuits/panels/circuit_termination.html b/netbox/templates/circuits/panels/circuit_termination.html deleted file mode 100644 index 5583d1536..000000000 --- a/netbox/templates/circuits/panels/circuit_termination.html +++ /dev/null @@ -1,16 +0,0 @@ -{% extends "ui/panels/_base.html" %} -{% load helpers i18n %} - -{% block panel_content %} - - - - - - - - - - {% include 'circuits/inc/circuit_termination_fields.html' with termination=object %} -
{% trans "Circuit" %}{{ object.circuit|linkify|placeholder }}
{% trans "Provider" %}{{ object.circuit.provider|linkify|placeholder }}
-{% endblock panel_content %}