From f89fb73571c59e8f423e81b771bb0ff180d543ef Mon Sep 17 00:00:00 2001
From: Jessica Wang
Date: Thu, 30 Dec 2010 16:36:15 -0800
Subject: [PATCH] Add host dialog - remove cluster section (new cluster,
existing cluster, standalone cluster).
---
ui/jsp/cluster.jsp | 35 ++-----
ui/jsp/host.jsp | 33 ++----
ui/jsp/pod.jsp | 35 ++-----
ui/jsp/resource.jsp | 35 ++-----
ui/jsp/zone.jsp | 34 ++-----
ui/scripts/cloud.core.pod.js | 122 +++++++++-------------
ui/scripts/cloud.core.resource.js | 163 +++++++++++++-----------------
ui/scripts/cloud.core.zone.js | 157 +++++++++-------------------
8 files changed, 217 insertions(+), 397 deletions(-)
diff --git a/ui/jsp/cluster.jsp b/ui/jsp/cluster.jsp
index ab0b0f3c7fd..c66fd635318 100644
--- a/ui/jsp/cluster.jsp
+++ b/ui/jsp/cluster.jsp
@@ -129,7 +129,7 @@
diff --git a/ui/jsp/zone.jsp b/ui/jsp/zone.jsp
index d20909bfe48..89bfde06186 100644
--- a/ui/jsp/zone.jsp
+++ b/ui/jsp/zone.jsp
@@ -576,7 +576,7 @@
diff --git a/ui/scripts/cloud.core.pod.js b/ui/scripts/cloud.core.pod.js
index 1c93c62b04e..c25a4624966 100644
--- a/ui/scripts/cloud.core.pod.js
+++ b/ui/scripts/cloud.core.pod.js
@@ -263,12 +263,10 @@ function refreshClsuterFieldInAddHostDialog(dialogAddHost, podId, clusterId, hyp
clusterSelect.append("
");
else
clusterSelect.append("
");
- }
- dialogAddHost.find("input[value=existing_cluster_radio]").attr("checked", true);
+ }
}
else {
- clusterSelect.append("
");
- dialogAddHost.find("input[value=new_cluster_radio]").attr("checked", true);
+ clusterSelect.append("
");
}
}
});
@@ -369,11 +367,20 @@ function bindAddClusterButton($leftmenuItem1) {
dataType: "json",
success: function(json) {
$thisDialog.find("#spinning_wheel").hide();
- $thisDialog.dialog("close");
-
- showMiddleMenu();
-
- clickClusterNodeAfterAddHost("new_cluster_radio", podId, clusterName, null, $thisDialog);
+ $thisDialog.dialog("close");
+
+ var $podNode = $("#pod_" + podId);
+ if($podNode.length > 0 && $podNode.css("display") != "none") {
+ if($podNode.find("#pod_arrow").hasClass("expanded_close")) { //if pod node is closed
+ $podNode.find("#pod_arrow").click(); //expand pod node
+ }
+ else { //if pod node is expanded
+ var $clusterNode = $("#leftmenu_cluster_node_template").clone(true);
+ var item = json.addclusterresponse.cluster;
+ clusterJSONToTreeNode(item, $clusterNode);
+ $podNode.find("#clusters_container").append($clusterNode.show());
+ }
+ }
},
error: function(XMLHttpResponse) {
handleError(XMLHttpResponse, function() {
@@ -421,6 +428,7 @@ function bindAddHostButton($leftmenuItem1) {
dialogAddHost.find("#zone_name").text(fromdb(hostObj.zonename));
dialogAddHost.find("#pod_name").text(fromdb(hostObj.podname));
}
+ /*
else if(currentRightPanelJSP == "jsp/primarystorage.jsp") {
var primarystorageObj = $leftmenuItem1.data("jsonObj");
zoneId = primarystorageObj.zoneid;
@@ -429,6 +437,7 @@ function bindAddHostButton($leftmenuItem1) {
dialogAddHost.find("#zone_name").text(fromdb(primarystorageObj.zonename));
dialogAddHost.find("#pod_name").text(fromdb(primarystorageObj.podname));
}
+ */
dialogAddHost.find("#host_hypervisor").change(function() {
if($(this).val() == "VmWare") {
@@ -441,7 +450,7 @@ function bindAddHostButton($leftmenuItem1) {
refreshClsuterFieldInAddHostDialog(dialogAddHost, podId, clusterId, $(this).val());
}).change();
-
+
dialogAddHost
.dialog('option', 'buttons', {
"Add": function() {
@@ -462,10 +471,7 @@ function bindAddHostButton($leftmenuItem1) {
isValid &= validateString("Host name", $thisDialog.find("#host_hostname"), $thisDialog.find("#host_hostname_errormsg"));
isValid &= validateString("User name", $thisDialog.find("#host_username"), $thisDialog.find("#host_username_errormsg"));
isValid &= validateString("Password", $thisDialog.find("#host_password"), $thisDialog.find("#host_password_errormsg"));
- }
- if(clusterRadio == "new_cluster_radio") {
- isValid &= validateString("Cluster Name", $thisDialog.find("#new_cluster_name"), $thisDialog.find("#new_cluster_name_errormsg"));
- }
+ }
if (!isValid)
return;
@@ -477,19 +483,12 @@ function bindAddHostButton($leftmenuItem1) {
array1.push("&clustertype=CloudManaged");
array1.push("&zoneId="+zoneId);
array1.push("&podId="+podId);
-
- var newClusterName, existingClusterId;
- if(clusterRadio == "new_cluster_radio") {
- newClusterName = trim($thisDialog.find("#new_cluster_name").val());
- array1.push("&clustername="+todb(newClusterName));
- }
- else if(clusterRadio == "existing_cluster_radio") {
- existingClusterId = $thisDialog.find("#cluster_select").val();
- // We will default to no cluster if someone selects Join Cluster with no cluster available.
- if (existingClusterId != '-1') {
- array1.push("&clusterid="+existingClusterId);
- }
- }
+
+ var clusterId = $thisDialog.find("#cluster_select").val();
+ if (clusterId != null && clusterId != '-1') {
+ array1.push("&clusterid="+clusterId);
+ }
+
if(hypervisor == "VmWare") {
var username = trim($thisDialog.find("#host_vcenter_username").val());
array1.push("&username="+todb(username));
@@ -522,43 +521,19 @@ function bindAddHostButton($leftmenuItem1) {
url = hostname;
array1.push("&url="+todb(url));
}
- //var $midmenuItem1 = beforeAddingMidMenuItem() ;
-
+
$.ajax({
data: createURL("command=addHost" + array1.join("")),
dataType: "json",
success: function(json) {
$thisDialog.find("#spinning_wheel").hide();
- $thisDialog.dialog("close");
-
- /*
- var $midmenuItem1 = $("#midmenu_item").clone();
- $("#midmenu_container").append($midmenuItem1.fadeIn("slow"));
- var items = json.addhostresponse.host;
- hostToMidmenu(items[0], $midmenuItem1);
- bindClickToMidMenu($midmenuItem1, hostToRightPanel, hostGetMidmenuId);
-
- if(items.length > 1) {
- for(var i=1; i
0) {
+ for (var i = 0; i < items.length; i++) {
+ $clusterNode = $("#leftmenu_cluster_node_template").clone(true);
+ var item = items[i];
+ clusterJSONToTreeNode(item, $clusterNode);
+ container.append($clusterNode.show());
+ }
+ }
+ }
+ });
}
else if(target.hasClass("expanded_open")) {
target.removeClass("expanded_open").addClass("expanded_close");
@@ -286,6 +302,7 @@ function buildZoneTree() {
});
}
+/*
function refreshClusterUnderPod($podNode, newClusterName, existingClusterId, noClicking) {
var podId = $podNode.data("podId");
if(podId == null) //e.g. $podNode is not on the screen (when zone tree is hidden) ($podNode.length==0)
@@ -322,6 +339,7 @@ function refreshClusterUnderPod($podNode, newClusterName, existingClusterId, noC
return $clusterNode;
}
+*/
function selectRowInZoneTree($rowToSelect) {
if($selectedSubMenu != null)
@@ -357,8 +375,7 @@ function zoneJSONToTreeNode(jsonObj, $zoneNode) {
success: function(json) {
var items = json.listpodsresponse.pod;
if (items != null && items.length > 0) {
- $zoneNode.find("#zone_arrow").removeClass("white_nonexpanded_close").addClass("expanded_close");
- forceLogout = false; // We don't force a logout if pod(s) exit.
+ $zoneNode.find("#zone_arrow").removeClass("white_nonexpanded_close").addClass("expanded_close");
}
}
});
@@ -371,9 +388,19 @@ function podJSONToTreeNode(json, $podNode) {
$podNode.data("podId", podid).data("name", fromdb(json.name));
var podName = $podNode.find("#pod_name").text(fromdb(json.name));
- podName.data("jsonObj", json);
+ podName.data("jsonObj", json);
- refreshClusterUnderPod($podNode);
+ $.ajax({
+ data: createURL("command=listClusters&podid="+podid),
+ dataType: "json",
+ async: false,
+ success: function(json) {
+ var items = json.listclustersresponse.cluster;
+ if (items != null && items.length > 0) {
+ $podNode.find("#pod_arrow").removeClass("white_nonexpanded_close").addClass("expanded_close");
+ }
+ }
+ });
}
function clusterJSONToTreeNode(json, $clusterNode) {
@@ -757,9 +784,7 @@ function initAddClusterShortcut() {
var clusterTotal = parseInt($("#cluster_total").text());
clusterTotal++;
- $("#cluster_total").text(clusterTotal.toString());
-
- //clickClusterNodeAfterAddHost("new_cluster_radio", podId, clusterName, null, $thisDialog);
+ $("#cluster_total").text(clusterTotal.toString());
},
error: function(XMLHttpResponse) {
handleError(XMLHttpResponse, function() {
@@ -778,23 +803,20 @@ function initAddClusterShortcut() {
function initAddHostShortcut() {
var $dialogAddHost = $("#dialog_add_host_in_resource_page");
+ var $podSelect = $dialogAddHost.find("#pod_dropdown");
- /*
- $.ajax({
- data: createURL("command=listZones&available=true"),
- dataType: "json",
- success: function(json) {
- var zones = json.listzonesresponse.zone;
- var zoneSelect = $dialogAddHost.find("#zone_dropdown").empty();
- if (zones != null && zones.length > 0) {
- for (var i = 0; i < zones.length; i++)
- zoneSelect.append("");
- }
- //$dialogAddHost.find("#zone_dropdown").change(); //comment out to avoid race condition, do it before dialog box pops up
- }
- });
- */
-
+ $dialogAddHost.find("#host_hypervisor").change(function() {
+ if($(this).val() == "VmWare") {
+ $('li[input_group="general"]', $dialogAddHost).hide();
+ $('li[input_group="vmware"]', $dialogAddHost).show();
+ } else {
+ $('li[input_group="vmware"]', $dialogAddHost).hide();
+ $('li[input_group="general"]', $dialogAddHost).show();
+ }
+
+ refreshClsuterFieldInAddHostDialog($dialogAddHost, $podSelect.val(), null, $(this).val());
+ });
+
$dialogAddHost.find("#zone_dropdown").bind("change", function(event) {
var zoneId = $(this).val();
if(zoneId == null)
@@ -815,19 +837,15 @@ function initAddHostShortcut() {
}
});
});
-
- $dialogAddHost.find("#pod_dropdown").bind("change", function(event) {
- var podId = $(this).val();
- if(podId == null || podId.length == 0)
- return;
- refreshClsuterFieldInAddHostDialog($dialogAddHost, podId, null);
- });
+
+ $dialogAddHost.find("#pod_dropdown").bind("change", function(event) {
+ $dialogAddHost.find("#host_hypervisor").change();
+ });
- $("#add_host_shortcut").unbind("click").bind("click", function(event) {
- $dialogAddHost.find("#zone_dropdown").change(); //refresh cluster dropdown (do it here to avoid race condition)
+ $("#add_host_shortcut").unbind("click").bind("click", function(event) {
$dialogAddHost.find("#info_container").hide();
- $dialogAddHost.find("#new_cluster_name").val("");
-
+ $dialogAddHost.find("#zone_dropdown").change();
+
$dialogAddHost
.dialog('option', 'buttons', {
"Add": function() {
@@ -841,10 +859,7 @@ function initAddHostShortcut() {
isValid &= validateDropDownBox("Pod", $thisDialog.find("#pod_dropdown"), $thisDialog.find("#pod_dropdown_errormsg"));
isValid &= validateString("Host name", $thisDialog.find("#host_hostname"), $thisDialog.find("#host_hostname_errormsg"));
isValid &= validateString("User name", $thisDialog.find("#host_username"), $thisDialog.find("#host_username_errormsg"));
- isValid &= validateString("Password", $thisDialog.find("#host_password"), $thisDialog.find("#host_password_errormsg"));
- if(clusterRadio == "new_cluster_radio") {
- isValid &= validateString("Cluster Name", $thisDialog.find("#new_cluster_name"), $thisDialog.find("#new_cluster_name_errormsg"));
- }
+ isValid &= validateString("Password", $thisDialog.find("#host_password"), $thisDialog.find("#host_password_errormsg"));
if (!isValid)
return;
@@ -872,19 +887,11 @@ function initAddHostShortcut() {
var password = trim($thisDialog.find("#host_password").val());
array1.push("&password="+todb(password));
-
- var newClusterName, existingClusterId;
- if(clusterRadio == "new_cluster_radio") {
- newClusterName = trim($thisDialog.find("#new_cluster_name").val());
- array1.push("&clustername="+todb(newClusterName));
- }
- else if(clusterRadio == "existing_cluster_radio") {
- existingClusterId = $thisDialog.find("#cluster_select").val();
- // We will default to no cluster if someone selects Join Cluster with no cluster available.
- if (existingClusterId != '-1') {
- array1.push("&clusterid="+existingClusterId);
- }
- }
+
+ var clusterId = $thisDialog.find("#cluster_select").val();
+ if (clusterId != '-1') {
+ array1.push("&clusterid="+clusterId);
+ }
var hostname = trim($thisDialog.find("#host_hostname").val());
var url;
@@ -893,49 +900,24 @@ function initAddHostShortcut() {
else
url = hostname;
array1.push("&url="+todb(url));
-
- //var $midmenuItem1 = beforeAddingMidMenuItem() ;
-
+
$.ajax({
data: createURL("command=addHost" + array1.join("")),
dataType: "json",
success: function(json) {
$thisDialog.find("#spinning_wheel").hide();
$thisDialog.dialog("close");
-
- showMiddleMenu();
-
+
var items = json.addhostresponse.host;
var hostTotal = parseInt($("#host_total").text());
hostTotal = hostTotal + items.length;
- $("#host_total").text(hostTotal.toString());
-
- /*
- var $midmenuItem1 = $("#midmenu_item").clone();
- $("#midmenu_container").append($midmenuItem1.fadeIn("slow"));
- hostToMidmenu(items[0], $midmenuItem1);
- bindClickToMidMenu($midmenuItem1, hostToRightPanel, hostGetMidmenuId);
-
- if(items.length > 1) {
- for(var i=1; iNone Available");
- $dialogAddPool.find("input[value=new_cluster_radio]").attr("checked", true);
+ $clusterSelect.append("");
}
}
});
@@ -1604,13 +1583,7 @@ function initAddPrimaryStorageShortcut($midmenuAddLink2, currentPageInRightPanel
$.ajax({
data: createURL("command=createStoragePool" + array1.join("")),
dataType: "json",
- success: function(json) {
- var $clusterNode = $("#cluster_"+clusterId);
- if($clusterNode.length > 0)
- $("#cluster_"+clusterId).find("#cluster_name").click();
- else //pod node is close. Expand pod node.
- refreshClusterUnderPod($("#pod_" + podId), null, clusterId);
-
+ success: function(json) {
var primarystorageTotal = parseInt($("#primarystorage_total").text());
primarystorageTotal++;
$("#primarystorage_total").text(primarystorageTotal.toString());
diff --git a/ui/scripts/cloud.core.zone.js b/ui/scripts/cloud.core.zone.js
index 45ee8fc6981..37ab383b33e 100644
--- a/ui/scripts/cloud.core.zone.js
+++ b/ui/scripts/cloud.core.zone.js
@@ -1137,11 +1137,7 @@ function bindAddClusterButtonOnZonePage($button, zoneId, zoneName) {
dataType: "json",
success: function(json) {
$thisDialog.find("#spinning_wheel").hide();
- $thisDialog.dialog("close");
-
- showMiddleMenu();
-
- clickClusterNodeAfterAddHost("new_cluster_radio", podId, clusterName, null, $thisDialog);
+ $thisDialog.dialog("close");
},
error: function(XMLHttpResponse) {
handleError(XMLHttpResponse, function() {
@@ -1160,51 +1156,43 @@ function bindAddClusterButtonOnZonePage($button, zoneId, zoneName) {
function bindAddHostButtonOnZonePage($button, zoneId, zoneName) {
- $button.show();
-
var $dialogAddHost = $("#dialog_add_host_in_zone_page");
var $podSelect = $dialogAddHost.find("#pod_dropdown");
-
- $podSelect.bind("change", function(event) {
- var podId = $(this).val();
- if(podId == null || podId.length == 0)
- return;
-
- var hypervisorType = $dialogAddHost.find("#host_hypervisor");
- refreshClsuterFieldInAddHostDialog($dialogAddHost, podId, null, hypervisorType);
- });
-
- $button.unbind("click").bind("click", function(event) {
- $dialogAddHost.find("#zone_name").text(zoneName);
+
+ $.ajax({
+ data: createURL("command=listPods&zoneid="+zoneId),
+ dataType: "json",
+ async: false,
+ success: function(json) {
+ var pods = json.listpodsresponse.pod;
+ $podSelect.empty();
+ if(pods != null && pods.length > 0) {
+ for(var i=0; i" + fromdb(pods[i].name) + "");
+ }
+ }
+ });
+
+ $dialogAddHost.find("#host_hypervisor").change(function() {
+ if($(this).val() == "VmWare") {
+ $('li[input_group="general"]', $dialogAddHost).hide();
+ $('li[input_group="vmware"]', $dialogAddHost).show();
+ } else {
+ $('li[input_group="vmware"]', $dialogAddHost).hide();
+ $('li[input_group="general"]', $dialogAddHost).show();
+ }
+
+ refreshClsuterFieldInAddHostDialog($dialogAddHost, $podSelect.val(), null, $(this).val());
+ });
+
+ $dialogAddHost.find("#pod_dropdown").bind("change", function(event) {
+ $dialogAddHost.find("#host_hypervisor").change();
+ });
+
+ $button.unbind("click").bind("click", function(event) {
$dialogAddHost.find("#info_container").hide();
- $dialogAddHost.find("#new_cluster_name").val("");
-
- $.ajax({
- data: createURL("command=listPods&zoneid="+zoneId),
- dataType: "json",
- async: false,
- success: function(json) {
- var pods = json.listpodsresponse.pod;
- $podSelect.empty();
- if(pods != null && pods.length > 0) {
- for(var i=0; i" + fromdb(pods[i].name) + "");
- }
- $podSelect.change();
- }
- });
-
- $dialogAddHost.find("#host_hypervisor").change(function() {
- if($(this).val() == "VmWare") {
- $('li[input_group="general"]', $dialogAddHost).hide();
- $('li[input_group="vmware"]', $dialogAddHost).show();
- } else {
- $('li[input_group="vmware"]', $dialogAddHost).hide();
- $('li[input_group="general"]', $dialogAddHost).show();
- }
-
- refreshClsuterFieldInAddHostDialog($dialogAddHost, $podSelect.val(), null, $(this).val());
- }).change();
+ $dialogAddHost.find("#zone_name").text(zoneName);
+ $dialogAddHost.find("#host_hypervisor").change();
$dialogAddHost
.dialog('option', 'buttons', {
@@ -1228,11 +1216,7 @@ function bindAddHostButtonOnZonePage($button, zoneId, zoneName) {
isValid &= validateString("Host name", $thisDialog.find("#host_hostname"), $thisDialog.find("#host_hostname_errormsg"));
isValid &= validateString("User name", $thisDialog.find("#host_username"), $thisDialog.find("#host_username_errormsg"));
isValid &= validateString("Password", $thisDialog.find("#host_password"), $thisDialog.find("#host_password_errormsg"));
- }
-
- if(clusterRadio == "new_cluster_radio") {
- isValid &= validateString("Cluster Name", $thisDialog.find("#new_cluster_name"), $thisDialog.find("#new_cluster_name_errormsg"));
- }
+ }
if (!isValid)
return;
@@ -1251,19 +1235,11 @@ function bindAddHostButtonOnZonePage($button, zoneId, zoneName) {
var podId = $thisDialog.find("#pod_dropdown").val();
array1.push("&podid="+podId);
-
- var newClusterName, existingClusterId;
- if(clusterRadio == "new_cluster_radio") {
- newClusterName = trim($thisDialog.find("#new_cluster_name").val());
- array1.push("&clustername="+todb(newClusterName));
- }
- else if(clusterRadio == "existing_cluster_radio") {
- existingClusterId = $thisDialog.find("#cluster_select").val();
- // We will default to no cluster if someone selects Join Cluster with no cluster available.
- if (existingClusterId != '-1') {
- array1.push("&clusterid="+existingClusterId);
- }
- }
+
+ var clusterId = $thisDialog.find("#cluster_select").val();
+ if (clusterId != null && clusterId.length > 0 && clusterId != '-1') {
+ array1.push("&clusterid="+clusterId);
+ }
if(hypervisor == "VmWare") {
var username = trim($thisDialog.find("#host_vcenter_username").val());
@@ -1298,44 +1274,19 @@ function bindAddHostButtonOnZonePage($button, zoneId, zoneName) {
url = hostname;
array1.push("&url="+todb(url));
}
-
- //var $midmenuItem1 = beforeAddingMidMenuItem() ;
-
+
$.ajax({
data: createURL("command=addHost" + array1.join("")),
dataType: "json",
success: function(json) {
$thisDialog.find("#spinning_wheel").hide();
- $thisDialog.dialog("close");
-
- /*
- var items = json.addhostresponse.host;
- var $midmenuItem1 = $("#midmenu_item").clone();
- $("#midmenu_container").append($midmenuItem1.fadeIn("slow"));
- hostToMidmenu(items[0], $midmenuItem1);
- bindClickToMidMenu($midmenuItem1, hostToRightPanel, hostGetMidmenuId);
-
- if(items.length > 1) {
- for(var i=1; iNone Available");
- $dialogAddPool.find("input[value=new_cluster_radio]").attr("checked", true);
+ $clusterSelect.append("");
}
}
});
});
- $("#cluster_select", $dialogAddPool).change(function() {
-
+ $("#cluster_select", $dialogAddPool).change(function() {
var curOption = $(this).val();
if(!curOption)
return false;
@@ -1517,13 +1464,7 @@ function bindAddPrimaryStorageButtonOnZonePage($button, zoneId, zoneName) {
$.ajax({
data: createURL("command=createStoragePool" + array1.join("")),
dataType: "json",
- success: function(json) {
- var $clusterNode = $("#cluster_"+clusterId);
- if($clusterNode.length > 0)
- $("#cluster_"+clusterId).find("#cluster_name").click();
- else //pod node is close. Expand pod node.
- refreshClusterUnderPod($("#pod_" + podId), null, clusterId);
-
+ success: function(json) {
$thisDialog.find("#spinning_wheel").hide();
$thisDialog.dialog("close");
},