red and green observer status icons
[plstackapi.git] / planetstack / core / static / observer_status.js
1 function updateObserverStatus() {
2     var url="/observer";
3     console.log("fetching observer status url " + url);
4     $.ajax({ url: url,
5              dataType : 'json',
6              type : 'GET',
7              success: function(newData) {
8                   console.log(newData);
9                   if (newData.health==":-)") {
10                       html = '<span style="margin-left: 16px;" title="last observer run time = ' + Math.floor(newData.last_duration) + ' seconds"><img src="/static/img/green-cloud.gif" width=16 height=16></span>';
11                   } else {
12                       html = '<span style="margin-left: 16px;" title="observer is offline"><img src="/static/img/red-cloud.gif"></span>';
13                   }
14                   $("#observer-status").html(html);
15                   setTimeout(function() { updateObserverStatus(); }, 60000);
16              },
17              error: function() {
18                   setTimeout(function() { updateObserverStatus(); }, 60000);
19              }
20 });
21 }
22
23 $( document ).ready(function() {
24     updateObserverStatus();
25 });