mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-05 11:46:50 -06:00
Standardized graph display; added templatization for graph links
This commit is contained in:
@@ -396,32 +396,7 @@ $(".powerport-toggle").click(function() {
|
||||
$(".interface-toggle").click(function() {
|
||||
return toggleConnection($(this), "/api/dcim/interface-connections/");
|
||||
});
|
||||
$('#graphs_modal').on('show.bs.modal', function (event) {
|
||||
var button = $(event.relatedTarget);
|
||||
var iface = button.data('interface');
|
||||
var iface_id = button.data('id');
|
||||
var modal_title = $(this).find('.modal-title');
|
||||
var modal_body = $(this).find('.modal-body');
|
||||
modal_title.text('{{ device.name }} - ' + iface);
|
||||
modal_body.empty();
|
||||
$.ajax({
|
||||
url: "/api/dcim/interfaces/" + iface_id + "/graphs/",
|
||||
dataType: 'json',
|
||||
success: function(json) {
|
||||
$.each(json, function(i, graph) {
|
||||
// Build in a 500ms delay per graph to avoid hammering the server
|
||||
setTimeout(function() {
|
||||
modal_body.append('<h4 class="text-center">' + graph.name + '</h4>');
|
||||
if (graph.link) {
|
||||
modal_body.append('<a href="' + graph.link + '"><img src="' + graph.embed_url + '" /></a>');
|
||||
} else {
|
||||
modal_body.append('<img src="' + graph.embed_url + '" />');
|
||||
}
|
||||
}, i*500);
|
||||
})
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script src="{% static 'js/graphs.js' %}"></script>
|
||||
<script src="{% static 'js/secrets.js' %}"></script>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user