diff --git a/netbox_topology_views/static/netbox_topology_views/js/app.js b/netbox_topology_views/static/netbox_topology_views/js/app.js index 39ad013..6bb48bf 100644 --- a/netbox_topology_views/static/netbox_topology_views/js/app.js +++ b/netbox_topology_views/static/netbox_topology_views/js/app.js @@ -1,5 +1,41 @@ var graph = null; var container = null; + +function iniPlotboxFull() { + document.addEventListener('DOMContentLoaded', function () { + container = document.getElementById('fullvisgraph'); + startRender(); + }, false); +} + +function startRender() { + var url = location.search; + + $.ajax({ + type: "GET", + url: "../../api/plugins/topology-views/search/search/" + url, + contentType: "application/json; charset=utf-8", + success: function (data_result, status, xhr) { + graph = null; + nodes = new vis.DataSet(); + edges = new vis.DataSet(); + graph = new vis.Network(container, { nodes: nodes, edges: edges }, options); + $.each(data_result["nodes"], function (index, device) { + nodes.add(device); + }); + $.each(data_result["edges"], function (index, edge) { + edges.add(edge); + }); + graph.fit(); + canvas = document.getElementById('fullvisgraph').getElementsByTagName('canvas')[0]; + }, + error: function (error_result) { + + }, +}); +} +var graph = null; +var container = null; var downloadButton = null; var MIME_TYPE = "image/png"; var canvas = null; @@ -41,6 +77,7 @@ function iniPlotboxIndex() { startLoadSearchBar(); handleButtonPress(); downloadButton = document.getElementById('btnDownloadImage'); + btnFullView = document.getElementById('btnFullView'); }, false); } @@ -244,7 +281,15 @@ function handleButtonPress() { headers: { "X-CSRFToken": csrftoken }, contentType: "application/json; charset=utf-8", dataType: "json", - success: function (data_result) { + beforeSend: function(){ + new_url = this.url.split("../../api/plugins/topology-views/search/search/?"); + new_url = new_url[1]; + new_url = "../../plugins/topology-views/full?" + new_url + + btnFullView.classList.remove("disabled"); + btnFullView.href = new_url; + }, + success: function (data_result, status, xhr) { $("#status").html('Drawing network'); graph = null; nodes = new vis.DataSet(); diff --git a/netbox_topology_views/static_dev/js/full.js b/netbox_topology_views/static_dev/js/full.js new file mode 100644 index 0000000..53c790b --- /dev/null +++ b/netbox_topology_views/static_dev/js/full.js @@ -0,0 +1,36 @@ +var graph = null; +var container = null; + +function iniPlotboxFull() { + document.addEventListener('DOMContentLoaded', function () { + container = document.getElementById('fullvisgraph'); + startRender(); + }, false); +} + +function startRender() { + var url = location.search; + + $.ajax({ + type: "GET", + url: "../../api/plugins/topology-views/search/search/" + url, + contentType: "application/json; charset=utf-8", + success: function (data_result, status, xhr) { + graph = null; + nodes = new vis.DataSet(); + edges = new vis.DataSet(); + graph = new vis.Network(container, { nodes: nodes, edges: edges }, options); + $.each(data_result["nodes"], function (index, device) { + nodes.add(device); + }); + $.each(data_result["edges"], function (index, edge) { + edges.add(edge); + }); + graph.fit(); + canvas = document.getElementById('fullvisgraph').getElementsByTagName('canvas')[0]; + }, + error: function (error_result) { + + }, +}); +} \ No newline at end of file diff --git a/netbox_topology_views/static_dev/js/home.js b/netbox_topology_views/static_dev/js/home.js index 39ad013..c3982de 100644 --- a/netbox_topology_views/static_dev/js/home.js +++ b/netbox_topology_views/static_dev/js/home.js @@ -41,6 +41,7 @@ function iniPlotboxIndex() { startLoadSearchBar(); handleButtonPress(); downloadButton = document.getElementById('btnDownloadImage'); + btnFullView = document.getElementById('btnFullView'); }, false); } @@ -244,7 +245,15 @@ function handleButtonPress() { headers: { "X-CSRFToken": csrftoken }, contentType: "application/json; charset=utf-8", dataType: "json", - success: function (data_result) { + beforeSend: function(){ + new_url = this.url.split("../../api/plugins/topology-views/search/search/?"); + new_url = new_url[1]; + new_url = "../../plugins/topology-views/full?" + new_url + + btnFullView.classList.remove("disabled"); + btnFullView.href = new_url; + }, + success: function (data_result, status, xhr) { $("#status").html('Drawing network'); graph = null; nodes = new vis.DataSet(); diff --git a/netbox_topology_views/templates/netbox_topology_views/full.html b/netbox_topology_views/templates/netbox_topology_views/full.html new file mode 100644 index 0000000..eeb79eb --- /dev/null +++ b/netbox_topology_views/templates/netbox_topology_views/full.html @@ -0,0 +1,24 @@ +{% load static %} +{% load helpers %} + +{% block content %} +{% with config=settings.PLUGINS_CONFIG.netbox_topology_views %} + + + + +