diff --git a/netbox/project-static/js/configcontext.js b/netbox/project-static/js/configcontext.js new file mode 100644 index 00000000000..1d731e696cf --- /dev/null +++ b/netbox/project-static/js/configcontext.js @@ -0,0 +1,11 @@ +$('.rendered-context-format').on('click', function() { + if (!$(this).hasClass('active')) { + // Update selection in the button group + $('span.rendered-context-format').removeClass('active'); + $('span.rendered-context-format[data-format=' + $(this).data('format') + ']').addClass('active'); + + // Hide all rendered contexts and only show the selected one + $('div.rendered-context-data').hide(); + $('div.rendered-context-data[data-format=' + $(this).data('format') + ']').show(); + } +}); diff --git a/netbox/templates/extras/configcontext.html b/netbox/templates/extras/configcontext.html index f9ea26c2bbf..7731acae58b 100644 --- a/netbox/templates/extras/configcontext.html +++ b/netbox/templates/extras/configcontext.html @@ -1,5 +1,6 @@ {% extends '_base.html' %} {% load helpers %} +{% load static %} {% block header %}
{% endblock %} + +{% block javascript %} + +{% endblock %} diff --git a/netbox/templates/extras/inc/configcontext_data.html b/netbox/templates/extras/inc/configcontext_data.html new file mode 100644 index 00000000000..d91960e2c0c --- /dev/null +++ b/netbox/templates/extras/inc/configcontext_data.html @@ -0,0 +1,8 @@ +{% load helpers %} + +{{ data|render_json }}
+{{ rendered_context|render_json }}
+ {% include 'extras/inc/configcontext_data.html' with data=rendered_context %}
{{ obj.local_context_data|render_json }}
+ {% include 'extras/inc/configcontext_data.html' with data=obj.local_context_data %}
{% else %}
None
{% endif %}
@@ -47,7 +49,7 @@
{% if context.description %}
{{ context.data|render_json }}
+ {% include 'extras/inc/configcontext_data.html' with data=context.data %}