From 94bd27bcf5e63283164e55b9c1a330a88ed667ed Mon Sep 17 00:00:00 2001 From: Miguel Teixeira <816267+CironAkono@users.noreply.github.com> Date: Sun, 24 Oct 2021 03:24:54 +0100 Subject: [PATCH 1/3] Fix interface icons on the device interfaces table --- netbox/dcim/tables/devices.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netbox/dcim/tables/devices.py b/netbox/dcim/tables/devices.py index c22e673b78c..8939c01be56 100644 --- a/netbox/dcim/tables/devices.py +++ b/netbox/dcim/tables/devices.py @@ -501,8 +501,8 @@ class Meta(DeviceComponentTable.Meta): class DeviceInterfaceTable(InterfaceTable): name = tables.TemplateColumn( - template_code=' {{ value }}', order_by=Accessor('_name'), attrs={'td': {'class': 'text-nowrap'}} From b07e88869aa382fa45643470f05bd6f7abbb1780 Mon Sep 17 00:00:00 2001 From: Miguel Teixeira <816267+CironAkono@users.noreply.github.com> Date: Sun, 24 Oct 2021 03:31:29 +0100 Subject: [PATCH 2/3] Fix interfaces row colors on device interfaces table --- netbox/dcim/tables/devices.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/netbox/dcim/tables/devices.py b/netbox/dcim/tables/devices.py index 8939c01be56..51202267991 100644 --- a/netbox/dcim/tables/devices.py +++ b/netbox/dcim/tables/devices.py @@ -53,6 +53,16 @@ def get_cabletermination_row_class(record): return '' +def get_interface_row_class(record): + if not record.enabled: + return 'danger' + elif not record.is_connectable: + return 'primary' + else: + return get_cabletermination_row_class(record) + return '' + + def get_interface_state_attribute(record): """ Get interface enabled state as string to attach to DOM element. @@ -534,7 +544,7 @@ class Meta(DeviceComponentTable.Meta): 'cable', 'connection', 'actions', ) row_attrs = { - 'class': get_cabletermination_row_class, + 'class': get_interface_row_class, 'data-name': lambda record: record.name, 'data-enabled': get_interface_state_attribute, } From 251abdb4ddc6224e9c41dfe493614767985ee889 Mon Sep 17 00:00:00 2001 From: CironAkono <816267+CironAkono@users.noreply.github.com> Date: Thu, 11 Nov 2021 16:36:13 +0000 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Jeremy Stretch --- netbox/dcim/tables/devices.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/netbox/dcim/tables/devices.py b/netbox/dcim/tables/devices.py index 51202267991..4be5c7634df 100644 --- a/netbox/dcim/tables/devices.py +++ b/netbox/dcim/tables/devices.py @@ -56,11 +56,9 @@ def get_cabletermination_row_class(record): def get_interface_row_class(record): if not record.enabled: return 'danger' - elif not record.is_connectable: + elif record.is_virtual: return 'primary' - else: - return get_cabletermination_row_class(record) - return '' + return get_cabletermination_row_class(record) def get_interface_state_attribute(record):