summaryrefslogtreecommitdiff
path: root/src/viz
diff options
context:
space:
mode:
Diffstat (limited to 'src/viz')
-rw-r--r--src/viz/stats.html47
1 files changed, 38 insertions, 9 deletions
diff --git a/src/viz/stats.html b/src/viz/stats.html
index ca6c8b2..e60e954 100644
--- a/src/viz/stats.html
+++ b/src/viz/stats.html
@@ -3,50 +3,79 @@
<head>
<meta charset="utf-8" />
<script type="text/javascript" src="/viz/jquery-2.1.1.min.js"></script>
+<style>
+.updateError {
+ background-color: #e30;
+}
+</style>
</head>
<body>
-<table>
+<table id="statstable">
+<tr><td>LastUpdate</td><td id="LastUpdate"></td></tr>
<tr><td>ClientCount</td><td id="ClientCount"></td></tr>
+<tr><td>HubCount</td><td id="HubCount"></td></tr>
+<tr><td>SourcesCount</td><td id="SourcesCount"></td></tr>
<tr><td>UpdateCount</td><td id="UpdateCount"></td></tr>
<tr><td>BytesSent</td><td id="BytesSent"></td></tr>
<tr><td>BytesReceived</td><td id="BytesReceived"></td></tr>
<tr><td>StartTime</td><td id="StartTime"></td></tr>
<tr><td>LastStartTime</td><td id="LastStartTime"></td></tr>
+<tr><td>Message</td><td id="message"></td></tr>
</table>
<script type="text/javascript">
-function pad(number) {
+var s5stats = {
+ lastUpdate: ""
+}
+
+s5stats.pad = function (number) {
if ( number < 10 ) {
return '0' + number;
}
return number;
}
-function toQueryIsoData(dateStr) {
+s5stats.toQueryIsoData = function(dateStr) {
ts = new Date(dateStr)
+ ts.setTime(ts.getTime() + 1 * 1000) // add a second, lowest resolution step for s5
return ts.toISOString();
}
-function updateStats() {
+s5stats.updateStats = function() {
var queryStr = "";
- if ($("#LastStartTime").text() != "") {
- queryStr = "?from=" + toQueryIsoData($("#LastStartTime").text())
+ if (s5stats.lastUpdate == "" && $("#LastStartTime").text() != "") {
+ s5stats.lastUpdate = $("#LastStartTime").text()
+ }
+ if (s5stats.lastUpdate != "") {
+ queryStr = "?from=" + s5stats.toQueryIsoData(s5stats.lastUpdate);
}
$.getJSON("/stats" + queryStr, function(data) {
$("#ClientCount").text(data.ClientCount);
+ $("#HubCount").text(data.HubCount);
+ $("#SourcesCount").text(data.SourcesCount);
$("#UpdateCount").text(data.UpdateCount);
$("#BytesSent").text(data.BytesSent);
$("#BytesReceived").text(data.BytesReceived);
$("#StartTime").text(data.StartTime);
$("#LastStartTime").text(data.LastStartTime);
- });
+ if (data.UpdateCount > 0) {
+ s5stats.lastUpdate = data.LastStartTime;
+ $("#LastUpdate").text(s5stats.lastUpdate)
+ }
+ $("#statstable").removeClass("updateError");
+ $("#message").text("");
+ })
+ .fail(function() {
+ $("#statstable").addClass("updateError");
+ $("#message").text("No connection to Hub!");
+ });
- setTimeout("updateStats()", 5000)
+ setTimeout("s5stats.updateStats()", 5000)
}
$(document).ready(function()
{
- updateStats();
+ s5stats.updateStats();
});
</script>
</body>