mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-17 19:14:40 +01:00
IP address page - optimize code to call listVirtualMachines only once.
This commit is contained in:
parent
9757b294b3
commit
5c25508949
@ -893,6 +893,8 @@ function ipJsonToDetailsTab() {
|
||||
//populate dropdown
|
||||
var IpDomainid = ipObj.domainid;
|
||||
var IpAccount = ipObj.account;
|
||||
ipPopulateVMarray(IpDomainid, IpAccount); //popoulate VM array
|
||||
|
||||
var $vmSelect = $("#dialog_enable_static_NAT").find("#vm_dropdown").empty();
|
||||
ipPopulateVMDropdown($vmSelect, IpDomainid, IpAccount);
|
||||
|
||||
@ -1217,19 +1219,14 @@ function refreshCreatePortForwardingRow() {
|
||||
ipPopulateVMDropdown($vmSelect, IpDomainid, IpAccount);
|
||||
}
|
||||
|
||||
function ipPopulateVMDropdown($vmSelect, IpDomainid, IpAccount) {
|
||||
var runningVMs, stoppedVMs;
|
||||
function ipPopulateVMarray(IpDomainid, IpAccount) {
|
||||
$.ajax({
|
||||
data: createURL("command=listVirtualMachines&domainid="+IpDomainid+"&account="+IpAccount+"&state=Running"),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
var instances = json.listvirtualmachinesresponse.virtualmachine;
|
||||
if (instances != null && instances.length > 0) {
|
||||
for (var i = 0; i < instances.length; i++) {
|
||||
var html = $("<option value='" + fromdb(instances[i].id) + "'>" + getVmName(instances[i].name, instances[i].displayname) + "</option>");
|
||||
$vmSelect.append(html);
|
||||
}
|
||||
}
|
||||
runningVMs = json.listvirtualmachinesresponse.virtualmachine;
|
||||
}
|
||||
});
|
||||
|
||||
@ -1238,15 +1235,24 @@ function ipPopulateVMDropdown($vmSelect, IpDomainid, IpAccount) {
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
var instances = json.listvirtualmachinesresponse.virtualmachine;
|
||||
if (instances != null && instances.length > 0) {
|
||||
for (var i = 0; i < instances.length; i++) {
|
||||
var html = $("<option value='" + fromdb(instances[i].id) + "'>" + getVmName(instances[i].name, instances[i].displayname) + "</option>");
|
||||
stoppedVMs = json.listvirtualmachinesresponse.virtualmachine;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function ipPopulateVMDropdown($vmSelect, IpDomainid, IpAccount) {
|
||||
if (runningVMs != null && runningVMs.length > 0) {
|
||||
for (var i = 0; i < runningVMs.length; i++) {
|
||||
var html = $("<option value='" + fromdb(runningVMs[i].id) + "'>" + getVmName(runningVMs[i].name, runningVMs[i].displayname) + "</option>");
|
||||
$vmSelect.append(html);
|
||||
}
|
||||
}
|
||||
if (stoppedVMs != null && stoppedVMs.length > 0) {
|
||||
for (var i = 0; i < stoppedVMs.length; i++) {
|
||||
var html = $("<option value='" + fromdb(stoppedVMs[i].id) + "'>" + getVmName(stoppedVMs[i].name, stoppedVMs[i].displayname) + "</option>");
|
||||
$vmSelect.append(html);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
//***** Port Forwarding tab (end) **********************************************************************************************************
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user