Skip to content

Commit 2cb141e

Browse files
committed
VPC: Update site-to-site VPN creation flow
If no VPN gateway exists for a VPC, then immediately show a dialog box asking if user wants to add. If so, create VPN gateway and show list view afterwards. - This removes the 'add' button from the list view, moving the code up a level in the object to siteToSiteVPN.add - In addition there is a new function, siteToSiteVPN.preCheck, which returns true/false. If true, then show list view immediately; if false, show dialog and go through creation process, showing list view afterwards. Conflicts: ui/scripts/vpc.js
1 parent cf06317 commit 2cb141e

2 files changed

Lines changed: 1777 additions & 1707 deletions

File tree

‎ui/scripts/ui-custom/vpc.js‎

Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
var elems = {
1919
vpcConfigureTooltip: function(args) {
2020
var $browser = args.$browser;
21+
var $chart = args.$chart;
2122
var ipAddresses = args.ipAddresses;
2223
var gateways = args.gateways;
2324
var siteToSiteVPN = args.siteToSiteVPN;
@@ -63,14 +64,59 @@
6364
});
6465
break;
6566
case 'site-to-site-vpn':
66-
$browser.cloudBrowser('addPanel', {
67-
title: 'Site-to-site VPNs',
68-
maximizeIfSelected: true,
69-
complete: function($panel) {
70-
//siteToSiteVPN is an object
71-
$panel.listView(siteToSiteVPN, {context: siteToSiteVPN.context});
72-
}
73-
});
67+
//siteToSiteVPN is an object
68+
var addAction = siteToSiteVPN.add;
69+
var isVPNPresent = addAction.preCheck({ context: siteToSiteVPN.context });
70+
var showVPNListView = function() {
71+
$browser.cloudBrowser('addPanel', {
72+
title: 'Site-to-site VPNs',
73+
maximizeIfSelected: true,
74+
complete: function($panel) {
75+
$panel.listView(siteToSiteVPN, {context: siteToSiteVPN.context});
76+
}
77+
});
78+
};
79+
80+
if (isVPNPresent) {
81+
showVPNListView();
82+
} else {
83+
cloudStack.dialog.confirm({
84+
message: 'Please confirm that you want to add a VPN gateway.',
85+
action: function() {
86+
var $loading = $('<div>').addClass('loading-overlay').appendTo($chart);
87+
var error = function(message) {
88+
$loading.remove();
89+
cloudStack.dialog.notice({ message: message });
90+
};
91+
92+
addAction.action({
93+
context: siteToSiteVPN.context,
94+
response: {
95+
success: function(args) {
96+
var _custom = args._custom;
97+
var notification = {
98+
poll: addAction.notification.poll,
99+
_custom: _custom,
100+
desc: addAction.messages.notification()
101+
};
102+
var success = function(args) {
103+
if (!$chart.is(':visible')) return;
104+
105+
$loading.remove();
106+
showVPNListView();
107+
};
108+
109+
cloudStack.ui.notifications.add(
110+
notification,
111+
success, {},
112+
error, {}
113+
);
114+
}
115+
}
116+
});
117+
}
118+
});
119+
}
74120
break;
75121
}
76122
});
@@ -98,6 +144,7 @@
98144
},
99145
vpcConfigureArea: function(args) {
100146
var $browser = args.$browser;
147+
var $chart = args.$chart;
101148
var ipAddresses = args.ipAddresses;
102149
var gateways = args.gateways;
103150
var siteToSiteVPN = args.siteToSiteVPN;
@@ -110,6 +157,7 @@
110157
$configIcon.mouseover(function() {
111158
var $tooltip = elems.vpcConfigureTooltip({
112159
$browser: $browser,
160+
$chart: $chart,
113161
ipAddresses: ipAddresses,
114162
gateways: gateways,
115163
siteToSiteVPN: siteToSiteVPN
@@ -300,6 +348,7 @@
300348
.append(
301349
elems.vpcConfigureArea({
302350
$browser: $browser,
351+
$chart: $chart,
303352
ipAddresses: $.extend(ipAddresses, {context: context}),
304353
gateways: $.extend(gateways, {context: context}),
305354
siteToSiteVPN: $.extend(siteToSiteVPN, {context: context})

0 commit comments

Comments
 (0)