cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jessicaw...@apache.org
Subject git commit: updated refs/heads/master to ad51b8e
Date Fri, 25 Oct 2013 20:49:00 GMT
Updated Branches:
  refs/heads/master aa9f8e64a -> ad51b8edf


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/ad51b8ed
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ad51b8ed
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ad51b8ed

Branch: refs/heads/master
Commit: ad51b8edfbb7e110db45368b118b55f89c7b7cba
Parents: aa9f8e6
Author: Jessica Wang <jessicawang@apache.org>
Authored: Fri Oct 25 13:48:38 2013 -0700
Committer: Jessica Wang <jessicawang@apache.org>
Committed: Fri Oct 25 13:48:50 2013 -0700

----------------------------------------------------------------------
 ui/scripts/instances.js             | 43 +++++++++++++++++++++++++-------
 ui/scripts/ui/widgets/detailView.js | 43 +++++++++++++++++++++++++++++++-
 2 files changed, 76 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ad51b8ed/ui/scripts/instances.js
----------------------------------------------------------------------
diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js
index b729c4b..ac8605a 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) {
+                        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) {
-                                                return json.queryasyncjobresultresponse.jobresult.virtualmachine;
+                                            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/ad51b8ed/ui/scripts/ui/widgets/detailView.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui/widgets/detailView.js b/ui/scripts/ui/widgets/detailView.js
index 7bb0e13..65f71b3 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);
 
@@ -374,6 +374,47 @@
             var isMultiple = tab.multiple;
             uiActions.remove($detailView, args);
         },            
+               
+        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


Mime
View raw message