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

Closes #578: Show topology maps not assigned to a site on the home view

Jeremy Stretch 8 лет назад
Родитель
Сommit
4accdf77f8
3 измененных файлов с 36 добавлено и 16 удалено
  1. 2 1
      netbox/netbox/views.py
  2. 2 2
      netbox/templates/dcim/site.html
  3. 32 13
      netbox/templates/home.html

+ 2 - 1
netbox/netbox/views.py

@@ -13,7 +13,7 @@ from circuits.tables import CircuitSearchTable, ProviderSearchTable
 from dcim.filters import DeviceFilter, DeviceTypeFilter, RackFilter, SiteFilter
 from dcim.filters import DeviceFilter, DeviceTypeFilter, RackFilter, SiteFilter
 from dcim.models import ConsolePort, Device, DeviceType, InterfaceConnection, PowerPort, Rack, Site
 from dcim.models import ConsolePort, Device, DeviceType, InterfaceConnection, PowerPort, Rack, Site
 from dcim.tables import DeviceSearchTable, DeviceTypeSearchTable, RackSearchTable, SiteSearchTable
 from dcim.tables import DeviceSearchTable, DeviceTypeSearchTable, RackSearchTable, SiteSearchTable
-from extras.models import UserAction
+from extras.models import TopologyMap, UserAction
 from ipam.filters import AggregateFilter, IPAddressFilter, PrefixFilter, VLANFilter, VRFFilter
 from ipam.filters import AggregateFilter, IPAddressFilter, PrefixFilter, VLANFilter, VRFFilter
 from ipam.models import Aggregate, IPAddress, Prefix, VLAN, VRF
 from ipam.models import Aggregate, IPAddress, Prefix, VLAN, VRF
 from ipam.tables import AggregateSearchTable, IPAddressSearchTable, PrefixSearchTable, VLANSearchTable, VRFSearchTable
 from ipam.tables import AggregateSearchTable, IPAddressSearchTable, PrefixSearchTable, VLANSearchTable, VRFSearchTable
@@ -148,6 +148,7 @@ def home(request):
     return render(request, 'home.html', {
     return render(request, 'home.html', {
         'search_form': SearchForm(),
         'search_form': SearchForm(),
         'stats': stats,
         'stats': stats,
+        'topology_maps': TopologyMap.objects.filter(site__isnull=True),
         'recent_activity': UserAction.objects.select_related('user')[:50]
         'recent_activity': UserAction.objects.select_related('user')[:50]
     })
     })
 
 

+ 2 - 2
netbox/templates/dcim/site.html

@@ -224,7 +224,7 @@
                 <table class="table table-hover panel-body">
                 <table class="table table-hover panel-body">
                     {% for rg in rack_groups %}
                     {% for rg in rack_groups %}
                         <tr>
                         <tr>
-                            <td><i class="fa fa-fw fa-folder"></i> <a href="{{ rg.get_absolute_url }}">{{ rg.name }}</a></td>
+                            <td><i class="fa fa-fw fa-folder-o"></i> <a href="{{ rg.get_absolute_url }}">{{ rg.name }}</a></td>
                             <td>{{ rg.rack_count }}</td>
                             <td>{{ rg.rack_count }}</td>
                         </tr>
                         </tr>
                     {% endfor %}
                     {% endfor %}
@@ -257,7 +257,7 @@
                 <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"></i> <a href="{% url 'extras-api:topologymap-render' pk=tm.pk %}" target="_blank">{{ tm }}</a></td>
+                            <td><i class="fa fa-fw fa-map-o"></i> <a href="{% url 'extras-api:topologymap-render' pk=tm.pk %}" target="_blank">{{ tm }}</a></td>
                             <td>{{ tm.description }}</td>
                             <td>{{ tm.description }}</td>
                         </tr>
                         </tr>
                     {% endfor %}
                     {% endfor %}

+ 32 - 13
netbox/templates/home.html

@@ -48,6 +48,20 @@
                 </div>
                 </div>
             </div>
             </div>
         </div>
         </div>
+        {% if perms.secrets %}
+            <div class="panel panel-default">
+                <div class="panel-heading">
+                    <strong>Secrets</strong>
+                </div>
+                <div class="list-group">
+                    <div class="list-group-item">
+                        <span class="badge pull-right">{{ stats.secret_count }}</span>
+                        <h4 class="list-group-item-heading"><a href="{% url 'secrets:secret_list' %}">Secrets</a></h4>
+                        <p class="list-group-item-text text-muted">Sensitive data (such as passwords) which has been stored securely</p>
+                    </div>
+                </div>
+            </div>
+        {% endif %}
     </div>
     </div>
     <div class="col-sm-6 col-md-4">
     <div class="col-sm-6 col-md-4">
         <div class="panel panel-default">
         <div class="panel panel-default">
@@ -101,20 +115,25 @@
         </div>
         </div>
     </div>
     </div>
     <div class="col-sm-6 col-md-4">
     <div class="col-sm-6 col-md-4">
-        {% if perms.secrets %}
-            <div class="panel panel-default">
-                <div class="panel-heading">
-                    <strong>Secrets</strong>
-                </div>
-                <div class="list-group">
-                    <div class="list-group-item">
-                        <span class="badge pull-right">{{ stats.secret_count }}</span>
-                        <h4 class="list-group-item-heading"><a href="{% url 'secrets:secret_list' %}">Secrets</a></h4>
-                        <p class="list-group-item-text text-muted">Sensitive data (such as passwords) which has been stored securely</p>
-                    </div>
-                </div>
+        <div class="panel panel-default">
+            <div class="panel-heading">
+                <strong>Global Topology Maps</strong>
             </div>
             </div>
-        {% endif %}
+            {% if topology_maps %}
+                <table class="table table-hover panel-body">
+                    {% for tm in topology_maps %}
+                        <tr>
+                            <td><i class="fa fa-fw fa-map-o"></i> <a href="{% url 'extras-api:topologymap-render' pk=tm.pk %}" target="_blank">{{ tm }}</a></td>
+                            <td>{{ tm.description }}</td>
+                        </tr>
+                    {% endfor %}
+                </table>
+            {% else %}
+                <div class="panel-body text-muted">
+                    None
+                </div>
+            {% endif %}
+        </div>
         <div class="panel panel-default">
         <div class="panel panel-default">
             <div class="panel-heading">
             <div class="panel-heading">
                 <strong>Recent Activity</strong>
                 <strong>Recent Activity</strong>