Browse Source

Fixes #1584: Colorized virtual machine role column

Jeremy Stretch 7 years ago
parent
commit
6c27e6c4fe
1 changed files with 5 additions and 0 deletions
  1. 5 0
      netbox/virtualization/tables.py

+ 5 - 0
netbox/virtualization/tables.py

@@ -24,6 +24,10 @@ VIRTUALMACHINE_STATUS = """
 <span class="label label-{{ record.get_status_class }}">{{ record.get_status_display }}</span>
 """
 
+VIRTUALMACHINE_ROLE = """
+<label class="label" style="background-color: #{{ record.role.color }}">{{ value }}</label>
+"""
+
 VIRTUALMACHINE_PRIMARY_IP = """
 {{ record.primary_ip6.address.ip|default:"" }}
 {% if record.primary_ip6 and record.primary_ip4 %}<br />{% endif %}
@@ -93,6 +97,7 @@ class VirtualMachineTable(BaseTable):
     name = tables.LinkColumn()
     status = tables.TemplateColumn(template_code=VIRTUALMACHINE_STATUS)
     cluster = tables.LinkColumn('virtualization:cluster', args=[Accessor('cluster.pk')])
+    role = tables.TemplateColumn(VIRTUALMACHINE_ROLE)
     tenant = tables.LinkColumn('tenancy:tenant', args=[Accessor('tenant.slug')])
 
     class Meta(BaseTable.Meta):