Revision fac6fbbe ui/templates/machines.html

b/ui/templates/machines.html
264 264
        //async: false,
265 265
        dataType: "json",
266 266
        success: function(data) {
267
            $.each(data.images, function(i,image){
268
                var img = $('#image-template').clone().attr("id","img-"+image.id).fadeIn("slow");
269
                img.find("label").attr('for',"img-radio-" + image.id);
270
                img.find(".image-title").text(image.name);
271
                img.find(".description").text(image.description);
272
                img.find("input.radio").attr('id',"img-radio-" + image.id);
273
                if (i==0) img.find("input.radio").attr("checked","checked"); 
274
                img.find("img.image-logo").attr('src','static/os_logos/'+image_tags[image.id]+'.png');
275
                if (image.serverId) {
276
                    img.appendTo("ul#custom-images");
277
                } else {
278
                    img.appendTo("ul#standard-images");
279
                }
280
            });
267
            if ($("ul#standard-images li").toArray().length + $("ul#custom-images li").toArray().length == 0) {
268
                $.each(data.images, function(i,image){
269
                    var img = $('#image-template').clone().attr("id","img-"+image.id).fadeIn("slow");
270
                    img.find("label").attr('for',"img-radio-" + image.id);
271
                    img.find(".image-title").text(image.name);
272
                    img.find(".description").text(image.description);
273
                    img.find("input.radio").attr('id',"img-radio-" + image.id);
274
                    if (i==0) img.find("input.radio").attr("checked","checked"); 
275
                    img.find("img.image-logo").attr('src','static/os_logos/'+image_tags[image.id]+'.png');
276
                    if (image.serverId) {
277
                        img.appendTo("ul#custom-images");
278
                    } else {
279
                        img.appendTo("ul#standard-images");
280
                    }
281
                });
282
            }
281 283
        }
282 284
    });
285
    return false;
283 286
}
284 287

  
285 288
// switch to list view
286 289
$("#list").click(function(){
287
    $.cookie("list", '1');
290
    $.cookie("list", '1'); // set list cookie
288 291
    $("div.standard#machinesview").load($("#list").attr("href"));
289 292
    $("a#standard")[0].className += ' activelink'
290 293
    this.style.color = '#5f8dd3';
......
302 305
    return false;
303 306
});
304 307

  
308
// redirect to list view if the list cookie is set
305 309
if ($.cookie("list") == '1') {
306 310
    $("#list").click();
307 311
} else {
308
    // execute the above function to populate the list
312
    // execute the update function to populate the list
309 313
    update();
310 314
}
311 315

  
......
461 465
});
462 466

  
463 467
// reboot action
464
$("div.actions a.action-reboot").live('click', function(){
468
function reboot(){
465 469
    var serverID = $(this).parent().parent().attr("id");
470
    alert("rebooting " + serverID);
466 471
    $.ajax({
467 472
	    url: '/api/v1.0/servers/' + serverID + '/action',
468 473
	    type: "POST",
......
473 478
	    dataType: "json",
474 479
	    success: function() {}
475 480
    });
476
});
481
    return false;
482
}
477 483

  
478 484
// shutdown action
479
$("div.actions a.action-shutdown").live('click', function(){
485
function shutdown() {
480 486
    var serverID = $(this).parent().parent().attr("id");
487
    alert("shutting down " + serverID);
481 488
	$.ajax({
482 489
		url: '/api/v1.0/servers/' + serverID + '/action',
483 490
		type: "POST",
......
488 495
		dataType: "json",
489 496
		success: function() {}
490 497
	});
491
});
498
    return false;    
499
}
500

  
501
// intercept action clicks
502
$("div.actions a.action-shutdown").live('click', shutdown);
503
$("div.actions a.action-reboot").live('click', reboot);
504

  
505

  
492 506
</script>

Also available in: Unified diff