From: VSORC Date: Fri, 27 Sep 2019 01:15:38 +0000 (-0400) Subject: Added images and made the visualizator work X-Git-Url: https://git.josue.xyz/?a=commitdiff_plain;h=6c19fe21cbfc617146dd8df2ffd48e430155bebb;p=VSoRC%2F.git Added images and made the visualizator work --- diff --git a/img/cloud.svg b/img/cloud.svg new file mode 100644 index 0000000..4b70e45 --- /dev/null +++ b/img/cloud.svg @@ -0,0 +1,27 @@ + + + + + + + + Page-1 + + Sheet.1 + + + + + + + + + diff --git a/img/pc.svg b/img/pc.svg new file mode 100644 index 0000000..3d5e6c8 --- /dev/null +++ b/img/pc.svg @@ -0,0 +1,55 @@ + + + + + + + + + + Page-1 + + + Sheet.3 + + + + Sheet.4 + + + + Sheet.5 + + + + Sheet.6 + + + + Sheet.9 + + + + Sheet.11 + + + + Sheet.12 + + + + Sheet.13 + + + + diff --git a/img/switch.svg b/img/switch.svg new file mode 100644 index 0000000..430ece1 --- /dev/null +++ b/img/switch.svg @@ -0,0 +1,38 @@ + + + + + + + + Page-1 + + Sheet.14 + + + + Sheet.2 + + + + Sheet.11 + + + + Sheet.12 + + + + diff --git a/js/topology/topology.js b/js/topology/topology.js index eb1d8d1..c2baab7 100644 --- a/js/topology/topology.js +++ b/js/topology/topology.js @@ -48,6 +48,7 @@ $(function () { var links = []; var lst = top.switches; + for (var i = 0; i < lst.length; i++) { nodes.push({ "id": lst[i].dpid, "type": "switch" }); } @@ -138,11 +139,11 @@ $(function () { node.append("image") .attr("xlink:href", function (d) { if (d.type === "switch") { - return "/home/img/switch.svg" + return "img/switch.svg" } else if (d.type === "cloud") { - return "/home/img/cloud.svg" + return "img/cloud.svg" } else { - return "/home/img/pc.svg" + return "img/pc.svg" } }) .on("mouseover", handleMouseOver) @@ -286,16 +287,16 @@ $(function () { function jsonget() { - const url = "http://"+location.hostname+":8080/topology" + let xhr = new XMLHttpRequest(); - xhr.open('GET', url , true); + xhr.open('GET', "/gettopo" , true); //console.log(xhr); //para ver en la consola xhr.onload = function() { if (xhr.status == 200) { //can use this.status instead //console.log(xhr.responseText);// para ver en la consola - data = JSON.parse(xhr.responseText) - listTopology(data) - plotGraph(toGraph(data)); + + listTopology(JSON.parse(xhr.responseText)); + plotGraph(toGraph(JSON.parse(xhr.responseText))); } } xhr.send(); diff --git a/src/index.js b/src/index.js index a2ece0f..072e61e 100644 --- a/src/index.js +++ b/src/index.js @@ -17,6 +17,7 @@ app.use(express.json()); //para que la ruta de estilos y js sea visible app.use('/styles', express.static('styles')); app.use('/js', express.static('js')); +app.use('/img', express.static('img')); //rutas app.use(require('./routes/index')); // Configurar cabeceras y cors diff --git a/src/routes/index.js b/src/routes/index.js index 3eb3ba4..8e13ede 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -61,5 +61,14 @@ router.get('/ifstat', (req, res) => { }); }); +router.get('/gettopo', (req, res) => { + var sys = require('sys') + var exec = require('child_process').exec; + var child; + child = exec("curl localhost:8080/topology", function(error, stdout, stderr) { + console.log("gettopo"); + res.send(stdout); + }); +}); module.exports = router;