Added cable connections to component lists

This commit is contained in:
Jeremy Stretch 2018-10-26 11:29:03 -04:00
parent 6bea8cc546
commit 957de0cd98
10 changed files with 162 additions and 56 deletions

View File

@ -886,7 +886,7 @@ class DeviceView(View):
) )
# Console server ports # 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
power_ports = natsorted( power_ports = natsorted(
@ -894,7 +894,7 @@ class DeviceView(View):
) )
# Power outlets # 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
interfaces = device.vc_interfaces.order_naturally( interfaces = device.vc_interfaces.order_naturally(

View File

@ -527,6 +527,7 @@
<th>Description</th> <th>Description</th>
<th>Mode</th> <th>Mode</th>
<th colspan="2">Connection</th> <th colspan="2">Connection</th>
<th>Cable</th>
<th></th> <th></th>
</tr> </tr>
</thead> </thead>
@ -590,6 +591,7 @@
{% endif %} {% endif %}
<th>Name</th> <th>Name</th>
<th colspan="2">Connection</th> <th colspan="2">Connection</th>
<th>Cable</th>
<th></th> <th></th>
</tr> </tr>
</thead> </thead>
@ -648,6 +650,7 @@
{% endif %} {% endif %}
<th>Name</th> <th>Name</th>
<th colspan="2">Connection</th> <th colspan="2">Connection</th>
<th>Cable</th>
<th></th> <th></th>
</tr> </tr>
</thead> </thead>

View File

@ -2,7 +2,7 @@
<tr> <tr>
<td>Device</td> <td>Device</td>
<td> <td>
<a href="{{ termination.device.parent.get_absolute_url }}">{{ termination.device }}</a> <a href="{{ termination.device.get_absolute_url }}">{{ termination.device }}</a>
</td> </td>
</tr> </tr>
<tr> <tr>

View File

@ -1,7 +1,11 @@
<tr class="consoleport{% if cp.connected_endpoint %} {% if cp.connection_status %}success{% else %}info{% endif %}{% endif %}"> <tr class="consoleport{% if cp.connected_endpoint %} {% if cp.connection_status %}success{% else %}info{% endif %}{% endif %}">
{# Name #}
<td> <td>
<i class="fa fa-fw fa-keyboard-o"></i> {{ cp }} <i class="fa fa-fw fa-keyboard-o"></i> {{ cp }}
</td> </td>
{# Connection #}
{% if cp.connected_endpoint %} {% if cp.connected_endpoint %}
<td> <td>
<a href="{% url 'dcim:device' pk=cp.connected_endpoint.device.pk %}">{{ cp.connected_endpoint.device }}</a> <a href="{% url 'dcim:device' pk=cp.connected_endpoint.device.pk %}">{{ cp.connected_endpoint.device }}</a>
@ -14,6 +18,17 @@
<span class="text-muted">Not connected</span> <span class="text-muted">Not connected</span>
</td> </td>
{% endif %} {% endif %}
{# Cable #}
<td>
{% with cable=cp.get_connected_cable %}
{% if cable %}
via <a href="{{ cable.get_absolute_url }}">{{ cable }}</a>
{% endif %}
{% endwith %}
</td>
{# Actions #}
<td class="text-right"> <td class="text-right">
{% if perms.dcim.change_consoleport %} {% if perms.dcim.change_consoleport %}
{% if cp.connected_endpoint %} {% if cp.connected_endpoint %}

View File

@ -1,12 +1,18 @@
<tr class="consoleserverport{% if csp.connected_endpoint %} {%if csp.connected_endpoint.connection_status %}success{% else %}info{% endif %}{% endif %}"> <tr class="consoleserverport{% if csp.connected_endpoint %} {%if csp.connected_endpoint.connection_status %}success{% else %}info{% endif %}{% endif %}">
{# Checkbox #}
{% if perms.dcim.change_consoleserverport or perms.dcim.delete_consoleserverport %} {% if perms.dcim.change_consoleserverport or perms.dcim.delete_consoleserverport %}
<td class="pk"> <td class="pk">
<input name="pk" type="checkbox" value="{{ csp.pk }}" /> <input name="pk" type="checkbox" value="{{ csp.pk }}" />
</td> </td>
{% endif %} {% endif %}
{# Name #}
<td> <td>
<i class="fa fa-fw fa-keyboard-o"></i> {{ csp }} <i class="fa fa-fw fa-keyboard-o"></i> {{ csp }}
</td> </td>
{# Connection #}
{% if csp.connected_endpoint %} {% if csp.connected_endpoint %}
<td> <td>
<a href="{% url 'dcim:device' pk=csp.connected_endpoint.device.pk %}">{{ csp.connected_endpoint.device }}</a> <a href="{% url 'dcim:device' pk=csp.connected_endpoint.device.pk %}">{{ csp.connected_endpoint.device }}</a>
@ -19,6 +25,20 @@
<span class="text-muted">Not connected</span> <span class="text-muted">Not connected</span>
</td> </td>
{% endif %} {% endif %}
{# Cable #}
<td>
{% with cable=csp.get_connected_cable %}
{% if cable %}
<a href="{{ cable.get_absolute_url }}">{{ cable }}</a>
{% if cable.far_end != csp.connected_endpoint %}
to <a href="{{ cable.far_end.device.get_absolute_url }}">{{ cable.far_end.device }}</a> {{ cable.far_end }}
{% endif %}
{% endif %}
{% endwith %}
</td>
{# Actions #}
<td class="text-right"> <td class="text-right">
{% if perms.dcim.change_consoleserverport %} {% if perms.dcim.change_consoleserverport %}
{% if csp.connected_endpoint %} {% if csp.connected_endpoint %}

View File

@ -1,34 +1,46 @@
<tr class="frontport"> {% with cable=frontport.get_connected_cable %}
{% if perms.dcim.change_frontport or perms.dcim.delete_frontport %} <tr class="frontport{% if cable %} {% if cable.status %}success{% else %}info{% endif %}{% endif %}">
<td class="pk">
<input name="pk" type="checkbox" value="{{ frontport.pk }}" /> {# Checkbox #}
{% if perms.dcim.change_frontport or perms.dcim.delete_frontport %}
<td class="pk">
<input name="pk" type="checkbox" value="{{ frontport.pk }}" />
</td>
{% endif %}
{# Name #}
<td>
<i class="fa fa-fw fa-square-o"></i> {{ frontport }}
</td> </td>
{% endif %}
<td> {# Type #}
<i class="fa fa-fw fa-square-o"></i> {{ frontport }} <td>{{ frontport.get_type_display }}</td>
</td>
<td>{{ frontport.get_type_display }}</td> {# Rear port #}
<td>{{ frontport.rear_port }}</td> <td>{{ frontport.rear_port }}</td>
<td>{{ frontport.rear_port_position }}</td> <td>{{ frontport.rear_port_position }}</td>
{% with cable=frontport.get_connected_cable %}
{# Cable #}
<td> <td>
{% if cable %} {% if cable %}
<a href="#">{{ cable }}</a> to <a href="{{ cable.far_end.device.get_absolute_url }}">{{ cable.far_end.device }}</a> <a href="{{ cable.far_end.get_absolute_url }}">{{ cable.far_end }}</a> <a href="{{ cable.get_absolute_url }}">{{ cable }}</a> to <a href="{{ cable.far_end.device.get_absolute_url }}">{{ cable.far_end.device }}</a> <a href="{{ cable.far_end.get_absolute_url }}">{{ cable.far_end }}</a>
{% else %} {% else %}
<span class="text-muted">Not connected</span> <span class="text-muted">Not connected</span>
{% endif %} {% endif %}
</td> </td>
{% endwith %}
<td class="text-right"> {# Actions #}
{% if perms.dcim.change_frontport %} <td class="text-right">
<a href="{% url 'dcim:frontport_edit' pk=frontport.pk %}?return_url={{ device.get_absolute_url }}" title="Edit port" class="btn btn-info btn-xs"> {% if perms.dcim.change_frontport %}
<i class="glyphicon glyphicon-pencil" aria-hidden="true"></i> <a href="{% url 'dcim:frontport_edit' pk=frontport.pk %}?return_url={{ device.get_absolute_url }}" title="Edit port" class="btn btn-info btn-xs">
</a> <i class="glyphicon glyphicon-pencil" aria-hidden="true"></i>
{% endif %} </a>
{% if perms.dcim.delete_frontport %} {% endif %}
<a href="{% url 'dcim:frontport_delete' pk=frontport.pk %}?return_url={{ device.get_absolute_url }}" title="Delete port" class="btn btn-danger btn-xs"> {% if perms.dcim.delete_frontport %}
<i class="glyphicon glyphicon-trash" aria-hidden="true"></i> <a href="{% url 'dcim:frontport_delete' pk=frontport.pk %}?return_url={{ device.get_absolute_url }}" title="Delete port" class="btn btn-danger btn-xs">
</a> <i class="glyphicon glyphicon-trash" aria-hidden="true"></i>
{% endif %} </a>
</td> {% endif %}
</tr> </td>
</tr>
{% endwith %}

View File

@ -69,6 +69,18 @@
</td> </td>
{% endif %} {% endif %}
{# Cable #}
<td>
{% with cable=iface.get_connected_cable %}
{% if cable %}
<a href="{{ cable.get_absolute_url }}">{{ cable }}</a>
{% if cable.far_end != csp.connected_endpoint %}
to <a href="{{ cable.far_end.device.get_absolute_url }}">{{ cable.far_end.device }}</a> {{ cable.far_end }}
{% endif %}
{% endif %}
{% endwith %}
</td>
{# Buttons #} {# Buttons #}
<td class="text-right text-nowrap"> <td class="text-right text-nowrap">
{% if show_graphs %} {% if show_graphs %}

View File

@ -1,12 +1,18 @@
<tr class="poweroutlet{% if po.connected_endpoint %} {% if po.connected_endpoint.connection_status %}success{% else %}info{% endif %}{% endif %}"> <tr class="poweroutlet{% if po.connected_endpoint %} {% if po.connected_endpoint.connection_status %}success{% else %}info{% endif %}{% endif %}">
{# Checkbox #}
{% if perms.dcim.change_poweroutlet or perms.dcim.delete_poweroutlet %} {% if perms.dcim.change_poweroutlet or perms.dcim.delete_poweroutlet %}
<td class="pk"> <td class="pk">
<input name="pk" type="checkbox" value="{{ po.pk }}" /> <input name="pk" type="checkbox" value="{{ po.pk }}" />
</td> </td>
{% endif %} {% endif %}
{# Name #}
<td> <td>
<i class="fa fa-fw fa-bolt"></i> {{ po }} <i class="fa fa-fw fa-bolt"></i> {{ po }}
</td> </td>
{# Connection #}
{% if po.connected_endpoint %} {% if po.connected_endpoint %}
<td> <td>
<a href="{% url 'dcim:device' pk=po.connected_endpoint.device.pk %}">{{ po.connected_endpoint.device }}</a> <a href="{% url 'dcim:device' pk=po.connected_endpoint.device.pk %}">{{ po.connected_endpoint.device }}</a>
@ -19,6 +25,17 @@
<span class="text-muted">Not connected</span> <span class="text-muted">Not connected</span>
</td> </td>
{% endif %} {% endif %}
{# Cable #}
<td>
{% with cable=po.get_connected_cable %}
{% if cable %}
<a href="{{ cable.get_absolute_url }}">{{ cable }}</a>
{% endif %}
{% endwith %}
</td>
{# Actions #}
<td class="text-right"> <td class="text-right">
{% if perms.dcim.change_poweroutlet %} {% if perms.dcim.change_poweroutlet %}
{% if po.connected_endpoint %} {% if po.connected_endpoint %}

View File

@ -1,7 +1,11 @@
<tr class="powerport{% if pp.connected_endpoint %} {% if pp.connection_status %}success{% else %}info{% endif %}{% endif %}"> <tr class="powerport{% if pp.connected_endpoint %} {% if pp.connection_status %}success{% else %}info{% endif %}{% endif %}">
{# Name #}
<td> <td>
<i class="fa fa-fw fa-bolt"></i> {{ pp }} <i class="fa fa-fw fa-bolt"></i> {{ pp }}
</td> </td>
{# Connection #}
{% if pp.connected_endpoint %} {% if pp.connected_endpoint %}
<td> <td>
<a href="{% url 'dcim:device' pk=pp.connected_endpoint.device.pk %}">{{ pp.connected_endpoint.device }}</a> <a href="{% url 'dcim:device' pk=pp.connected_endpoint.device.pk %}">{{ pp.connected_endpoint.device }}</a>
@ -14,6 +18,17 @@
<span class="text-muted">Not connected</span> <span class="text-muted">Not connected</span>
</td> </td>
{% endif %} {% endif %}
{# Cable #}
<td>
{% with cable=pp.get_connected_cable %}
{% if cable %}
via <a href="{{ cable.get_absolute_url }}">{{ cable }}</a>
{% endif %}
{% endwith %}
</td>
{# Actions #}
<td class="text-right"> <td class="text-right">
{% if perms.dcim.change_powerport %} {% if perms.dcim.change_powerport %}
{% if pp.connected_endpoint %} {% if pp.connected_endpoint %}

View File

@ -1,33 +1,45 @@
<tr class="rearport"> {% with cable=rearport.get_connected_cable %}
{% if perms.dcim.change_rearport or perms.dcim.delete_rearport %} <tr class="rearport{% if cable %} {% if cable.status %}success{% else %}info{% endif %}{% endif %}">
<td class="pk">
<input name="pk" type="checkbox" value="{{ rearport.pk }}" /> {# Checkbox #}
{% if perms.dcim.change_rearport or perms.dcim.delete_rearport %}
<td class="pk">
<input name="pk" type="checkbox" value="{{ rearport.pk }}" />
</td>
{% endif %}
{# Name #}
<td>
<i class="fa fa-fw fa-square-o"></i> {{ rearport }}
</td> </td>
{% endif %}
<td> {# Type #}
<i class="fa fa-fw fa-square-o"></i> {{ rearport }} <td>{{ rearport.get_type_display }}</td>
</td>
<td>{{ rearport.get_type_display }}</td> {# Positions #}
<td>{{ rearport.positions }}</td> <td>{{ rearport.positions }}</td>
{% with cable=rearport.get_connected_cable %}
{# Cable #}
<td> <td>
{% if cable %} {% if cable %}
<a href="#">{{ cable }}</a> to <a href="{{ cable.far_end.device.get_absolute_url }}">{{ cable.far_end.device }}</a> <a href="{{ cable.far_end.get_absolute_url }}">{{ cable.far_end }}</a> <a href="{{ cable.get_absolute_url }}">{{ cable }}</a> to <a href="{{ cable.far_end.device.get_absolute_url }}">{{ cable.far_end.device }}</a> <a href="{{ cable.far_end.get_absolute_url }}">{{ cable.far_end }}</a>
{% else %} {% else %}
<span class="text-muted">Not connected</span> <span class="text-muted">Not connected</span>
{% endif %} {% endif %}
</td> </td>
{% endwith %}
<td class="text-right"> {# Actions #}
{% if perms.dcim.change_rearport %} <td class="text-right">
<a href="{% url 'dcim:rearport_edit' pk=rearport.pk %}?return_url={{ device.get_absolute_url }}" title="Edit port" class="btn btn-info btn-xs"> {% if perms.dcim.change_rearport %}
<i class="glyphicon glyphicon-pencil" aria-hidden="true"></i> <a href="{% url 'dcim:rearport_edit' pk=rearport.pk %}?return_url={{ device.get_absolute_url }}" title="Edit port" class="btn btn-info btn-xs">
</a> <i class="glyphicon glyphicon-pencil" aria-hidden="true"></i>
{% endif %} </a>
{% if perms.dcim.delete_rearport %} {% endif %}
<a href="{% url 'dcim:rearport_delete' pk=rearport.pk %}?return_url={{ device.get_absolute_url }}" title="Delete port" class="btn btn-danger btn-xs"> {% if perms.dcim.delete_rearport %}
<i class="glyphicon glyphicon-trash" aria-hidden="true"></i> <a href="{% url 'dcim:rearport_delete' pk=rearport.pk %}?return_url={{ device.get_absolute_url }}" title="Delete port" class="btn btn-danger btn-xs">
</a> <i class="glyphicon glyphicon-trash" aria-hidden="true"></i>
{% endif %} </a>
</td> {% endif %}
</tr> </td>
</tr>
{% endwith %}