initial dashboard files
authorpeusterm <manuel.peuster@uni-paderborn.de>
Wed, 11 Jan 2017 18:16:28 +0000 (19:16 +0100)
committerpeusterm <manuel.peuster@uni-paderborn.de>
Wed, 11 Jan 2017 18:16:28 +0000 (19:16 +0100)
dashboard/css/main.css [new file with mode: 0644]
dashboard/img/SONATA_new.png [new file with mode: 0644]
dashboard/index.html [new file with mode: 0644]
dashboard/js/main.js [new file with mode: 0644]

diff --git a/dashboard/css/main.css b/dashboard/css/main.css
new file mode 100644 (file)
index 0000000..bbcdc59
--- /dev/null
@@ -0,0 +1,40 @@
+body {
+       margin: 16px;
+       height: 100%;
+}
+
+#logo {
+    height: 90px;
+    text-align: right;
+}
+
+#content {
+}
+
+#input_filter {
+       width: 100px;
+}
+
+
+.tbl-timestamp {
+       font-size: 10px;
+    color: #2b669a;
+}
+
+.tbl-message {
+       font-size: 14px;
+}
+
+.tbl-address {
+       font-size: 14px;
+    vertical-align: middle;
+}
+
+.tbl-cat {
+       font-size: 14px;
+    vertical-align: middle;
+}
+
+.unitbutton {
+       cursor: pointer;
+}
diff --git a/dashboard/img/SONATA_new.png b/dashboard/img/SONATA_new.png
new file mode 100644 (file)
index 0000000..8fd99f4
Binary files /dev/null and b/dashboard/img/SONATA_new.png differ
diff --git a/dashboard/index.html b/dashboard/index.html
new file mode 100644 (file)
index 0000000..4ef59b6
--- /dev/null
@@ -0,0 +1,76 @@
+<html>
+<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="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 id="logo"><img src="img/SONATA_new.png" alt="SONATA Logo" width="252" height="70"></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>
+      <a class="navbar-brand" href="#">MeDICINE Dashboard</a>
+    </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">PoP 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>
+      <div class="navbar-form navbar- navbar-btn btn-group" role="group" aria-label="category">
+         <button type="button" class="btn btn-default active" id="btn_autorefresh">Auto-refresh</button>
+      </div>
+    </div><!-- /.navbar-collapse -->
+  </div><!-- /.container-fluid -->
+</nav>
+</div>
+<div id="content">
+<div class="panel panel-primary">
+  <!-- Default panel contents -->
+  <div class="panel-heading"><span>Messages</span> <span class="badge" id="lbl_msg_count">0</span><span class="pull-right" id="lbl_lateness">Lateness: -</span></div>
+  <!-- Table -->
+  <table class="table table-striped table-hover" id="table_messages">
+  </table>
+</div>
+
+</div>
+
+<footer class="footer text-center small">(c) 2017 by Manuel Peuster (manuel.peuster [at] upb.de)</footer>
+
+
+</body>
+
+</html>
diff --git a/dashboard/js/main.js b/dashboard/js/main.js
new file mode 100644 (file)
index 0000000..928adf7
--- /dev/null
@@ -0,0 +1,83 @@
+var API_HOST = "http://127.0.0.1:5001";
+var ERROR_ALERT = true;
+var TIMESTAMP = 0;
+
+
+
+function updateMessageTable(msg_list) {
+   
+}
+
+function updateMessageCount(msg_list) {
+    $("#lbl_msg_count").text(msg_list.length);
+}
+
+function fetchMessages() {
+   
+}
+
+
+function autoFetchMessages() {
+    fetchMessages();
+    // do periodic update
+    if(AUTO_REFRESH)
+           setTimeout(autoFetchMessages, AUTO_REFRESH_INTERVAL);
+}
+
+function updateLateness() {
+    lateness = (Date.now() - LAST_UPDATE_TIMESTAMP) / 1000;
+    $("#lbl_lateness").text("Lateness: " + Number(lateness).toPrecision(3) + "s")
+    setTimeout(updateLateness, LATENESS_UPDATE_INTERVAL)
+}
+
+function errorAjaxConnection()
+{
+    // only do once
+    if(!ERROR_ALERT)
+    {
+        ERROR_ALERT = true;
+        // show message
+        bootbox.alert("ERROR!\nAPI request failed.\n\n Please check the backend connection.", function() {
+            // callback
+            ERROR_ALERT = false;
+        });
+    }
+}
+
+function change_auto_refresh(event)
+{
+    console.debug("trigger btn_auto_refresh");
+    AUTO_REFRESH = !AUTO_REFRESH;
+    if(AUTO_REFRESH) {
+        $("#btn_autorefresh").addClass("active");
+        autoFetchMessages();
+    }
+    else {
+        $("#btn_autorefresh").removeClass("active");
+    }
+}
+
+
+$(document).ready(function(){
+    console.info("document ready");
+       // setup global connection error handling
+       $.ajaxSetup({
+      "error": errorAjaxConnection
+       });
+
+    // add listeners
+    //TODO
+
+    // activate message fetching
+    autoFetchMessages();
+    LAST_UPDATE_TIMESTAMP = Date.now();
+    updateLateness();
+
+
+    // refresh on window focus
+    $(window).focus(function () {
+        // TODO observe if this works well
+        fetchMessages();
+    });
+
+});