Browse Source

:art: Add services to UI

Ettore Di Giacinto 3 years ago
parent
commit
661b997ad4
4 changed files with 148 additions and 6 deletions
  1. 5 1
      api/public/blockchain.html
  2. 8 4
      api/public/index.html
  3. 135 0
      api/public/services.html
  4. 0 1
      pkg/edgevpn/services.go

+ 5 - 1
api/public/blockchain.html

@@ -36,9 +36,13 @@
     <div class="navbar-menu">
       <div class="navbar-start">
         <a class="navbar-item" href="/index.html">
-          <i class="fas fa-desktop"></i>&nbsp;
+          <i class="fas fa-server"></i>&nbsp;
           Machines
         </a>
+        <a class="navbar-item" href="/services.html">
+          <i class="fas fa-project-diagram"></i>&nbsp;
+          Services
+        </a>
         <a class="navbar-item" href="/blockchain.html">
           <i class="fas fa-dice-d20"></i>&nbsp;
           Blockchain

+ 8 - 4
api/public/index.html

@@ -37,9 +37,13 @@
     <div class="navbar-menu">
       <div class="navbar-start">
         <a class="navbar-item" href="/index.html">
-          <i class="fas fa-desktop"></i>&nbsp;
+          <i class="fas fa-server"></i>&nbsp;
           Machines
         </a>
+        <a class="navbar-item" href="/services.html">
+          <i class="fas fa-project-diagram"></i>&nbsp;
+          Services
+        </a>
         <a class="navbar-item" href="/blockchain.html">
           <i class="fas fa-dice-d20"></i>&nbsp;
           Blockchain
@@ -64,10 +68,10 @@
       <div class="hero-body">
         <div class="container">
           <h1 class="title">
-            <i class="fas fa-desktop"></i> Connected Machines
+            <i class="fas fa-server"></i> Connected Machines
           </h1>
           <h2 class="subtitle">
-            Accessible via api at <a href="/api/data" target=_blank><code> /api/data </code></a>
+            Accessible via api at <a href="/api/machines" target=_blank><code> /api/machines </code></a>
           </h2>
         </div>
       </div>
@@ -104,7 +108,7 @@
                 var table = $('#table').DataTable( {
                     "processing": true,
                     "ajax": {
-                        "url": "/api/data",
+                        "url": "/api/machines",
                         "type": "GET",
                         "dataSrc": '',
                     },

+ 135 - 0
api/public/services.html

@@ -0,0 +1,135 @@
+<html>
+<head>
+  <link rel="preconnect" href="https://fonts.googleapis.com">
+  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
+  <link href="https://fonts.googleapis.com/css2?family=Duru+Sans&family=Hammersmith+One&family=Lato&family=Nunito&family=Nunito+Sans:wght@400;600&family=Zen+Kurenaido&display=swap" rel="stylesheet"> 
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.9.1/css/bulma.css" />
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css" integrity="sha512-+4zCK9k+qNFUR5X+cKL9EIR+ZOhtIloNl9GIKS57V1MyNsYpYcUrUeQc9vNfzsWfV28IaLL3i96P9sdNyeRssA==" crossorigin="anonymous" />
+
+<!-- datatables -->
+<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> 
+
+<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.22/css/jquery.dataTables.css">
+
+<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.22/js/jquery.dataTables.js"></script>
+
+<script src="/js/dt.js"></script> 
+
+<link rel="stylesheet" type="text/css" href="/css/style.css">
+
+<title>EdgeVPN - Services index</title>
+</head>
+
+<body>
+  <nav class="navbar is-dark is-spaced has-shadow" role="navigation" aria-label="main navigation">
+    <div class="navbar-brand">
+      <a class="navbar-item" href="/">
+      <!--  <img src="/images/logo.png" width="112" height="28"> -->
+      <i class="fas fa-ship"></i>
+      </a>
+  
+      <a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
+        <span aria-hidden="true"></span>
+        <span aria-hidden="true"></span>
+        <span aria-hidden="true"></span>
+      </a>
+    </div>
+    <div class="navbar-menu">
+      <div class="navbar-start">
+        <a class="navbar-item" href="/index.html">
+          <i class="fas fa-server"></i>&nbsp;
+          Machines
+        </a>
+        <a class="navbar-item" href="/services.html">
+          <i class="fas fa-project-diagram"></i>&nbsp;
+          Services
+        </a>
+        <a class="navbar-item" href="/blockchain.html">
+          <i class="fas fa-dice-d20"></i>&nbsp;
+          Blockchain
+        </a>
+      </div>
+      <div class="navbar-end">
+        <div class="navbar-item">
+          <div class="buttons">
+            <a class="button is-link" href="https://github.com/mudler/edgevpn" target=_blank>
+             <strong><i class="fab fa-github-alt"></i> GitHub</strong>
+            </a>
+            <a class="button is-light" href="https://github.com/mudler/edgevpn/issues/new" target=_blank>
+             <i class="fas fa-bug"></i>&nbsp; Report issue
+            </a>
+          </div>
+        </div>
+      </div>
+    </div>
+  </nav>
+
+    <section class="hero">
+      <div class="hero-body">
+        <div class="container">
+          <h1 class="title">
+            <i class="fas fa-project-diagram"></i> Exposed services
+          </h1>
+          <h2 class="subtitle">
+            Accessible via api at <a href="/api/services" target=_blank><code> /api/services </code></a>
+            Connect to any service by running <code>edgevpn service-connect --name "service_name" --srcaddress ":9090"</code>
+          </h2>
+        </div>
+      </div>
+    </section>
+    <section class="section">
+        <div class="container">
+        </div>
+    </section>
+
+
+    <div class="container">
+        <table  data-toggle="table"
+          data-search="true"
+          data-show-columns="true"
+          id="table"  >
+          <thead>
+        
+          <tr>
+              <th ><abbr title="ip">Name</abbr></th>
+              <th ><abbr title="peer">PeerID</abbr></th>
+
+            </tr>
+          </thead>
+        </table> 
+      </div>
+      
+        <script type="text/javascript">
+            $(document).ready(function() {
+                var table = $('#table').DataTable( {
+                    "processing": true,
+                    "ajax": {
+                        "url": "/api/services",
+                        "type": "GET",
+                        "dataSrc": '',
+                    },
+                    'language':{ 
+                      "loadingRecords": "",
+                      "processing": ""
+                    },
+                    "columns": [
+                        { "data": "Name" },
+                        { "data": "PeerID" },
+                    ],
+                } );
+
+                setInterval( function () {
+                    table.ajax.reload();
+                }, 5000 ); // 5 s
+            } );
+        </script>
+        <footer class="footer">
+          <div class="content has-text-centered">
+            <p>
+              <strong>EdgeVPN</strong> by <a href="https://github.com/mudler/edgevpn">Ettore Di Giacinto</a>. The source code is licensed
+              <a href="https://github.com/mudler/edgevpn/blob/master/LICENSE">GPLv3</a>.
+            </p>
+          </div>
+        </footer>  
+    </body>
+</html>

+ 0 - 1
pkg/edgevpn/services.go

@@ -64,7 +64,6 @@ func (e *EdgeVPN) ExposeService(ledger *blockchain.Ledger, serviceID, dstaddress
 
 		}()
 	}
-
 }
 
 func (e *EdgeVPN) ConnectToService(ledger *blockchain.Ledger, serviceID string, srcaddr string) error {