mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-25 08:46:10 -06:00
Fixes #13033: add formatted speed column to Interfaces
This commit is contained in:
parent
0f0cf683c4
commit
59e657867c
@ -1,4 +1,5 @@
|
|||||||
from .cables import *
|
from .cables import *
|
||||||
|
from .columns import *
|
||||||
from .connections import *
|
from .connections import *
|
||||||
from .devices import *
|
from .devices import *
|
||||||
from .devicetypes import *
|
from .devicetypes import *
|
||||||
|
21
netbox/dcim/tables/columns.py
Normal file
21
netbox/dcim/tables/columns.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import django_tables2 as tables
|
||||||
|
|
||||||
|
__all__ = (
|
||||||
|
'SpeedColumn',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class SpeedColumn(tables.TemplateColumn):
|
||||||
|
"""
|
||||||
|
Humanize the speed in the column view
|
||||||
|
"""
|
||||||
|
template_code = """
|
||||||
|
{% load helpers %}
|
||||||
|
{{ value|humanize_speed|placeholder }}
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(template_code=self.template_code, *args, **kwargs)
|
||||||
|
|
||||||
|
def value(self, value, **kwargs):
|
||||||
|
return super().value(value=value, **kwargs) if value else None
|
@ -5,6 +5,7 @@ from tenancy.tables import ContactsColumnMixin, TenancyColumnsMixin
|
|||||||
|
|
||||||
from netbox.tables import NetBoxTable, columns
|
from netbox.tables import NetBoxTable, columns
|
||||||
|
|
||||||
|
from .columns import *
|
||||||
from .template_code import *
|
from .template_code import *
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
@ -545,6 +546,10 @@ class InterfaceTable(ModularDeviceComponentTable, BaseInterfaceTable, PathEndpoi
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
mgmt_only = columns.BooleanColumn()
|
mgmt_only = columns.BooleanColumn()
|
||||||
|
speed_formatted = SpeedColumn(
|
||||||
|
accessor=Accessor('speed'),
|
||||||
|
verbose_name='Speed'
|
||||||
|
)
|
||||||
wireless_link = tables.Column(
|
wireless_link = tables.Column(
|
||||||
linkify=True
|
linkify=True
|
||||||
)
|
)
|
||||||
@ -568,7 +573,7 @@ class InterfaceTable(ModularDeviceComponentTable, BaseInterfaceTable, PathEndpoi
|
|||||||
model = models.Interface
|
model = models.Interface
|
||||||
fields = (
|
fields = (
|
||||||
'pk', 'id', 'name', 'device', 'module_bay', 'module', 'label', 'enabled', 'type', 'mgmt_only', 'mtu',
|
'pk', 'id', 'name', 'device', 'module_bay', 'module', 'label', 'enabled', 'type', 'mgmt_only', 'mtu',
|
||||||
'speed', 'duplex', 'mode', 'mac_address', 'wwn', 'poe_mode', 'poe_type', 'rf_role', 'rf_channel',
|
'speed', 'speed_formatted', 'duplex', 'mode', 'mac_address', 'wwn', 'poe_mode', 'poe_type', 'rf_role', 'rf_channel',
|
||||||
'rf_channel_frequency', 'rf_channel_width', 'tx_power', 'description', 'mark_connected', 'cable',
|
'rf_channel_frequency', 'rf_channel_width', 'tx_power', 'description', 'mark_connected', 'cable',
|
||||||
'cable_color', 'wireless_link', 'wireless_lans', 'link_peer', 'connection', 'tags', 'vdcs', 'vrf', 'l2vpn',
|
'cable_color', 'wireless_link', 'wireless_lans', 'link_peer', 'connection', 'tags', 'vdcs', 'vrf', 'l2vpn',
|
||||||
'ip_addresses', 'fhrp_groups', 'untagged_vlan', 'tagged_vlans', 'created', 'last_updated',
|
'ip_addresses', 'fhrp_groups', 'untagged_vlan', 'tagged_vlans', 'created', 'last_updated',
|
||||||
|
Loading…
Reference in New Issue
Block a user