netbox-community / netbox

The premier source of truth powering network automation. Open source under Apache 2. Public demo: https://demo.netbox.dev
http://netboxlabs.com/oss/netbox/
Apache License 2.0
15.43k stars 2.51k forks source link

Show device location in breadcrumbs #14972

Open llamafilm opened 5 months ago

llamafilm commented 5 months ago

NetBox version

v3.7.0

Feature type

Change to existing functionality

Proposed functionality

When viewing a device, the breadcrumbs at the top of the page currently show the site and parent device. I'd like to also include the location here. Mockup image:

image

Use case

My devices are primarily organized using the hierarchy Site > Location > Device. This would save a lot of time when editing a device, to be able to quickly jump to a list of other devices in the same location. (By the way, location means room name in my system).

Database changes

none

External dependencies

none

llamafilm commented 5 months ago

At first glance, it seems like all that is required is adding these lines in netbox/templates/dcim/device/base.html

  {% if object.location %}
    <li class="breadcrumb-item"><a href="{% url 'dcim:device_list' %}?site_id={{ object.site.pk }}&location_id={{ object.location.pk }}">{{ object.location }}</a></li>
  {% endif %}
sleepinggenius2 commented 5 months ago

As Locations can be nested, I would assume that the full hierarchy would be desirable, so the code would be a little more complicated. It looks like it's already being done on MPTT views themselves, like Location, Region, and Site Group, so it would probably make sense to make a template tag like the existing nested_tree one to handle this use case.