Add data properties for device interface table
Preparatory work for factoring row styling decisions out of Python code.
This commit is contained in:
parent
9b325f4b86
commit
d76ede17d3
|
@ -69,6 +69,36 @@ def get_interface_state_attribute(record):
|
|||
return "disabled"
|
||||
|
||||
|
||||
def get_interface_virtual_attribute(record):
|
||||
"""
|
||||
Get interface virtual state as string to attach to <tr/> DOM element.
|
||||
"""
|
||||
if record.is_virtual:
|
||||
return "true"
|
||||
else:
|
||||
return "false"
|
||||
|
||||
|
||||
def get_interface_mark_connected_attribute(record):
|
||||
"""
|
||||
Get interface enabled state as string to attach to <tr/> DOM element.
|
||||
"""
|
||||
if record.mark_connected:
|
||||
return "true"
|
||||
else:
|
||||
return "false"
|
||||
|
||||
|
||||
def get_interface_cable_status_attribute(record):
|
||||
"""
|
||||
Get interface enabled state as string to attach to <tr/> DOM element.
|
||||
"""
|
||||
if record.cable:
|
||||
return record.cable.status
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
||||
#
|
||||
# Device roles
|
||||
#
|
||||
|
@ -673,6 +703,9 @@ class DeviceInterfaceTable(InterfaceTable):
|
|||
'class': get_interface_row_class,
|
||||
'data-name': lambda record: record.name,
|
||||
'data-enabled': get_interface_state_attribute,
|
||||
'data-virtual': get_interface_virtual_attribute,
|
||||
'data-mark-connected': get_interface_mark_connected_attribute,
|
||||
'data-cable-status': get_interface_cable_status_attribute,
|
||||
'data-type': lambda record: record.type,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue