mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Merge pull request #7767 from CironAkono/FR6925
Fixes: #6925 Interfaces Table - bring back the visual aids from v2.9
This commit is contained in:
@ -53,6 +53,14 @@ def get_cabletermination_row_class(record):
|
|||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
|
def get_interface_row_class(record):
|
||||||
|
if not record.enabled:
|
||||||
|
return 'danger'
|
||||||
|
elif record.is_virtual:
|
||||||
|
return 'primary'
|
||||||
|
return get_cabletermination_row_class(record)
|
||||||
|
|
||||||
|
|
||||||
def get_interface_state_attribute(record):
|
def get_interface_state_attribute(record):
|
||||||
"""
|
"""
|
||||||
Get interface enabled state as string to attach to <tr/> DOM element.
|
Get interface enabled state as string to attach to <tr/> DOM element.
|
||||||
@ -501,8 +509,8 @@ class InterfaceTable(DeviceComponentTable, BaseInterfaceTable, PathEndpointTable
|
|||||||
|
|
||||||
class DeviceInterfaceTable(InterfaceTable):
|
class DeviceInterfaceTable(InterfaceTable):
|
||||||
name = tables.TemplateColumn(
|
name = tables.TemplateColumn(
|
||||||
template_code='<i class="mdi mdi-{% if iface.mgmt_only %}wrench{% elif iface.is_lag %}drag-horizontal-variant'
|
template_code='<i class="mdi mdi-{% if record.mgmt_only %}wrench{% elif record.is_lag %}reorder-horizontal'
|
||||||
'{% elif iface.is_virtual %}circle{% elif iface.is_wireless %}wifi{% else %}ethernet'
|
'{% elif record.is_virtual %}circle{% elif record.is_wireless %}wifi{% else %}ethernet'
|
||||||
'{% endif %}"></i> <a href="{{ record.get_absolute_url }}">{{ value }}</a>',
|
'{% endif %}"></i> <a href="{{ record.get_absolute_url }}">{{ value }}</a>',
|
||||||
order_by=Accessor('_name'),
|
order_by=Accessor('_name'),
|
||||||
attrs={'td': {'class': 'text-nowrap'}}
|
attrs={'td': {'class': 'text-nowrap'}}
|
||||||
@ -534,7 +542,7 @@ class DeviceInterfaceTable(InterfaceTable):
|
|||||||
'cable', 'connection', 'actions',
|
'cable', 'connection', 'actions',
|
||||||
)
|
)
|
||||||
row_attrs = {
|
row_attrs = {
|
||||||
'class': get_cabletermination_row_class,
|
'class': get_interface_row_class,
|
||||||
'data-name': lambda record: record.name,
|
'data-name': lambda record: record.name,
|
||||||
'data-enabled': get_interface_state_attribute,
|
'data-enabled': get_interface_state_attribute,
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user