Browse Source

Added 'recent activity' panel to home view

Jeremy Stretch 9 years ago
parent
commit
199bc57932
2 changed files with 31 additions and 15 deletions
  1. 2 0
      netbox/netbox/views.py
  2. 29 15
      netbox/templates/home.html

+ 2 - 0
netbox/netbox/views.py

@@ -2,6 +2,7 @@ from django.shortcuts import render
 
 
 from circuits.models import Provider, Circuit
 from circuits.models import Provider, Circuit
 from dcim.models import Site, Rack, Device, ConsolePort, PowerPort, InterfaceConnection
 from dcim.models import Site, Rack, Device, ConsolePort, PowerPort, InterfaceConnection
+from extras.models import UserAction
 from ipam.models import Aggregate, Prefix, IPAddress, VLAN
 from ipam.models import Aggregate, Prefix, IPAddress, VLAN
 from secrets.models import Secret
 from secrets.models import Secret
 
 
@@ -35,6 +36,7 @@ def home(request):
 
 
     return render(request, 'home.html', {
     return render(request, 'home.html', {
         'stats': stats,
         'stats': stats,
+        'recent_activity': UserAction.objects.all()[:20]
     })
     })
 
 
 
 

+ 29 - 15
netbox/templates/home.html

@@ -79,6 +79,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-md-4">
     <div class="col-md-4">
         <div class="panel panel-default">
         <div class="panel panel-default">
@@ -108,8 +122,6 @@
                 </div>
                 </div>
             </div>
             </div>
         </div>
         </div>
-    </div>
-    <div class="col-md-4">
         <div class="panel panel-default">
         <div class="panel panel-default">
             <div class="panel-heading">
             <div class="panel-heading">
                 <strong>Circuits</strong>
                 <strong>Circuits</strong>
@@ -127,20 +139,22 @@
                 </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>
+    <div class="col-md-4">
+        <div class="panel panel-default">
+            <div class="panel-heading">
+                <strong>Recent Activity</strong>
             </div>
             </div>
-        {% endif %}
+            <table class="table table-hover panel-body">
+                {% for a in recent_activity %}
+                    <tr>
+                        <td>{{ a.time|date:"Y-m-d H:i" }}</td>
+                        <td>{{ a.user }}</td>
+                        <td>{{ a.message|safe }}</td>
+                    </tr>
+                {% endfor %}
+            </table>
+        </div>
     </div>
     </div>
 </div>
 </div>
 {% endblock %}
 {% endblock %}