Просмотр исходного кода

Clean up power connection tables

Jeremy Stretch 5 лет назад
Родитель
Сommit
c813ae4f04

+ 25 - 2
netbox/dcim/tables.py

@@ -67,6 +67,19 @@ INTERFACE_TAGGED_VLANS = """
 {% 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
@@ -977,6 +990,15 @@ class PowerFeedTable(BaseTable):
     max_utilization = tables.TemplateColumn(
         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(
         verbose_name='Available power (VA)'
     )
@@ -988,8 +1010,9 @@ class PowerFeedTable(BaseTable):
         model = PowerFeed
         fields = (
             '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 = (
-            'pk', 'name', 'power_panel', 'rack', 'status', 'type', 'supply', 'voltage', 'amperage', 'phase',
+            'pk', 'name', 'power_panel', 'rack', 'status', 'type', 'supply', 'voltage', 'amperage', 'phase', 'cable',
+            'connection',
         )

+ 0 - 2
netbox/templates/dcim/device.html

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

+ 1 - 4
netbox/templates/dcim/inc/poweroutlet.html

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

+ 1 - 4
netbox/templates/dcim/inc/powerport.html

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

+ 5 - 5
netbox/templates/dcim/powerpanel.html

@@ -58,7 +58,7 @@
 
 {% block content %}
 <div class="row">
-	<div class="col-md-3">
+	<div class="col-md-6">
         <div class="panel panel-default">
             <div class="panel-heading">
                 <strong>Power Panel</strong>
@@ -82,17 +82,17 @@
                 </tr>
             </table>
         </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 %}
     </div>
-	<div class="col-md-9">
-        {% include 'panel_table.html' with table=powerfeed_table heading='Connected Feeds' %}
+	<div class="col-md-6">
+        {% 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 %}
     </div>
 </div>
 <div class="row">
     <div class="col-md-12">
+        {% include 'panel_table.html' with table=powerfeed_table heading='Connected Feeds' %}
         {% plugin_full_width_page powerpanel %}
     </div>
 </div>