mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-19 05:21:55 -06:00
Fixed color display
This commit is contained in:
parent
3518d023dc
commit
83dec3b587
@ -2,7 +2,7 @@ import django_tables2 as tables
|
|||||||
from django_tables2.utils import Accessor
|
from django_tables2.utils import Accessor
|
||||||
|
|
||||||
from tenancy.tables import COL_TENANT
|
from tenancy.tables import COL_TENANT
|
||||||
from utilities.tables import BaseTable, BooleanColumn, ToggleColumn
|
from utilities.tables import BaseTable, BooleanColumn, ColorColumn, ToggleColumn
|
||||||
from .models import (
|
from .models import (
|
||||||
Cable, ConsolePort, ConsolePortTemplate, ConsoleServerPort, ConsoleServerPortTemplate, Device, DeviceBay,
|
Cable, ConsolePort, ConsolePortTemplate, ConsoleServerPort, ConsoleServerPortTemplate, Device, DeviceBay,
|
||||||
DeviceBayTemplate, DeviceRole, DeviceType, FrontPort, FrontPortTemplate, Interface, InterfaceTemplate,
|
DeviceBayTemplate, DeviceRole, DeviceType, FrontPort, FrontPortTemplate, Interface, InterfaceTemplate,
|
||||||
@ -662,6 +662,7 @@ class CableTable(BaseTable):
|
|||||||
template_code=CABLE_LENGTH,
|
template_code=CABLE_LENGTH,
|
||||||
order_by='_abs_length'
|
order_by='_abs_length'
|
||||||
)
|
)
|
||||||
|
color = ColorColumn()
|
||||||
|
|
||||||
class Meta(BaseTable.Meta):
|
class Meta(BaseTable.Meta):
|
||||||
model = Cable
|
model = Cable
|
||||||
|
@ -416,6 +416,10 @@ table.report th a {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Misc */
|
/* Misc */
|
||||||
|
.color-block {
|
||||||
|
display: block;
|
||||||
|
width: 80px;
|
||||||
|
}
|
||||||
.text-nowrap {
|
.text-nowrap {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>Color</td>
|
<td>Color</td>
|
||||||
<td>
|
<td>
|
||||||
<span style="background-color: #{{ cable.color }}">{{ cable.color }}A</span>
|
<span class="label color-block" style="background-color: #{{ cable.color }}"> </span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -46,3 +46,13 @@ class BooleanColumn(tables.Column):
|
|||||||
else:
|
else:
|
||||||
rendered = '<span class="text-muted">—</span>'
|
rendered = '<span class="text-muted">—</span>'
|
||||||
return mark_safe(rendered)
|
return mark_safe(rendered)
|
||||||
|
|
||||||
|
|
||||||
|
class ColorColumn(tables.Column):
|
||||||
|
"""
|
||||||
|
Display a color (#RRGGBB).
|
||||||
|
"""
|
||||||
|
def render(self, value):
|
||||||
|
return mark_safe(
|
||||||
|
'<span class="label color-block" style="background-color: #{}"> </span>'.format(value)
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user