mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-24 17:38:37 -06:00
Adds description to elevation device tooltip (#12488)
* adds description to elevation device tooltip #11801 * changes as per review * changes as per review * Rearrange attrs, add headings, and update docstring --------- Co-authored-by: jeremystretch <jstretch@netboxlabs.com>
This commit is contained in:
parent
9d62174e1e
commit
abdcfdecf5
@ -37,15 +37,28 @@ def get_device_name(device):
|
||||
|
||||
|
||||
def get_device_description(device):
|
||||
return '{} ({}) — {} {} ({}U) {} {}'.format(
|
||||
device.name,
|
||||
device.device_role,
|
||||
device.device_type.manufacturer.name,
|
||||
device.device_type.model,
|
||||
floatformat(device.device_type.u_height),
|
||||
device.asset_tag or '',
|
||||
device.serial or ''
|
||||
)
|
||||
"""
|
||||
Return a description for a device to be rendered in the rack elevation in the following format
|
||||
|
||||
Name: <name>
|
||||
Role: <device_role>
|
||||
Device Type: <manufacturer> <model> (<u_height>)
|
||||
Asset tag: <asset_tag> (if defined)
|
||||
Serial: <serial> (if defined)
|
||||
Description: <description> (if defined)
|
||||
"""
|
||||
description = f'Name: {device.name}'
|
||||
description += f'\nRole: {device.device_role}'
|
||||
u_height = f'{floatformat(device.device_type.u_height)}U'
|
||||
description += f'\nDevice Type: {device.device_type.manufacturer.name} {device.device_type.model} ({u_height})'
|
||||
if device.asset_tag:
|
||||
description += f'\nAsset tag: {device.asset_tag}'
|
||||
if device.serial:
|
||||
description += f'\nSerial: {device.serial}'
|
||||
if device.description:
|
||||
description += f'\nDescription: {device.description}'
|
||||
|
||||
return description
|
||||
|
||||
|
||||
class RackElevationSVG:
|
||||
|
Loading…
Reference in New Issue
Block a user