Add host dialog - remove cluster section (new cluster, existing cluster, standalone cluster).

This commit is contained in:
Jessica Wang 2010-12-30 16:36:15 -08:00
parent 5694cda19d
commit f89fb73571
8 changed files with 217 additions and 397 deletions

View File

@ -129,7 +129,7 @@
</p>
<div class="dialog_formcontent">
<form action="#" method="post" id="form_acquire">
<ol>
<ol>
<li>
<label for="host_hypervisor">Hypervisor:</label>
<select class="select" id="host_hypervisor">
@ -137,7 +137,15 @@
<option value="KVM">KVM</option>
<option value="VmWare">VMware</option>
</select>
</li>
</li>
<li>
<label>
Cluster:</label>
<select class="select" id="cluster_select">
</select>
<div id="cluster_dropdown_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li input_group="general">
<label for="host_hostname">
Host name:</label>
@ -193,28 +201,7 @@
<input class="text" type="text" name="host_vcenter_host" id="host_vcenter_host" />
<div id="host_vcenter_host_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li id="cluster_options_container">
<label>
&nbsp;</label><span><u>Cluster Options</u></span> </li>
<li id="new_cluster_radio_container">
<label>
<input type="radio" name="cluster" value="new_cluster_radio" checked />&nbsp;New
cluster:</label>
<input class="text" type="text" id="new_cluster_name" />
<div id="new_cluster_name_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li id="existing_cluster_radio_container">
<label>
<input type="radio" name="cluster" value="existing_cluster_radio" />&nbsp;Join cluster:</label>
<select class="select" id="cluster_select">
</select>
</li>
<li id="no_cluster_radio_container">
<label>
<input type="radio" name="cluster" value="no_cluster_radio" />&nbsp;Standalone</label>
<span style="padding-left: 20px"></span></li>
</li>
</ol>
</form>
</div>

View File

@ -823,7 +823,7 @@
</p>
<div class="dialog_formcontent">
<form action="#" method="post" id="form_acquire">
<ol>
<ol>
<li>
<label for="host_hypervisor">Hypervisor:</label>
<select class="select" id="host_hypervisor">
@ -832,6 +832,14 @@
<option value="VmWare">VMware</option>
</select>
</li>
<li>
<label>
Cluster:</label>
<select class="select" id="cluster_select">
</select>
<div id="cluster_dropdown_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li input_group="general">
<label for="host_hostname">
Host name:</label>
@ -887,28 +895,7 @@
<input class="text" type="text" name="host_vcenter_host" id="host_vcenter_host" />
<div id="host_vcenter_host_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li id="cluster_options_container">
<label>
&nbsp;</label><span><u>Cluster Options</u></span> </li>
<li id="new_cluster_radio_container">
<label>
<input type="radio" name="cluster" value="new_cluster_radio" checked />&nbsp;New
cluster:</label>
<input class="text" type="text" id="new_cluster_name" />
<div id="new_cluster_name_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li id="existing_cluster_radio_container">
<label>
<input type="radio" name="cluster" value="existing_cluster_radio" />&nbsp;Join cluster:</label>
<select class="select" id="cluster_select">
</select>
</li>
<li id="no_cluster_radio_container">
<label>
<input type="radio" name="cluster" value="no_cluster_radio" />&nbsp;Standalone</label>
<span style="padding-left: 20px"></span></li>
</li>
</ol>
</form>
</div>

View File

@ -272,7 +272,7 @@
</p>
<div class="dialog_formcontent">
<form action="#" method="post" id="form_acquire">
<ol>
<ol>
<li>
<label for="host_hypervisor">Hypervisor:</label>
<select class="select" id="host_hypervisor">
@ -280,7 +280,15 @@
<option value="KVM">KVM</option>
<option value="VmWare">VMware</option>
</select>
</li>
</li>
<li>
<label>
Cluster:</label>
<select class="select" id="cluster_select">
</select>
<div id="cluster_dropdown_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li input_group="general">
<label for="host_hostname">
Host name:</label>
@ -336,28 +344,7 @@
<input class="text" type="text" name="host_vcenter_host" id="host_vcenter_host" />
<div id="host_vcenter_host_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li id="cluster_options_container">
<label>
&nbsp;</label><span><u>Cluster Options</u></span> </li>
<li id="new_cluster_radio_container">
<label>
<input type="radio" name="cluster" value="new_cluster_radio" checked />&nbsp;New
cluster:</label>
<input class="text" type="text" id="new_cluster_name" />
<div id="new_cluster_name_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li id="existing_cluster_radio_container">
<label>
<input type="radio" name="cluster" value="existing_cluster_radio" />&nbsp;Join cluster:</label>
<select class="select" id="cluster_select">
</select>
</li>
<li id="no_cluster_radio_container">
<label>
<input type="radio" name="cluster" value="no_cluster_radio" />&nbsp;Standalone</label>
<span style="padding-left: 20px"></span></li>
</li>
</ol>
</form>
</div>

View File

@ -699,7 +699,7 @@
<div id="dialog_add_host_in_resource_page" title="Add Host" style="display: none">
<div class="dialog_formcontent">
<form action="#" method="post" id="form_acquire">
<ol>
<ol>
<li>
<label for="host_hypervisor">Hypervisor:</label>
<select class="select" id="host_hypervisor">
@ -724,7 +724,15 @@
</select>
<div id="pod_dropdown_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
</li>
<li>
<label>
Cluster:</label>
<select class="select" id="cluster_select">
</select>
<div id="cluster_dropdown_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li>
<label for="host_hostname">
Host name:</label>
@ -745,28 +753,7 @@
<input class="text" type="password" name="host_password" id="host_password" autocomplete="off" />
<div id="host_password_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li id="cluster_options_container">
<label>
&nbsp;</label><span><u>Cluster Options</u></span> </li>
<li id="new_cluster_radio_container">
<label>
<input type="radio" name="cluster" value="new_cluster_radio" checked />&nbsp;New
cluster:</label>
<input class="text" type="text" id="new_cluster_name" />
<div id="new_cluster_name_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li id="existing_cluster_radio_container">
<label>
<input type="radio" name="cluster" value="existing_cluster_radio" />&nbsp;Join cluster:</label>
<select class="select" id="cluster_select">
</select>
</li>
<li id="no_cluster_radio_container">
<label>
<input type="radio" name="cluster" value="no_cluster_radio" />&nbsp;Standalone</label>
<span style="padding-left: 20px"></span></li>
</li>
</ol>
</form>
</div>

View File

@ -576,7 +576,7 @@
</p>
<div class="dialog_formcontent">
<form action="#" method="post" id="form_acquire">
<ol>
<ol>
<li>
<label for="host_hypervisor">Hypervisor:</label>
<select class="select" id="host_hypervisor">
@ -592,7 +592,15 @@
</select>
<div id="pod_dropdown_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
</li>
<li>
<label>
Cluster:</label>
<select class="select" id="cluster_select">
</select>
<div id="cluster_dropdown_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li input_group="general">
<label for="host_hostname">
Host name:</label>
@ -649,28 +657,6 @@
<div id="host_vcenter_host_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li id="cluster_options_container">
<label>
&nbsp;</label><span><u>Cluster Options</u></span> </li>
<li id="new_cluster_radio_container">
<label>
<input type="radio" name="cluster" value="new_cluster_radio" checked />&nbsp;New
cluster:</label>
<input class="text" type="text" id="new_cluster_name" />
<div id="new_cluster_name_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li id="existing_cluster_radio_container">
<label>
<input type="radio" name="cluster" value="existing_cluster_radio" />&nbsp;Join cluster:</label>
<select class="select" id="cluster_select">
</select>
</li>
<li id="no_cluster_radio_container">
<label>
<input type="radio" name="cluster" value="no_cluster_radio" />&nbsp;Standalone</label>
<span style="padding-left: 20px"></span></li>
</ol>
</form>
</div>

View File

@ -263,12 +263,10 @@ function refreshClsuterFieldInAddHostDialog(dialogAddHost, podId, clusterId, hyp
clusterSelect.append("<option value='" + fromdb(items[i].id) + "' selected>" + fromdb(items[i].name) + "</option>");
else
clusterSelect.append("<option value='" + fromdb(items[i].id) + "'>" + fromdb(items[i].name) + "</option>");
}
dialogAddHost.find("input[value=existing_cluster_radio]").attr("checked", true);
}
}
else {
clusterSelect.append("<option value='-1'>None Available</option>");
dialogAddHost.find("input[value=new_cluster_radio]").attr("checked", true);
clusterSelect.append("<option value='-1'>None Available</option>");
}
}
});
@ -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<items.length; i++) {
var $midmenuItem2 = $("#midmenu_item").clone();
hostToMidmenu(items[i], $midmenuItem2);
bindClickToMidMenu($midmenuItem2, hostToRightPanel, hostGetMidmenuId);
$("#midmenu_container").append($midmenuItem2.fadeIn("slow"));
}
}
*/
//clickClusterNodeAfterAddHost(clusterRadio, podId, newClusterName, existingClusterId, $thisDialog);
expandClusterNodeAfterAddHost(clusterRadio, podId, newClusterName, existingClusterId, $thisDialog); //expand cluster node to see host node
$thisDialog.dialog("close");
//expandClusterNodeAfterAddHost(clusterRadio, podId, newClusterName, clusterId, $thisDialog); //expand cluster node to see host node
},
error: function(XMLHttpResponse) {
handleError(XMLHttpResponse, function() {
refreshClsuterFieldInAddHostDialog($thisDialog, podId, clusterId, dialogAddHost.find("#host_hypervisor").val());
handleErrorInDialog(XMLHttpResponse, $thisDialog);
if(clusterRadio == "new_cluster_radio") { //*** new cluster ***
refreshClusterUnderPod($("#pod_" + podId), newClusterName, null, true); //refresh clusters under pod, but no clicking at any cluster
$thisDialog.find("#new_cluster_name").val("");
}
handleErrorInDialog(XMLHttpResponse, $thisDialog);
});
}
});
@ -571,35 +546,30 @@ function bindAddHostButton($leftmenuItem1) {
});
}
function clickClusterNodeAfterAddHost(clusterRadio, podId, newClusterName, existingClusterId, $thisDialog) {
/*
function clickClusterNodeAfterAddHost(clusterRadio, podId, newClusterName, clusterId, $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();
else if(clusterRadio == "existing_cluster_radio") { //*** existing cluster ***
if (clusterId != null && clusterId != '-1') {
$("#cluster_"+clusterId).find("#cluster_name").click();
}
}
}
*/
//expand cluster node to see host node
function expandClusterNodeAfterAddHost(clusterRadio, podId, newClusterName, existingClusterId, $thisDialog) {
if(clusterRadio == "new_cluster_radio") { //*** new cluster ***
$thisDialog.find("#new_cluster_name").val("");
var $clusterNode = refreshClusterUnderPod($("#pod_" + podId), newClusterName, null, true);
var $arrow = $clusterNode.find("#cluster_arrow");
/*
function expandClusterNodeAfterAddHost(clusterRadio, podId, newClusterName, clusterId, $thisDialog) {
if (clusterId != null && clusterId != '-1') {
var $arrow = $("#cluster_"+clusterId).find("#cluster_arrow");
if($arrow.hasClass("expanded_close"))
$arrow.click();
}
else if(clusterRadio == "existing_cluster_radio") { //*** existing cluster ***
if (existingClusterId != null && existingClusterId != '-1') {
var $arrow = $("#cluster_"+existingClusterId).find("#cluster_arrow");
if($arrow.hasClass("expanded_close"))
$arrow.click();
}
}
$arrow.click();
}
}
*/
function bindAddPrimaryStorageButton($leftmenuItem1) {
var $button = $("#add_primarystorage_button");
@ -622,7 +592,8 @@ function bindAddPrimaryStorageButton($leftmenuItem1) {
sourceClusterId = clusterObj.id;
dialogAddPool.find("#zone_name").text(fromdb(clusterObj.zonename));
dialogAddPool.find("#pod_name").text(fromdb(clusterObj.podname));
}
}
/*
else if(currentRightPanelJSP == "jsp/host.jsp") {
var hostObj = $leftmenuItem1.data("jsonObj");
zoneId = hostObj.zoneid;
@ -631,6 +602,7 @@ function bindAddPrimaryStorageButton($leftmenuItem1) {
dialogAddPool.find("#zone_name").text(fromdb(hostObj.zonename));
dialogAddPool.find("#pod_name").text(fromdb(hostObj.podname));
}
*/
else if(currentRightPanelJSP == "jsp/primarystorage.jsp") {
var primarystorageObj = $leftmenuItem1.data("jsonObj");
zoneId = primarystorageObj.zoneid;

View File

@ -159,8 +159,24 @@ function buildZoneTree() {
var $podContent = $podNode.find("#pod_content");
if(target.hasClass("expanded_close")) {
target.removeClass("expanded_close").addClass("expanded_open");
$podContent.show();
refreshClusterUnderPod($podNode);
$podContent.show();
$.ajax({
data: createURL("command=listClusters&podid="+podObj.id),
dataType: "json",
async: false,
success: function(json) {
var items = json.listclustersresponse.cluster;
var container = $podContent.find("#clusters_container").empty();
if (items != null && items.length > 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("<option value='" + zones[i].id + "'>" + fromdb(zones[i].name) + "</option>");
}
//$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; i<items.length; i++) {
var $midmenuItem2 = $("#midmenu_item").clone();
hostToMidmenu(items[i], $midmenuItem2);
bindClickToMidMenu($midmenuItem2, hostToRightPanel, hostGetMidmenuId);
$("#midmenu_container").append($midmenuItem2.fadeIn("slow"));
}
}
*/
clickClusterNodeAfterAddHost(clusterRadio, podId, newClusterName, existingClusterId, $thisDialog);
$("#host_total").text(hostTotal.toString());
},
error: function(XMLHttpResponse) {
handleError(XMLHttpResponse, function() {
refreshClsuterFieldInAddHostDialog($thisDialog, podId, null);
handleErrorInDialog(XMLHttpResponse, $thisDialog);
if(clusterRadio == "new_cluster_radio") { //*** new cluster ***
refreshClusterUnderPod($("#pod_" + podId), newClusterName, null, true); //refresh clusters under pod, but no clicking at any cluster
$thisDialog.find("#new_cluster_name").val("");
}
handleErrorInDialog(XMLHttpResponse, $thisDialog);
});
}
});
@ -1484,13 +1466,10 @@ function initAddPrimaryStorageShortcut($midmenuAddLink2, currentPageInRightPanel
if(!$clusterSelect.val())
$("option", $clusterSelect)[0].attr("selected", "selected");
$clusterSelect.change();
$dialogAddPool.find("input[value=existing_cluster_radio]").attr("checked", true);
$clusterSelect.change();
}
else {
$clusterSelect.append("<option value='-1'>None Available</option>");
$dialogAddPool.find("input[value=new_cluster_radio]").attr("checked", true);
$clusterSelect.append("<option value='-1'>None Available</option>");
}
}
});
@ -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());

View File

@ -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<pods.length; i++)
$podSelect.append("<option value='" + pods[i].id + "'>" + fromdb(pods[i].name) + "</option>");
}
}
});
$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<pods.length; i++)
$podSelect.append("<option value='" + pods[i].id + "'>" + fromdb(pods[i].name) + "</option>");
}
$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; i<items.length; i++) {
var $midmenuItem2 = $("#midmenu_item").clone();
hostToMidmenu(items[i], $midmenuItem2);
bindClickToMidMenu($midmenuItem2, hostToRightPanel, hostGetMidmenuId);
$("#midmenu_container").append($midmenuItem2.fadeIn("slow"));
}
}
*/
//clickClusterNodeAfterAddHost(clusterRadio, podId, newClusterName, existingClusterId, $thisDialog);
expandClusterNodeAfterAddHost(clusterRadio, podId, newClusterName, existingClusterId, $thisDialog); //expand cluster node to see host node
$thisDialog.dialog("close");
//expandClusterNodeAfterAddHost(clusterRadio, podId, newClusterName, clusterId, $thisDialog); //expand cluster node to see host node
},
error: function(XMLHttpResponse) {
handleError(XMLHttpResponse, function() {
refreshClsuterFieldInAddHostDialog($thisDialog, podId, null, $dialogAddHost.find("#host_hypervisor").val());
handleErrorInDialog(XMLHttpResponse, $thisDialog);
if(clusterRadio == "new_cluster_radio") { //*** new cluster ***
refreshClusterUnderPod($("#pod_" + podId), newClusterName, null, true); //refresh clusters under pod, but no clicking at any cluster
$thisDialog.find("#new_cluster_name").val("");
}
handleErrorInDialog(XMLHttpResponse, $thisDialog);
});
}
});
@ -1382,20 +1333,16 @@ function bindAddPrimaryStorageButtonOnZonePage($button, zoneId, zoneName) {
if(!$clusterSelect.val()) {
$("option", $clusterSelect)[0].attr("selected", "selected");
}
$clusterSelect.change();
$dialogAddPool.find("input[value=existing_cluster_radio]").attr("checked", true);
$clusterSelect.change();
}
else {
$clusterSelect.append("<option value='-1'>None Available</option>");
$dialogAddPool.find("input[value=new_cluster_radio]").attr("checked", true);
$clusterSelect.append("<option value='-1'>None Available</option>");
}
}
});
});
$("#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");
},