Scott Baker | ac543a7 | 2015-01-27 15:29:41 -0800 | [diff] [blame] | 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==":-)") { |
Scott Baker | 9edfdc0 | 2015-02-11 15:54:44 -0800 | [diff] [blame] | 10 | tooltip = 'last observer run time = ' + Math.floor(newData.last_duration) + ' seconds'; |
| 11 | icon = "/static/img/green-cloud.gif"; |
Scott Baker | ac543a7 | 2015-01-27 15:29:41 -0800 | [diff] [blame] | 12 | } else { |
Scott Baker | 9edfdc0 | 2015-02-11 15:54:44 -0800 | [diff] [blame] | 13 | tooltip = "observer is offline"; |
| 14 | icon = "/static/img/red-cloud.gif"; |
Scott Baker | ac543a7 | 2015-01-27 15:29:41 -0800 | [diff] [blame] | 15 | } |
Scott Baker | 9edfdc0 | 2015-02-11 15:54:44 -0800 | [diff] [blame] | 16 | |
| 17 | html = '<span style="margin-left: 16px; cursor: pointer;" title="' + tooltip + '"><img src="' + icon + |
| 18 | '" width=16 height=16 onClick="showObserverCalendar();"></span>'; |
| 19 | |
Scott Baker | ac543a7 | 2015-01-27 15:29:41 -0800 | [diff] [blame] | 20 | $("#observer-status").html(html); |
| 21 | setTimeout(function() { updateObserverStatus(); }, 60000); |
| 22 | }, |
| 23 | error: function() { |
| 24 | setTimeout(function() { updateObserverStatus(); }, 60000); |
| 25 | } |
| 26 | }); |
| 27 | } |
| 28 | |
Scott Baker | 9edfdc0 | 2015-02-11 15:54:44 -0800 | [diff] [blame] | 29 | function showObserverCalendar() { |
| 30 | $("#dialog-placeholder").html('<iframe src="https://www.google.com/calendar/embed?src=qlnr1b3rsquq702nbns42l88s4%40group.calendar.google.com&ctz=America/New_York" style="border: 0" width="800" height="600" frameborder="0" scrolling="no"></iframe>'); |
| 31 | $("#dialog-placeholder").dialog({ |
| 32 | autoOpen: false, |
| 33 | modal: true, |
| 34 | width: 850, |
| 35 | buttons : { |
| 36 | "Ok" : function() { |
| 37 | $(this).dialog("close"); |
| 38 | } |
| 39 | } |
| 40 | }); |
| 41 | $("#dialog-placeholder").dialog("open"); |
| 42 | } |
| 43 | |
Scott Baker | ac543a7 | 2015-01-27 15:29:41 -0800 | [diff] [blame] | 44 | $( document ).ready(function() { |
| 45 | updateObserverStatus(); |
| 46 | }); |