From 029605f926e4fab5cfb2260c8d6d03c7fe7161ac Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Mon, 6 Dec 2021 13:43:02 -0500 Subject: [PATCH] Clean up site view --- netbox/dcim/views.py | 1 + netbox/templates/dcim/site.html | 524 +++++++++++++++++--------------- 2 files changed, 273 insertions(+), 252 deletions(-) diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index e353f24d0..b1a53e93c 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -312,6 +312,7 @@ class SiteView(generic.ObjectView): def get_extra_context(self, request, instance): stats = { + 'location_count': Location.objects.restrict(request.user, 'view').filter(site=instance).count(), 'rack_count': Rack.objects.restrict(request.user, 'view').filter(site=instance).count(), 'device_count': Device.objects.restrict(request.user, 'view').filter(site=instance).count(), 'prefix_count': Prefix.objects.restrict(request.user, 'view').filter(site=instance).count(), diff --git a/netbox/templates/dcim/site.html b/netbox/templates/dcim/site.html index b895d3cec..2ad970301 100644 --- a/netbox/templates/dcim/site.html +++ b/netbox/templates/dcim/site.html @@ -20,266 +20,286 @@ {% block content %}
-
-
-
- Site -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Region - {% if object.region %} - {% for region in object.region.get_ancestors %} - {{ region }} / - {% endfor %} - {{ object.region }} - {% else %} - None - {% endif %} -
Group - {% if object.group %} - {% for group in object.group.get_ancestors %} - {{ group }} / - {% endfor %} - {{ object.group }} - {% else %} - None - {% endif %} -
Status - {{ object.get_status_display }} -
Tenant - {% if object.tenant %} - {% if object.tenant.group %} - {{ object.tenant.group }} / - {% endif %} - {{ object.tenant }} - {% else %} - None - {% endif %} -
Facility{{ object.facility|placeholder }}
Description{{ object.description|placeholder }}
AS Number{{ object.asn|placeholder }}
Time Zone - {% if object.time_zone %} - {{ object.time_zone }} (UTC {{ object.time_zone|tzoffset }})
- Site time: {% timezone object.time_zone %}{% annotated_now %}{% endtimezone %} - {% else %} - - {% endif %} -
-
-
-
-
Contact Info
-
- {% with deprecation_warning="This field will be removed in a future release. Please migrate this data to contact objects." %} - - - - - - - - - - - - - - - - - - - - - - - - - -
Physical Address - {% if object.physical_address %} - - {{ object.physical_address|linebreaksbr }} - {% else %} - - {% endif %} -
Shipping Address{{ object.shipping_address|linebreaksbr|placeholder }}
GPS Coordinates - {% if object.latitude and object.longitude %} - - {{ object.latitude }}, {{ object.longitude }} - {% else %} - - {% endif %} -
Contact Name - {% if object.contact_name %} -
- -
- {% endif %} - {{ object.contact_name|placeholder }} -
Contact Phone - {% if object.contact_phone %} -
- -
- {{ object.contact_phone }} - {% else %} - - {% endif %} -
Contact E-Mail - {% if object.contact_email %} -
- -
- {{ object.contact_email }} - {% else %} - - {% endif %} -
- {% endwith %} -
-
- {% include 'inc/panels/custom_fields.html' %} - {% include 'inc/panels/comments.html' %} - {% include 'inc/panels/contacts.html' %} - {% plugin_left_page object %} -
-
-
-
- Stats -
-
-
- -
-

{{ stats.device_count }}

-

Devices

-
-
-

{{ stats.prefix_count }}

-

Prefixes

-
- -
-

{{ stats.circuit_count }}

-

Circuits

-
-
-

{{ stats.vm_count }}

-

Virtual Machines

-
- -
-
-
-
-
- Locations -
-
- {% if locations %} - - - - - - - - {% for location in locations %} - - - - - - - {% endfor %} -
LocationRacksDevices
- {% for i in location.level|as_range %}{% endfor %} - {{ location }} - - {{ location.rack_count }} - - {{ location.device_count }} - - - - -
- {% else %} - None - {% endif %} -
-
-
-
- ASNs -
-
- {% if asns %} - {% for asn in asns %} - {{ asn }} +
+
+
Site
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {# Legacy contact fields #} + {% with deprecation_warning="This field will be removed in a future release. Please migrate this data to contact objects." %} + {% if object.contact_name %} + + + + + {% endif %} + {% if object.contact_phone %} + + + + + {% endif %} + {% if object.contact_email %} + + + + + {% endif %} + {% endwith %} +
Region + {% if object.region %} + {% for region in object.region.get_ancestors %} + {{ region }} / {% endfor %} + {{ object.region }} {% else %} None {% endif %} +
Group + {% if object.group %} + {% for group in object.group.get_ancestors %} + {{ group }} / + {% endfor %} + {{ object.group }} + {% else %} + None + {% endif %} +
Status + {{ object.get_status_display }} +
Tenant + {% if object.tenant %} + {% if object.tenant.group %} + {{ object.tenant.group }} / + {% endif %} + {{ object.tenant }} + {% else %} + None + {% endif %} +
Facility{{ object.facility|placeholder }}
Description{{ object.description|placeholder }}
AS Number{{ object.asn|placeholder }}
Time Zone + {% if object.time_zone %} + {{ object.time_zone }} (UTC {{ object.time_zone|tzoffset }})
+ Site time: {% timezone object.time_zone %}{% annotated_now %}{% endtimezone %} + {% else %} + + {% endif %} +
Physical Address + {% if object.physical_address %} + + {{ object.physical_address|linebreaksbr }} + {% else %} + + {% endif %} +
Shipping Address{{ object.shipping_address|linebreaksbr|placeholder }}
GPS Coordinates + {% if object.latitude and object.longitude %} + + {{ object.latitude }}, {{ object.longitude }} + {% else %} + + {% endif %} +
Contact Name + {% if object.contact_name %} +
+ +
+ {% endif %} + {{ object.contact_name|placeholder }} +
Contact Phone + {% if object.contact_phone %} +
+ +
+ {{ object.contact_phone }} + {% else %} + + {% endif %} +
Contact E-Mail + {% if object.contact_email %} +
+ +
+ {{ object.contact_email }} + {% else %} + + {% endif %} +
+
+
+ {% include 'inc/panels/custom_fields.html' %} + {% include 'inc/panels/tags.html' %} + {% include 'inc/panels/comments.html' %} + {% plugin_left_page object %} +
+
+
+
Stats
+
+
+ + +
+

{{ stats.device_count }}

+

Devices

+
+
+

{{ stats.prefix_count }}

+

Prefixes

+
+ +
+

{{ stats.circuit_count }}

+

Circuits

+
+
+

{{ stats.vm_count }}

+

Virtual Machines

+
+ +
- {% include 'inc/panels/image_attachments.html' %} - {% plugin_right_page object %} +
+ {% include 'inc/panels/contacts.html' %} +
+
Locations
+
+ {% if locations %} + + + + + + + + {% for location in locations %} + + + + + + + {% endfor %} +
LocationRacksDevices
+ {% for i in location.level|as_range %}{% endfor %} + {{ location }} + + {{ location.rack_count }} + + {{ location.device_count }} + + + + +
+ {% else %} + None + {% endif %} +
+ {% if perms.dcim.add_location %} + + {% endif %} +
+
+
ASNs
+
+ {% if asns %} + + + + + + {% for asn in asns %} + + + + + {% endfor %} +
ASNDescription
{{ asn }}{{ asn.description|placeholder }}
+ {% else %} + None + {% endif %} +
+ {% if perms.ipam.add_asn %} + + {% endif %} +
+ {% include 'inc/panels/image_attachments.html' %} + {% plugin_right_page object %}
-
- {% plugin_full_width_page object %} -
+
+ {% plugin_full_width_page object %} +
{% endblock %}