Clean up power connection tables

This commit is contained in:
Jeremy Stretch 2020-10-06 13:30:28 -04:00
parent d984dbd83b
commit c813ae4f04
5 changed files with 32 additions and 17 deletions

View File

@ -67,6 +67,19 @@ INTERFACE_TAGGED_VLANS = """
{% endfor %} {% endfor %}
""" """
POWERFEED_CABLE = """
<a href="{{ value.get_absolute_url }}">{{ value }}</a>
<a href="{% url 'dcim:powerfeed_trace' pk=record.pk %}" class="btn btn-primary btn-xs" title="Trace">
<i class="fa fa-share-alt" aria-hidden="true"></i>
</a>
"""
POWERFEED_CABLETERMINATION = """
<a href="{{ value.parent.get_absolute_url }}">{{ value.parent }}</a>
<i class="fa fa-caret-right"></i>
<a href="{{ value.get_absolute_url }}">{{ value }}</a>
"""
# #
# Regions # Regions
@ -977,6 +990,15 @@ class PowerFeedTable(BaseTable):
max_utilization = tables.TemplateColumn( max_utilization = tables.TemplateColumn(
template_code="{{ value }}%" template_code="{{ value }}%"
) )
cable = tables.TemplateColumn(
template_code=POWERFEED_CABLE,
orderable=False
)
connection = tables.TemplateColumn(
accessor='get_cable_peer',
template_code=POWERFEED_CABLETERMINATION,
orderable=False
)
available_power = tables.Column( available_power = tables.Column(
verbose_name='Available power (VA)' verbose_name='Available power (VA)'
) )
@ -988,8 +1010,9 @@ class PowerFeedTable(BaseTable):
model = PowerFeed model = PowerFeed
fields = ( fields = (
'pk', 'name', 'power_panel', 'rack', 'status', 'type', 'supply', 'voltage', 'amperage', 'phase', 'pk', 'name', 'power_panel', 'rack', 'status', 'type', 'supply', 'voltage', 'amperage', 'phase',
'max_utilization', 'available_power', 'tags', 'max_utilization', 'cable', 'connection', 'available_power', 'tags',
) )
default_columns = ( default_columns = (
'pk', 'name', 'power_panel', 'rack', 'status', 'type', 'supply', 'voltage', 'amperage', 'phase', 'pk', 'name', 'power_panel', 'rack', 'status', 'type', 'supply', 'voltage', 'amperage', 'phase', 'cable',
'connection',
) )

View File

@ -792,7 +792,6 @@
<th>Draw</th> <th>Draw</th>
<th>Description</th> <th>Description</th>
<th>Cable</th> <th>Cable</th>
<th colspan="2">Cable Termination</th>
<th colspan="2">Connection</th> <th colspan="2">Connection</th>
<th></th> <th></th>
</tr> </tr>
@ -847,7 +846,6 @@
<th>Input/Leg</th> <th>Input/Leg</th>
<th>Description</th> <th>Description</th>
<th>Cable</th> <th>Cable</th>
<th colspan="2">Cable Termination</th>
<th colspan="3">Connection</th> <th colspan="3">Connection</th>
<th></th> <th></th>
</tr> </tr>

View File

@ -44,11 +44,8 @@
<i class="fa fa-share-alt" aria-hidden="true"></i> <i class="fa fa-share-alt" aria-hidden="true"></i>
</a> </a>
</td> </td>
{% include 'dcim/inc/cabletermination.html' with termination=po.get_cable_peer %}
{% else %} {% else %}
<td colspan="3"> <td><span class="text-muted">Not connected</span></td>
<span class="text-muted">Not connected</span>
</td>
{% endif %} {% endif %}
{# Connection #} {# Connection #}

View File

@ -40,11 +40,8 @@
<i class="fa fa-share-alt" aria-hidden="true"></i> <i class="fa fa-share-alt" aria-hidden="true"></i>
</a> </a>
</td> </td>
{% include 'dcim/inc/cabletermination.html' with termination=pp.get_cable_peer %}
{% else %} {% else %}
<td colspan="3"> <td><span class="text-muted">Not connected</span></td>
<span class="text-muted">Not connected</span>
</td>
{% endif %} {% endif %}
{# Connection #} {# Connection #}

View File

@ -58,7 +58,7 @@
{% block content %} {% block content %}
<div class="row"> <div class="row">
<div class="col-md-3"> <div class="col-md-6">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<strong>Power Panel</strong> <strong>Power Panel</strong>
@ -82,17 +82,17 @@
</tr> </tr>
</table> </table>
</div> </div>
{% include 'inc/custom_fields_panel.html' with obj=powerpanel %}
{% include 'extras/inc/tags_panel.html' with tags=powerpanel.tags.all url='dcim:powerpanel_list' %}
{% plugin_left_page powerpanel %} {% plugin_left_page powerpanel %}
</div> </div>
<div class="col-md-9"> <div class="col-md-6">
{% include 'panel_table.html' with table=powerfeed_table heading='Connected Feeds' %} {% include 'inc/custom_fields_panel.html' with obj=powerpanel %}
{% include 'extras/inc/tags_panel.html' with tags=powerpanel.tags.all url='dcim:powerpanel_list' %}
{% plugin_right_page powerpanel %} {% plugin_right_page powerpanel %}
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
{% include 'panel_table.html' with table=powerfeed_table heading='Connected Feeds' %}
{% plugin_full_width_page powerpanel %} {% plugin_full_width_page powerpanel %}
</div> </div>
</div> </div>