From cbfb25f00309cc95164df9cb5f8f9a858735e275 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 29 Oct 2018 16:45:20 -0400 Subject: [PATCH] Initial work on a cable tracing modal --- netbox/project-static/js/cabletrace.js | 24 +++++++++++++++++++ netbox/templates/circuits/provider.html | 2 +- netbox/templates/dcim/device.html | 4 +++- netbox/templates/dcim/inc/interface.html | 3 +++ netbox/templates/dcim/site.html | 2 +- .../inc/{graphs_modal.html => modal.html} | 4 ++-- 6 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 netbox/project-static/js/cabletrace.js rename netbox/templates/inc/{graphs_modal.html => modal.html} (68%) diff --git a/netbox/project-static/js/cabletrace.js b/netbox/project-static/js/cabletrace.js new file mode 100644 index 000000000..2307cef87 --- /dev/null +++ b/netbox/project-static/js/cabletrace.js @@ -0,0 +1,24 @@ +$('#cabletrace_modal').on('show.bs.modal', function (event) { + var button = $(event.relatedTarget); + var obj = button.data('obj'); + var url = button.data('url'); + var modal_title = $(this).find('.modal-title'); + var modal_body = $(this).find('.modal-body'); + modal_title.text(obj); + modal_body.empty(); + $.ajax({ + url: url, + dataType: 'json', + success: function(json) { + $.each(json, function(i, segment) { + modal_body.append( + '
' + + '
' + segment[0].device.name + '
' + segment[0].name + '
' + + '
Cable #' + segment[1].id + '
' + + '
' + segment[2].device.name + '
' + segment[2].name + '
' + + '

' + ); + }) + } + }); +}); diff --git a/netbox/templates/circuits/provider.html b/netbox/templates/circuits/provider.html index 4ec9adee1..733632342 100644 --- a/netbox/templates/circuits/provider.html +++ b/netbox/templates/circuits/provider.html @@ -205,7 +205,7 @@ -{% include 'inc/graphs_modal.html' %} +{% include 'inc/modal.html' with modal_name='graphs' %} {% endblock %} {% block javascript %} diff --git a/netbox/templates/dcim/device.html b/netbox/templates/dcim/device.html index 29f187825..1c2bbfccd 100644 --- a/netbox/templates/dcim/device.html +++ b/netbox/templates/dcim/device.html @@ -776,7 +776,8 @@ {% endif %} -{% include 'inc/graphs_modal.html' %} +{% include 'inc/modal.html' with modal_name='graphs' %} +{% include 'inc/modal.html' with modal_name='cabletrace' %} {% include 'secrets/inc/private_key_modal.html' %} {% endblock %} @@ -847,6 +848,7 @@ $('button.toggle-ips').click(function() { return false; }); + {% endblock %} diff --git a/netbox/templates/dcim/inc/interface.html b/netbox/templates/dcim/inc/interface.html index 1ee1706ab..8b6583ace 100644 --- a/netbox/templates/dcim/inc/interface.html +++ b/netbox/templates/dcim/inc/interface.html @@ -32,6 +32,9 @@ {% if iface.cable %} {{ iface.cable }} + {% else %} — {% endif %} diff --git a/netbox/templates/dcim/site.html b/netbox/templates/dcim/site.html index f4623b57b..8fedfbcee 100644 --- a/netbox/templates/dcim/site.html +++ b/netbox/templates/dcim/site.html @@ -330,7 +330,7 @@ -{% include 'inc/graphs_modal.html' %} +{% include 'inc/modal.html' with modal_name='graphs' %} {% endblock %} {% block javascript %} diff --git a/netbox/templates/inc/graphs_modal.html b/netbox/templates/inc/modal.html similarity index 68% rename from netbox/templates/inc/graphs_modal.html rename to netbox/templates/inc/modal.html index 29eaf18bf..b70b9115f 100644 --- a/netbox/templates/inc/graphs_modal.html +++ b/netbox/templates/inc/modal.html @@ -1,9 +1,9 @@ -