Skip to content

Fixes: #15948 - Fixes cable fanin/fanout when both are required #15953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading