mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-24 17:38:37 -06:00
Closes: #8457 - implement nonracked devices on locations and sites
This commit is contained in:
parent
1add5accf2
commit
5abde866f1
@ -328,6 +328,11 @@ class SiteView(generic.ObjectView):
|
|||||||
'device_count',
|
'device_count',
|
||||||
cumulative=True
|
cumulative=True
|
||||||
).restrict(request.user, 'view').filter(site=instance)
|
).restrict(request.user, 'view').filter(site=instance)
|
||||||
|
nonracked_devices = Device.objects.filter(
|
||||||
|
site=instance,
|
||||||
|
position__isnull=True,
|
||||||
|
parent_bay__isnull=True
|
||||||
|
).prefetch_related('device_type__manufacturer')
|
||||||
|
|
||||||
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()
|
||||||
@ -338,6 +343,7 @@ class SiteView(generic.ObjectView):
|
|||||||
'stats': stats,
|
'stats': stats,
|
||||||
'locations': locations,
|
'locations': locations,
|
||||||
'asns': asns,
|
'asns': asns,
|
||||||
|
'nonracked_devices': nonracked_devices,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -415,11 +421,17 @@ class LocationView(generic.ObjectView):
|
|||||||
).filter(pk__in=location_ids).exclude(pk=instance.pk)
|
).filter(pk__in=location_ids).exclude(pk=instance.pk)
|
||||||
child_locations_table = tables.LocationTable(child_locations)
|
child_locations_table = tables.LocationTable(child_locations)
|
||||||
paginate_table(child_locations_table, request)
|
paginate_table(child_locations_table, request)
|
||||||
|
nonracked_devices = Device.objects.filter(
|
||||||
|
location=instance,
|
||||||
|
position__isnull=True,
|
||||||
|
parent_bay__isnull=True
|
||||||
|
).prefetch_related('device_type__manufacturer')
|
||||||
|
|
||||||
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
62
netbox/templates/dcim/inc/nonracked_devices.html
Normal file
62
netbox/templates/dcim/inc/nonracked_devices.html
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
{% load helpers %}
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<h5 class="card-header">
|
||||||
|
Non-Racked Devices
|
||||||
|
</h5>
|
||||||
|
<div class="card-body">
|
||||||
|
{% if nonracked_devices %}
|
||||||
|
<table class="table table-hover">
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Role</th>
|
||||||
|
<th>Type</th>
|
||||||
|
<th colspan="2">Parent Device</th>
|
||||||
|
</tr>
|
||||||
|
{% for device in nonracked_devices %}
|
||||||
|
<tr{% if device.device_type.u_height %} class="warning"{% endif %}>
|
||||||
|
<td>
|
||||||
|
<a href="{% url 'dcim:device' pk=device.pk %}">{{ device }}</a>
|
||||||
|
</td>
|
||||||
|
<td>{{ device.device_role }}</td>
|
||||||
|
<td>{{ device.device_type }}</td>
|
||||||
|
{% if device.parent_bay %}
|
||||||
|
<td><a href="{{ device.parent_bay.device.get_absolute_url }}">{{ device.parent_bay.device }}</a></td>
|
||||||
|
<td>{{ device.parent_bay }}</td>
|
||||||
|
{% else %}
|
||||||
|
<td colspan="2" class="text-muted">—</td>
|
||||||
|
{% endif %}
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
{% else %}
|
||||||
|
<div class="text-muted">
|
||||||
|
None
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% if perms.dcim.add_device %}
|
||||||
|
{% if object|meta:'verbose_name' == 'rack' %}
|
||||||
|
<div class="card-footer text-end noprint">
|
||||||
|
<a href="{% url 'dcim:device_add' %}?site={{ object.site.pk }}&rack={{ object.pk }}" class="btn btn-primary btn-sm">
|
||||||
|
<i class="mdi mdi-plus-thick" aria-hidden="true"></i>
|
||||||
|
Add a Non-Racked Device
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% elif object|meta:'verbose_name' == 'site' %}
|
||||||
|
<div class="card-footer text-end noprint">
|
||||||
|
<a href="{% url 'dcim:device_add' %}?site={{ object.pk }}" class="btn btn-primary btn-sm">
|
||||||
|
<i class="mdi mdi-plus-thick" aria-hidden="true"></i>
|
||||||
|
Add a Non-Racked Device
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% elif object|meta:'verbose_name' == 'location' %}
|
||||||
|
<div class="card-footer text-end noprint">
|
||||||
|
<a href="{% url 'dcim:device_add' %}?site={{ object.site.pk }}&location={{ object.pk }}" class="btn btn-primary btn-sm">
|
||||||
|
<i class="mdi mdi-plus-thick" aria-hidden="true"></i>
|
||||||
|
Add a Non-Racked Device
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
@ -90,6 +90,7 @@
|
|||||||
<div class="col col-md-6">
|
<div class="col col-md-6">
|
||||||
{% include 'inc/panels/custom_fields.html' %}
|
{% include 'inc/panels/custom_fields.html' %}
|
||||||
{% include 'inc/panels/contacts.html' %}
|
{% include 'inc/panels/contacts.html' %}
|
||||||
|
{% include 'dcim/inc/nonracked_devices.html' %}
|
||||||
{% include 'inc/panels/image_attachments.html' %}
|
{% include 'inc/panels/image_attachments.html' %}
|
||||||
{% plugin_right_page object %}
|
{% plugin_right_page object %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -288,50 +288,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card">
|
{% include 'dcim/inc/nonracked_devices.html' %}
|
||||||
<h5 class="card-header">
|
|
||||||
Non-Racked Devices
|
|
||||||
</h5>
|
|
||||||
<div class="card-body">
|
|
||||||
{% if nonracked_devices %}
|
|
||||||
<table class="table table-hover">
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Role</th>
|
|
||||||
<th>Type</th>
|
|
||||||
<th colspan="2">Parent Device</th>
|
|
||||||
</tr>
|
|
||||||
{% for device in nonracked_devices %}
|
|
||||||
<tr{% if device.device_type.u_height %} class="warning"{% endif %}>
|
|
||||||
<td>
|
|
||||||
<a href="{% url 'dcim:device' pk=device.pk %}">{{ device }}</a>
|
|
||||||
</td>
|
|
||||||
<td>{{ device.device_role }}</td>
|
|
||||||
<td>{{ device.device_type }}</td>
|
|
||||||
{% if device.parent_bay %}
|
|
||||||
<td><a href="{{ device.parent_bay.device.get_absolute_url }}">{{ device.parent_bay.device }}</a></td>
|
|
||||||
<td>{{ device.parent_bay }}</td>
|
|
||||||
{% else %}
|
|
||||||
<td colspan="2" class="text-muted">—</td>
|
|
||||||
{% endif %}
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
{% else %}
|
|
||||||
<div class="text-muted">
|
|
||||||
None
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
{% if perms.dcim.add_device %}
|
|
||||||
<div class="card-footer text-end noprint">
|
|
||||||
<a href="{% url 'dcim:device_add' %}?site={{ object.site.pk }}&rack={{ object.pk }}" class="btn btn-primary btn-sm">
|
|
||||||
<i class="mdi mdi-plus-thick" aria-hidden="true"></i>
|
|
||||||
Add a Non-Racked Device
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
{% include 'inc/panels/contacts.html' %}
|
{% include 'inc/panels/contacts.html' %}
|
||||||
{% plugin_right_page object %}
|
{% plugin_right_page object %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -277,6 +277,7 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% include 'dcim/inc/nonracked_devices.html' %}
|
||||||
{% include 'inc/panels/contacts.html' %}
|
{% include 'inc/panels/contacts.html' %}
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h5 class="card-header">Locations</h5>
|
<h5 class="card-header">Locations</h5>
|
||||||
|
Loading…
Reference in New Issue
Block a user