diff --git a/netbox/dcim/tables/devices.py b/netbox/dcim/tables/devices.py index c6ad3ad6d..ef4e59343 100644 --- a/netbox/dcim/tables/devices.py +++ b/netbox/dcim/tables/devices.py @@ -44,6 +44,14 @@ __all__ = ( ) +def get_cabletermination_row_class(record): + if record.mark_connected: + return 'success' + elif record.cable: + return record.cable.get_status_class() + return '' + + # # Device roles # @@ -287,7 +295,7 @@ class DeviceConsolePortTable(ConsolePortTable): ) default_columns = ('pk', 'name', 'label', 'type', 'speed', 'description', 'cable', 'connection', 'actions') row_attrs = { - 'class': lambda record: record.cable.get_status_class() if record.cable else '' + 'class': get_cabletermination_row_class } @@ -325,7 +333,7 @@ class DeviceConsoleServerPortTable(ConsoleServerPortTable): ) default_columns = ('pk', 'name', 'label', 'type', 'speed', 'description', 'cable', 'connection', 'actions') row_attrs = { - 'class': lambda record: record.cable.get_status_class() if record.cable else '' + 'class': get_cabletermination_row_class } @@ -366,7 +374,7 @@ class DevicePowerPortTable(PowerPortTable): 'actions', ) row_attrs = { - 'class': lambda record: record.cable.get_status_class() if record.cable else '' + 'class': get_cabletermination_row_class } @@ -408,7 +416,7 @@ class DevicePowerOutletTable(PowerOutletTable): 'pk', 'name', 'label', 'type', 'power_port', 'feed_leg', 'description', 'cable', 'connection', 'actions', ) row_attrs = { - 'class': lambda record: record.cable.get_status_class() if record.cable else '' + 'class': get_cabletermination_row_class } @@ -476,7 +484,7 @@ class DeviceInterfaceTable(InterfaceTable): 'cable', 'connection', 'actions', ) row_attrs = { - 'class': lambda record: record.cable.get_status_class() if record.cable else '', + 'class': get_cabletermination_row_class, 'data-name': lambda record: record.name, } @@ -524,7 +532,7 @@ class DeviceFrontPortTable(FrontPortTable): 'actions', ) row_attrs = { - 'class': lambda record: record.cable.get_status_class() if record.cable else '' + 'class': get_cabletermination_row_class } @@ -564,7 +572,7 @@ class DeviceRearPortTable(RearPortTable): 'pk', 'name', 'label', 'type', 'positions', 'description', 'cable', 'cable_peer', 'actions', ) row_attrs = { - 'class': lambda record: record.cable.get_status_class() if record.cable else '' + 'class': get_cabletermination_row_class } diff --git a/netbox/dcim/tables/template_code.py b/netbox/dcim/tables/template_code.py index 7449bb9c8..4324f802f 100644 --- a/netbox/dcim/tables/template_code.py +++ b/netbox/dcim/tables/template_code.py @@ -91,16 +91,20 @@ CONSOLEPORT_BUTTONS = """ {% elif perms.dcim.add_cable %} - - - - + {% if not record.mark_connected %} + + + + + {% else %} + + {% endif %} {% endif %} """ @@ -116,16 +120,20 @@ CONSOLESERVERPORT_BUTTONS = """ {% elif perms.dcim.add_cable %} - - - - + {% if not record.mark_connected %} + + + + + {% else %} + + {% endif %} {% endif %} """ @@ -141,15 +149,19 @@ POWERPORT_BUTTONS = """ {% elif perms.dcim.add_cable %} - - - - + {% if not record.mark_connected %} + + + + + {% else %} + + {% endif %} {% endif %} """ @@ -165,9 +177,13 @@ POWEROUTLET_BUTTONS = """ {% elif perms.dcim.add_cable %} - - - + {% if not record.mark_connected %} + + + + {% else %} + + {% endif %} {% endif %} """ @@ -188,17 +204,21 @@ INTERFACE_BUTTONS = """ {% elif record.is_connectable and perms.dcim.add_cable %} - - - - + {% if not record.mark_connected %} + + + + + {% else %} + + {% endif %} {% endif %} """ @@ -214,19 +234,23 @@ FRONTPORT_BUTTONS = """ {% elif perms.dcim.add_cable %} - - - - + {% if not record.mark_connected %} + + + + + {% else %} + + {% endif %} {% endif %} """ @@ -242,17 +266,21 @@ REARPORT_BUTTONS = """ {% elif perms.dcim.add_cable %} - - - - + {% if not record.mark_connected %} + + + + + {% else %} + + {% endif %} {% endif %} """