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

Extend device view to show local cable termination for all components

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

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

@@ -506,6 +506,7 @@
                                         <th>MTU</th>
                                         <th>MTU</th>
                                         <th>Mode</th>
                                         <th>Mode</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>
@@ -566,7 +567,7 @@
                                         <th>Position</th>
                                         <th>Position</th>
                                         <th>Description</th>
                                         <th>Description</th>
                                         <th>Cable</th>
                                         <th>Cable</th>
-                                        <th colspan="2">Connection</th>
+                                        <th colspan="2">Cable Termination</th>
                                         <th></th>
                                         <th></th>
                                     </tr>
                                     </tr>
                                 </thead>
                                 </thead>
@@ -623,7 +624,7 @@
                                         <th>Positions</th>
                                         <th>Positions</th>
                                         <th>Description</th>
                                         <th>Description</th>
                                         <th>Cable</th>
                                         <th>Cable</th>
-                                        <th colspan="2">Connection</th>
+                                        <th colspan="2">Cable Termination</th>
                                         <th></th>
                                         <th></th>
                                     </tr>
                                     </tr>
                                 </thead>
                                 </thead>
@@ -679,6 +680,7 @@
                                         <th>Type</th>
                                         <th>Type</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>
@@ -732,6 +734,7 @@
                                         <th>Type</th>
                                         <th>Type</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>
@@ -789,6 +792,7 @@
                                         <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>
@@ -843,6 +847,7 @@
                                         <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>

+ 14 - 0
netbox/templates/dcim/inc/cabletermination.html

@@ -0,0 +1,14 @@
+<td>
+    {% if termination.parent.provider %}
+        <i class="fa fa-fw fa-globe" title="Circuit"></i>
+        <a href="{{ termination.parent.get_absolute_url }}">
+            {{ termination.parent.provider }}
+            {{ termination.parent }}
+        </a>
+    {% else %}
+        <a href="{{ termination.parent.get_absolute_url }}">{{ termination.parent }}</a>
+    {% endif %}
+</td>
+<td>
+    <a href="{{ termination.get_absolute_url }}">{{ termination }}</a>
+</td>

+ 9 - 6
netbox/templates/dcim/inc/consoleport.html

@@ -24,16 +24,19 @@
     </td>
     </td>
 
 
     {# Cable #}
     {# Cable #}
-    <td>
-        {% if cp.cable %}
+    {% if cp.cable %}
+        <td>
             <a href="{{ cp.cable.get_absolute_url }}">{{ cp.cable }}</a>
             <a href="{{ cp.cable.get_absolute_url }}">{{ cp.cable }}</a>
             <a href="{% url 'dcim:consoleport_trace' pk=cp.pk %}" class="btn btn-primary btn-xs" title="Trace">
             <a href="{% url 'dcim:consoleport_trace' pk=cp.pk %}" class="btn btn-primary btn-xs" title="Trace">
                 <i class="fa fa-share-alt" aria-hidden="true"></i>
                 <i class="fa fa-share-alt" aria-hidden="true"></i>
             </a>
             </a>
-        {% else %}
-            &mdash;
-        {% endif %}
-    </td>
+        </td>
+        {% include 'dcim/inc/cabletermination.html' with termination=cp.get_cable_peer %}
+    {% else %}
+        <td colspan="3">
+            <span class="text-muted">Not connected</span>
+        </td>
+    {% endif %}
 
 
     {# Connection #}
     {# Connection #}
     {% include 'dcim/inc/endpoint_connection.html' with path=cp.path %}
     {% include 'dcim/inc/endpoint_connection.html' with path=cp.path %}

+ 9 - 6
netbox/templates/dcim/inc/consoleserverport.html

@@ -26,16 +26,19 @@
     </td>
     </td>
 
 
     {# Cable #}
     {# Cable #}
-    <td class="text-nowrap">
-        {% if csp.cable %}
+    {% if csp.cable %}
+        <td>
             <a href="{{ csp.cable.get_absolute_url }}">{{ csp.cable }}</a>
             <a href="{{ csp.cable.get_absolute_url }}">{{ csp.cable }}</a>
             <a href="{% url 'dcim:consoleserverport_trace' pk=csp.pk %}" class="btn btn-primary btn-xs" title="Trace">
             <a href="{% url 'dcim:consoleserverport_trace' pk=csp.pk %}" class="btn btn-primary btn-xs" title="Trace">
                 <i class="fa fa-share-alt" aria-hidden="true"></i>
                 <i class="fa fa-share-alt" aria-hidden="true"></i>
             </a>
             </a>
-        {% else %}
-            <span class="text-muted">&mdash;</span>
-        {% endif %}
-    </td>
+        </td>
+        {% include 'dcim/inc/cabletermination.html' with termination=csp.get_cable_peer %}
+    {% else %}
+        <td colspan="3">
+            <span class="text-muted">Not connected</span>
+        </td>
+    {% endif %}
 
 
     {# Connection #}
     {# Connection #}
     {% include 'dcim/inc/endpoint_connection.html' with path=csp.path %}
     {% include 'dcim/inc/endpoint_connection.html' with path=csp.path %}

+ 1 - 16
netbox/templates/dcim/inc/frontport.html

@@ -32,22 +32,7 @@
                 <i class="fa fa-share-alt" aria-hidden="true"></i>
                 <i class="fa fa-share-alt" aria-hidden="true"></i>
             </a>
             </a>
         </td>
         </td>
-        {% with far_end=frontport.get_cable_peer %}
-            <td>
-                {% if far_end.parent.provider %}
-                    <i class="fa fa-fw fa-globe" title="Circuit"></i>
-                    <a href="{{ far_end.parent.get_absolute_url }}">
-                        {{ far_end.parent.provider }}
-                        {{ far_end.parent }}
-                    </a>
-                {% else %}
-                    <a href="{{ far_end.parent.get_absolute_url }}">
-                        {{ far_end.parent }}
-                    </a>
-                {% endif %}
-            </td>
-            <td>{{ far_end }}</td>
-        {% endwith %}
+        {% include 'dcim/inc/cabletermination.html' with termination=frontport.get_cable_peer %}
     {% else %}
     {% else %}
         <td colspan="3">
         <td colspan="3">
             <span class="text-muted">Not connected</span>
             <span class="text-muted">Not connected</span>

+ 9 - 9
netbox/templates/dcim/inc/interface.html

@@ -45,19 +45,19 @@
     <td>{{ iface.get_mode_display|default:"&mdash;" }}</td>
     <td>{{ iface.get_mode_display|default:"&mdash;" }}</td>
 
 
     {# Cable #}
     {# Cable #}
-    <td class="text-nowrap">
-        {% if iface.cable %}
+    {% if iface.cable %}
+        <td>
             <a href="{{ iface.cable.get_absolute_url }}">{{ iface.cable }}</a>
             <a href="{{ iface.cable.get_absolute_url }}">{{ iface.cable }}</a>
-            {% if iface.cable.color %}
-            <span class="inline-color-block" style="background-color: #{{ iface.cable.color }}">&nbsp;</span>
-            {% endif %}
             <a href="{% url 'dcim:interface_trace' pk=iface.pk %}" class="btn btn-primary btn-xs" title="Trace">
             <a href="{% url 'dcim:interface_trace' pk=iface.pk %}" class="btn btn-primary btn-xs" title="Trace">
                 <i class="fa fa-share-alt" aria-hidden="true"></i>
                 <i class="fa fa-share-alt" aria-hidden="true"></i>
             </a>
             </a>
-        {% else %}
-            <span class="text-muted">&mdash;</span>
-        {% endif %}
-    </td>
+        </td>
+        {% include 'dcim/inc/cabletermination.html' with termination=iface.get_cable_peer %}
+    {% else %}
+        <td colspan="3">
+            <span class="text-muted">Not connected</span>
+        </td>
+    {% endif %}
 
 
     {# Connection or type #}
     {# Connection or type #}
     {% if iface.is_lag %}
     {% if iface.is_lag %}

+ 9 - 6
netbox/templates/dcim/inc/poweroutlet.html

@@ -37,16 +37,19 @@
     </td>
     </td>
 
 
     {# Cable #}
     {# Cable #}
-    <td class="text-nowrap">
-        {% if po.cable %}
+    {% if po.cable %}
+        <td>
             <a href="{{ po.cable.get_absolute_url }}">{{ po.cable }}</a>
             <a href="{{ po.cable.get_absolute_url }}">{{ po.cable }}</a>
             <a href="{% url 'dcim:poweroutlet_trace' pk=po.pk %}" class="btn btn-primary btn-xs" title="Trace">
             <a href="{% url 'dcim:poweroutlet_trace' pk=po.pk %}" class="btn btn-primary btn-xs" title="Trace">
                 <i class="fa fa-share-alt" aria-hidden="true"></i>
                 <i class="fa fa-share-alt" aria-hidden="true"></i>
             </a>
             </a>
-        {% else %}
-            <span class="text-muted">&mdash;</span>
-        {% endif %}
-    </td>
+        </td>
+        {% include 'dcim/inc/cabletermination.html' with termination=po.get_cable_peer %}
+    {% else %}
+        <td colspan="3">
+            <span class="text-muted">Not connected</span>
+        </td>
+    {% endif %}
 
 
     {# Connection #}
     {# Connection #}
     {% with path=po.path %}
     {% with path=po.path %}

+ 9 - 6
netbox/templates/dcim/inc/powerport.html

@@ -33,16 +33,19 @@
     </td>
     </td>
 
 
     {# Cable #}
     {# Cable #}
-    <td>
-        {% if pp.cable %}
+    {% if pp.cable %}
+        <td>
             <a href="{{ pp.cable.get_absolute_url }}">{{ pp.cable }}</a>
             <a href="{{ pp.cable.get_absolute_url }}">{{ pp.cable }}</a>
             <a href="{% url 'dcim:powerport_trace' pk=pp.pk %}" class="btn btn-primary btn-xs" title="Trace">
             <a href="{% url 'dcim:powerport_trace' pk=pp.pk %}" class="btn btn-primary btn-xs" title="Trace">
                 <i class="fa fa-share-alt" aria-hidden="true"></i>
                 <i class="fa fa-share-alt" aria-hidden="true"></i>
             </a>
             </a>
-        {% else %}
-            &mdash;
-        {% endif %}
-    </td>
+        </td>
+        {% include 'dcim/inc/cabletermination.html' with termination=pp.get_cable_peer %}
+    {% else %}
+        <td colspan="3">
+            <span class="text-muted">Not connected</span>
+        </td>
+    {% endif %}
 
 
     {# Connection #}
     {# Connection #}
     {% include 'dcim/inc/endpoint_connection.html' with path=pp.path %}
     {% include 'dcim/inc/endpoint_connection.html' with path=pp.path %}

+ 1 - 16
netbox/templates/dcim/inc/rearport.html

@@ -31,22 +31,7 @@
                 <i class="fa fa-share-alt" aria-hidden="true"></i>
                 <i class="fa fa-share-alt" aria-hidden="true"></i>
             </a>
             </a>
         </td>
         </td>
-        {% with far_end=rearport.get_cable_peer %}
-            <td>
-                {% if far_end.parent.provider %}
-                    <i class="fa fa-fw fa-globe" title="Circuit"></i>
-                    <a href="{{ far_end.parent.get_absolute_url }}">
-                        {{ far_end.parent.provider }}
-                        {{ far_end.parent }}
-                    </a>
-                {% else %}
-                    <a href="{{ far_end.parent.get_absolute_url }}">
-                        {{ far_end.parent }}
-                    </a>
-                {% endif %}
-            </td>
-            <td>{{ far_end }}</td>
-        {% endwith %}
+        {% include 'dcim/inc/cabletermination.html' with termination=rearport.get_cable_peer %}
     {% else %}
     {% else %}
         <td colspan="3">
         <td colspan="3">
             <span class="text-muted">Not connected</span>
             <span class="text-muted">Not connected</span>