Prechádzať zdrojové kódy

undo home template path change

checktheroads 4 rokov pred
rodič
commit
d7d004b48e

+ 1 - 1
netbox/netbox/views/__init__.py

@@ -30,7 +30,7 @@ from virtualization.models import Cluster, VirtualMachine
 
 
 
 
 class HomeView(View):
 class HomeView(View):
-    template_name = 'pages/home.html'
+    template_name = 'home.html'
 
 
     def get(self, request):
     def get(self, request):
         if settings.LOGIN_REQUIRED and not request.user.is_authenticated:
         if settings.LOGIN_REQUIRED and not request.user.is_authenticated:

+ 45 - 299
netbox/templates/home.html

@@ -1,309 +1,55 @@
-{% extends 'layout.html' %} {% load helpers %} {% block header %} 
-{{ block.super }} {% if new_release %} {# new_release is set only if the current user is a superuser or staff member #}
-<div class="alert alert-info text-center" role="alert">
-  <i class="mdi mdi-information-outline"></i>
-  A new release is available:
-  <a href="{{ new_release.url }}">NetBox v{{ new_release.version }}</a> |
-  <a href="https://netbox.readthedocs.io/en/stable/installation/upgrading/"
-    >Upgrade instructions</a
-  >
-</div>
-{% endif %} {% endblock %} {%block title %} Home {% endblock %}
-{% block content %} {% include 'search_form.html' %}
-<div class="row">
-    <div class="col-sm-6 col-md-4">
-        <div class="panel panel-default">
-            <div class="panel-heading">
-                <strong>Organization</strong>
-            </div>
-            <div class="list-group">
-                <div class="list-group-item">
-                    {% if perms.dcim.view_site %}
-                        <span class="badge pull-right">{{ stats.site_count }}</span>
-                        <h4 class="list-group-item-heading"><a href="{% url 'dcim:site_list' %}">Sites</a></h4>
-                    {% else %}
-                        <span class="badge pull-right"><i class="mdi mdi-lock"></i></span>
-                        <h4 class="list-group-item-heading">Sites</h4>
-                    {% endif %}
-                    <p class="list-group-item-text text-muted">Discrete points of presence</p>
-                </div>
-                <div class="list-group-item">
-                    {% if perms.dcim.view_location %}
-                        <span class="badge pull-right">{{ stats.location_count }}</span>
-                        <h4 class="list-group-item-heading"><a href="{% url 'dcim:location_list' %}">Locations</a></h4>
-                    {% else %}
-                        <span class="badge pull-right"><i class="mdi mdi-lock"></i></span>
-                        <h4 class="list-group-item-heading">Locations</h4>
-                    {% endif %}
-                    <p class="list-group-item-text text-muted">Locations within sites</p>
-                </div>
-                <div class="list-group-item">
-                    {% if perms.tenancy.view_tenant %}
-                        <span class="badge pull-right">{{ stats.tenant_count }}</span>
-                        <h4 class="list-group-item-heading"><a href="{% url 'tenancy:tenant_list' %}">Tenants</a></h4>
-                    {% else %}
-                        <span class="badge pull-right"><i class="mdi mdi-lock"></i></span>
-                        <h4 class="list-group-item-heading">Tenants</h4>
-                    {% endif %}
-                        <p class="list-group-item-text text-muted">Customers or departments</p>
-                    </div>
-            </div>
-        </div>
-        <div class="list-group-item">
-          {% if perms.ipam.view_prefix %}
-          <span class="badge pull-right">{{ stats.prefix_count }}</span>
-          <h4 class="list-group-item-heading">
-            <a href="{% url 'ipam:prefix_list' %}">Prefixes</a>
-          </h4>
-          {% else %}
-          <span class="badge pull-right"><i class="mdi mdi-lock"></i></span>
-          <h4 class="list-group-item-heading">Prefixes</h4>
-          {% endif %}
-          <p class="list-group-item-text text-muted">
-            IPv4 and IPv6 network assignments
-          </p>
-        </div>
-        <div class="list-group-item">
-          {% if perms.ipam.view_ipaddress %}
-          <span class="badge pull-right">{{ stats.ipaddress_count }}</span>
-          <h4 class="list-group-item-heading">
-            <a href="{% url 'ipam:ipaddress_list' %}">IP Addresses</a>
-          </h4>
-          {% else %}
-          <span class="badge pull-right"><i class="mdi mdi-lock"></i></span>
-          <h4 class="list-group-item-heading">IP Addresses</h4>
-          {% endif %}
-          <p class="list-group-item-text text-muted">
-            Individual IPv4 and IPv6 addresses
-          </p>
-        </div>
-        <div class="list-group-item">
-          {% if perms.ipam.view_vlan %}
-          <span class="badge pull-right">{{ stats.vlan_count }}</span>
-          <h4 class="list-group-item-heading">
-            <a href="{% url 'ipam:vlan_list' %}">VLANs</a>
-          </h4>
-          {% else %}
-          <span class="badge pull-right"><i class="mdi mdi-lock"></i></span>
-          <h4 class="list-group-item-heading">VLANs</h4>
-          {% endif %}
-          <p class="list-group-item-text text-muted">
-            Layer two domains, identified by VLAN ID
-          </p>
-        </div>
-      </div>
-    </div>
-    <div class="panel panel-default">
-      <div class="panel-heading">
-        <strong>Circuits</strong>
-      </div>
-      <div class="list-group">
-        <div class="list-group-item">
-          {% if perms.circuits.view_provider %}
-          <span class="badge pull-right">{{ stats.provider_count }}</span>
-          <h4 class="list-group-item-heading">
-            <a href="{% url 'circuits:provider_list' %}">Providers</a>
-          </h4>
-          {% else %}
-          <span class="badge pull-right"><i class="mdi mdi-lock"></i></span>
-          <h4 class="list-group-item-heading">Providers</h4>
-          {% endif %}
-          <p class="list-group-item-text text-muted">
-            Organizations which provide circuit connectivity
-          </p>
-        </div>
-        <div class="list-group-item">
-          {% if perms.circuits.view_circuit %}
-          <span class="badge pull-right">{{ stats.circuit_count }}</span>
-          <h4 class="list-group-item-heading">
-            <a href="{% url 'circuits:circuit_list' %}">Circuits</a>
-          </h4>
-          {% else %}
-          <span class="badge pull-right"><i class="mdi mdi-lock"></i></span>
-          <h4 class="list-group-item-heading">Circuits</h4>
-          {% endif %}
-          <p class="list-group-item-text text-muted">
-            Communication links for Internet transit, peering, and other
-            services
-          </p>
-        </div>
-      </div>
-    </div>
-    <div class="panel panel-default">
-      <div class="panel-heading">
-        <strong>Virtualization</strong>
-      </div>
-      <div class="list-group">
-        <div class="list-group-item">
-          {% if perms.virtualization.view_cluster %}
-          <span class="badge pull-right">{{ stats.cluster_count }}</span>
-          <h4 class="list-group-item-heading">
-            <a href="{% url 'virtualization:cluster_list' %}">Clusters</a>
-          </h4>
-          {% else %}
-          <span class="badge pull-right"><i class="mdi mdi-lock"></i></span>
-          <h4 class="list-group-item-heading">Clusters</h4>
-          {% endif %}
-          <p class="list-group-item-text text-muted">
-            Clusters of physical hosts in which VMs reside
-          </p>
-        </div>
-        <div class="list-group-item">
-          {% if perms.virtualization.view_virtualmachine %}
-          <span class="badge pull-right">{{ stats.virtualmachine_count }}</span>
-          <h4 class="list-group-item-heading">
-            <a href="{% url 'virtualization:virtualmachine_list' %}"
-              >Virtual Machines</a
+{% extends 'layout.html' %} {% load helpers %} {%block title %} Home
+{%endblock%} {% block content %}
+
+<div class="stats-container">
+  <div class="row row-cols-auto masonry">
+    {% for section in stats %}
+    <div class="col col-4 my-2 masonry-item">
+      <div class="card">
+        <h5 class="card-header text-primary">{{ section.label }}</h5>
+        <div class="card-body">
+          <div class="list-group list-group-flush">
+            {% for item in section.items %}
+            <a
+              href="{% url item.url %}"
+              class="list-group-item list-group-item-action"
             >
             >
-          </h4>
-          {% else %}
-          <span class="badge pull-right"><i class="mdi mdi-lock"></i></span>
-          <h4 class="list-group-item-heading">Virtual Machines</h4>
-          {% endif %}
-          <p class="list-group-item-text text-muted">
-            Virtual compute instances running inside clusters
-          </p>
+              <div
+                class="d-flex w-100 justify-content-between align-items-center"
+              >
+                <div class="d-flex flex-column align-items-start">
+                  <h6 class="mb-1">{{ item.label }}</h6>
+                  {% if item.description %}
+                  <small class="mb-1 text-muted">{{ item.description }}</small>
+                  {% endif %}
+                </div>
+
+                <span class="badge bg-secondary rounded-pill"
+                  >{{ item.count }}</span
+                >
+              </div>
+            </a>
+            {% endfor %}
+          </div>
+          <div class="display-4 font-weight-normal text-primary">
+            {{ item.count }}
+          </div>
         </div>
         </div>
       </div>
       </div>
     </div>
     </div>
+    {% endfor %}
   </div>
   </div>
-  <div class="col-sm-6 col-md-4">
-    <div class="panel panel-default">
-      <div class="panel-heading">
-        <strong>Secrets</strong>
-      </div>
-      <div class="list-group">
-        <div class="list-group-item">
-          {% if perms.secrets.view_secret %}
-          <span class="badge pull-right">{{ stats.secret_count }}</span>
-          <h4 class="list-group-item-heading">
-            <a href="{% url 'secrets:secret_list' %}">Secrets</a>
-          </h4>
-          {% else %}
-          <span class="badge pull-right"><i class="mdi mdi-lock"></i></span>
-          <h4 class="list-group-item-heading">Secrets</h4>
-          {% endif %}
-          <p class="list-group-item-text text-muted">
-            Cryptographically secured secret data
-          </p>
-        </div>
-      </div>
-    </div>
-    <div class="panel panel-default">
-      <div class="panel-heading">
-        <strong>Reports</strong>
-      </div>
-      {% if report_results and perms.extras.view_report %}
-      <table class="table table-hover panel-body">
-        {% for result in report_results %}
-        <tr>
-          <td>
-            <a href="{% url 'extras:report_result' job_result_pk=result.pk %}"
-              >{{ result.name }}</a
-            >
-          </td>
-          <td class="text-right">
-            <span title="{{ result.created }}"
-              >{% include 'extras/inc/job_label.html' %}</span
-            >
-          </td>
-        </tr>
-        {% endfor %}
-      </table>
-      {% elif perms.extras.view_report %}
-      <div class="panel-body text-muted">
-        None found
-      </div>
-      {% else %}
-      <div class="panel-body text-muted">
-        <i class="mdi mdi-lock"></i> No permission
-      </div>
-      {% endif %}
-    </div>
-    <div class="panel panel-default">
-      <div class="panel-heading">
-        <strong>Change Log</strong>
-      </div>
-      {% if changelog and perms.extras.view_objectchange %}
-      <div class="list-group">
-        {% for change in changelog %} {% with
-        action=change.get_action_display|lower %}
-        <div class="list-group-item">
-          {% if action == 'created' %}
-          <span class="label label-success">Created</span>
-          {% elif action == 'updated' %}
-          <span class="label label-warning">Modified</span>
-          {% elif action == 'deleted' %}
-          <span class="label label-danger">Deleted</span>
-          {% endif %} {{ change.changed_object_type.name|bettertitle }} {% if
-          change.changed_object.get_absolute_url %}
-          <a href="{{ change.changed_object.get_absolute_url }}"
-            >{{ change.changed_object }}</a
-          >
-          {% else %} {{ change.changed_object|default:change.object_repr }} {%
-          endif %}
-          <br />
-          <small>
-            <span class="text-muted"
-              >{{ change.user|default:change.user_name }} -</span
-            >
-            <a href="{{ change.get_absolute_url }}" class="text-muted"
-              >{{ change.time|date:'SHORT_DATETIME_FORMAT' }}</a
-            >
-          </small>
-        </div>
-        <div class="panel panel-default">
-            <div class="panel-heading">
-                <strong>Change Log</strong>
-            </div>
-            {% if changelog and perms.extras.view_objectchange %}
-                <div class="list-group">
-                    {% for change in changelog %}
-                        {% with action=change.get_action_display|lower %}
-                            <div class="list-group-item">
-                                <span class="label label-{{ change.get_action_class }}">{{ change.get_action_display }}</span>
-                                {{ change.changed_object_type.name|bettertitle }}
-                                {% if change.changed_object.get_absolute_url %}
-                                    <a href="{{ change.changed_object.get_absolute_url }}">{{ change.changed_object }}</a>
-                                {% else %}
-                                    {{ change.changed_object|default:change.object_repr }}
-                                {% endif %}
-                                <br />
-                                <small>
-                                    <span class="text-muted">{{ change.user|default:change.user_name }} -</span>
-                                    <a href="{{ change.get_absolute_url }}" class="text-muted">{{ change.time|date:'SHORT_DATETIME_FORMAT' }}</a>
-                                </small>
-                            </div>
-                        {% endwith %}
-                        {% if forloop.last %}
-                            <div class="list-group-item text-right">
-                                <a href="{% url 'extras:objectchange_list' %}">View All Changes</a>
-                            </div>
-                        {% endif %}
-                    {% endfor %}
-                </div>
-            {% elif perms.extras.view_objectchange %}
-                <div class="panel-body text-muted">
-                    No change history found
-                </div>
-            {% else %}
-                <div class="panel-body text-muted">
-                    <i class="mdi mdi-lock"></i> No permission
-                </div>
-            {% endif %}
-        </div>
-        {% endif %} {% endfor %}
-      </div>
-      {% elif perms.extras.view_objectchange %}
-      <div class="panel-body text-muted">
-        No change history found
-      </div>
-      {% else %}
-      <div class="panel-body text-muted">
-        <i class="mdi mdi-lock"></i> No permission
+</div>
+
+<div class="row my-4 flex-grow-1 changelog-container">
+  <div class="col">
+    <div class="card">
+      <h4 class="card-header">Changelog</h4>
+      <div class="card-body">
+        {% include 'changelog.html' %}
       </div>
       </div>
-      {% endif %}
     </div>
     </div>
   </div>
   </div>
 </div>
 </div>
+
 {% endblock %}
 {% endblock %}

+ 0 - 55
netbox/templates/pages/home.html

@@ -1,55 +0,0 @@
-{% extends 'layout.html' %} {% load helpers %} {%block title %} Home
-{%endblock%} {% block content %}
-
-<div class="stats-container">
-  <div class="row row-cols-auto masonry">
-    {% for section in stats %}
-    <div class="col col-4 my-2 masonry-item">
-      <div class="card">
-        <h5 class="card-header text-primary">{{ section.label }}</h5>
-        <div class="card-body">
-          <div class="list-group list-group-flush">
-            {% for item in section.items %}
-            <a
-              href="{% url item.url %}"
-              class="list-group-item list-group-item-action"
-            >
-              <div
-                class="d-flex w-100 justify-content-between align-items-center"
-              >
-                <div class="d-flex flex-column align-items-start">
-                  <h6 class="mb-1">{{ item.label }}</h6>
-                  {% if item.description %}
-                  <small class="mb-1 text-muted">{{ item.description }}</small>
-                  {% endif %}
-                </div>
-
-                <span class="badge bg-secondary rounded-pill"
-                  >{{ item.count }}</span
-                >
-              </div>
-            </a>
-            {% endfor %}
-          </div>
-          <div class="display-4 font-weight-normal text-primary">
-            {{ item.count }}
-          </div>
-        </div>
-      </div>
-    </div>
-    {% endfor %}
-  </div>
-</div>
-
-<div class="row my-4 flex-grow-1 changelog-container">
-  <div class="col">
-    <div class="card">
-      <h4 class="card-header">Changelog</h4>
-      <div class="card-body">
-        {% include '../changelog.html' %}
-      </div>
-    </div>
-  </div>
-</div>
-
-{% endblock %}