Commit a28ebd26 authored by Mike Muzurakis's avatar Mike Muzurakis
Browse files

fix welcome page timing issues, Refs #279

use our own timers to keep count of the server list
instead of waiting for the ajax calls
parent 83aeb938
......@@ -702,6 +702,7 @@ function get_metadata(serverID) {
// show the welcome screen
function showWelcome() {
$("#view-select").fadeOut("fast");
$("#machinesview.standard").fadeOut("fast");
$("#createcontainer").addClass('emptycreatecontainer')
$("#create").addClass('emptycreate')
$("#emptymachineslist").fadeIn("fast");
......@@ -716,6 +717,7 @@ function hideWelcome() {
$("#createcontainer").removeClass('emptycreatecontainer')
$("#create").removeClass('emptycreate')
$("#view-select").fadeIn("fast");
$("#machinesview.standard").fadeIn("fast");
$("div#view-select").show();
$("#create").css("display", "inline");
}
......
......@@ -122,6 +122,7 @@ $("a.enabled#action-destroy").live('click', function() {
checked.each(function(i,c) {
serverID=c.id;
serverName = $('#'+serverID+' span.name').text();
serverlength -= 1;
pending_actions.push([destroy, serverID]);
});
update_confirmations();
......@@ -170,12 +171,15 @@ $("a.enabled#action-shutdown").live('click', function() {
return false;
});
var serverlength = 0;
function update_machines_view(data){
/*
Go through the servers in the input data. Update existing entries, add
new ones to the list
*/
tableData = vmTable.fnGetData();
$.each(data.servers.values, function(i,server){
current = -1;
// check server status to select the appropriate OS icon
......@@ -189,7 +193,7 @@ function update_machines_view(data){
current = index;
}
});
serverlength += 1;
if (current != -1) { // if it's there, update the values
// get current status description, including non api states
var server_row = $('#' + server.id).parent().parent();
......@@ -201,11 +205,7 @@ function update_machines_view(data){
// when server is in deleted status it must be removed from the list
if (server.status == "DELETED") {
vmTable.fnDeleteRow(current);
// Reload the page to check if server list is empty
if (tableData.length == 1) {
hideWelcome()
standard_view();
}
serverlength -= 1;
} else { // when server is not be deleted, it should be updated
if (['BUILD','ACTIVE','REBOOT'].indexOf(server.status) >= 0 &&
[STATUS_MESSAGES['STOPPED'], STATUS_MESSAGES['ERROR'],
......@@ -299,9 +299,11 @@ function update_machines_view(data){
}
// show message in case user has no servers!
if (servers.length > 0) {
if (serverlength == 0) {
standard_view();
} else {
hideWelcome();
$("#machinesview_content").fadeIn("fast")
$("#machinesview_content").fadeIn("fast");
}
// set confirm box position
......
......@@ -141,6 +141,7 @@ $("div.actions a.action-destroy").live('click', function(){
$(this).addClass('selected');
$(this).parent().addClass('display')
$(this).parent().parent().find('.action_error').hide();
serverlength -= 1;
for (i=0;i<pending_actions.length;i++){ // if there is already a pending action for this server replace it
if (pending_actions[i][1]==serverID){
......@@ -206,14 +207,14 @@ $("div.action_error .details").live('click', function(){
$(this).parent().hide();
});
var serverlength = 0;
// update the servers list
function update_machines_view(data){
/*
Go through the servers in the input data. Update existing entries, add
new ones to the list
*/
$.each(data.servers.values, function(i,server){
existing = $('#' + server.id);
......@@ -225,27 +226,25 @@ function update_machines_view(data){
var server_image = os_icon(server.metadata);
serverlength += 1;
// server already exists in DOM
if (existing.length){
$("div.machine:last-child").find("div.separator").show();
// if the status is deleted, delete it from the DOM
if (server.status == 'DELETED') {
existing.remove();
// Reload the page to check if server list is empty
standard_view()
serverlength -= 1;
try {
console.info(existing.find("a.name span.name").text() + ' removed');
} catch(err) {}
} else if (existing.find(".status").text() != STATUS_MESSAGES[server.status]) {
try { // firebug console logging
console.info(existing.find("a.name span.name").text() + ' from '
+ existing.find(".status").text() + ' to ' + STATUS_MESSAGES[server.status]);
} catch(err) {}
//show reboot and shutdown actions
if (server.status == 'ACTIVE' || server.status == 'REBOOT') {
$('div.#' + server.id + ' a.action-reboot').attr('style','');
$('div.#' + server.id + ' a.action-shutdown').attr('style','');
$('div.#' + server.id + ' a.action-destroy').removeClass('destroy-padding');
......@@ -333,11 +332,12 @@ function update_machines_view(data){
$("#mini.separator").fadeOut("slow");
}
// show message in case user has no servers!
if (servers.length == 0) {
showWelcome()
if (serverlength == 0) {
showWelcome();
} else {
hideWelcome()
hideWelcome();
}
// set confirm box position
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment