1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Standardize path endpoint templates

This commit is contained in:
Jeremy Stretch
2020-10-05 13:23:55 -04:00
parent 50aecd02f4
commit 32b8148da1
8 changed files with 158 additions and 94 deletions

View File

@ -150,6 +150,10 @@ class PathEndpoint(models.Model):
# Return the path as a list of three-tuples (A termination, cable, B termination)
return list(zip(*[iter(path)] * 3))
@property
def path(self):
return self._path
@property
def connected_endpoint(self):
"""

View File

@ -385,5 +385,6 @@ urlpatterns = [
path('power-feeds/<int:pk>/delete/', views.PowerFeedDeleteView.as_view(), name='powerfeed_delete'),
path('power-feeds/<int:pk>/trace/', views.PathTraceView.as_view(), name='powerfeed_trace', kwargs={'model': PowerFeed}),
path('power-feeds/<int:pk>/changelog/', ObjectChangeLogView.as_view(), name='powerfeed_changelog', kwargs={'model': PowerFeed}),
path('power-feeds/<int:termination_a_id>/connect/<str:termination_b_type>/', views.CableCreateView.as_view(), name='powerfeed_connect', kwargs={'termination_a_type': PowerFeed}),
]

View File

@ -44,6 +44,15 @@
</div>
{% if instance.cable %}
<table class="table table-hover panel-body attr-table">
<tr>
<td>Cable</td>
<td>
<a href="{{ instance.cable.get_absolute_url }}">{{ instance.cable }}</a>
<a href="{% url 'dcim:consoleport_trace' pk=instance.pk %}" class="btn btn-primary btn-xs" title="Trace">
<i class="fa fa-share-alt" aria-hidden="true"></i>
</a>
</td>
</tr>
{% if instance.connected_endpoint %}
<tr>
<td>Device</td>
@ -65,26 +74,17 @@
<td>Description</td>
<td>{{ instance.connected_endpoint.description|placeholder }}</td>
</tr>
{% endif %}
<tr>
<td>Cable</td>
<td>Path Status</td>
<td>
<a href="{{ instance.cable.get_absolute_url }}">{{ instance.cable }}</a>
<a href="{% url 'dcim:consoleport_trace' pk=instance.pk %}" class="btn btn-primary btn-xs" title="Trace">
<i class="fa fa-share-alt" aria-hidden="true"></i>
</a>
</td>
</tr>
<tr>
<td>Connection Status</td>
<td>
{% if instance.connection_status %}
<span class="label label-success">{{ instance.get_connection_status_display }}</span>
{% if instance.path.is_active %}
<span class="label label-success">Reachable</span>
{% else %}
<span class="label label-info">{{ instance.get_connection_status_display }}</span>
<span class="label label-danger">Not Reachable</span>
{% endif %}
</td>
</tr>
{% endif %}
</table>
{% else %}
<div class="panel-body text-muted">

View File

@ -44,6 +44,15 @@
</div>
{% if instance.cable %}
<table class="table table-hover panel-body attr-table">
<tr>
<td>Cable</td>
<td>
<a href="{{ instance.cable.get_absolute_url }}">{{ instance.cable }}</a>
<a href="{% url 'dcim:consoleserverport_trace' pk=instance.pk %}" class="btn btn-primary btn-xs" title="Trace">
<i class="fa fa-share-alt" aria-hidden="true"></i>
</a>
</td>
</tr>
{% if instance.connected_endpoint %}
<tr>
<td>Device</td>
@ -65,26 +74,17 @@
<td>Description</td>
<td>{{ instance.connected_endpoint.description|placeholder }}</td>
</tr>
{% endif %}
<tr>
<td>Cable</td>
<td>Path Status</td>
<td>
<a href="{{ instance.cable.get_absolute_url }}">{{ instance.cable }}</a>
<a href="{% url 'dcim:consoleserverport_trace' pk=instance.pk %}" class="btn btn-primary btn-xs" title="Trace">
<i class="fa fa-share-alt" aria-hidden="true"></i>
</a>
</td>
</tr>
<tr>
<td>Connection Status</td>
<td>
{% if instance.connection_status %}
<span class="label label-success">{{ instance.get_connection_status_display }}</span>
{% if instance.path.is_active %}
<span class="label label-success">Reachable</span>
{% else %}
<span class="label label-info">{{ instance.get_connection_status_display }}</span>
<span class="label label-danger">Not Reachable</span>
{% endif %}
</td>
</tr>
{% endif %}
</table>
{% else %}
<div class="panel-body text-muted">

View File

@ -77,6 +77,15 @@
</div>
{% if instance.cable %}
<table class="table table-hover panel-body attr-table">
<tr>
<td>Cable</td>
<td>
<a href="{{ instance.cable.get_absolute_url }}">{{ instance.cable }}</a>
<a href="{% url 'dcim:interface_trace' pk=instance.pk %}" class="btn btn-primary btn-xs" title="Trace">
<i class="fa fa-share-alt" aria-hidden="true"></i>
</a>
</td>
</tr>
{% if instance.connected_endpoint.device %}
{% with iface=instance.connected_endpoint %}
<tr>
@ -149,21 +158,12 @@
{% endwith %}
{% endif %}
<tr>
<td>Cable</td>
<td>Path Status</td>
<td>
<a href="{{ instance.cable.get_absolute_url }}">{{ instance.cable }}</a>
<a href="{% url 'dcim:interface_trace' pk=instance.pk %}" class="btn btn-primary btn-xs" title="Trace">
<i class="fa fa-share-alt" aria-hidden="true"></i>
</a>
</td>
</tr>
<tr>
<td>Connection Status</td>
<td>
{% if instance.connection_status %}
<span class="label label-success">{{ instance.get_connection_status_display }}</span>
{% if instance.path.is_active %}
<span class="label label-success">Reachable</span>
{% else %}
<span class="label label-info">{{ instance.get_connection_status_display }}</span>
<span class="label label-danger">Not Reachable</span>
{% endif %}
</td>
</tr>

View File

@ -123,11 +123,6 @@
</tr>
</table>
</div>
{% include 'inc/custom_fields_panel.html' with obj=powerfeed %}
{% include 'extras/inc/tags_panel.html' with tags=powerfeed.tags.all url='dcim:powerfeed_list' %}
{% plugin_left_page powerfeed %}
</div>
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<strong>Electrical Characteristics</strong>
@ -155,6 +150,70 @@
</tr>
</table>
</div>
{% include 'inc/custom_fields_panel.html' with obj=powerfeed %}
{% include 'extras/inc/tags_panel.html' with tags=powerfeed.tags.all url='dcim:powerfeed_list' %}
{% plugin_left_page powerfeed %}
</div>
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<strong>Connection</strong>
</div>
{% if powerfeed.cable %}
<table class="table table-hover panel-body attr-table">
<tr>
<td>Cable</td>
<td>
<a href="{{ powerfeed.cable.get_absolute_url }}">{{ powerfeed.cable }}</a>
<a href="{% url 'dcim:consoleport_trace' pk=powerfeed.pk %}" class="btn btn-primary btn-xs" title="Trace">
<i class="fa fa-share-alt" aria-hidden="true"></i>
</a>
</td>
</tr>
{% if powerfeed.connected_endpoint %}
<tr>
<td>Device</td>
<td>
<a href="{{ powerfeed.connected_endpoint.device.get_absolute_url }}">{{ powerfeed.connected_endpoint.device }}</a>
</td>
</tr>
<tr>
<td>Name</td>
<td>
<a href="{{ powerfeed.connected_endpoint.get_absolute_url }}">{{ powerfeed.connected_endpoint.name }}</a>
</td>
</tr>
<tr>
<td>Type</td>
<td>{{ powerfeed.connected_endpoint.get_type_display|placeholder }}</td>
</tr>
<tr>
<td>Description</td>
<td>{{ powerfeed.connected_endpoint.description|placeholder }}</td>
</tr>
<tr>
<td>Path Status</td>
<td>
{% if powerfeed.path.is_active %}
<span class="label label-success">Reachable</span>
{% else %}
<span class="label label-danger">Not Reachable</span>
{% endif %}
</td>
</tr>
{% endif %}
</table>
{% else %}
<div class="panel-body text-muted">
{% if perms.dcim.add_cable %}
<a href="{% url 'dcim:powerfeed_connect' termination_a_id=powerfeed.pk termination_b_type='power-port' %}?return_url={{ powerfeed.get_absolute_url }}" class="btn btn-primary btn-sm pull-right">
<span class="glyphicon glyphicon-resize-small" aria-hidden="true"></span> Connect
</a>
{% endif %}
Not connected
</div>
{% endif %}
</div>
<div class="panel panel-default">
<div class="panel-heading">
<strong>Comments</strong>

View File

@ -52,6 +52,15 @@
</div>
{% if instance.cable %}
<table class="table table-hover panel-body attr-table">
<tr>
<td>Cable</td>
<td>
<a href="{{ instance.cable.get_absolute_url }}">{{ instance.cable }}</a>
<a href="{% url 'dcim:poweroutlet_trace' pk=instance.pk %}" class="btn btn-primary btn-xs" title="Trace">
<i class="fa fa-share-alt" aria-hidden="true"></i>
</a>
</td>
</tr>
{% if instance.connected_endpoint %}
<tr>
<td>Device</td>
@ -73,26 +82,17 @@
<td>Description</td>
<td>{{ instance.connected_endpoint.description|placeholder }}</td>
</tr>
{% endif %}
<tr>
<td>Cable</td>
<td>Path Status</td>
<td>
<a href="{{ instance.cable.get_absolute_url }}">{{ instance.cable }}</a>
<a href="{% url 'dcim:poweroutlet_trace' pk=instance.pk %}" class="btn btn-primary btn-xs" title="Trace">
<i class="fa fa-share-alt" aria-hidden="true"></i>
</a>
</td>
</tr>
<tr>
<td>Connection Status</td>
<td>
{% if instance.connection_status %}
<span class="label label-success">{{ instance.get_connection_status_display }}</span>
{% if instance.path.is_active %}
<span class="label label-success">Reachable</span>
{% else %}
<span class="label label-info">{{ instance.get_connection_status_display }}</span>
<span class="label label-danger">Not Reachable</span>
{% endif %}
</td>
</tr>
{% endif %}
</table>
{% else %}
<div class="panel-body text-muted">

View File

@ -52,6 +52,15 @@
</div>
{% if instance.cable %}
<table class="table table-hover panel-body attr-table">
<tr>
<td>Cable</td>
<td>
<a href="{{ instance.cable.get_absolute_url }}">{{ instance.cable }}</a>
<a href="{% url 'dcim:powerport_trace' pk=instance.pk %}" class="btn btn-primary btn-xs" title="Trace">
<i class="fa fa-share-alt" aria-hidden="true"></i>
</a>
</td>
</tr>
{% if instance.connected_endpoint %}
<tr>
<td>Device</td>
@ -73,26 +82,17 @@
<td>Description</td>
<td>{{ instance.connected_endpoint.description|placeholder }}</td>
</tr>
{% endif %}
<tr>
<td>Cable</td>
<td>Path Status</td>
<td>
<a href="{{ instance.cable.get_absolute_url }}">{{ instance.cable }}</a>
<a href="{% url 'dcim:powerport_trace' pk=instance.pk %}" class="btn btn-primary btn-xs" title="Trace">
<i class="fa fa-share-alt" aria-hidden="true"></i>
</a>
</td>
</tr>
<tr>
<td>Connection Status</td>
<td>
{% if instance.connection_status %}
<span class="label label-success">{{ instance.get_connection_status_display }}</span>
{% if instance.path.is_active %}
<span class="label label-success">Reachable</span>
{% else %}
<span class="label label-info">{{ instance.get_connection_status_display }}</span>
<span class="label label-danger">Not Reachable</span>
{% endif %}
</td>
</tr>
{% endif %}
</table>
{% else %}
<div class="panel-body text-muted">