X-Git-Url: https://git.josue.xyz/?a=blobdiff_plain;f=src%2Fviews%2Fstarter.ejs;h=e7ac311ff1f1a467602883b06aecb6aa0d8b40b4;hb=8bd25d906f766566ceee02d3d70e9890689a4c1a;hp=c760c6b89e7dd95f1c7b38baf4087073d4ebcb21;hpb=3253f871623a1d1f767923771a593a42b121df0f;p=VSoRC%2F.git diff --git a/src/views/starter.ejs b/src/views/starter.ejs index c760c6b..e7ac311 100644 --- a/src/views/starter.ejs +++ b/src/views/starter.ejs @@ -22,17 +22,17 @@ -
- - - - + + + + +
@@ -42,9 +42,19 @@ + + + +
- +
+ + +
+ +
+
@@ -52,8 +62,10 @@
+
+ +
-
@@ -61,17 +73,49 @@ - 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 + + comando.addEventListener('keypress', function(event) { + if (event.keyCode == 13) { + event.preventDefault(); + if(comando.value != ""){ + document.getElementById('btnsend').click(); +} + } + }); + + let timeVsorc = 1000; let timeController = 1000; - //Estos time son para especificar cada cuantos ms se pedira leer la data de los archivos aichivo y controllerout + 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 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); //Para ver que rpi estan UP + + + 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); @@ -82,7 +126,29 @@ } } xhr.send(); - intervalController=setInterval(getcontrollerdata, timeController); + } + function startcontrollerrouter() { + let xhr = new XMLHttpRequest(); + xhr.open('GET', '/startcontrollerrouter', true); + //console.log(xhr); //para ver en la consola + xhr.onload = function() { + if (xhr.status == 200) { //can use this.status instead + console.log("controller started router"); + } + } + xhr.send(); + } + 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() { @@ -95,7 +161,7 @@ } } xhr.send(); - clearInterval(intervalController); + //clearInterval(intervalController); controllerout.value=''; } function getcontrollerdata() { @@ -104,14 +170,39 @@ 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('^'); //La data del controlador y el estado de este llegan separados por ^ + if(controllerstat[1] === "true"){ + document.getElementById('btnstopcontroller').disabled = false; + document.getElementById('btnstartcontroller').disabled = true; + document.getElementById('btnstartcontrollerrouter').disabled = true; + }else{ + document.getElementById('btnstopcontroller').disabled = true; + document.getElementById('btnstartcontroller').disabled = false; + document.getElementById('btnstartcontrollerrouter').disabled = false; + } + controllerout.value=controllerstat[0]; console.log("getting controller data"); + console.log(controllerstat); } } xhr.send(); controllerout.scrollTop = controllerout.scrollHeight; } + function sendcommand() { + let xhr = new XMLHttpRequest(); + cmd = 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(); @@ -124,7 +215,7 @@ } } xhr.send(); - intervalVsorc = setInterval(getvsorcdata, timeVsorc); + } function stopvsorc() { @@ -138,7 +229,7 @@ } } xhr.send(); - clearInterval(intervalVsorc); + //clearInterval(intervalVsorc); vsorcout.value=''; } @@ -148,7 +239,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"); @@ -158,6 +263,8 @@ vsorcout.scrollTop = vsorcout.scrollHeight; } + + function pingall() { let xhr = new XMLHttpRequest(); xhr.open('GET', '/pingall', true); @@ -180,13 +287,14 @@ if (xhr.status == 200) { //can use this.status instead //console.log(xhr.responseText);// para ver en la consola vsorcout.value+=xhr.response; - console.log("pingall"); + console.log("iperf"); } } xhr.send(); } + function placement() { let xhr = new XMLHttpRequest(); xhr.open('GET', '/placement', true); @@ -201,34 +309,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