new UI - add primary storage - after action, show primary storage in middle menu with a title "Primary Storage" on it.

This commit is contained in:
Jessica Wang 2010-10-27 17:47:21 -07:00
parent 36a14c014f
commit 8759c3f1f5

View File

@ -1338,16 +1338,16 @@ function initAddHostButton($midmenuAddLink1) {
var password = trim($thisDialog.find("#host_password").val()); var password = trim($thisDialog.find("#host_password").val());
array1.push("&password="+encodeURIComponent(password)); array1.push("&password="+encodeURIComponent(password));
var newClusterName; var newClusterName, existingClusterId;
if(clusterRadio == "new_cluster_radio") { if(clusterRadio == "new_cluster_radio") {
newClusterName = trim($thisDialog.find("#new_cluster_name").val()); newClusterName = trim($thisDialog.find("#new_cluster_name").val());
array1.push("&clustername="+todb(newClusterName)); array1.push("&clustername="+todb(newClusterName));
} }
else if(clusterRadio == "existing_cluster_radio") { else if(clusterRadio == "existing_cluster_radio") {
var clusterId = $thisDialog.find("#cluster_select").val(); existingClusterId = $thisDialog.find("#cluster_select").val();
// We will default to no cluster if someone selects Join Cluster with no cluster available. // We will default to no cluster if someone selects Join Cluster with no cluster available.
if (clusterId != '-1') { if (existingClusterId != '-1') {
array1.push("&clusterid="+clusterId); array1.push("&clusterid="+existingClusterId);
} }
} }
@ -1369,6 +1369,8 @@ function initAddHostButton($midmenuAddLink1) {
$thisDialog.dialog("close"); $thisDialog.dialog("close");
showMiddleMenu(); showMiddleMenu();
/*
var $midmenuItem1 = $("#midmenu_item").clone(); var $midmenuItem1 = $("#midmenu_item").clone();
$("#midmenu_container").append($midmenuItem1.fadeIn("slow")); $("#midmenu_container").append($midmenuItem1.fadeIn("slow"));
var items = json.addhostresponse.host; var items = json.addhostresponse.host;
@ -1383,17 +1385,12 @@ function initAddHostButton($midmenuAddLink1) {
$("#midmenu_container").append($midmenuItem2.fadeIn("slow")); $("#midmenu_container").append($midmenuItem2.fadeIn("slow"));
} }
} }
*/
if(clusterRadio == "new_cluster_radio") { clickClusterNodeAfterAddHost(clusterRadio, podObj.id, newClusterName, existingClusterId, $thisDialog);
refreshClusterUnderPod($("#pod_" + podObj.id), newClusterName);
$thisDialog.find("#new_cluster_name").val("");
}
}, },
error: function(XMLHttpResponse) { error: function(XMLHttpResponse) {
if(clusterRadio == "new_cluster_radio") { clickClusterNodeAfterAddHost(clusterRadio, podObj.id, newClusterName, existingClusterId, $thisDialog);
refreshClusterUnderPod($("#pod_" + podObj.id), newClusterName);
$thisDialog.find("#new_cluster_name").val(""); //even AddHost fails, new cluster is still created. So, we clean up new cluster field to avoid the same one gets created twice.
}
handleErrorInDialog(XMLHttpResponse, $thisDialog); handleErrorInDialog(XMLHttpResponse, $thisDialog);
} }
}); });
@ -1406,6 +1403,18 @@ function initAddHostButton($midmenuAddLink1) {
}); });
} }
function clickClusterNodeAfterAddHost(clusterRadio, podId, newClusterName, existingClusterId, $thisDialog) {
if(clusterRadio == "new_cluster_radio") { //*** new cluster ***
refreshClusterUnderPod($("#pod_" + podId), newClusterName); //this function will click the new cluster node
$thisDialog.find("#new_cluster_name").val("");
}
else if(clusterRadio == "existing_cluster_radio") { //*** existing cluster ***
if (existingClusterId != null && existingClusterId != '-1') {
$("#cluster_"+existingClusterId).find("#cluster_name").click();
}
}
}
function refreshClusterUnderPod($podNode, newClusterName) { function refreshClusterUnderPod($podNode, newClusterName) {
var podId = $podNode.data("podId"); var podId = $podNode.data("podId");
$.ajax({ $.ajax({
@ -1517,12 +1526,14 @@ function initAddPrimaryStorageButton($midmenuAddLink2) {
success: function(json) { success: function(json) {
$thisDialog.find("#spinning_wheel").hide(); $thisDialog.find("#spinning_wheel").hide();
$thisDialog.dialog("close"); $thisDialog.dialog("close");
$("#cluster_"+clusterId).find("#cluster_name").click();
/*
var $midmenuItem1 = $("#midmenu_item").clone(); var $midmenuItem1 = $("#midmenu_item").clone();
$("#midmenu_container").append($midmenuItem1.fadeIn("slow")); $("#midmenu_container").append($midmenuItem1.fadeIn("slow"));
var item = json.createstoragepoolresponse; var item = json.createstoragepoolresponse;
primarystorageToMidmenu(item, $midmenuItem1); primarystorageToMidmenu(item, $midmenuItem1);
bindClickToMidMenu($midmenuItem1, primarystorageToRightPanel, primarystorageGetMidmenuId); bindClickToMidMenu($midmenuItem1, primarystorageToRightPanel, primarystorageGetMidmenuId);
*/
}, },
error: function(XMLHttpResponse) { error: function(XMLHttpResponse) {
handleErrorInDialog(XMLHttpResponse, $thisDialog); handleErrorInDialog(XMLHttpResponse, $thisDialog);