Revision c5a032c4 ui/static/synnefo.js
b/ui/static/synnefo.js | ||
---|---|---|
1 | 1 |
var flavors = [], images = [], servers = [], disks = [], cpus = [], ram = []; |
2 | 2 |
var changes_since = 0, deferred = 0, update_request = false; |
3 | 3 |
|
4 |
function ISODateString(d){ |
|
5 |
//return a date in an ISO 8601 format using UTC. |
|
6 |
//do not include time zone info (Z) at the end |
|
7 |
//taken from the Mozilla Developer Center |
|
8 |
function pad(n){return n<10 ? '0'+n : n} |
|
9 |
return d.getUTCFullYear()+'-' |
|
10 |
+ pad(d.getUTCMonth()+1)+'-' |
|
11 |
+ pad(d.getUTCDate())+'T' |
|
12 |
+ pad(d.getUTCHours())+':' |
|
13 |
+ pad(d.getUTCMinutes())+':' |
|
14 |
+ pad(d.getUTCSeconds())} |
|
15 |
|
|
16 |
|
|
17 |
|
|
4 | 18 |
function list_view() { |
5 | 19 |
changes_since = 0; // to reload full list |
6 | 20 |
clearTimeout(deferred); // clear old deferred calls |
... | ... | |
119 | 133 |
try{ console.info('updating machines'); } catch(err){} |
120 | 134 |
var uri='/api/v1.0/servers/detail'; |
121 | 135 |
|
122 |
if (changes_since > 0)
|
|
136 |
if (changes_since != 0)
|
|
123 | 137 |
uri+='?changes-since='+changes_since |
124 | 138 |
|
125 | 139 |
update_request = $.ajax({ |
... | ... | |
139 | 153 |
return false; |
140 | 154 |
}, |
141 | 155 |
success: function(data, textStatus, jqXHR) { |
142 |
changes_since = Date.parse(jqXHR.getResponseHeader('Date'))/1000; |
|
156 |
changes_since_date = new Date(jqXHR.getResponseHeader('Date')); |
|
157 |
changes_since = ISODateString(changes_since_date); |
|
143 | 158 |
if (interval) { |
144 | 159 |
clearTimeout(deferred); // clear old deferred calls |
145 | 160 |
deferred = setTimeout(update_vms,interval,interval); |
Also available in: Unified diff