mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Fix tracing from front/rear ports
This commit is contained in:
@ -2026,6 +2026,7 @@ class PathTraceView(ObjectView):
|
|||||||
# If tracing a PathEndpoint, locate the CablePath (if one exists) by its origin
|
# If tracing a PathEndpoint, locate the CablePath (if one exists) by its origin
|
||||||
if isinstance(obj, PathEndpoint):
|
if isinstance(obj, PathEndpoint):
|
||||||
path = obj._path
|
path = obj._path
|
||||||
|
|
||||||
# Otherwise, find all CablePaths which traverse the specified object
|
# Otherwise, find all CablePaths which traverse the specified object
|
||||||
else:
|
else:
|
||||||
related_paths = CablePath.objects.filter(path__contains=obj).prefetch_related('origin')
|
related_paths = CablePath.objects.filter(path__contains=obj).prefetch_related('origin')
|
||||||
@ -2041,9 +2042,9 @@ class PathTraceView(ObjectView):
|
|||||||
|
|
||||||
return render(request, 'dcim/cable_trace.html', {
|
return render(request, 'dcim/cable_trace.html', {
|
||||||
'obj': obj,
|
'obj': obj,
|
||||||
'path': obj.trace(),
|
'path': path,
|
||||||
'related_paths': related_paths,
|
'related_paths': related_paths,
|
||||||
'total_length': path.get_total_length(),
|
'total_length': path.get_total_length() if path else None,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,58 +8,59 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-5 col-sm-12 text-center">
|
<div class="col-md-5 col-sm-12 text-center">
|
||||||
{% for near_end, cable, far_end in path %}
|
{% with traced_path=path.origin.trace %}
|
||||||
|
{% for near_end, cable, far_end in traced_path %}
|
||||||
|
|
||||||
{# Near end #}
|
{# Near end #}
|
||||||
{% if near_end.device %}
|
{% if near_end.device %}
|
||||||
{% include 'dcim/trace/device.html' with device=near_end.device %}
|
{% include 'dcim/trace/device.html' with device=near_end.device %}
|
||||||
{% include 'dcim/trace/termination.html' with termination=near_end %}
|
{% include 'dcim/trace/termination.html' with termination=near_end %}
|
||||||
{% elif near_end.power_panel %}
|
{% elif near_end.power_panel %}
|
||||||
{% include 'dcim/trace/powerfeed.html' with powerfeed=near_end %}
|
{% include 'dcim/trace/powerfeed.html' with powerfeed=near_end %}
|
||||||
{% elif near_end.circuit %}
|
{% elif near_end.circuit %}
|
||||||
{% include 'dcim/trace/circuit.html' with circuit=near_end.circuit %}
|
{% include 'dcim/trace/circuit.html' with circuit=near_end.circuit %}
|
||||||
{% include 'dcim/trace/termination.html' with termination=near_end %}
|
{% include 'dcim/trace/termination.html' with termination=near_end %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<h3 class="text-danger text-center">Split Paths!</h3>
|
<h3 class="text-danger text-center">Split Paths!</h3>
|
||||||
{# TODO: Present the user with successive paths to choose from #}
|
{# TODO: Present the user with successive paths to choose from #}
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{# Cable #}
|
|
||||||
{% if cable %}
|
|
||||||
<div class="row">
|
|
||||||
{% include 'dcim/trace/cable.html' %}
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{# Far end #}
|
|
||||||
{% if far_end.device %}
|
|
||||||
{% include 'dcim/trace/termination.html' with termination=far_end %}
|
|
||||||
{% if forloop.last %}
|
|
||||||
{% include 'dcim/trace/device.html' with device=far_end.device %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% elif far_end.power_panel %}
|
|
||||||
{% include 'dcim/trace/powerfeed.html' with powerfeed=far_end %}
|
|
||||||
{% elif far_end.circuit %}
|
|
||||||
{% include 'dcim/trace/termination.html' with termination=far_end %}
|
|
||||||
{% if forloop.last %}
|
|
||||||
{% include 'dcim/trace/circuit.html' with circuit=far_end.circuit %}
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if forloop.last and far_end %}
|
{# Cable #}
|
||||||
<div class="row">
|
{% if cable %}
|
||||||
<div class="text-center">
|
<div class="row">
|
||||||
<h3 class="text-success text-center">Trace completed!</h3>
|
{% include 'dcim/trace/cable.html' %}
|
||||||
<h5>Total segments: {{ path|length }}</h5>
|
|
||||||
{% if total_length %}
|
|
||||||
<h5>Total length: {{ total_length|floatformat:"-2" }} Meters<h5>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{% endif %}
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% endfor %}
|
{# Far end #}
|
||||||
|
{% if far_end.device %}
|
||||||
|
{% include 'dcim/trace/termination.html' with termination=far_end %}
|
||||||
|
{% if forloop.last %}
|
||||||
|
{% include 'dcim/trace/device.html' with device=far_end.device %}
|
||||||
|
{% endif %}
|
||||||
|
{% elif far_end.power_panel %}
|
||||||
|
{% include 'dcim/trace/powerfeed.html' with powerfeed=far_end %}
|
||||||
|
{% elif far_end.circuit %}
|
||||||
|
{% include 'dcim/trace/termination.html' with termination=far_end %}
|
||||||
|
{% if forloop.last %}
|
||||||
|
{% include 'dcim/trace/circuit.html' with circuit=far_end.circuit %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if forloop.last and far_end %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="text-center">
|
||||||
|
<h3 class="text-success text-center">Trace completed!</h3>
|
||||||
|
<h5>Total segments: {{ traced_path|length }}</h5>
|
||||||
|
{% if total_length %}
|
||||||
|
<h5>Total length: {{ total_length|floatformat:"-2" }} Meters<h5>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
{% endwith %}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-7 col-sm-12">
|
<div class="col-md-7 col-sm-12">
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user