mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Create Shared function bindAddPrimaryStorageDialog() to bind event handler to cluster dropdown in Add Primary Storage dialog.
This commit is contained in:
parent
7a9000328a
commit
cec16baf8e
@ -631,7 +631,7 @@ function bindAddPrimaryStorageButton($leftmenuItem1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var $clusterSelect = $("#dialog_add_pool").find("#pool_cluster").empty();
|
var $clusterSelect = $("#dialog_add_pool").find("#pool_cluster").empty();
|
||||||
var mapClusters = {};
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
data: createURL("command=listClusters&podid=" + podId),
|
data: createURL("command=listClusters&podid=" + podId),
|
||||||
async: false,
|
async: false,
|
||||||
@ -639,9 +639,9 @@ function bindAddPrimaryStorageButton($leftmenuItem1) {
|
|||||||
success: function(json) {
|
success: function(json) {
|
||||||
var items = json.listclustersresponse.cluster;
|
var items = json.listclustersresponse.cluster;
|
||||||
if(items != null && items.length > 0) {
|
if(items != null && items.length > 0) {
|
||||||
mapClusters = {};
|
clustersUnderPod = {};
|
||||||
for(var i=0; i<items.length; i++) {
|
for(var i=0; i<items.length; i++) {
|
||||||
mapClusters["cluster_"+items[i].id] = items[i];
|
clustersUnderPod["cluster_"+items[i].id] = items[i];
|
||||||
if(sourceClusterId != null && items[i].id == sourceClusterId)
|
if(sourceClusterId != null && items[i].id == sourceClusterId)
|
||||||
$clusterSelect.append("<option value='" + items[i].id + "' selected>" + fromdb(items[i].name) + "</option>");
|
$clusterSelect.append("<option value='" + items[i].id + "' selected>" + fromdb(items[i].name) + "</option>");
|
||||||
else
|
else
|
||||||
@ -651,34 +651,7 @@ function bindAddPrimaryStorageButton($leftmenuItem1) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$dialogAddPool.find("#pool_cluster").unbind("change").bind("change", function() {
|
bindAddPrimaryStorageDialog($dialogAddPool);
|
||||||
var curOption = $(this).val();
|
|
||||||
if(!curOption)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
var $protocolSelector = $dialogAddPool.find("#add_pool_protocol");
|
|
||||||
var objCluster = mapClusters['cluster_'+curOption];
|
|
||||||
|
|
||||||
if(objCluster == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(objCluster.hypervisortype == "KVM") {
|
|
||||||
$protocolSelector.empty();
|
|
||||||
$protocolSelector.append('<option value="nfs">NFS</option>');
|
|
||||||
$protocolSelector.append('<option value="SharedMountPoint">SharedMountPoint</option>');
|
|
||||||
} else if(objCluster.hypervisortype == "XenServer") {
|
|
||||||
$protocolSelector.empty();
|
|
||||||
$protocolSelector.append('<option value="nfs">NFS</option>');
|
|
||||||
$protocolSelector.append('<option value="PreSetup">PreSetup</option>');
|
|
||||||
$protocolSelector.append('<option value="iscsi">iSCSI</option>');
|
|
||||||
} else if(objCluster.hypervisortype == "VMware") {
|
|
||||||
$protocolSelector.empty();
|
|
||||||
$protocolSelector.append('<option value="nfs">NFS</option>');
|
|
||||||
$protocolSelector.append('<option value="vmfs">VMFS datastore</option>');
|
|
||||||
}
|
|
||||||
|
|
||||||
$protocolSelector.change();
|
|
||||||
});
|
|
||||||
|
|
||||||
$button.unbind("click").bind("click", function(event) {
|
$button.unbind("click").bind("click", function(event) {
|
||||||
$dialogAddPool.find("#info_container").hide();
|
$dialogAddPool.find("#info_container").hide();
|
||||||
|
|||||||
@ -449,20 +449,7 @@ function initAddPodShortcut() {
|
|||||||
var $dialogAddPod = $("#dialog_add_pod_in_resource_page");
|
var $dialogAddPod = $("#dialog_add_pod_in_resource_page");
|
||||||
|
|
||||||
var $zoneDropdown = $dialogAddPod.find("#zone_dropdown");
|
var $zoneDropdown = $dialogAddPod.find("#zone_dropdown");
|
||||||
/*
|
|
||||||
$.ajax({
|
|
||||||
data: createURL("command=listZones&available=true"),
|
|
||||||
dataType: "json",
|
|
||||||
async: false,
|
|
||||||
success: function(json) {
|
|
||||||
var items = json.listzonesresponse.zone;
|
|
||||||
if (items != null && items.length > 0) {
|
|
||||||
for(var i=0; i<items.length; i++)
|
|
||||||
$zoneDropdown.append("<option value='" + items[i].id + "'>" + fromdb(items[i].name) + "</option>");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
$zoneDropdown.bind("change", function(event) {
|
$zoneDropdown.bind("change", function(event) {
|
||||||
var zoneId = $(this).val();
|
var zoneId = $(this).val();
|
||||||
if(zoneId == null)
|
if(zoneId == null)
|
||||||
@ -1629,6 +1616,37 @@ function initUpdateConsoleCertButton($midMenuAddLink2) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var clustersUnderPod = {};
|
||||||
|
function bindAddPrimaryStorageDialog($dialog) {
|
||||||
|
$dialog.find("#pool_cluster").unbind("change").change(function() {
|
||||||
|
var curOption = $(this).val();
|
||||||
|
if(!curOption)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var $protocolSelector = $dialog.find("#add_pool_protocol");
|
||||||
|
var objCluster = clustersUnderPod['cluster_'+curOption];
|
||||||
|
|
||||||
|
if(objCluster == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(objCluster.hypervisortype == "KVM") {
|
||||||
|
$protocolSelector.empty();
|
||||||
|
$protocolSelector.append('<option value="nfs">NFS</option>');
|
||||||
|
$protocolSelector.append('<option value="SharedMountPoint">SharedMountPoint</option>');
|
||||||
|
} else if(objCluster.hypervisortype == "XenServer") {
|
||||||
|
$protocolSelector.empty();
|
||||||
|
$protocolSelector.append('<option value="nfs">NFS</option>');
|
||||||
|
$protocolSelector.append('<option value="PreSetup">PreSetup</option>');
|
||||||
|
$protocolSelector.append('<option value="iscsi">iSCSI</option>');
|
||||||
|
} else if(objCluster.hypervisortype == "VMware") {
|
||||||
|
$protocolSelector.empty();
|
||||||
|
$protocolSelector.append('<option value="nfs">NFS</option>');
|
||||||
|
$protocolSelector.append('<option value="vmfs">VMFS datastore</option>');
|
||||||
|
}
|
||||||
|
|
||||||
|
$protocolSelector.change();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function initAddPrimaryStorageShortcut($midmenuAddLink2, currentPageInRightPanel) {
|
function initAddPrimaryStorageShortcut($midmenuAddLink2, currentPageInRightPanel) {
|
||||||
var $dialogAddPool = $("#dialog_add_pool_in_resource_page");
|
var $dialogAddPool = $("#dialog_add_pool_in_resource_page");
|
||||||
@ -1656,7 +1674,6 @@ function initAddPrimaryStorageShortcut($midmenuAddLink2, currentPageInRightPanel
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
var mapClusters = {};
|
|
||||||
$dialogAddPool.find("#pod_dropdown").bind("change", function(event) {
|
$dialogAddPool.find("#pod_dropdown").bind("change", function(event) {
|
||||||
var podId = $(this).val();
|
var podId = $(this).val();
|
||||||
if(podId == null || podId.length == 0)
|
if(podId == null || podId.length == 0)
|
||||||
@ -1667,11 +1684,11 @@ function initAddPrimaryStorageShortcut($midmenuAddLink2, currentPageInRightPanel
|
|||||||
dataType: "json",
|
dataType: "json",
|
||||||
async: false,
|
async: false,
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
mapClusters = {};
|
clustersUnderPod = {};
|
||||||
var items = json.listclustersresponse.cluster;
|
var items = json.listclustersresponse.cluster;
|
||||||
if(items != null && items.length > 0) {
|
if(items != null && items.length > 0) {
|
||||||
for(var i=0; i<items.length; i++) {
|
for(var i=0; i<items.length; i++) {
|
||||||
mapClusters["cluster_"+items[i].id] = items[i];
|
clustersUnderPod["cluster_"+items[i].id] = items[i];
|
||||||
$clusterSelect.append("<option value='" + items[i].id + "'>" + fromdb(items[i].name) + "</option>");
|
$clusterSelect.append("<option value='" + items[i].id + "'>" + fromdb(items[i].name) + "</option>");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1683,34 +1700,7 @@ function initAddPrimaryStorageShortcut($midmenuAddLink2, currentPageInRightPanel
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$dialogAddPool.find("#pool_cluster").change(function() {
|
bindAddPrimaryStorageDialog($dialogAddPool);
|
||||||
var curOption = $(this).val();
|
|
||||||
if(!curOption)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
var $protocolSelector = $("#add_pool_protocol", $dialogAddPool);
|
|
||||||
var objCluster = mapClusters['cluster_'+curOption];
|
|
||||||
|
|
||||||
if(objCluster == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(objCluster.hypervisortype == "KVM") {
|
|
||||||
$protocolSelector.empty();
|
|
||||||
$protocolSelector.append('<option value="nfs">NFS</option>');
|
|
||||||
$protocolSelector.append('<option value="SharedMountPoint">SharedMountPoint</option>');
|
|
||||||
} else if(objCluster.hypervisortype == "XenServer") {
|
|
||||||
$protocolSelector.empty();
|
|
||||||
$protocolSelector.append('<option value="nfs">NFS</option>');
|
|
||||||
$protocolSelector.append('<option value="PreSetup">PreSetup</option>');
|
|
||||||
$protocolSelector.append('<option value="iscsi">iSCSI</option>');
|
|
||||||
} else if(objCluster.hypervisortype == "VMware") {
|
|
||||||
$protocolSelector.empty();
|
|
||||||
$protocolSelector.append('<option value="nfs">NFS</option>');
|
|
||||||
$protocolSelector.append('<option value="vmfs">VMFS datastore</option>');
|
|
||||||
}
|
|
||||||
|
|
||||||
$protocolSelector.change();
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#add_primarystorage_shortcut").unbind("click").bind("click", function(event) {
|
$("#add_primarystorage_shortcut").unbind("click").bind("click", function(event) {
|
||||||
$dialogAddPool.find("#zone_dropdown").change(); //refresh cluster dropdown (do it here to avoid race condition)
|
$dialogAddPool.find("#zone_dropdown").change(); //refresh cluster dropdown (do it here to avoid race condition)
|
||||||
|
|||||||
@ -826,8 +826,6 @@ function bindAddPrimaryStorageButtonOnZonePage($button, zoneId, zoneName) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var mapClusters = {};
|
|
||||||
|
|
||||||
$podSelect.unbind("change").bind("change", function(event) {
|
$podSelect.unbind("change").bind("change", function(event) {
|
||||||
var podId = $(this).val();
|
var podId = $(this).val();
|
||||||
if(podId == null || podId.length == 0)
|
if(podId == null || podId.length == 0)
|
||||||
@ -840,9 +838,9 @@ function bindAddPrimaryStorageButtonOnZonePage($button, zoneId, zoneName) {
|
|||||||
success: function(json) {
|
success: function(json) {
|
||||||
var items = json.listclustersresponse.cluster;
|
var items = json.listclustersresponse.cluster;
|
||||||
if(items != null && items.length > 0) {
|
if(items != null && items.length > 0) {
|
||||||
mapClusters = {};
|
clustersUnderPod = {};
|
||||||
for(var i=0; i<items.length; i++) {
|
for(var i=0; i<items.length; i++) {
|
||||||
mapClusters["cluster_"+items[i].id] = items[i];
|
clustersUnderPod["cluster_"+items[i].id] = items[i];
|
||||||
$clusterSelect.append("<option value='" + items[i].id + "'>" + fromdb(items[i].name) + "</option>");
|
$clusterSelect.append("<option value='" + items[i].id + "'>" + fromdb(items[i].name) + "</option>");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -855,34 +853,7 @@ function bindAddPrimaryStorageButtonOnZonePage($button, zoneId, zoneName) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#pool_cluster", $dialogAddPool).unbind("change").bind("change", function(event) {
|
bindAddPrimaryStorageDialog($dialogAddPool);
|
||||||
var curOption = $(this).val();
|
|
||||||
if(!curOption)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
var $protocolSelector = $("#add_pool_protocol", $dialogAddPool);
|
|
||||||
var objCluster = mapClusters['cluster_'+curOption];
|
|
||||||
|
|
||||||
if(objCluster == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(objCluster.hypervisortype == "KVM") {
|
|
||||||
$protocolSelector.empty();
|
|
||||||
$protocolSelector.append('<option value="nfs">NFS</option>');
|
|
||||||
$protocolSelector.append('<option value="SharedMountPoint">SharedMountPoint</option>');
|
|
||||||
} else if(objCluster.hypervisortype == "XenServer") {
|
|
||||||
$protocolSelector.empty();
|
|
||||||
$protocolSelector.append('<option value="nfs">NFS</option>');
|
|
||||||
$protocolSelector.append('<option value="PreSetup">PreSetup</option>');
|
|
||||||
$protocolSelector.append('<option value="iscsi">iSCSI</option>');
|
|
||||||
} else if(objCluster.hypervisortype == "VMware") {
|
|
||||||
$protocolSelector.empty();
|
|
||||||
$protocolSelector.append('<option value="nfs">NFS</option>');
|
|
||||||
$protocolSelector.append('<option value="vmfs">VMFS datastore</option>');
|
|
||||||
}
|
|
||||||
|
|
||||||
$protocolSelector.change();
|
|
||||||
});
|
|
||||||
|
|
||||||
$button.unbind("click").bind("click", function(event) {
|
$button.unbind("click").bind("click", function(event) {
|
||||||
$dialogAddPool.find("#info_container").hide();
|
$dialogAddPool.find("#info_container").hide();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user