X-Git-Url: https://git.josue.xyz/?a=blobdiff_plain;f=src%2Fviews%2Fstarter.ejs;h=07d5f07c532b8afeb9f955de0d57db1267941d99;hb=ea20f018c05bcc4e56b2dfa3eee30af0d6ffabf3;hp=3528815030c7396a3bbf6ac1f160795320392ba8;hpb=2b1de44527123fab80901384e0f374367500ced8;p=VSoRC%2F.git diff --git a/src/views/starter.ejs b/src/views/starter.ejs index 3528815..07d5f07 100644 --- a/src/views/starter.ejs +++ b/src/views/starter.ejs @@ -22,17 +22,16 @@ -
- - - - + + + +
@@ -42,9 +41,19 @@ + + + +
- +
+ +
+ + +
+
@@ -52,8 +61,10 @@
+
+ +
-
@@ -61,15 +72,37 @@ - let topo = document.getElementById('comandos') //Donde van escrito el DSL - let vsorcout = document.getElementById('vsorcout') //salida del vsorc - let controllerout = document.getElementById('controllerout') //salida del controlador + let topo = document.getElementById('comandos'); //Donde van escrito el DSL + let comando = document.getElementById('vsorccommand'); //Donde va escrito el comando para la terminal + let vsorcout = document.getElementById('vsorcout'); //salida del vsorc + let controllerout = document.getElementById('controllerout'); //salida del controlador + let raspberry = document.getElementById('raspberrys'); //monitor de las rpi disponibles - let intervalController = null; - let intervalVsorc = null + let timeVsorc = 1000; + let timeController = 1000; + let timeping = 5000; + //Estos time son para especificar cada cuantos ms se pedira leer la data de los archivos aichivo, controllerout y que raspberry estan activas - function startcontroller() { + let intervalController = null;//Para tener el id del interval para obtener data del controller + let intervalVsorc = null; //Para tener el id del interval para obtener data del vsorc + + intervalVsorc = setInterval(getvsorcdata, timeVsorc); + intervalController=setInterval(getcontrollerdata, timeController); + setInterval(rpiping,timeping); + function rpiping() { + let xhr = new XMLHttpRequest(); + xhr.open('GET', '/rpiping', true); + xhr.onload = function() { + if (xhr.status == 200) { //can use this.status instead + //console.log(xhr.responseText);// para ver en la consola + raspberry.value=xhr.response; + console.log("getting controller data"); + } + } + xhr.send(); + } + function startcontroller() { let xhr = new XMLHttpRequest(); xhr.open('GET', '/startcontroller', true); //console.log(xhr); //para ver en la consola @@ -79,7 +112,19 @@ } } xhr.send(); - intervalController=setInterval(getcontrollerdata, 500); + + } + function cancel() { + let xhr = new XMLHttpRequest(); + xhr.open('GET', '/cancel', true); + //console.log(xhr); //para ver en la consola + xhr.onload = function() { + if (xhr.status == 200) { //can use this.status instead + console.log("cancelled"); + } + } + xhr.send(); + } function stopcontroller() { @@ -92,7 +137,7 @@ } } xhr.send(); - clearInterval(intervalController); + //clearInterval(intervalController); controllerout.value=''; } function getcontrollerdata() { @@ -101,7 +146,15 @@ xhr.onload = function() { if (xhr.status == 200) { //can use this.status instead //console.log(xhr.responseText);// para ver en la consola - controllerout.value=xhr.response; + let controllerstat = xhr.response.split('^'); + if(controllerstat[1] === "true"){ + document.getElementById('btnstopcontroller').disabled = false; + document.getElementById('btnstartcontroller').disabled = true; + }else{ + document.getElementById('btnstopcontroller').disabled = true; + document.getElementById('btnstartcontroller').disabled = false; + } + controllerout.value=controllerstat[0]; console.log("getting controller data"); } } @@ -109,6 +162,19 @@ controllerout.scrollTop = controllerout.scrollHeight; } + function sendcommand() { + let xhr = new XMLHttpRequest(); + cmd = JSON.stringify(comando.value); + xhr.open('GET', '/sendcommand?cmd=' + cmd, true); + xhr.onload = function() { + if (xhr.status == 200) { //can use this.status instead + //console.log(xhr.responseText);// para ver en la consola + console.log("command sended is "+cmd); + } + } + xhr.send(); + + } function startvsorc() { let xhr = new XMLHttpRequest(); @@ -121,7 +187,7 @@ } } xhr.send(); - intervalVsorc = setInterval(getvsorcdata, 2000); + } function stopvsorc() { @@ -135,7 +201,7 @@ } } xhr.send(); - clearInterval(intervalVsorc); + //clearInterval(intervalVsorc); vsorcout.value=''; } @@ -145,7 +211,21 @@ xhr.onload = function() { if (xhr.status == 200) { //can use this.status instead //console.log(xhr.responseText);// para ver en la consola - vsorcout.value=xhr.response; + + //strip + //cambiar boton con vaina[1] + //vsorcout = vaina[0] + let vsorcstat = xhr.response.split('^'); + if(vsorcstat[1] === "true"){ + document.getElementById('btnstopvsorc').disabled = false; + document.getElementById('btnstartvsorc').disabled = true; + }else{ + document.getElementById('btnstopvsorc').disabled = true; + document.getElementById('btnstartvsorc').disabled = false; + } + + vsorcout.value=vsorcstat[0]; + console.log("getting vsorc data"); @@ -155,6 +235,8 @@ vsorcout.scrollTop = vsorcout.scrollHeight; } + + function pingall() { let xhr = new XMLHttpRequest(); xhr.open('GET', '/pingall', true); @@ -169,6 +251,22 @@ } xhr.send(); } + + function iperf() { + let xhr = new XMLHttpRequest(); + xhr.open('GET', '/iperf', true); + xhr.onload = function() { + if (xhr.status == 200) { //can use this.status instead + //console.log(xhr.responseText);// para ver en la consola + vsorcout.value+=xhr.response; + console.log("iperf"); + + + } + } + xhr.send(); + } + function placement() { let xhr = new XMLHttpRequest(); xhr.open('GET', '/placement', true); @@ -183,34 +281,67 @@ } xhr.send(); } - ///////////////////////////////////////////////////////////////////////CODIGO DE LA terminal - // No idea what these are about. Just copied them from the demo code - // Terminal.applyAddon(attach); - // Terminal.applyAddon(fit); - // Terminal.applyAddon(winptyCompat); - // The terminal - // const fitAddon = new FitAddon(); - // term.loadAddon(fitAddon); + function net() { + let xhr = new XMLHttpRequest(); + xhr.open('GET', '/net', true); + xhr.onload = function() { + if (xhr.status == 200) { //can use this.status instead + //console.log(xhr.responseText);// para ver en la consola + vsorcout.value+=xhr.response; + console.log("net"); + + + } + } + xhr.send(); + } + + function nodes() { + let xhr = new XMLHttpRequest(); + xhr.open('GET', '/nodes', true); + xhr.onload = function() { + if (xhr.status == 200) { //can use this.status instead + //console.log(xhr.responseText);// para ver en la consola + vsorcout.value+=xhr.response; + console.log("nodes"); + + + } + } + xhr.send(); + } + + function status() { + let xhr = new XMLHttpRequest(); + xhr.open('GET', '/statusnodes', true); + xhr.onload = function() { + if (xhr.status == 200) { //can use this.status instead + //console.log(xhr.responseText);// para ver en la consola + vsorcout.value+=xhr.response; + console.log("statusnodes"); + + + } + } + xhr.send(); + } + + function intfs() { + let xhr = new XMLHttpRequest(); + xhr.open('GET', '/intfs', true); + xhr.onload = function() { + if (xhr.status == 200) { //can use this.status instead + //console.log(xhr.responseText);// para ver en la consola + vsorcout.value+=xhr.response; + console.log("interfaces"); + + } + } + xhr.send(); + } - const term = new Terminal(); - // No idea what this does - // term.winptyCompatInit(); - // This kinda makes sense - const container = document.getElementById('terminal'); - term.open(container); - // Open the websocket connection to the backend - const protocol = (location.protocol === 'https:') ? 'wss://' : 'ws://'; - const port = location.port ? `:${location.port}` : ''; - const socketUrl = `${protocol}${location.hostname}${port}/shell`; - const socket = new WebSocket(socketUrl); - const attachAddon = new AttachAddon(socket); - term.loadAddon(attachAddon); - // Attach the socket to the terminal - socket.onopen = (ev) => { term.attach(socket); }; - // Not going to worry about close/error for the websocket - //////////////////////////////////////////////////////////////////////FIN DEL CODIGO DE LA TERMINAL