|
@@ -13,6 +13,8 @@ from django.template import Template, Context
|
|
from django.utils.encoding import python_2_unicode_compatible
|
|
from django.utils.encoding import python_2_unicode_compatible
|
|
from django.utils.safestring import mark_safe
|
|
from django.utils.safestring import mark_safe
|
|
|
|
|
|
|
|
+from utilities.utils import foreground_color
|
|
|
|
+
|
|
|
|
|
|
CUSTOMFIELD_MODELS = (
|
|
CUSTOMFIELD_MODELS = (
|
|
'site', 'rack', 'devicetype', 'device', # DCIM
|
|
'site', 'rack', 'devicetype', 'device', # DCIM
|
|
@@ -336,8 +338,9 @@ class TopologyMap(models.Model):
|
|
for query in device_set.split(';'): # Split regexes on semicolons
|
|
for query in device_set.split(';'): # Split regexes on semicolons
|
|
devices += Device.objects.filter(name__regex=query).select_related('device_role')
|
|
devices += Device.objects.filter(name__regex=query).select_related('device_role')
|
|
for d in devices:
|
|
for d in devices:
|
|
- fillcolor = '#{}'.format(d.device_role.color)
|
|
|
|
- subgraph.node(d.name, style='filled', fillcolor=fillcolor)
|
|
|
|
|
|
+ bg_color = '#{}'.format(d.device_role.color)
|
|
|
|
+ fg_color = '#{}'.format(foreground_color(d.device_role.color))
|
|
|
|
+ subgraph.node(d.name, style='filled', fillcolor=bg_color, fontcolor=fg_color, fontname='sans')
|
|
|
|
|
|
# Add an invisible connection to each successive device in a set to enforce horizontal order
|
|
# Add an invisible connection to each successive device in a set to enforce horizontal order
|
|
for j in range(0, len(devices) - 1):
|
|
for j in range(0, len(devices) - 1):
|