Browse Source

Fixes #61: Added list of RackGroups to Site view

Jeremy Stretch 8 years ago
parent
commit
8b357a311d
2 changed files with 22 additions and 1 deletions
  1. 2 0
      netbox/dcim/views.py
  2. 20 1
      netbox/templates/dcim/site.html

+ 2 - 0
netbox/dcim/views.py

@@ -75,11 +75,13 @@ def site(request, slug):
         'vlan_count': VLAN.objects.filter(site=site).count(),
         'vlan_count': VLAN.objects.filter(site=site).count(),
         'circuit_count': Circuit.objects.filter(site=site).count(),
         'circuit_count': Circuit.objects.filter(site=site).count(),
     }
     }
+    rack_groups = RackGroup.objects.filter(site=site).annotate(rack_count=Count('racks'))
     topology_maps = TopologyMap.objects.filter(site=site)
     topology_maps = TopologyMap.objects.filter(site=site)
 
 
     return render(request, 'dcim/site.html', {
     return render(request, 'dcim/site.html', {
         'site': site,
         'site': site,
         'stats': stats,
         'stats': stats,
+        'rack_groups': rack_groups,
         'topology_maps': topology_maps,
         'topology_maps': topology_maps,
     })
     })
 
 

+ 20 - 1
netbox/templates/dcim/site.html

@@ -126,13 +126,32 @@
         </div>
         </div>
         <div class="panel panel-default">
         <div class="panel panel-default">
             <div class="panel-heading">
             <div class="panel-heading">
+                <strong>Rack Groups</strong>
+            </div>
+            {% if rack_groups %}
+                <table class="table table-hover panel-body">
+                    {% for rg in rack_groups %}
+                        <tr>
+                            <td><i class="fa fa-fw fa-folder"></i> <a href="{{ rg.get_absolute_url }}">{{ rg.name }}</a></td>
+                            <td>{{ rg.rack_count }}</td>
+                        </tr>
+                    {% endfor %}
+                </table>
+            {% else %}
+                <div class="panel-body text-muted">
+                    None
+                </div>
+            {% endif %}
+        </div>
+        <div class="panel panel-default">
+            <div class="panel-heading">
                 <strong>Topology Maps</strong>
                 <strong>Topology Maps</strong>
             </div>
             </div>
             {% if topology_maps %}
             {% if topology_maps %}
                 <table class="table table-hover panel-body">
                 <table class="table table-hover panel-body">
                     {% for tm in topology_maps %}
                     {% for tm in topology_maps %}
                         <tr>
                         <tr>
-                            <td><i class="fa fa-fw fa-map text-success"></i> <a href="{% url 'dcim-api:topology_map' slug=tm.slug %}" target="_blank">{{ tm }}</a></td>
+                            <td><i class="fa fa-fw fa-map"></i> <a href="{% url 'dcim-api:topology_map' slug=tm.slug %}" target="_blank">{{ tm }}</a></td>
                             <td>{{ tm.description }}</td>
                             <td>{{ tm.description }}</td>
                         </tr>
                         </tr>
                     {% endfor %}
                     {% endfor %}