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: updated refs/heads/ui-vpc-redesign to ce78024
Date Tue, 14 May 2013 00:34:36 GMT
Updated Branches:
  refs/heads/ui-vpc-redesign 3c24380f9 -> ce7802413


Implement refresh VPC chart


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

Branch: refs/heads/ui-vpc-redesign
Commit: d6ceef2a29a0d32bec1965031eba23bfc4337759
Parents: 3c24380
Author: Brian Federle <brian.federle@citrix.com>
Authored: Mon May 13 17:05:03 2013 -0700
Committer: Brian Federle <brian.federle@citrix.com>
Committed: Mon May 13 17:20:08 2013 -0700

----------------------------------------------------------------------
 ui/modules/vpc/vpc.js |  185 ++++++++++++++++++++++++++------------------
 1 files changed, 110 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d6ceef2a/ui/modules/vpc/vpc.js
----------------------------------------------------------------------
diff --git a/ui/modules/vpc/vpc.js b/ui/modules/vpc/vpc.js
index 22a8250..283ae68 100644
--- a/ui/modules/vpc/vpc.js
+++ b/ui/modules/vpc/vpc.js
@@ -27,7 +27,10 @@
                 $browser: $browser,
                 context: $.extend(true, {}, context, {
                   networks: [tier]
-                })
+                }),
+                onActionComplete: function() {
+                  $tier.closest('.vpc-network-chart').trigger('reload');
+                }
               })
             );
 
@@ -92,6 +95,8 @@
                     // Success
                     function(args) {
                       $loading.remove();
+                      $placeholder.closest('.vpc-network-chart').trigger('reload');
+                      
                       // addNewTier({
                       //   ipAddresses: ipAddresses,
                       //   $browser: $browser,
@@ -181,90 +186,120 @@
     var vpcChart = function(args) {
       var context = args.context;
       var vpcItem = context.vpc[0];
-      var $chart = $('<div>').addClass('vpc-network-chart');
-      var $tiers = $('<div>').addClass('tiers');
-      var $toolbar = $('<div>').addClass('toolbar');
-
-      $toolbar.appendTo($chart);
-      $tiers.appendTo($chart);
       
-      // Get tiers
-      vpc.tiers.dataProvider({
-        context: context,
-        response: {
-          success: function(data) {
-            var tiers = data.tiers;
-
-            $(tiers).map(function(index, tier) {
-              var $tier = elems.tier({
-                context: context,
-                tier: tier,
-                dashboardItems: [
-                  {
-                    id: 'tierLoadBalancers',
-                    name: 'Load balancers',
-                    total: 5
-                  },
-                  {
-                    id: 'tierPortForwarders',
-                    name: 'Port forwarders',
-                    total: 4
-                  },
-                  {
-                    id: 'tierStaticNATs',
-                    name: 'Static NATs',
-                    total: 3
-                  },
-                  {
-                    id: 'tierVMs',
-                    name: 'Virtual Machines',
-                    total: 300
-                  }
-                ]
+      var chart = function(args) {
+        args = args ? args : {};
+
+        var $chart = $('<div>').addClass('vpc-network-chart');
+        var $tiers = $('<div>').addClass('tiers');
+        var $toolbar = $('<div>').addClass('toolbar');
+        var $refresh = $('<div>').addClass('button refresh');
+
+        $refresh.appendTo($toolbar);
+        $toolbar.appendTo($chart);
+        $tiers.appendTo($chart);
+
+        $refresh.click(function() {
+          $('.vpc-network-chart').trigger('reload');
+        });
+        
+        // Get tiers
+        var $loading = $('<div>').addClass('loading-overlay').prependTo($chart);
+        vpc.tiers.dataProvider({
+          context: context,
+          response: {
+            success: function(data) {
+              var tiers = data.tiers;
+
+              $(tiers).map(function(index, tier) {
+                var $tier = elems.tier({
+                  context: context,
+                  tier: tier,
+                  dashboardItems: [
+                    {
+                      id: 'tierLoadBalancers',
+                      name: 'Load balancers',
+                      total: 5
+                    },
+                    {
+                      id: 'tierPortForwarders',
+                      name: 'Port forwarders',
+                      total: 4
+                    },
+                    {
+                      id: 'tierStaticNATs',
+                      name: 'Static NATs',
+                      total: 3
+                    },
+                    {
+                      id: 'tierVMs',
+                      name: 'Virtual Machines',
+                      total: 300
+                    }
+                  ]
+                });
+
+                $tier.appendTo($tiers);
               });
 
-              $tier.appendTo($tiers);
-            });
+              // Add placeholder tier
+              $tiers.append(elems.tierPlaceholder({
+                context: context
+              }));
 
-            // Add placeholder tier
-            $tiers.append(elems.tierPlaceholder({
-              context: context
-            }));
+              $loading.remove();
+              
+              if (args.complete) {
+                args.complete($chart);
+              }
+            }
           }
-        }
-      });
+        });
+
+        // Router
+        $router = elems.router({
+          context: context,
+          dashboardItems: [
+            {
+              id: 'privateGateways',
+              name: 'Private gateways',
+              total: 1
+            },
+            {
+              id: 'publicIPs',
+              name: 'Public IP addresses',
+              total: 2
+            },
+            {
+              id: 'siteToSiteVPNs',
+              name: 'Site-to-site VPNs',
+              total: 3
+            },
+            {
+              id: 'networkACLLists',
+              name: 'Network ACL lists',
+              total: 2
+            }
+          ]
+        }).appendTo($chart);
+
+        $chart.bind('reload', function() {
+          chart({
+            complete: function($newChart) {
+              $chart.replaceWith($newChart);              
+            }
+          });
+        });
+
+        return $chart;
+      };
 
-      // Router
-      $router = elems.router({
-        context: context,
-        dashboardItems: [
-          {
-            id: 'privateGateways',
-            name: 'Private gateways',
-            total: 1
-          },
-          {
-            id: 'publicIPs',
-            name: 'Public IP addresses',
-            total: 2
-          },
-          {
-            id: 'siteToSiteVPNs',
-            name: 'Site-to-site VPNs',
-            total: 3
-          },
-          {
-            id: 'networkACLLists',
-            name: 'Network ACL lists',
-            total: 2
-          }
-        ]
-      }).appendTo($chart);
-      
       $('#browser .container').cloudBrowser('addPanel', {
         title: vpcItem.displaytext ? vpcItem.displaytext : vpcItem.name,
         maximizeIfSelected: true,
         complete: function($panel) {
+          var $chart = chart();
+
           $chart.appendTo($panel);
         }
       });


Mime
View raw message