Scott Baker | ac543a7 | 2015-01-27 15:29:41 -0800 | [diff] [blame] | 1 | function updateObserverStatus() { |
| 2 | var url="/observer"; |
Scott Baker | ac543a7 | 2015-01-27 15:29:41 -0800 | [diff] [blame] | 3 | $.ajax({ url: url, |
| 4 | dataType : 'json', |
| 5 | type : 'GET', |
| 6 | success: function(newData) { |
| 7 | console.log(newData); |
| 8 | if (newData.health==":-)") { |
Sapan Bhatia | bfb1a89 | 2016-03-25 16:51:49 +0100 | [diff] [blame] | 9 | tooltip = 'last synchronizer run time = ' + Math.floor(newData.last_duration) + ' seconds'; |
Scott Baker | 9edfdc0 | 2015-02-11 15:54:44 -0800 | [diff] [blame] | 10 | icon = "/static/img/green-cloud.gif"; |
Scott Baker | ac543a7 | 2015-01-27 15:29:41 -0800 | [diff] [blame] | 11 | } else { |
Sapan Bhatia | bfb1a89 | 2016-03-25 16:51:49 +0100 | [diff] [blame] | 12 | tooltip = "synchronizer is offline"; |
Matteo Scandolo | 2500e39 | 2016-03-25 17:20:27 -0700 | [diff] [blame] | 13 | icon = "/static/img/red-cloud.gif"; |
Scott Baker | ac543a7 | 2015-01-27 15:29:41 -0800 | [diff] [blame] | 14 | } |
Scott Baker | 9edfdc0 | 2015-02-11 15:54:44 -0800 | [diff] [blame] | 15 | |
| 16 | html = '<span style="margin-left: 16px; cursor: pointer;" title="' + tooltip + '"><img src="' + icon + |
| 17 | '" width=16 height=16 onClick="showObserverCalendar();"></span>'; |
| 18 | |
Scott Baker | ac543a7 | 2015-01-27 15:29:41 -0800 | [diff] [blame] | 19 | $("#observer-status").html(html); |
| 20 | setTimeout(function() { updateObserverStatus(); }, 60000); |
| 21 | }, |
| 22 | error: function() { |
| 23 | setTimeout(function() { updateObserverStatus(); }, 60000); |
| 24 | } |
| 25 | }); |
| 26 | } |
| 27 | |
Scott Baker | 9edfdc0 | 2015-02-11 15:54:44 -0800 | [diff] [blame] | 28 | function showObserverCalendar() { |
| 29 | $("#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>'); |
| 30 | $("#dialog-placeholder").dialog({ |
| 31 | autoOpen: false, |
| 32 | modal: true, |
| 33 | width: 850, |
| 34 | buttons : { |
| 35 | "Ok" : function() { |
| 36 | $(this).dialog("close"); |
| 37 | } |
| 38 | } |
| 39 | }); |
| 40 | $("#dialog-placeholder").dialog("open"); |
| 41 | } |
| 42 | |
Scott Baker | ac543a7 | 2015-01-27 15:29:41 -0800 | [diff] [blame] | 43 | $( document ).ready(function() { |
| 44 | updateObserverStatus(); |
| 45 | }); |