Olga,

I just reviewed and pushed your patch to master branch.

I also checked in another change:
(1) to distinguish between getUpdatedItem() and getUpdatedData(), I renamed 
getUpdatedData() to getUpdatedItemWhenAsyncJobFails() since it's being called 
only when async job fails. 
(2) to fix the space problem (tab size is not 2) from your patch.

Jessica

-----Original Message-----
From: olgasmola [mailto:olya.sm...@gmail.com] 
Sent: Monday, June 25, 2012 5:43 AM
To: cloudstack-dev@incubator.apache.org
Subject: [PATCH] CS-15329: Instances with Error states appear in Instances

list after creating.

---
 ui/scripts/instances.js           |   15 ++++++++++++++-
 ui/scripts/sharedFunctions.js     |    9 ++++++++-
 ui/scripts/ui/widgets/listView.js |   12 +++++++++++-
 3 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js
index b892fd7..779011d 100644
--- a/ui/scripts/instances.js
+++ b/ui/scripts/instances.js
@@ -537,6 +537,7 @@
                   dataType: "json",
                   success: function(json) {
                     var jid = json.deployvirtualmachineresponse.jobid;
+                                       var vmid = 
json.deployvirtualmachineresponse.id;
                     args.response.success(
                       {_custom:
                        {jobId: jid,
@@ -548,7 +549,19 @@
                         },
                         getActionFilter: function() {
                           return vmActionfilter;
-                        }
+                        },
+                                               getUpdatedData: function() {
+                                                       var item;
+                                                       $.ajax({
+                                                         url: 
createURL("listVirtualMachines&id="+vmid),
+                                                         dataType: "json",
+                                                         async: false,
+                                                         success: 
function(json) {
+                                                               item = 
json.listvirtualmachinesresponse.virtualmachine[0];
+                                                         }
+                                                       });
+                                                       return item;
+                                               }
                        }
                       }
                     );
diff --git a/ui/scripts/sharedFunctions.js b/ui/scripts/sharedFunctions.js
index e7d2aeb..e0fb8e8 100644
--- a/ui/scripts/sharedFunctions.js
+++ b/ui/scripts/sharedFunctions.js
@@ -82,7 +82,14 @@ var pollAsyncJobResult = function(args) {
         }
         else if (result.jobstatus == 2) { // Failed          
           var msg = (result.jobresult.errortext == null)? "": 
result.jobresult.errortext;
-          args.error({message: msg});
+                 if (args._custom.getUpdatedData != null && 
args._custom.getActionFilter != null) {
+                       args.error({message: msg, updatedData: 
args._custom.getUpdatedData(), actionFilter: args._custom.getActionFilter()});
+                 } else if (args._custom.getUpdatedData != null && 
args._custom.getActionFilter == null) {
+                       args.error({message: msg, updatedData: 
args._custom.getUpdatedData()});
+                 }
+                 else {
+                       args.error({message: msg});
+                 }
         }
       }
     },
diff --git a/ui/scripts/ui/widgets/listView.js 
b/ui/scripts/ui/widgets/listView.js
index 0f20592..96ba8e1 100644
--- a/ui/scripts/ui/widgets/listView.js
+++ b/ui/scripts/ui/widgets/listView.js
@@ -93,7 +93,17 @@
 
                 // Error
                 function(args) {
-                  $item.remove();
+                                       if (args && args.updatedData) {
+                                               if ($item.is(':visible') && 
!isHeader) {
+                                                       replaceItem(
+                                                         $item,
+                                                         args.updatedData,
+                                                         args.actionFilter
+                                                       );
+                                               }
+                                       } else {
+                                               $item.remove();
+                                       }
                 }
               );
             }
-- 
1.7.10.msysgit.1



Reply via email to