From 3133f8bf9bfc64daeb913dab8ac86efb5ad12640 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Fri, 20 Jul 2012 12:59:26 -0700 Subject: [PATCH] cloudstack 3.0 UI - VPN Customer Gateway - Create VPN Connection action - if selected VPC does not have a VPN gateway, action won't proceed. --- ui/scripts/network.js | 44 ++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 98ac793ddf6..ed122194b36 100644 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -3962,7 +3962,7 @@ } }, action: function(args) { - var vpngatewayid; + var vpngatewayid = null; $.ajax({ url: createURL('listVpnGateways'), data: { @@ -3973,30 +3973,32 @@ var items = json.listvpngatewaysresponse.vpngateway; if(items != null && items.length > 0) { vpngatewayid = items[0].id; - } - else { - cloudStack.dialog.notice({ message: 'The selected VPC does not have a VPN gateway. Please create a VPN gateway for the VPC first.' }); - return; - } + } } - }); - $.ajax({ - url: createURL('createVpnConnection'), - data: { + }); + + 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 - } - } - ); - } - }); + success: function(json) { + var jid = json.createvpnconnectionresponse.jobid; + args.response.success( + {_custom: + { + jobId: jid + } + } + ); + } + }); }, notification: { poll: pollAsyncJobResult