-# 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
+++ /dev/null
-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;
-}
--- /dev/null
+../src/emuvim/dashboard/
\ No newline at end of file
+++ /dev/null
-<!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 <span class="glyphicon glyphicon-play-circle"></span></button>
- <button type="button" class="btn btn-danger disabled" id="btn_disconnect">Disconnect <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> <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"> </div>
-
-<div class="panel panel-primary">
- <!-- Default panel contents -->
- <div class="panel-heading"><span>Running Containers</span> <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>
+++ /dev/null
-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();
- }
- });
-
-});
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',
acknowledge the contributions of their colleagues of the SONATA
partner consortium (www.sonata-nfv.eu).
"""
+
import logging
import threading
from flask import Flask
import monitor
from monitor import MonitorInterfaceAction, MonitorFlowAction, MonitorLinkAction, MonitorSkewAction
+import pkg_resources
+from os import path
+
logging.basicConfig(level=logging.INFO)
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
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(
api.add_resource(Exit, '/emulator/exit')
-#def initialize_GK():
-# global GK
-# GK = Gatekeeper()
-
def start_rest_api(host, port, datacenters=dict()):
GK.dcs = datacenters
--- /dev/null
+# 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.
+
--- /dev/null
+"""
+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
--- /dev/null
+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;
+}
--- /dev/null
+<!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 <span class="glyphicon glyphicon-play-circle"></span></button>
+ <button type="button" class="btn btn-danger disabled" id="btn_disconnect">Disconnect <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> <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"> </div>
+
+<div class="panel panel-primary">
+ <!-- Default panel contents -->
+ <div class="panel-heading"><span>Running Containers</span> <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>
--- /dev/null
+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();
+ }
+ });
+
+});