Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes: #6925 Interfaces Table - bring back the visual aids from v2.9 #7767

Merged
merged 3 commits into from
Nov 11, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions netbox/dcim/tables/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
teixemf marked this conversation as resolved.
Show resolved Hide resolved
return 'primary'
else:
return get_cabletermination_row_class(record)
return ''
teixemf marked this conversation as resolved.
Show resolved Hide resolved


def get_interface_state_attribute(record):
"""
Get interface enabled state as string to attach to <tr/> DOM element.
Expand Down Expand Up @@ -501,8 +511,8 @@ class Meta(DeviceComponentTable.Meta):

class DeviceInterfaceTable(InterfaceTable):
name = tables.TemplateColumn(
template_code='<i class="mdi mdi-{% if iface.mgmt_only %}wrench{% elif iface.is_lag %}drag-horizontal-variant'
'{% elif iface.is_virtual %}circle{% elif iface.is_wireless %}wifi{% else %}ethernet'
template_code='<i class="mdi mdi-{% if record.mgmt_only %}wrench{% elif record.is_lag %}reorder-horizontal'
'{% elif record.is_virtual %}circle{% elif record.is_wireless %}wifi{% else %}ethernet'
'{% endif %}"></i> <a href="{{ record.get_absolute_url }}">{{ value }}</a>',
order_by=Accessor('_name'),
attrs={'td': {'class': 'text-nowrap'}}
Expand Down Expand Up @@ -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,
}
Expand Down