mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 17:08:41 -06:00
Limit amount of nonracked devices displayed
Fixes #8920 Limits the amount of non-racked devices on Site and Location view to 10 and provides a link to the device list this is pre-filtered to the relevant site or location.
This commit is contained in:
parent
b9f6a5625f
commit
c3d9910e08
@ -346,7 +346,13 @@ class SiteView(generic.ObjectView):
|
|||||||
site=instance,
|
site=instance,
|
||||||
position__isnull=True,
|
position__isnull=True,
|
||||||
parent_bay__isnull=True
|
parent_bay__isnull=True
|
||||||
).prefetch_related('device_type__manufacturer')
|
).prefetch_related('device_type__manufacturer').order_by('-pk')[:10]
|
||||||
|
|
||||||
|
total_nonracked_devices_count = Device.objects.filter(
|
||||||
|
site=instance,
|
||||||
|
position__isnull=True,
|
||||||
|
parent_bay__isnull=True
|
||||||
|
).count()
|
||||||
|
|
||||||
asns = ASN.objects.restrict(request.user, 'view').filter(sites=instance)
|
asns = ASN.objects.restrict(request.user, 'view').filter(sites=instance)
|
||||||
asn_count = asns.count()
|
asn_count = asns.count()
|
||||||
@ -358,6 +364,7 @@ class SiteView(generic.ObjectView):
|
|||||||
'locations': locations,
|
'locations': locations,
|
||||||
'asns': asns,
|
'asns': asns,
|
||||||
'nonracked_devices': nonracked_devices,
|
'nonracked_devices': nonracked_devices,
|
||||||
|
'total_nonracked_devices_count': total_nonracked_devices_count,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -439,13 +446,20 @@ class LocationView(generic.ObjectView):
|
|||||||
location=instance,
|
location=instance,
|
||||||
position__isnull=True,
|
position__isnull=True,
|
||||||
parent_bay__isnull=True
|
parent_bay__isnull=True
|
||||||
).prefetch_related('device_type__manufacturer')
|
).prefetch_related('device_type__manufacturer').order_by('-pk')[:10]
|
||||||
|
|
||||||
|
total_nonracked_devices_count = Device.objects.filter(
|
||||||
|
location=instance,
|
||||||
|
position__isnull=True,
|
||||||
|
parent_bay__isnull=True
|
||||||
|
).count()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'rack_count': rack_count,
|
'rack_count': rack_count,
|
||||||
'device_count': device_count,
|
'device_count': device_count,
|
||||||
'child_locations_table': child_locations_table,
|
'child_locations_table': child_locations_table,
|
||||||
'nonracked_devices': nonracked_devices,
|
'nonracked_devices': nonracked_devices,
|
||||||
|
'total_nonracked_devices_count': total_nonracked_devices_count,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,12 +29,26 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
{% if nonracked_devices.count == 10 %}
|
||||||
|
{% if object|meta:'verbose_name' == 'site' %}
|
||||||
|
<div class="text-muted">
|
||||||
|
Displaying 10 of {{ total_nonracked_devices_count }} devices (<a href="{% url 'dcim:device_list' %}?site_id={{ object.pk }}&rack_id=null">View full list</a>)
|
||||||
|
</div>
|
||||||
|
{% elif object|meta:'verbose_name' == 'location' %}
|
||||||
|
<div class="text-muted">
|
||||||
|
Displaying 10 of {{ total_nonracked_devices_count }} devices (<a href="{% url 'dcim:device_list' %}?location_id={{ object.pk }}&rack_id=null">View full list</a>)
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="text-muted">
|
<div class="text-muted">
|
||||||
None
|
None
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if perms.dcim.add_device %}
|
{% if perms.dcim.add_device %}
|
||||||
{% if object|meta:'verbose_name' == 'rack' %}
|
{% if object|meta:'verbose_name' == 'rack' %}
|
||||||
<div class="card-footer text-end noprint">
|
<div class="card-footer text-end noprint">
|
||||||
|
Loading…
Reference in New Issue
Block a user