Răsfoiți Sursa

Add data properties for device interface table

Preparatory work for factoring row styling decisions out of Python code.
Per von Zweigbergk 2 ani în urmă
părinte
comite
d76ede17d3
1 a modificat fișierele cu 33 adăugiri și 0 ștergeri
  1. 33 0
      netbox/dcim/tables/devices.py

+ 33 - 0
netbox/dcim/tables/devices.py

@@ -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,
         }