You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by je...@apache.org on 2013/10/25 23:33:30 UTC

git commit: updated refs/heads/4.2 to a59f809

Updated Branches:
  refs/heads/4.2 d188534f3 -> a59f8096b


CLOUDSTACK-4966: UI: (1) detailView widget: extend detailView widget to support destroy action that will close detailView and remove item from listView when toRemove parameter is passed.
(2)Destroy Instance action: add expunge option for root-admin and domain-admin. When expunge is set to true, instance will be expunged right after destroyed.


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

Branch: refs/heads/4.2
Commit: a59f8096baeae00116dc3360ffef214b08134808
Parents: d188534
Author: Jessica Wang <je...@apache.org>
Authored: Fri Oct 25 13:48:38 2013 -0700
Committer: Jessica Wang <je...@apache.org>
Committed: Fri Oct 25 13:59:00 2013 -0700

----------------------------------------------------------------------
 ui/scripts/instances.js             | 37 ++++++++++++++++++++++-----
 ui/scripts/ui/widgets/detailView.js | 44 ++++++++++++++++++++++++++++++--
 2 files changed, 73 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a59f8096/ui/scripts/instances.js
----------------------------------------------------------------------
diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js
index 436e1aa..e225f39 100644
--- a/ui/scripts/instances.js
+++ b/ui/scripts/instances.js
@@ -535,26 +535,51 @@
                     destroy: {
                         label: 'label.action.destroy.instance',
                         compactLabel: 'label.destroy',
-                        messages: {
-                            confirm: function(args) {
-                                return 'message.action.destroy.instance';
+                        createForm: {
+                            title: 'label.action.destroy.instance', 
+                            desc: 'Please confirm that you want to destroy this instance',
+                            preFilter: function(args) {
+                            	if (isAdmin() || isDomainAdmin()) {
+                            		args.$form.find('.form-item[rel=expunge]').css('display', 'inline-block');
+                            	} else {
+                            		args.$form.find('.form-item[rel=expunge]').hide();
+                            	}
                             },
+                            fields: {
+                            	expunge: {
+                                    label: 'Expunge',
+                                    isBoolean: true,
+                                    isChecked: false
+                                }
+                            }
+                        },                        
+                        messages: {                            
                             notification: function(args) {
                                 return 'label.action.destroy.instance';
                             }
                         },
                         action: function(args) {
+                        	var data = {
+                        		id: args.context.instances[0].id		
+                        	};                        	
+                        	if (args.data.expunge == 'on') {
+                        		$.extend(data, {
+                        			expunge: true
+                        		});
+                        	}                        	
                             $.ajax({
-                                url: createURL("destroyVirtualMachine&id=" + args.context.instances[0].id),
-                                dataType: "json",
-                                async: true,
+                                url: createURL('destroyVirtualMachine'),
+                                data: data,                                
                                 success: function(json) {
                                     var jid = json.destroyvirtualmachineresponse.jobid;
                                     args.response.success({
                                         _custom: {
                                             jobId: jid,
                                             getUpdatedItem: function(json) {
+                                            	if ('virtualmachine' in json.queryasyncjobresultresponse.jobresult) //destroy without expunge                                            	
                                                 return json.queryasyncjobresultresponse.jobresult.virtualmachine;
+                                            	else //destroy with expunge
+                                            		return { 'toRemove': true };
                                             },
                                             getActionFilter: function() {
                                                 return vmActionfilter;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a59f8096/ui/scripts/ui/widgets/detailView.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui/widgets/detailView.js b/ui/scripts/ui/widgets/detailView.js
index 6801288..780c18b 100644
--- a/ui/scripts/ui/widgets/detailView.js
+++ b/ui/scripts/ui/widgets/detailView.js
@@ -231,7 +231,7 @@
                                         }
                                         if (additional && additional.complete) additional.complete($.extend(true, args, {
                                             $detailView: $detailView
-                                        }));
+                                        }), args2);
 
                                         replaceListViewItem($detailView, args.data ? args.data : args2.data);
 
@@ -368,8 +368,48 @@
                 }
             });
         },
+               
+        destroy: function($detailView, args) {
+            var tab = args.tabs[args.activeTab];
+            var isMultiple = tab.multiple;
 
-        /**
+            uiActions.standard($detailView, args, {
+                noRefresh: true,
+                complete: function(args, args2) {                   	
+                	if ((!('id' in args2.data)) && ('toRemove' in args2.data) && (args2.data.toRemove == true)) {   
+	                    if (isMultiple && $detailView.is(':visible')) {
+	                        $detailView.find('.refresh').click(); // Reload tab
+	                    } else {
+	                        var $browser = $('#browser .container');
+	                        var $panel = $detailView.closest('.panel');
+	
+	                        if ($detailView.is(':visible')) {
+	                            $browser.cloudBrowser('selectPanel', {
+	                                panel: $panel.prev()
+	                            });
+	                        }
+	
+	                        if ($detailView.data("list-view-row") != null) {
+	                            var $row = $detailView.data('list-view-row');
+	                            var $tbody = $row.closest('tbody');
+	
+	                            $row.remove();
+	                            if (!$tbody.find('tr').size()) {
+	                                $("<tr>").addClass('empty').append(
+	                                    $("<td>").html(_l('label.no.data'))
+	                                ).appendTo($tbody);
+	                            }
+	                            $tbody.closest('table').dataTable('refresh');
+	                        }
+	                    }
+                	}  else {
+                		$detailView.find('.refresh').click(); // Reload tab
+                	}
+                }
+            });
+        },
+       
+      /**
          * Convert editable fields to text boxes; clicking again saves data
          *
          * @param $detailView