mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
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.
This commit is contained in:
parent
aa9f8e64ae
commit
ad51b8edfb
@ -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;
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user