X-Git-Url: https://git.josue.xyz/?a=blobdiff_plain;f=src%2Fviews%2Fstarter.ejs;h=b80c839a6a9bf11fb4465d299759accdb9491c3d;hb=4432984c42bfe5cb4e33a214df9abc74d346f180;hp=3528815030c7396a3bbf6ac1f160795320392ba8;hpb=2b1de44527123fab80901384e0f374367500ced8;p=VSoRC%2F.git diff --git a/src/views/starter.ejs b/src/views/starter.ejs old mode 100644 new mode 100755 index 3528815..b80c839 --- a/src/views/starter.ejs +++ b/src/views/starter.ejs @@ -22,17 +22,17 @@ -
- - - - + + + + +
@@ -42,18 +42,30 @@ + + + +
- +
+ + +
+ +
+
- + +
+
+
-
@@ -61,15 +73,50 @@ - 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 + comando.addEventListener('keypress', function(event) { + if (event.keyCode == 13) { + event.preventDefault(); + if(comando.value != ""){ + document.getElementById('btnsend').click(); +} + } + }); + + + + 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 + + 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 startcontroller() { + 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 +126,29 @@ } } xhr.send(); - intervalController=setInterval(getcontrollerdata, 500); + } + 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() { @@ -92,7 +161,7 @@ } } xhr.send(); - clearInterval(intervalController); + //clearInterval(intervalController); controllerout.value=''; } function getcontrollerdata() { @@ -101,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(); @@ -121,7 +215,7 @@ } } xhr.send(); - intervalVsorc = setInterval(getvsorcdata, 2000); + } function stopvsorc() { @@ -135,7 +229,7 @@ } } xhr.send(); - clearInterval(intervalVsorc); + //clearInterval(intervalVsorc); vsorcout.value=''; } @@ -145,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"); @@ -155,6 +263,8 @@ vsorcout.scrollTop = vsorcout.scrollHeight; } + + function pingall() { let xhr = new XMLHttpRequest(); xhr.open('GET', '/pingall', true); @@ -169,6 +279,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 +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"); - 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 + } + } + 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(); + } +