diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 2bd662f8c3b..b5b7fc27de2 100644 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -4023,117 +4023,7 @@ detailView: { name: 'label.details', - actions: { - add: { - addRow: 'false', - label: 'Create VPN Connection', - messages: { - confirm: function(args) { - return 'Please confirm that you want to create VPN connection.'; - }, - notification: function(args) { - return 'Create VPN Connection'; - } - }, - createForm: { - title: 'Create VPN Connection', - fields: { - zoneid: { - label: 'Zone', - validation: { required: true }, - select: function(args) { - $.ajax({ - url: createURL('listZones'), - data: { - available: true - }, - success: function(json) { - var zones = json.listzonesresponse.zone; - args.response.success({ - data: $.map(zones, function(zone) { - return { - id: zone.id, - description: zone.name - }; - }) - }); - } - }); - } - }, - vpcid: { - label: 'VPC', - validation: { required: true }, - dependsOn: 'zoneid', - select: function(args) { - $.ajax({ - url: createURL('listVPCs'), - data: { - zoneid: args.zoneid, - listAll: true - }, - success: function(json) { - var items = json.listvpcsresponse.vpc; - var data; - if(items != null && items.length > 0) { - data = $.map(items, function(item) { - return { - id: item.id, - description: item.name - } - }); - } - args.response.success({ data: data }); - } - }); - } - } - } - }, - action: function(args) { - var vpngatewayid = null; - $.ajax({ - url: createURL('listVpnGateways'), - data: { - vpcid: args.data.vpcid - }, - async: false, - success: function(json) { - var items = json.listvpngatewaysresponse.vpngateway; - if(items != null && items.length > 0) { - vpngatewayid = items[0].id; - } - } - }); - - if(vpngatewayid == null) { - args.response.error('The selected VPC does not have a VPN gateway. Please create a VPN gateway for the VPC first.'); - return; - } - - $.ajax({ - url: createURL('createVpnConnection'), - data: { - s2svpngatewayid: vpngatewayid, - s2scustomergatewayid: args.context.vpnCustomerGateway[0].id - }, - success: function(json) { - var jid = json.createvpnconnectionresponse.jobid; - args.response.success( - {_custom: - { - jobId: jid - } - } - ); - } - }); - }, - notification: { - poll: pollAsyncJobResult - } - }, - + actions: { edit: { label: 'label.edit', action: function(args) { diff --git a/ui/scripts/vpc.js b/ui/scripts/vpc.js index 2e65d52411c..89aa5c17045 100644 --- a/ui/scripts/vpc.js +++ b/ui/scripts/vpc.js @@ -908,79 +908,90 @@ }); }, - actions:{ - add: { - label:'add VPN connection', - messages: { - - notification:function(args) { - return 'add VPN connection'; + actions:{ + add: { + label: 'Create VPN Connection', + messages: { + notification: function(args) { + return 'Create VPN Connection'; + } + }, + createForm: { + title: 'Create VPN Connection', + fields: { + vpncustomergatewayid: { + label: 'VPN Customer Gateway', + validation: { required: true }, + select: function(args) { + $.ajax({ + url: createURL("listVpnCustomerGateways"), + data: { + listAll: true + }, + success: function(json) { + var items = json.listvpncustomergatewaysresponse.vpncustomergateway; + args.response.success({ + data: $.map(items, function(item) { + return { + id: item.id, + description: item.name + }; + }) + + }); + } + }); } - }, - createForm: { - - title:'add VPN connection', - fields: { - zoneid: { - label:'Zone', - validation:{required:true}, - select: function(args) { - $.ajax({ - url: createURL('listZones'), - data: { - available: true - }, - success: function(json) { - var zones = json.listzonesresponse.zone; - args.response.success({ - data: $.map(zones, function(zone) { - return { - id: zone.id, - description: zone.name - }; - }) - }); - } - }); - } - - }, - vpcid:{ - label:'VPC', - validation:{ required:true}, - dependsOn: 'zoneid', - select: function(args) { - $.ajax({ - url: createURL('listVPCs'), - data: { - zoneid: args.zoneid, - listAll: true - }, - success: function(json) { - var items = json.listvpcsresponse.vpc; - var data; - if(items != null && items.length > 0) { - data = $.map(items, function(item) { - return { - id: item.id, - description: item.name - } - }); - } - args.response.success({ data: data }); - } - }); - } - - } - } - }, - action:function(args) { - // Code for passing the customer gateway ID and VPN id - - } - } - }, + } + } + }, + action: function(args) { + var vpngatewayid = null; + $.ajax({ + url: createURL('listVpnGateways'), + data: { + vpcid: args.data.vpcid + }, + async: false, + success: function(json) { + var items = json.listvpngatewaysresponse.vpngateway; + if(items != null && items.length > 0) { + vpngatewayid = items[0].id; + } + } + }); + if(vpngatewayid == null) { + args.response.error('The selected VPC does not have a VPN gateway. Please create a VPN gateway for the VPC first.'); + return; + } + + $.ajax({ + url: createURL('createVpnConnection'), + data: { + s2svpngatewayid: vpngatewayid, + s2scustomergatewayid: args.data.vpncustomergatewayid + }, + success: function(json) { + var jid = json.createvpnconnectionresponse.jobid; + args.response.success( + {_custom: + { + jobId: jid, + getUpdatedItem: function(json) { + debugger; + return json.queryasyncjobresultresponse.jobresult.vpnconnection; + } + } + } + ); + } + }); + }, + notification: { + poll: pollAsyncJobResult + } + } + }, detailView: { name: 'label.details',