cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [1/2] git commit: VPC: Update site-to-site VPN creation flow
Date Thu, 02 Aug 2012 18:35:00 GMT
Updated Branches:
  refs/heads/vpc cf0631767 -> 2cb141e6a


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


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/2cb141e6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/2cb141e6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/2cb141e6

Branch: refs/heads/vpc
Commit: 2cb141e6ae32d6b118a818a52e2505bc8ffbf0f0
Parents: cf06317
Author: Brian Federle <brian.federle@citrix.com>
Authored: Thu Aug 2 11:31:58 2012 -0700
Committer: Brian Federle <brian.federle@citrix.com>
Committed: Thu Aug 2 11:34:51 2012 -0700

----------------------------------------------------------------------
 ui/scripts/ui-custom/vpc.js |   65 +-
 ui/scripts/vpc.js           | 3419 +++++++++++++++++++-------------------
 2 files changed, 1777 insertions(+), 1707 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2cb141e6/ui/scripts/ui-custom/vpc.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui-custom/vpc.js b/ui/scripts/ui-custom/vpc.js
index eb5a4ad..b97b06e 100644
--- a/ui/scripts/ui-custom/vpc.js
+++ b/ui/scripts/ui-custom/vpc.js
@@ -18,6 +18,7 @@
   var elems = {
     vpcConfigureTooltip: function(args) {
       var $browser = args.$browser;
+      var $chart = args.$chart;
       var ipAddresses = args.ipAddresses;
       var gateways = args.gateways;
       var siteToSiteVPN = args.siteToSiteVPN;
@@ -63,14 +64,59 @@
             });
             break;
           case 'site-to-site-vpn':
-            $browser.cloudBrowser('addPanel', {
-              title: 'Site-to-site VPNs',
-              maximizeIfSelected: true,
-              complete: function($panel) {
-                //siteToSiteVPN is an object
-                $panel.listView(siteToSiteVPN, {context: siteToSiteVPN.context});
-              }
-            });
+            //siteToSiteVPN is an object
+            var addAction = siteToSiteVPN.add;
+            var isVPNPresent = addAction.preCheck({ context: siteToSiteVPN.context });
+            var showVPNListView = function() {
+              $browser.cloudBrowser('addPanel', {
+                title: 'Site-to-site VPNs',
+                maximizeIfSelected: true,
+                complete: function($panel) {
+                  $panel.listView(siteToSiteVPN, {context: siteToSiteVPN.context});
+                }
+              });
+            };
+
+            if (isVPNPresent) {
+              showVPNListView();
+            } else {
+              cloudStack.dialog.confirm({
+                message: 'Please confirm that you want to add a VPN gateway.',
+                action: function() {
+                  var $loading = $('<div>').addClass('loading-overlay').appendTo($chart);
+                  var error = function(message) {
+                    $loading.remove();
+                    cloudStack.dialog.notice({ message: message });
+                  };
+
+                  addAction.action({
+                    context: siteToSiteVPN.context,
+                    response: {
+                      success: function(args) {
+                        var _custom = args._custom;
+                        var notification = {
+                          poll: addAction.notification.poll,
+                          _custom: _custom,
+                          desc: addAction.messages.notification()
+                        };
+                        var success = function(args) {
+                          if (!$chart.is(':visible')) return;
+                          
+                          $loading.remove();
+                          showVPNListView();
+                        };
+                        
+                        cloudStack.ui.notifications.add(
+                          notification,
+                          success, {},
+                          error, {}
+                        );
+                      }
+                    }
+                  });
+                }
+              });
+            }
             break;
           }
         });
@@ -98,6 +144,7 @@
     },
     vpcConfigureArea: function(args) {
       var $browser = args.$browser;
+      var $chart = args.$chart;
       var ipAddresses = args.ipAddresses;
       var gateways = args.gateways;
       var siteToSiteVPN = args.siteToSiteVPN;
@@ -110,6 +157,7 @@
       $configIcon.mouseover(function() {
         var $tooltip = elems.vpcConfigureTooltip({
           $browser: $browser,
+          $chart: $chart,
           ipAddresses: ipAddresses,
           gateways: gateways,
           siteToSiteVPN: siteToSiteVPN
@@ -300,6 +348,7 @@
             .append(
               elems.vpcConfigureArea({
                 $browser: $browser,
+                $chart: $chart,
                 ipAddresses: $.extend(ipAddresses, {context: context}),
                 gateways: $.extend(gateways, {context: context}),
                 siteToSiteVPN: $.extend(siteToSiteVPN, {context: context})


Mime
View raw message