mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-18 19:44:21 +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
|
//populate dropdown
|
||||||
var IpDomainid = ipObj.domainid;
|
var IpDomainid = ipObj.domainid;
|
||||||
var IpAccount = ipObj.account;
|
var IpAccount = ipObj.account;
|
||||||
|
ipPopulateVMarray(IpDomainid, IpAccount); //popoulate VM array
|
||||||
|
|
||||||
var $vmSelect = $("#dialog_enable_static_NAT").find("#vm_dropdown").empty();
|
var $vmSelect = $("#dialog_enable_static_NAT").find("#vm_dropdown").empty();
|
||||||
ipPopulateVMDropdown($vmSelect, IpDomainid, IpAccount);
|
ipPopulateVMDropdown($vmSelect, IpDomainid, IpAccount);
|
||||||
|
|
||||||
@ -1217,19 +1219,14 @@ function refreshCreatePortForwardingRow() {
|
|||||||
ipPopulateVMDropdown($vmSelect, IpDomainid, IpAccount);
|
ipPopulateVMDropdown($vmSelect, IpDomainid, IpAccount);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ipPopulateVMDropdown($vmSelect, IpDomainid, IpAccount) {
|
var runningVMs, stoppedVMs;
|
||||||
|
function ipPopulateVMarray(IpDomainid, IpAccount) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
data: createURL("command=listVirtualMachines&domainid="+IpDomainid+"&account="+IpAccount+"&state=Running"),
|
data: createURL("command=listVirtualMachines&domainid="+IpDomainid+"&account="+IpAccount+"&state=Running"),
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
async: false,
|
async: false,
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
var instances = json.listvirtualmachinesresponse.virtualmachine;
|
runningVMs = 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1238,15 +1235,24 @@ function ipPopulateVMDropdown($vmSelect, IpDomainid, IpAccount) {
|
|||||||
dataType: "json",
|
dataType: "json",
|
||||||
async: false,
|
async: false,
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
var instances = json.listvirtualmachinesresponse.virtualmachine;
|
stoppedVMs = 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>");
|
}
|
||||||
|
|
||||||
|
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);
|
$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) **********************************************************************************************************
|
//***** Port Forwarding tab (end) **********************************************************************************************************
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user