Parcourir la source

Fixes #1721: Differentiated child IP count from utilization percentage for prefixes

Jeremy Stretch il y a 7 ans
Parent
commit
40ab272995

+ 0 - 4
netbox/ipam/views.py

@@ -454,9 +454,6 @@ class PrefixView(View):
         except Aggregate.DoesNotExist:
             aggregate = None
 
-        # Count child IP addresses
-        ipaddress_count = prefix.get_child_ips().count()
-
         # Parent prefixes table
         parent_prefixes = Prefix.objects.filter(
             Q(vrf=prefix.vrf) | Q(vrf__isnull=True)
@@ -507,7 +504,6 @@ class PrefixView(View):
         return render(request, 'ipam/prefix.html', {
             'prefix': prefix,
             'aggregate': aggregate,
-            'ipaddress_count': ipaddress_count,
             'parent_prefix_table': parent_prefix_table,
             'child_prefix_table': child_prefix_table,
             'duplicate_prefix_table': duplicate_prefix_table,

+ 1 - 1
netbox/templates/ipam/inc/prefix_header.html

@@ -45,5 +45,5 @@
 {% include 'inc/created_updated.html' with obj=prefix %}
 <ul class="nav nav-tabs" style="margin-bottom: 20px">
     <li role="presentation"{% if active_tab == 'prefix' %} class="active"{% endif %}><a href="{% url 'ipam:prefix' pk=prefix.pk %}">Prefix</a></li>
-    <li role="presentation"{% if active_tab == 'ip-addresses' %} class="active"{% endif %}><a href="{% url 'ipam:prefix_ipaddresses' pk=prefix.pk %}">IP Addresses</a></li>
+    <li role="presentation"{% if active_tab == 'ip-addresses' %} class="active"{% endif %}><a href="{% url 'ipam:prefix_ipaddresses' pk=prefix.pk %}">IP Addresses <span class="badge">{{ prefix.get_child_ips.count }}</span></a></li>
 </ul>

+ 10 - 9
netbox/templates/ipam/prefix.html

@@ -1,4 +1,5 @@
 {% extends '_base.html' %}
+{% load helpers %}
 
 {% block title %}{{ prefix }}{% endblock %}
 
@@ -101,28 +102,28 @@
                     </td>
                 </tr>
                 <tr>
-                    <td>Is a pool</td>
+                    <td>Description</td>
                     <td>
-                        {% if prefix.is_pool %}
-                            <i class="glyphicon glyphicon-ok text-success" title="Yes"></i>
+                        {% if prefix.description %}
+                            <span>{{ prefix.description }}</span>
                         {% else %}
-                            <i class="glyphicon glyphicon-remove text-danger" title="No"></i>
+                            <span class="text-muted">N/A</span>
                         {% endif %}
                     </td>
                 </tr>
                 <tr>
-                    <td>Description</td>
+                    <td>Is a pool</td>
                     <td>
-                        {% if prefix.description %}
-                            <span>{{ prefix.description }}</span>
+                        {% if prefix.is_pool %}
+                            <i class="glyphicon glyphicon-ok text-success" title="Yes"></i>
                         {% else %}
-                            <span class="text-muted">N/A</span>
+                            <i class="glyphicon glyphicon-remove text-danger" title="No"></i>
                         {% endif %}
                     </td>
                 </tr>
                 <tr>
                     <td>Utilization</td>
-                    <td><a href="{% url 'ipam:prefix_ipaddresses' pk=prefix.pk %}">{{ ipaddress_count }} IP addresses</a> ({{ prefix.get_utilization }}%)</td>
+                    <td>{% utilization_graph prefix.get_utilization %}</td>
                 </tr>
             </table>
         </div>