autorefresh in the stats and minor color changes
[VSoRC/.git] / src / views / starter.ejs
index 17503f677d2171905c1ccb4170b7d6a853d5a6bf..01b83278f1dd3d2eb4a99485b82be695da6886a8 100644 (file)
   <!-- <link rel="stylesheet" type="text/css" href="/styles/main.css" /> -->
   <%include ../../partials/head%>
   <style media="screen">
-    body{
+    body {
       display: flex;
       flex-flow: row wrap;
     }
-    main{
+
+    main {
+      width: 100%;
       flex-grow: 2;
     }
-    aside{
+
+    aside {
       flex-grow: 1;
     }
-    footer{
+
+    footer {
       position: absolute;
       top: 100%;
     }
 
-    input[type="text"]{
-      background-color: rgba(200,200,200,0.5);
-      border: 0;
-      border-bottom: 2px black solid;
-      overflow: hidden;
-      width: 15em;
+    .buttons {
+      display: flex;
+      width: 100%;
+      margin: 0;
+      padding: 0;
     }
-    input[type="submit"]{
+
+    button {
+      flex-grow: 1;
       border: 0;
       border-bottom: 2px black solid;
       overflow: hidden;
       width: 15em;
       background-color: white;
+      transition: background-color 0.3s ease-in, color 0.3s ease-in;
+    }
+
+    button:hover {
+      background-color: darkgrey;
+      color: white
+    }
+
+    textarea {
+      width: 25%;
+      font-size: 1.5em;
+      overflow: auto;
+      height: 15em;
+      background-color: rgba(255, 255, 255, 0.8);
+      padding: 0;
+      margin: 0;
     }
   </style>
 </head>
 <header>
   <%include ../../partials/header%>
 </header>
+
 <body>
 
   <main>
-    <form class="" action="/startcontroller" method="get">
-      <input type="text" name="" value="" placeholder="Inserte vaina">
-      <input type="submit" name="" value="Inicar controlador" >
-    </form>
-    <form class="" action="/startproyect" method="post">
-      <input type="text" name="" value="" placeholder="Ip del controlador">
-      <input type="submit" name="" value="Iniciar Proyecto">
-    </form>
+    <div class="buttons">
+      <button type="button" name="button" onclick="startvsorc()">Iniciar VsoRc</button>
+      <button type="button" name="button" onclick="stopvsorc()">Detener VsoRc</button>
+      <button type="button" name="button" onclick="startcontroller()">Iniciar controlador</button>
+      <button type="button" name="button" onclick="stopcontroller()">Detener controlador</button>
+    </div>
+    <textarea rows="20" cols="7" id="comandos"></textarea>
+    <script type="text/javascript">
+      let topo = document.getElementById('comandos') //Donde van escrito el DSL
+
+
+
+      function stopcontroller() {
+        let xhr = new XMLHttpRequest();
+        xhr.open('GET', '/stopcontroller', true);
+        xhr.onload = function() {
+          if (xhr.status == 200) { //can use this.status instead
+            //console.log(xhr.responseText);// para ver en la consola
+            console.log("controller stoped");
+          }
+        }
+        xhr.send();
+
+      }
+
+      function startcontroller() {
+        let xhr = new XMLHttpRequest();
+        xhr.open('GET', '/startcontroller', 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");
+          }
+        }
+        xhr.send();
+      }
+
+      function startvsorc() {
+        let xhr = new XMLHttpRequest();
+        topology = JSON.stringify(topo.value)
+        xhr.open('GET', '/startvsorc?topology=' + topology, true);
+        xhr.onload = function() {
+          if (xhr.status == 200) { //can use this.status instead
+            //console.log(xhr.responseText);// para ver en la consola
+            console.log("vsorc started");
+          }
+        }
+
+        xhr.send();
+
+      }
+
+      function stopvsorc() {
+        let xhr = new XMLHttpRequest();
+        xhr.open('GET', '/stopvsorc', true);
+        xhr.onload = function() {
+          if (xhr.status == 200) { //can use this.status instead
+            //console.log(xhr.responseText);// para ver en la consola
+            console.log("vsorc stopped");
+          }
+        }
+        xhr.send();
+      }
+    </script>
   </main>
   <aside class="">
     <div class="statuscontroller">
 </footer>
 
 
-</html>
+</html>
\ No newline at end of file