201 |
201 |
// create tabs for main menu
|
202 |
202 |
$("ul.tabs").tabs("div.panes ul");
|
203 |
203 |
|
204 |
|
// switch to list view
|
205 |
|
$("#list").click(function(){
|
206 |
|
$("div.standard#machinesview").load($("#list").attr("href"));
|
207 |
|
$("a#standard")[0].className += ' activelink'
|
208 |
|
this.style.color = '#5f8dd3';
|
209 |
|
update();
|
210 |
|
return false;
|
211 |
|
});
|
212 |
|
|
213 |
|
// switch to standard view
|
214 |
|
$("a#standard").click(function(){
|
215 |
|
href=$("a#standard").attr("href");
|
216 |
|
$("div.pane#machines-pane").load(href);
|
217 |
|
//$("a#standard")[0].className += ' activelink'
|
218 |
|
//this.style.color = '#5f8dd3';
|
219 |
|
return false;
|
220 |
|
});
|
221 |
|
|
222 |
204 |
// get and show list of running and terminated machines
|
223 |
205 |
function update() {
|
224 |
206 |
|
... | ... | |
226 |
208 |
$(".terminated").text('');
|
227 |
209 |
$("ul#standard-images").text('');
|
228 |
210 |
$("ul#custom-images").text('');
|
229 |
|
|
230 |
211 |
$.ajax({
|
231 |
212 |
url: '/api/v1.0/servers/detail',
|
232 |
213 |
type: "GET",
|
233 |
214 |
//async: false,
|
234 |
215 |
dataType: "json",
|
235 |
216 |
success: function(data) {
|
236 |
|
$.each(data.servers, function(i,server){
|
237 |
|
|
238 |
|
var machine = $("#machine-template").clone().attr("id", server.id).fadeIn("slow");
|
239 |
|
machine.find("input[type='checkbox']").attr("id", "input-" + server.id);
|
240 |
|
machine.find("input[type='checkbox']").attr("class", server.status);
|
241 |
|
machine.find("a.name span.name").text(server.name);
|
242 |
|
machine.find("img.logo").attr("src","static/machines/"+image_tags[server.imageId]+'.png');
|
243 |
|
machine.find("img.list-logo").attr("src","static/os_logos/"+image_tags[server.imageId]+'.png');
|
244 |
|
machine.find("img.list-logo").attr("title",image_tags[server.imageId]);
|
245 |
|
machine.find("span.imagetag").text(image_tags[server.imageId]);
|
246 |
|
|
247 |
|
machine.find("a.ip span.public").text(String(server.addresses.public).replace(',',' '));
|
248 |
|
|
249 |
|
if (server.status == 'PE_VM_MIGRATING'){
|
250 |
|
machine.find(".status").text('Building');
|
251 |
|
machine.appendTo(".running");
|
252 |
|
} else if (server.status == 'PE_VM_RUNNING') {
|
253 |
|
machine.find(".status").text('Running');
|
254 |
|
machine.appendTo(".running");
|
255 |
|
} else if (server.status == 'PE_VM_SUSPENDED') {
|
256 |
|
machine.find(".status").text('Terminated');
|
257 |
|
machine.find("img.logo").attr("src","static/machines/"+image_tags[server.imageId]+'-off.png');
|
258 |
|
machine.find("img.list-logo").attr("src","static/os_logos/"+image_tags[server.imageId]+'-off.png');
|
259 |
|
machine.appendTo(".terminated");
|
260 |
|
$("#mini.seperator").fadeIn("slow");
|
261 |
|
} else {
|
262 |
|
machine.find(".status").text('Unknown');
|
263 |
|
machine.find("img.logo").attr("src","static/machines/"+image_tags[server.imageId]+'-off.png');
|
264 |
|
machine.find("img.list-logo").attr("src","static/os_logos/"+image_tags[server.imageId]+'-off.png');
|
265 |
|
machine.appendTo(".terminated");
|
266 |
|
}
|
267 |
|
});
|
|
217 |
if ($(".running a.name").toArray().length + $(".terminated a.name").toArray().length == 0) {
|
|
218 |
|
|
219 |
$.each(data.servers, function(i,server){
|
|
220 |
var machine = $("#machine-template").clone().attr("id", server.id).fadeIn("slow");
|
|
221 |
machine.find("input[type='checkbox']").attr("id", "input-" + server.id);
|
|
222 |
machine.find("input[type='checkbox']").attr("class", server.status);
|
|
223 |
machine.find("a.name span.name").text(server.name);
|
|
224 |
machine.find("img.logo").attr("src","static/machines/"+image_tags[server.imageId]+'.png');
|
|
225 |
machine.find("img.list-logo").attr("src","static/os_logos/"+image_tags[server.imageId]+'.png');
|
|
226 |
machine.find("img.list-logo").attr("title",image_tags[server.imageId]);
|
|
227 |
machine.find("span.imagetag").text(image_tags[server.imageId]);
|
|
228 |
|
|
229 |
machine.find("a.ip span.public").text(String(server.addresses.public).replace(',',' '));
|
|
230 |
|
|
231 |
if (server.status == 'PE_VM_MIGRATING'){
|
|
232 |
machine.find(".status").text('Building');
|
|
233 |
machine.appendTo(".running");
|
|
234 |
} else if (server.status == 'PE_VM_RUNNING') {
|
|
235 |
machine.find(".status").text('Running');
|
|
236 |
machine.appendTo(".running");
|
|
237 |
} else if (server.status == 'PE_VM_SUSPENDED') {
|
|
238 |
machine.find(".status").text('Terminated');
|
|
239 |
machine.find("img.logo").attr("src","static/machines/"+image_tags[server.imageId]+'-off.png');
|
|
240 |
machine.find("img.list-logo").attr("src","static/os_logos/"+image_tags[server.imageId]+'-off.png');
|
|
241 |
machine.appendTo(".terminated");
|
|
242 |
$("#mini.seperator").fadeIn("slow");
|
|
243 |
} else {
|
|
244 |
machine.find(".status").text('Unknown');
|
|
245 |
machine.find("img.logo").attr("src","static/machines/"+image_tags[server.imageId]+'-off.png');
|
|
246 |
machine.find("img.list-logo").attr("src","static/os_logos/"+image_tags[server.imageId]+'-off.png');
|
|
247 |
machine.appendTo(".terminated");
|
|
248 |
}
|
|
249 |
});
|
|
250 |
}
|
268 |
251 |
$("div.machine:last-child").find("div.seperator").hide();
|
269 |
252 |
$("#spinner").hide();
|
270 |
253 |
$(".list table").show();
|
... | ... | |
299 |
282 |
});
|
300 |
283 |
}
|
301 |
284 |
|
302 |
|
// execute the above function to populate the list
|
303 |
|
update();
|
|
285 |
// switch to list view
|
|
286 |
$("#list").click(function(){
|
|
287 |
$.cookie("list", '1');
|
|
288 |
$("div.standard#machinesview").load($("#list").attr("href"));
|
|
289 |
$("a#standard")[0].className += ' activelink'
|
|
290 |
this.style.color = '#5f8dd3';
|
|
291 |
update();
|
|
292 |
return false;
|
|
293 |
});
|
|
294 |
|
|
295 |
// switch to standard view
|
|
296 |
$("a#standard").click(function(){
|
|
297 |
$.cookie("list", '0');
|
|
298 |
href=$("a#standard").attr("href");
|
|
299 |
$("div.pane#machines-pane").load(href);
|
|
300 |
//$("a#standard")[0].className += ' activelink'
|
|
301 |
//this.style.color = '#5f8dd3';
|
|
302 |
return false;
|
|
303 |
});
|
|
304 |
|
|
305 |
if ($.cookie("list") == '1') {
|
|
306 |
$("#list").click();
|
|
307 |
} else {
|
|
308 |
// execute the above function to populate the list
|
|
309 |
update();
|
|
310 |
}
|
304 |
311 |
|
305 |
312 |
// launch VM creation wizard
|
306 |
313 |
$("a#create").click(function(){
|