You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by al...@apache.org on 2012/06/29 02:45:06 UTC

[13/50] [abbrv] git commit: VPC tier UI: Update state after performing actions

VPC tier UI: Update state after performing actions

After performing an action that changes state, namely starting and
stopping a tier, run through the action pre-filter again, to make sure
that the allowable actions are properly refreshed.

Conflicts:
	ui/scripts/ui-custom/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/b1a5ec13
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/b1a5ec13
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/b1a5ec13

Branch: refs/heads/vpc
Commit: b1a5ec13cd3705272926b8d12fd000b09ede9886
Parents: 28e49e8
Author: Brian Federle <br...@citrix.com>
Authored: Thu Jun 28 15:19:06 2012 -0700
Committer: Brian Federle <br...@citrix.com>
Committed: Thu Jun 28 15:23:37 2012 -0700

----------------------------------------------------------------------
 ui/scripts/ui-custom/vpc.js |   27 ++++++++++++++++++++++-----
 ui/scripts/vpc.js           |   11 ++++++++---
 2 files changed, 30 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b1a5ec13/ui/scripts/ui-custom/vpc.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui-custom/vpc.js b/ui/scripts/ui-custom/vpc.js
index 6db1f61..c728bec 100644
--- a/ui/scripts/ui-custom/vpc.js
+++ b/ui/scripts/ui-custom/vpc.js
@@ -112,11 +112,13 @@
             if ($action.hasClass('disabled')) {
               return false;
             }
-                
+
             tierAction({
               action: action,
+              actionPreFilter: actionPreFilter,
               context: context,
-              $tier: $tier
+              $tier: $tier,
+              $actions: $actions
             });
 
             return true;
@@ -158,7 +160,7 @@
         if ($(this).find('.loading-overlay').size()) {
           return false;
         }
-        
+
         addTierDialog({
           $tiers: $tiers,
           context: context,
@@ -210,7 +212,7 @@
 
     disabledActions = actionPreFilter ? actionPreFilter({
       context: context
-    }) : [];  
+    }) : [];
 
     // Visual appearance for disabled actions
     $actions.find('.action').map(function(index, action) {
@@ -229,12 +231,14 @@
   var tierAction = function(args) {
     var $tier = args.$tier;
     var $loading = $('<div>').addClass('loading-overlay');
+    var $actions = args.$actions;
     var actionArgs = args.action.action;
     var action = actionArgs.action;
     var actionID = args.action.id;
     var notification = actionArgs.notification;
     var label = actionArgs.label;
     var context = args.context;
+    var actionPreFilter = args.actionPreFilter;
 
     var success = function(args) {
       var remove = args ? args.remove : false;
@@ -250,6 +254,13 @@
 
         // Success
         function(args) {
+          var newData = args.data ? args.data : {};
+          var newTier = $.extend(true, {}, context.tiers[0], newData);
+          var newContext = $.extend(true, {}, context);
+
+          // Update data
+          newContext.tiers = [newTier];
+
           if (remove) {
             $tier.remove();
           } else {
@@ -264,6 +275,12 @@
 
             $total.html(newTotal);
           }
+
+          filterActions({
+            $actions: $actions,
+            actionPreFilter: actionPreFilter,
+            context: newContext
+          });
         },
 
         {},
@@ -367,7 +384,7 @@
           response: {
             success: function(args) {
               var tier = args.data;
-              
+
               cloudStack.ui.notifications.add(
                 // Notification
                 {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b1a5ec13/ui/scripts/vpc.js
----------------------------------------------------------------------
diff --git a/ui/scripts/vpc.js b/ui/scripts/vpc.js
index 94e6dcb..e4f13df 100644
--- a/ui/scripts/vpc.js
+++ b/ui/scripts/vpc.js
@@ -376,7 +376,10 @@
     },
     tiers: {
       actionPreFilter: function(args) {
-        return ['start'];
+        var tier = args.context.tiers[0];
+        var state = tier.state;
+
+        return state == 'Running' ? ['start'] : ['stop'];
       },
       actions: {
         // Add new tier
@@ -413,7 +416,7 @@
             args.response.success();
           },
           notification: {
-            poll: function(args) { args.complete(); }
+            poll: function(args) { args.complete({ data: { state: 'Running' } }); }
           }
         },
         stop: {
@@ -423,7 +426,7 @@
             args.response.success();
           },
           notification: {
-            poll: function(args) { args.complete(); }
+            poll: function(args) { args.complete({ data: { state: 'Stopped' } }); }
           }
         },
         addVM: {
@@ -459,6 +462,7 @@
             id: 1,
             name: 'web',
             cidr: '192.168.0.0/24',
+            state: 'Running',
             virtualMachines: [
               { name: 'i-2-VM' },
               { name: 'i-3-VM' }
@@ -467,6 +471,7 @@
           {
             id: 2,
             name: 'app',
+            state: 'Stopped',
             cidr: '10.0.0.0/24',
             virtualMachines: []
           }