add son-emu dashboard to the python setup file, so it is served from the Flask app...
authorstevenvanrossem <steven.vanrossem@intec.ugent.be>
Sat, 8 Apr 2017 11:41:15 +0000 (13:41 +0200)
committerstevenvanrossem <steven.vanrossem@intec.ugent.be>
Sat, 8 Apr 2017 11:41:15 +0000 (13:41 +0200)
17 files changed:
dashboard/README.md
dashboard/css/main.css [deleted file]
dashboard/dashboard [new symlink]
dashboard/img/SONATA_new.png [deleted file]
dashboard/index.html [deleted file]
dashboard/js/main.js [deleted file]
dashboard/son-emu-dashboard-screenshot.png [deleted file]
setup.py
src/emuvim/api/rest/rest_api_endpoint.py
src/emuvim/api/sonata/dummygatekeeper.py
src/emuvim/dashboard/README.md [new file with mode: 0755]
src/emuvim/dashboard/__init__.py [new file with mode: 0644]
src/emuvim/dashboard/css/main.css [new file with mode: 0755]
src/emuvim/dashboard/img/SONATA_new.png [new file with mode: 0755]
src/emuvim/dashboard/index.html [new file with mode: 0755]
src/emuvim/dashboard/js/main.js [new file with mode: 0755]
src/emuvim/dashboard/son-emu-dashboard-screenshot.png [new file with mode: 0755]

index db15c9d..70161b7 100755 (executable)
@@ -1,4 +1 @@
-# son-emu Dashboard
-
-A simple web-based dashboard that polls the REST API and displays running services etc. It does not do much more than son-cli but it looks nicer and improves the visualization of the emulator state for live demos.
-
+dashboard is moved to src/emuvim/dashboard so it can be part of the python-based installation script
diff --git a/dashboard/css/main.css b/dashboard/css/main.css
deleted file mode 100755 (executable)
index 7b10dbc..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-body {
-       margin: 16px;
-       height: 100%;
-}
-
-#logo {
-    height: 90px;
-    text-align: right;
-}
-
-#content {
-}
-
-
-.tbl-head {
-    font-weight: bold;
-    border-bottom: 1px solid #2c3e50;
-    background-color: #c9ced3;
-}
-
-.tbl-head > td {
-    padding-top: 4px;
-    padding-bottom: 4px;
-}
-
-.tbl-row > td {
-    padding-top: 4px;
-    padding-bottom: 4px;
-
-}
-
-.spacer {
-    height: 20px;
-}
diff --git a/dashboard/dashboard b/dashboard/dashboard
new file mode 120000 (symlink)
index 0000000..fa6d186
--- /dev/null
@@ -0,0 +1 @@
+../src/emuvim/dashboard/
\ No newline at end of file
diff --git a/dashboard/img/SONATA_new.png b/dashboard/img/SONATA_new.png
deleted file mode 100755 (executable)
index 8fd99f4..0000000
Binary files a/dashboard/img/SONATA_new.png and /dev/null differ
diff --git a/dashboard/index.html b/dashboard/index.html
deleted file mode 100755 (executable)
index 3c31bec..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-    <meta charset="utf-8">
-    <meta http-equiv="X-UA-Compatible" content="IE=edge">
-    <meta name="viewport" content="width=device-width, initial-scale=1">
-    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
-    <title>MeDICINE Dashboard</title>
-
-    <!-- Bootstrap -->
-    <!--<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">-->
-    <link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" integrity="sha384-+ENW/yibaokMnme+vBLnHMphUYxHs34h9lpdbSLuAwGkOKFRl4C34WkjazBtb7eT" crossorigin="anonymous">
-
-    <link href="css/main.css" rel="stylesheet">
-
-    <!-- jQuery -->
-   <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js" type="text/javascript"></script>
-    <!--<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.jss" type="text/javascript"></script>-->
-    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/4.4.0/bootbox.min.js" type="text/javascript"></script>
-
-    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
-    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
-    <!--[if lt IE 9]>
-    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
-    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
-    <![endif]-->
-
-    <script src="js/main.js" type="text/javascript"></script>
-</head>
-
-<body>
-
-  <div id="page-top">
-    <div class="row">
-      <div class="col-sm-8"><h1>MeDICINE Dashboard</h1></div>
-      <div class="col-sm-4" id="logo"><a href="http://sonata-nfv.eu" target="_blank"><img src="img/SONATA_new.png" alt="SONATA Logo" width="252" height="70"></a></div>
-    </div>
-
-<nav class="navbar navbar-default">
-  <div class="container-fluid">
-    <!-- Brand and toggle get grouped for better mobile display -->
-    <div class="navbar-header">
-      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
-        <span class="sr-only">Toggle navigation</span>
-        <span class="icon-bar"></span>
-        <span class="icon-bar"></span>
-        <span class="icon-bar"></span>
-      </button>
-    </div>
-
-    <!-- Collect the nav links, forms, and other content for toggling -->
-    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
-      <div class="navbar-form navbar- navbar-btn btn-group" role="group" aria-label="category">
-          <!--<button type="button" class="btn btn-default active" id="btn_tab_pop">Datacenter List</button>-->
-          <!--<button type="button" class="btn btn-default" id="btn_tab_container">Container List</button>-->
-          <!--<button type="button" class="btn btn-default" id="btn_tab_other">Other</button> -->
-      </div>
-      <form class="navbar-form navbar-right">
-       <div class="input-group">
-          <span class="input-group-addon">http://</span>
-         <input type="text" class="form-control" placeholder="api-url.or.ip" value="sonata-emulator.cs.upb.de:5001" id="text_api_host" data-provide="typeahead" size="30">
-       </div>
-       <button type="button" class="btn btn-success" id="btn_connect">Connect &nbsp;<span class="glyphicon glyphicon-play-circle"></span></button>
-       <button type="button" class="btn btn-danger disabled" id="btn_disconnect">Disconnect &nbsp;<span class="glyphicon glyphicon-off"></span></button>
-               </form> 
-    </div><!-- /.navbar-collapse -->
-  </div><!-- /.container-fluid -->
-</nav>
-</div>
-  <div id="content">
-
-
-<div class="panel panel-primary">
-  <!-- Default panel contents -->
-  <div class="panel-heading"><span>Emulated Datacenters</span>&nbsp;&nbsp;<span class="badge" id="lbl_datacenter_count">0</span><span class="pull-right" id="lbl_lateness_datacenter">Lateness: -</span></div>
-  <!-- Table -->
-  <table class="table table-striped table-hover" id="table_datacenter">
-  </table>
-</div>
-
-<div class="spacer">&nbsp;</div>
-<div class="panel panel-primary">
-  <!-- Default panel contents -->
-  <div class="panel-heading"><span>Running Containers</span>&nbsp;&nbsp;<span class="badge" id="lbl_container_count">0</span><span class="pull-right" id="lbl_lateness_container">Lateness: -</span></div>
-  <!-- Table -->
-  <table class="table table-striped table-hover" id="table_container">
-  </table>
-</div>
-</div>
-
-<footer class="footer text-center small">(c) 2017 by SONATA Consortium and Paderborn University</footer>
-
-
-</body>
-
-</html>
diff --git a/dashboard/js/main.js b/dashboard/js/main.js
deleted file mode 100755 (executable)
index 71741f2..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-var API_HOST = "http://127.0.0.1:5001";
-var ERROR_ALERT = false;
-var TIMESTAMP = 0;
-var CONNECTED = false;
-var LATENESS_UPDATE_INTERVAL = 50;
-var DATA_UPDATE_INTERVAL = 1000 * 10;
-var LAST_UPDATE_TIMESTAMP_CONTAINER = 0;
-var LAST_UPDATE_TIMESTAMP_DATACENTER = 0;
-
-
-function update_lateness_loop() {
-    lateness_datacenter= (Date.now() - LAST_UPDATE_TIMESTAMP_DATACENTER) / 1000;
-    $("#lbl_lateness_datacenter").text("Lateness: " + Number(lateness_datacenter).toPrecision(3) + "s");
-    lateness_container= (Date.now() - LAST_UPDATE_TIMESTAMP_CONTAINER) / 1000;
-    $("#lbl_lateness_container").text("Lateness: " + Number(lateness_container).toPrecision(3) + "s");
-    // loop while connected
-    if(CONNECTED)
-        setTimeout(update_lateness_loop, LATENESS_UPDATE_INTERVAL)
-}
-
-
-function errorAjaxConnection()
-{
-    // only do once
-    if(!ERROR_ALERT)
-    {
-        ERROR_ALERT = true;
-        // show message
-        alert("ERROR!\nAPI request failed.\n\n Please check the backend connection.", function() {
-            // callback
-            ERROR_ALERT = false;
-        });
-    }
-}
-
-
-function update_table_datacenter(data)
-{
-    console.debug(data)
-    // clear table
-    $("#table_datacenter").empty();
-    // header
-    $("#table_datacenter").append('<tr class="tbl-head"><td>Label</td><td>Int. Name</td><td>Switch</td><td>Num. Containers</td><td>Metadata Items</td></tr>');
-    // fill table
-    $.each(data, function(i, item) {
-        var row_str = "";
-        row_str += '<tr class="tbl-row clickable_row" id="datacenter_row_' + i +'">';
-        row_str += '<td>' + item.label + '1</td>';
-        row_str += '<td>' + item.internalname + '</td>';
-        row_str += '<td>' + item.switch + '</td>';
-        row_str += '<td><span class="badge">' + item.n_running_containers + '</span></td>';
-        row_str += '<td><span class="badge">' + Object.keys(item.metadata).length + '</span></td>';
-        row_str += '<tr>';
-       $("#table_datacenter").append(row_str);
-    });
-    $("#lbl_datacenter_count").text(data.length);
-    // update lateness counter
-    LAST_UPDATE_TIMESTAMP_DATACENTER = Date.now();
-}
-
-
-function update_table_container(data)
-{
-    console.debug(data)
-    // clear table
-    $("#table_container").empty();
-    // header
-    $("#table_container").append('<tr class="tbl-head"><td>Datacenter</td><td>Container</td><td>Image</td><td>docker0</td><td>Status</td></tr>');
-    // fill table
-    $.each(data, function(i, item) {
-        var row_str = "";
-        row_str += '<tr class="tbl-row clickable_row" id="container_row_' + i +'">';
-        row_str += '<td>' + item[1].datacenter + '</td>';
-        row_str += '<td>' + item[0] + '</td>';
-        row_str += '<td>' + item[1].image + '</td>';
-        row_str += '<td><code>' + item[1].docker_network + '<code></td>';
-        if(item[1].state.Status == "running")
-            row_str += '<td><span class="label label-success">running</span></td>';
-        else
-            row_str += '<td><span class="label label-danger">stopped</span></td>';
-        row_str += '<tr>';
-       $("#table_container").append(row_str);
-    });
-    $("#lbl_container_count").text(data.length);
-    // update lateness counter
-    LAST_UPDATE_TIMESTAMP_CONTAINER = Date.now();
-}
-
-
-function fetch_datacenter()
-{
-    // do HTTP request and trigger gui update on success
-    var request_url = API_HOST + "/restapi/datacenter";
-    console.debug("fetching from: " + request_url);
-    $.getJSON(request_url,  update_table_datacenter);
-}
-
-
-function fetch_container()
-{
-    // do HTTP request and trigger gui update on success
-    var request_url = API_HOST + "/restapi/compute";
-    console.debug("fetching from: " + request_url);
-    $.getJSON(request_url,  update_table_container);
-}
-
-
-function fetch_loop()
-{
-    // only fetch if we are connected
-    if(!CONNECTED)
-        return;
-
-    // download data
-    fetch_datacenter();
-    fetch_container();
-    
-    // loop while connected
-    if(CONNECTED)
-        setTimeout(fetch_loop, DATA_UPDATE_INTERVAL);
-}
-
-
-function connect()
-{
-    console.info("connect()");
-    // get host address
-    API_HOST = "http://" + $("#text_api_host").val();
-    console.debug("API address: " + API_HOST);
-    // reset data
-    LAST_UPDATE_TIMESTAMP_DATACENTER = Date.now();
-    LAST_UPDATE_TIMESTAMP_CONTAINER = Date.now();
-    CONNECTED = true;
-    // restart lateness counter
-    update_lateness_loop();
-    // restart data fetch loop
-    fetch_loop();
-    // gui updates
-    $("#btn_disconnect").removeClass("disabled");
-    $("#btn_connect").addClass("disabled");
-}
-
-function disconnect()
-{
-    console.info("disconnect()");
-    CONNECTED = false;
-     // gui updates
-    $("#btn_connect").removeClass("disabled");
-    $("#btn_disconnect").addClass("disabled");
-}
-
-
-$(document).ready(function(){
-    console.info("document ready");
-    // setup global connection error handling
-    $.ajaxSetup({
-        "error": errorAjaxConnection
-    });
-
-    // add listeners
-    $("#btn_connect").click(connect);
-    $("#btn_disconnect").click(disconnect);
-
-    // additional refresh on window focus
-    $(window).focus(function () {
-        if(CONNECTED)
-        {
-            fetch_datacenter();
-            fetch_container();  
-        }
-    });
-
-});
diff --git a/dashboard/son-emu-dashboard-screenshot.png b/dashboard/son-emu-dashboard-screenshot.png
deleted file mode 100755 (executable)
index 8274984..0000000
Binary files a/dashboard/son-emu-dashboard-screenshot.png and /dev/null differ
index ce1c47f..186356c 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -38,7 +38,8 @@ setup(name='emuvim',
       packages=find_packages('src'),
       include_package_data=True,
       package_data= {
-              'emuvim.api.sonata': ['*.yml']
+              'emuvim.api.sonata': ['*.yml'],
+              'emuvim.dashboard' : ['*.html', 'css/*.css','img/*','js/*.js']
       },
       install_requires=[
           'pyaml',
index 4767be4..71f87b9 100755 (executable)
@@ -25,6 +25,7 @@ the Horizon 2020 and 5G-PPP programmes. The authors would like to
 acknowledge the contributions of their colleagues of the SONATA
 partner consortium (www.sonata-nfv.eu).
 """
+
 import logging
 import threading
 from flask import Flask
@@ -42,6 +43,9 @@ from network import NetworkAction
 import monitor
 from monitor import MonitorInterfaceAction, MonitorFlowAction, MonitorLinkAction, MonitorSkewAction
 
+import pkg_resources
+from os import path
+
 logging.basicConfig(level=logging.INFO)
 
 
@@ -57,7 +61,12 @@ class RestApiEndpoint(object):
         self.port = port
 
         # setup Flask
-        self.app = Flask(__name__)
+        # find directory of dashboard files
+        dashboard_file = pkg_resources.resource_filename('emuvim.dashboard', "index.html")
+        dashboard_dir = path.dirname(dashboard_file)
+        logging.info("Started emu dashboard: {0}".format(dashboard_dir))
+
+        self.app = Flask(__name__, static_folder=dashboard_dir, static_url_path='/dashboard')
         self.api = Api(self.app)
 
         # setup endpoints
@@ -96,6 +105,7 @@ class RestApiEndpoint(object):
 
         logging.debug("Created API endpoint %s(%s:%d)" % (self.__class__.__name__, self.ip, self.port))
 
+
     def connectDatacenter(self, dc):
         compute.dcs[dc.label] = dc
         logging.info(
index 4e98c6a..76ed3c2 100755 (executable)
@@ -1012,10 +1012,6 @@ api.add_resource(Instantiations, '/instantiations', '/api/v2/instantiations', '/
 api.add_resource(Exit, '/emulator/exit')
 
 
-#def initialize_GK():
-#    global GK
-#    GK = Gatekeeper()
-
 
 def start_rest_api(host, port, datacenters=dict()):
     GK.dcs = datacenters
diff --git a/src/emuvim/dashboard/README.md b/src/emuvim/dashboard/README.md
new file mode 100755 (executable)
index 0000000..db15c9d
--- /dev/null
@@ -0,0 +1,4 @@
+# son-emu Dashboard
+
+A simple web-based dashboard that polls the REST API and displays running services etc. It does not do much more than son-cli but it looks nicer and improves the visualization of the emulator state for live demos.
+
diff --git a/src/emuvim/dashboard/__init__.py b/src/emuvim/dashboard/__init__.py
new file mode 100644 (file)
index 0000000..45ad698
--- /dev/null
@@ -0,0 +1,27 @@
+"""
+Copyright (c) 2017 SONATA-NFV
+ALL RIGHTS RESERVED.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Neither the name of the SONATA-NFV [, ANY ADDITIONAL AFFILIATION]
+nor the names of its contributors may be used to endorse or promote
+products derived from this software without specific prior written
+permission.
+
+This work has been performed in the framework of the SONATA project,
+funded by the European Commission under Grant number 671517 through
+the Horizon 2020 and 5G-PPP programmes. The authors would like to
+acknowledge the contributions of their colleagues of the SONATA
+partner consortium (www.sonata-nfv.eu).
+"""
\ No newline at end of file
diff --git a/src/emuvim/dashboard/css/main.css b/src/emuvim/dashboard/css/main.css
new file mode 100755 (executable)
index 0000000..7b10dbc
--- /dev/null
@@ -0,0 +1,34 @@
+body {
+       margin: 16px;
+       height: 100%;
+}
+
+#logo {
+    height: 90px;
+    text-align: right;
+}
+
+#content {
+}
+
+
+.tbl-head {
+    font-weight: bold;
+    border-bottom: 1px solid #2c3e50;
+    background-color: #c9ced3;
+}
+
+.tbl-head > td {
+    padding-top: 4px;
+    padding-bottom: 4px;
+}
+
+.tbl-row > td {
+    padding-top: 4px;
+    padding-bottom: 4px;
+
+}
+
+.spacer {
+    height: 20px;
+}
diff --git a/src/emuvim/dashboard/img/SONATA_new.png b/src/emuvim/dashboard/img/SONATA_new.png
new file mode 100755 (executable)
index 0000000..8fd99f4
Binary files /dev/null and b/src/emuvim/dashboard/img/SONATA_new.png differ
diff --git a/src/emuvim/dashboard/index.html b/src/emuvim/dashboard/index.html
new file mode 100755 (executable)
index 0000000..6f77d08
--- /dev/null
@@ -0,0 +1,97 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
+    <title>MeDICINE Dashboard</title>
+
+    <!-- Bootstrap -->
+    <!--<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">-->
+    <link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" integrity="sha384-+ENW/yibaokMnme+vBLnHMphUYxHs34h9lpdbSLuAwGkOKFRl4C34WkjazBtb7eT" crossorigin="anonymous">
+
+    <link href="css/main.css" rel="stylesheet">
+
+    <!-- jQuery -->
+   <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js" type="text/javascript"></script>
+    <!--<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.jss" type="text/javascript"></script>-->
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/4.4.0/bootbox.min.js" type="text/javascript"></script>
+
+    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
+    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
+    <!--[if lt IE 9]>
+    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
+    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
+    <![endif]-->
+
+    <script src="js/main.js" type="text/javascript"></script>
+</head>
+
+<body>
+
+  <div id="page-top">
+    <div class="row">
+      <div class="col-sm-8"><h1>MeDICINE Dashboard</h1></div>
+      <div class="col-sm-4" id="logo"><a href="http://sonata-nfv.eu" target="_blank"><img src="img/SONATA_new.png" alt="SONATA Logo" width="252" height="70"></a></div>
+    </div>
+
+<nav class="navbar navbar-default">
+  <div class="container-fluid">
+    <!-- Brand and toggle get grouped for better mobile display -->
+    <div class="navbar-header">
+      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
+        <span class="sr-only">Toggle navigation</span>
+        <span class="icon-bar"></span>
+        <span class="icon-bar"></span>
+        <span class="icon-bar"></span>
+      </button>
+    </div>
+
+    <!-- Collect the nav links, forms, and other content for toggling -->
+    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+      <div class="navbar-form navbar- navbar-btn btn-group" role="group" aria-label="category">
+          <!--<button type="button" class="btn btn-default active" id="btn_tab_pop">Datacenter List</button>-->
+          <!--<button type="button" class="btn btn-default" id="btn_tab_container">Container List</button>-->
+          <!--<button type="button" class="btn btn-default" id="btn_tab_other">Other</button> -->
+      </div>
+      <form class="navbar-form navbar-right">
+       <div class="input-group">
+          <span class="input-group-addon">http://</span>
+         <input type="text" class="form-control" placeholder="api-url.or.ip" value="localhost:5001" id="text_api_host" data-provide="typeahead" size="30">
+       </div>
+       <button type="button" class="btn btn-success" id="btn_connect">Connect &nbsp;<span class="glyphicon glyphicon-play-circle"></span></button>
+       <button type="button" class="btn btn-danger disabled" id="btn_disconnect">Disconnect &nbsp;<span class="glyphicon glyphicon-off"></span></button>
+               </form> 
+    </div><!-- /.navbar-collapse -->
+  </div><!-- /.container-fluid -->
+</nav>
+</div>
+  <div id="content">
+
+
+<div class="panel panel-primary">
+  <!-- Default panel contents -->
+  <div class="panel-heading"><span>Emulated Datacenters</span>&nbsp;&nbsp;<span class="badge" id="lbl_datacenter_count">0</span><span class="pull-right" id="lbl_lateness_datacenter">Lateness: -</span></div>
+  <!-- Table -->
+  <table class="table table-striped table-hover" id="table_datacenter">
+  </table>
+</div>
+
+<div class="spacer">&nbsp;</div>
+<div class="panel panel-primary">
+  <!-- Default panel contents -->
+  <div class="panel-heading"><span>Running Containers</span>&nbsp;&nbsp;<span class="badge" id="lbl_container_count">0</span><span class="pull-right" id="lbl_lateness_container">Lateness: -</span></div>
+  <!-- Table -->
+  <table class="table table-striped table-hover" id="table_container">
+  </table>
+</div>
+</div>
+
+<footer class="footer text-center small">(c) 2017 by SONATA Consortium and Paderborn University</footer>
+
+
+</body>
+
+</html>
diff --git a/src/emuvim/dashboard/js/main.js b/src/emuvim/dashboard/js/main.js
new file mode 100755 (executable)
index 0000000..71741f2
--- /dev/null
@@ -0,0 +1,173 @@
+var API_HOST = "http://127.0.0.1:5001";
+var ERROR_ALERT = false;
+var TIMESTAMP = 0;
+var CONNECTED = false;
+var LATENESS_UPDATE_INTERVAL = 50;
+var DATA_UPDATE_INTERVAL = 1000 * 10;
+var LAST_UPDATE_TIMESTAMP_CONTAINER = 0;
+var LAST_UPDATE_TIMESTAMP_DATACENTER = 0;
+
+
+function update_lateness_loop() {
+    lateness_datacenter= (Date.now() - LAST_UPDATE_TIMESTAMP_DATACENTER) / 1000;
+    $("#lbl_lateness_datacenter").text("Lateness: " + Number(lateness_datacenter).toPrecision(3) + "s");
+    lateness_container= (Date.now() - LAST_UPDATE_TIMESTAMP_CONTAINER) / 1000;
+    $("#lbl_lateness_container").text("Lateness: " + Number(lateness_container).toPrecision(3) + "s");
+    // loop while connected
+    if(CONNECTED)
+        setTimeout(update_lateness_loop, LATENESS_UPDATE_INTERVAL)
+}
+
+
+function errorAjaxConnection()
+{
+    // only do once
+    if(!ERROR_ALERT)
+    {
+        ERROR_ALERT = true;
+        // show message
+        alert("ERROR!\nAPI request failed.\n\n Please check the backend connection.", function() {
+            // callback
+            ERROR_ALERT = false;
+        });
+    }
+}
+
+
+function update_table_datacenter(data)
+{
+    console.debug(data)
+    // clear table
+    $("#table_datacenter").empty();
+    // header
+    $("#table_datacenter").append('<tr class="tbl-head"><td>Label</td><td>Int. Name</td><td>Switch</td><td>Num. Containers</td><td>Metadata Items</td></tr>');
+    // fill table
+    $.each(data, function(i, item) {
+        var row_str = "";
+        row_str += '<tr class="tbl-row clickable_row" id="datacenter_row_' + i +'">';
+        row_str += '<td>' + item.label + '1</td>';
+        row_str += '<td>' + item.internalname + '</td>';
+        row_str += '<td>' + item.switch + '</td>';
+        row_str += '<td><span class="badge">' + item.n_running_containers + '</span></td>';
+        row_str += '<td><span class="badge">' + Object.keys(item.metadata).length + '</span></td>';
+        row_str += '<tr>';
+       $("#table_datacenter").append(row_str);
+    });
+    $("#lbl_datacenter_count").text(data.length);
+    // update lateness counter
+    LAST_UPDATE_TIMESTAMP_DATACENTER = Date.now();
+}
+
+
+function update_table_container(data)
+{
+    console.debug(data)
+    // clear table
+    $("#table_container").empty();
+    // header
+    $("#table_container").append('<tr class="tbl-head"><td>Datacenter</td><td>Container</td><td>Image</td><td>docker0</td><td>Status</td></tr>');
+    // fill table
+    $.each(data, function(i, item) {
+        var row_str = "";
+        row_str += '<tr class="tbl-row clickable_row" id="container_row_' + i +'">';
+        row_str += '<td>' + item[1].datacenter + '</td>';
+        row_str += '<td>' + item[0] + '</td>';
+        row_str += '<td>' + item[1].image + '</td>';
+        row_str += '<td><code>' + item[1].docker_network + '<code></td>';
+        if(item[1].state.Status == "running")
+            row_str += '<td><span class="label label-success">running</span></td>';
+        else
+            row_str += '<td><span class="label label-danger">stopped</span></td>';
+        row_str += '<tr>';
+       $("#table_container").append(row_str);
+    });
+    $("#lbl_container_count").text(data.length);
+    // update lateness counter
+    LAST_UPDATE_TIMESTAMP_CONTAINER = Date.now();
+}
+
+
+function fetch_datacenter()
+{
+    // do HTTP request and trigger gui update on success
+    var request_url = API_HOST + "/restapi/datacenter";
+    console.debug("fetching from: " + request_url);
+    $.getJSON(request_url,  update_table_datacenter);
+}
+
+
+function fetch_container()
+{
+    // do HTTP request and trigger gui update on success
+    var request_url = API_HOST + "/restapi/compute";
+    console.debug("fetching from: " + request_url);
+    $.getJSON(request_url,  update_table_container);
+}
+
+
+function fetch_loop()
+{
+    // only fetch if we are connected
+    if(!CONNECTED)
+        return;
+
+    // download data
+    fetch_datacenter();
+    fetch_container();
+    
+    // loop while connected
+    if(CONNECTED)
+        setTimeout(fetch_loop, DATA_UPDATE_INTERVAL);
+}
+
+
+function connect()
+{
+    console.info("connect()");
+    // get host address
+    API_HOST = "http://" + $("#text_api_host").val();
+    console.debug("API address: " + API_HOST);
+    // reset data
+    LAST_UPDATE_TIMESTAMP_DATACENTER = Date.now();
+    LAST_UPDATE_TIMESTAMP_CONTAINER = Date.now();
+    CONNECTED = true;
+    // restart lateness counter
+    update_lateness_loop();
+    // restart data fetch loop
+    fetch_loop();
+    // gui updates
+    $("#btn_disconnect").removeClass("disabled");
+    $("#btn_connect").addClass("disabled");
+}
+
+function disconnect()
+{
+    console.info("disconnect()");
+    CONNECTED = false;
+     // gui updates
+    $("#btn_connect").removeClass("disabled");
+    $("#btn_disconnect").addClass("disabled");
+}
+
+
+$(document).ready(function(){
+    console.info("document ready");
+    // setup global connection error handling
+    $.ajaxSetup({
+        "error": errorAjaxConnection
+    });
+
+    // add listeners
+    $("#btn_connect").click(connect);
+    $("#btn_disconnect").click(disconnect);
+
+    // additional refresh on window focus
+    $(window).focus(function () {
+        if(CONNECTED)
+        {
+            fetch_datacenter();
+            fetch_container();  
+        }
+    });
+
+});
diff --git a/src/emuvim/dashboard/son-emu-dashboard-screenshot.png b/src/emuvim/dashboard/son-emu-dashboard-screenshot.png
new file mode 100755 (executable)
index 0000000..8274984
Binary files /dev/null and b/src/emuvim/dashboard/son-emu-dashboard-screenshot.png differ