1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

dcim: fix fonts & texts in svg

This commit is contained in:
hellerve
2019-11-20 18:27:04 +01:00
parent 808f5c95e3
commit 1a9b9f50d8

View File

@ -225,7 +225,9 @@ class RackElevationViewSet(ViewSet):
elevation = rack.get_rear_elevation()
else:
return HttpResponseBadRequest('side should either be "front" or "back".')
drawing = svgwrite.Drawing(size=(230, len(elevation)*20), style="box-sizing: border-box")
drawing.defs.add(drawing.style('* { font-family: "Helvetica Neue"; }'))
for i, u in enumerate(elevation):
device = u['device']
@ -234,7 +236,7 @@ class RackElevationViewSet(ViewSet):
if device:
link = drawing.add(drawing.a(reverse('dcim:device', kwargs={'pk': device.pk}), fill='black'))
link.add(drawing.rect((0, start), (230, end), fill='#{}'.format(device.device_role.color), stroke='grey'))
link.add(drawing.text(device.name, insert=(0, start+20)))
link.add(drawing.text(device.name, insert=(115, start+10), text_anchor="middle", dominant_baseline="middle"))
else:
link = drawing.add(
drawing.a('{}?{}'.format(