Skip to content

Commit

Permalink
Fixes: #15948 - Fixes cable fanin/fanout when both are required (#15953)
Browse files Browse the repository at this point in the history
* Preliminary fix for #15948

* Tweaking of line height
  • Loading branch information
DanSheps authored May 6, 2024
1 parent 4cc5079 commit 56e0449
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions netbox/dcim/svg/cables.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
LINE_HEIGHT = 20
FANOUT_HEIGHT = 35
FANOUT_LEG_HEIGHT = 15
CABLE_HEIGHT = 4 * LINE_HEIGHT + FANOUT_HEIGHT + FANOUT_LEG_HEIGHT
CABLE_HEIGHT = 5 * LINE_HEIGHT + FANOUT_HEIGHT + FANOUT_LEG_HEIGHT


class Node(Hyperlink):
Expand Down Expand Up @@ -405,7 +405,17 @@ def render(self):
end = far[0].top_center
text_offset = 0

if len(near) > 1:
if len(near) > 1 and len(far) > 1:
start_center = sum([pos.bottom_center[0] for pos in near]) / len(near)
end_center = sum([pos.bottom_center[0] for pos in far]) / len(far)
center_x = (start_center + end_center) / 2

start = (center_x, start[1] + FANOUT_HEIGHT + FANOUT_LEG_HEIGHT)
end = (center_x, end[1] - FANOUT_HEIGHT - FANOUT_LEG_HEIGHT)
text_offset -= (FANOUT_HEIGHT + FANOUT_LEG_HEIGHT)
self.draw_fanin(start, near, color)
self.draw_fanout(end, far, color)
elif len(near) > 1:
# Handle Fan-In - change start position to be directly below start
start = (end[0], start[1] + FANOUT_HEIGHT + FANOUT_LEG_HEIGHT)
self.draw_fanin(start, near, color)
Expand Down

0 comments on commit 56e0449

Please sign in to comment.