cloudstack 3.0 UI - VPC - IP addresses - implement acquire new IP dialog box with tier dropdown.

This commit is contained in:
Jessica Wang 2012-07-09 15:36:29 -07:00
parent 9c9b7ee299
commit b6ebbc93e7
1 changed files with 68 additions and 20 deletions

View File

@ -984,18 +984,75 @@
actions: {
add: {
label: 'label.acquire.new.ip',
addRow: 'true',
action: function(args) {
var apiCmd = "associateIpAddress";
if(args.context.networks[0].type == "Shared" && !args.context.projects)
apiCmd += "&domainid=" + g_domainid + "&account=" + g_account;
addRow: 'true',
messages: {
notification: function(args) {
return 'label.acquire.new.ip';
}
},
createForm: {
title: 'label.acquire.new.ip',
desc: 'Please confirm that you want to acquire a new IP',
preFilter: function(args) {
if('vpc' in args.context) {
args.$form.find('.form-item[rel=networkid]').css('display', 'inline-block'); //shown
}
else {
args.$form.find('.form-item[rel=networkid]').hide(); //hidden
}
},
fields: {
networkid: {
label: 'tier',
select: function(args) {
if('vpc' in args.context) {
$.ajax({
url: createURL("listNetworks"),
data: {
vpcid: args.context.vpc[0].id,
listAll: true
},
success: function(json) {
var networks = json.listnetworksresponse.network;
var items = [];
$(networks).each(function(){
items.push({id: this.id, description: this.displaytext});
});
args.response.success({data: items});
}
});
}
else {
args.response.success({data: []});
}
}
}
}
},
action: function(args) {
var dataObj = {};
if('vpc' in args.context) { //from VPC section
$.extend(dataObj, {
vpcid: args.context.vpc[0].id,
networkid: args.data.networkid
});
}
else if('networks' in args.context) { //from Guest Network section
$.extend(dataObj, {
networkid: args.context.networks[0].id
});
if(args.context.networks[0].type == "Shared" && !args.context.projects) {
$.extend(dataObj, {
domainid: g_domainid,
account: g_account
});
}
}
$.ajax({
url: createURL(apiCmd),
data: {
networkId: args.context.networks[0].id
},
dataType: 'json',
async: true,
url: createURL('associateIpAddress'),
data: dataObj,
success: function(data) {
args.response.success({
_custom: {
@ -1019,15 +1076,6 @@
});
},
messages: {
confirm: function(args) {
return 'message.acquire.new.ip';
},
notification: function(args) {
return 'label.acquire.new.ip';
}
},
notification: {
poll: pollAsyncJobResult
}