cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pran...@apache.org
Subject [47/50] git commit: updated refs/heads/master to b03e419
Date Tue, 28 May 2013 07:59:32 GMT
Site-to-site VPN UI: Show confirm dialog if no gateways exist


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

Branch: refs/heads/master
Commit: cd7287a4e17c605be71910b260540dfa685f4ef8
Parents: 4893969
Author: Brian Federle <brian.federle@citrix.com>
Authored: Fri May 24 13:06:51 2013 -0700
Committer: Brian Federle <brian.federle@citrix.com>
Committed: Fri May 24 13:06:51 2013 -0700

----------------------------------------------------------------------
 ui/modules/vpc/vpc.js |   71 ++++++++++++++++++++++++++++++++------------
 ui/scripts/vpc.js     |   43 ++++++++++++++++++++++++++-
 2 files changed, 94 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd7287a4/ui/modules/vpc/vpc.js
----------------------------------------------------------------------
diff --git a/ui/modules/vpc/vpc.js b/ui/modules/vpc/vpc.js
index 302ab6c..6eb721a 100644
--- a/ui/modules/vpc/vpc.js
+++ b/ui/modules/vpc/vpc.js
@@ -168,27 +168,60 @@
         $dashboardItem.appendTo($dashboard);
 
         $dashboardItem.click(function() {
-          $('#browser .container').cloudBrowser('addPanel', {
-            title: tier.name + ' - ' + dashboardItem.name,
-            maximizeIfSelected: true,
-            complete: function($panel) {
-              var section = cloudStack.vpc.sections[id];
-              var $section = $('<div>');
-
-              if ($.isFunction(section)) {
-                section = cloudStack.vpc.sections[id]();
-              }
+          var section = cloudStack.vpc.sections[id];
+          var $section = $('<div>');
+          var $loading = $('<div>').addClass('loading-overlay');
+          
+          if ($.isFunction(section)) {
+            section = cloudStack.vpc.sections[id]();
+          }
 
-              if (section.listView) {
-                $section.listView($.extend(true, {}, section, {
-                  onActionComplete: function() {
-                    $dashboardItem.closest('.vpc-network-chart').trigger('reload');
-                  },
-                  context: context
-                }));
-              }
+          var before = section.before;
+          var load = function() {
+            $('#browser .container').cloudBrowser('addPanel', {
+              title: tier.name + ' - ' + dashboardItem.name,
+              maximizeIfSelected: true,
+              complete: function($panel) {
+                if (section.listView) {
+                  $section.listView($.extend(true, {}, section, {
+                    onActionComplete: function() {
+                      $dashboardItem.closest('.vpc-network-chart').trigger('reload');
+                    },
+                    context: context
+                  }));
+                }
 
-              $section.appendTo($panel);
+                $section.appendTo($panel);
+              }
+            });            
+          };
+
+          before.check({
+            context: context,
+            response: {
+              success: function(result) {
+                // true means content exists
+                if (result) {
+                  load();
+                } else {
+                  cloudStack.dialog.confirm({
+                    message: before.messages.confirm,
+                    action: function() {
+                      $loading.appendTo($dashboardItem.closest('.vpc-network-chart'));
+                      before.action({
+                        context: context,
+                        response: {
+                          success: function() {
+                            $loading.remove();
+                            $dashboardItem.closest('.vpc-network-chart').trigger('reload');
+                            load();
+                          }
+                        }
+                      });
+                    }
+                  })
+                }
+              }
             }
           });
         });

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cd7287a4/ui/scripts/vpc.js
----------------------------------------------------------------------
diff --git a/ui/scripts/vpc.js b/ui/scripts/vpc.js
index 2183aba..3581b88 100644
--- a/ui/scripts/vpc.js
+++ b/ui/scripts/vpc.js
@@ -801,7 +801,48 @@
           // 'listView' block
           //
           // -- use this as a flag for VPC chart to render as a list view
-          listView: true
+          listView: true,
+          before: {
+            messages: {
+              confirm: 'Please confirm that you would like to create a site-to-site VPN gateway
for this VPC.',
+              notification: 'Create site-to-site VPN gateway'
+            },
+            check: function(args) {
+              var items;
+              
+              $.ajax({
+                url: createURL('listVpnGateways&listAll=true'),
+                data: {
+                  vpcid: args.context.vpc[0].id
+                },
+                success: function(json) {
+                  var items = json.listvpngatewaysresponse.vpngateway;
+
+                  args.response.success(items && items.length);
+                }
+              });
+            },
+            action: function(args) {
+              $.ajax({
+                url: createURL("createVpnGateway"),
+                data: {
+                  vpcid: args.context.vpc[0].id
+                },
+                success: function(json) {
+                  var jid = json.createvpngatewayresponse.jobid;
+                  var pollTimer = setInterval(function() {
+                    pollAsyncJobResult({
+                      _custom: { jobId: jid },
+                      complete: function() {
+                        clearInterval(pollTimer);
+                        args.response.success();
+                      }
+                    });
+                  }, g_queryAsyncJobResultInterval);
+                }
+              });             
+            }
+          }
         });
       }
     },


Mime
View raw message