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

Improved cable trace UI

This commit is contained in:
Jeremy Stretch
2020-11-12 16:55:02 -05:00
parent f3f3993963
commit e84a6b99a8
8 changed files with 85 additions and 54 deletions

View File

@@ -2,12 +2,12 @@
{% load helpers %}
{% block header %}
<h1>{% block title %}Cable Trace for {{ obj }}{% endblock %}</h1>
<h1>{% block title %}Cable Trace for {{ obj|meta:"verbose_name"|bettertitle }} {{ obj }}{% endblock %}</h1>
{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-5 col-sm-12 text-center">
<div class="col-md-5 col-sm-12 cable-trace">
{% with traced_path=path.origin.trace %}
{% for near_end, cable, far_end in traced_path %}
@@ -16,7 +16,8 @@
{% include 'dcim/trace/device.html' with device=near_end.device %}
{% include 'dcim/trace/termination.html' with termination=near_end %}
{% elif near_end.power_panel %}
{% include 'dcim/trace/powerfeed.html' with powerfeed=near_end %}
{% include 'dcim/trace/powerpanel.html' with powerpanel=near_end.power_panel %}
{% include 'dcim/trace/termination.html' with termination=far_end%}
{% elif near_end.circuit %}
{% include 'dcim/trace/circuit.html' with circuit=near_end.circuit %}
{% include 'dcim/trace/termination.html' with termination=near_end %}
@@ -27,9 +28,7 @@
{# Cable #}
{% if cable %}
<div class="row">
{% include 'dcim/trace/cable.html' %}
</div>
{% include 'dcim/trace/cable.html' %}
{% endif %}
{# Far end #}
@@ -39,7 +38,8 @@
{% 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 %}
{% include 'dcim/trace/termination.html' with termination=far_end %}
{% include 'dcim/trace/powerpanel.html' with powerpanel=far_end.power_panel %}
{% elif far_end.circuit %}
{% include 'dcim/trace/termination.html' with termination=far_end %}
{% if forloop.last %}
@@ -47,15 +47,17 @@
{% 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 forloop.last %}
<div class="trace-end">
<h3{% if far_end %} class="text-success"{% endif %}>Trace completed</h3>
<h5>Total segments: {{ traced_path|length }}</h5>
<h5>Total length:
{% if total_length %}
<h5>Total length: {{ total_length|floatformat:"-2" }} Meters<h5>
{{ total_length|floatformat:"-2" }} Meters
{% else %}
<span class="text-muted">N/A</span>
{% endif %}
</div>
<h5>
</div>
{% endif %}

View File

@@ -1,15 +1,15 @@
<div class="col-md-6 col-md-offset-3">
<h4><i class="mdi mdi-arrow-up-bold"></i></h4>
<h4>
<div class="cable" style="border-left-color: #{{ cable.color|default:'606060' }}; {% if cable.status != 'connected' %} border-left-style: dashed{% endif %}">
<strong>
<a href="{% url 'dcim:cable' pk=cable.pk %}">
{% if cable.label %}<code>{{ cable.label }}</code>{% else %}Cable #{{ cable.pk }}{% endif %}
</a>
</h4>
<p><span class="label label-{{ cable.get_status_class }}">{{ cable.get_status_display }}</span></p>
<p>{{ cable.get_type_display|default:"" }}</p>
{% if cable.length %}{{ cable.length }} {{ cable.get_length_unit_display }}{% endif %}
{% if cable.color %}
<span class="label color-block center-block" style="background-color: #{{ cable.color }}">&nbsp;</span>
</strong><br />
{% if cable.type %}
{{ cable.get_type_display|default:"" }}
{% if cable.length %}
({{ cable.length }} {{ cable.get_length_unit_display }})
{% endif %}
<br />
{% endif %}
<h4><i class="mdi mdi-arrow-down-bold"></i></h4>
<span class="label label-{{ cable.get_status_class }}">{{ cable.get_status_display }}</span>
</div>

View File

@@ -1,6 +1,5 @@
<div class="panel panel-warning">
<div class="panel-heading">
<strong>Circuit <a href="{{ circuit.get_absolute_url }}">{{ circuit }}</a></strong><br />
<a href="{{ circuit.provider.get_absolute_url }}">{{ circuit.provider }}</a>
</div>
<div class="node">
<strong><a href="{{ circuit.get_absolute_url }}">{{ circuit }}</a></strong><br />
Circuit<br />
<a href="{{ circuit.provider.get_absolute_url }}">{{ circuit.provider }}</a>
</div>

View File

@@ -1,9 +1,8 @@
<div class="panel panel-info">
<div class="panel-heading">
<strong>Device <a href="{{ device.get_absolute_url }}">{{ device }}</a></strong><br />
<a href="{{ device.site.get_absolute_url }}">{{ device.site }}</a>
{% if device.rack %}
/ <a href="{{ device.rack.get_absolute_url }}">{{ device.rack }}</a>
{% endif %}
</div>
<div class="node">
<strong><a href="{{ device.get_absolute_url }}">{{ device }}</a></strong><br />
{{ device.device_type.manufacturer }} {{ device.device_type }}<br />
<a href="{{ device.site.get_absolute_url }}">{{ device.site }}</a>
{% if device.rack %}
/ <a href="{{ device.rack.get_absolute_url }}">{{ device.rack }}</a>
{% endif %}
</div>

View File

@@ -1,9 +0,0 @@
<div class="panel panel-danger">
<div class="panel-heading">
<strong>Power Feed <a href="{{ powerfeed.get_absolute_url }}">{{ powerfeed }}</a></strong><br />
<a href="{{ powerfeed.power_panel.get_absolute_url }}">{{ powerfeed.power_panel }}</a>
{% if powerfeed.rack %}
/ <a href="{{ powerfeed.rack.get_absolute_url }}">{{ powerfeed.rack }}</a>
{% endif %}
</div>
</div>

View File

@@ -0,0 +1,5 @@
<div class="node">
<strong><a href="{{ powerpanel.get_absolute_url }}">{{ powerpanel }}</a></strong><br />
Power Panel<br />
<a href="{{ powerpanel.site.get_absolute_url }}">{{ powerpanel.site }}</a>
</div>

View File

@@ -1,9 +1,8 @@
{% load helpers %}
<div class="panel panel-default">
<div class="panel-body">
{{ termination|meta:"verbose_name"|bettertitle }} <a href="{{ termination.get_absolute_url }}">{{ termination }}</a>
{% if termination.type %}
<br/>{{ termination.get_type_display }}
{% endif %}
</div>
</div>
<div class="termination">
<strong><a href="{{ termination.get_absolute_url }}">{{ termination }}</a></strong><br />
{{ termination|meta:"verbose_name"|bettertitle }}
{% if termination.type %}
({{ termination.get_type_display }})
{% endif %}
</div>