mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 12266
- Show 'delete' instead of 'create' in dialog - Select domain's parent upon deletion, for UI consistency
This commit is contained in:
parent
fdb21b5521
commit
e7c4bc48fd
@ -24,15 +24,16 @@
|
||||
notification: function(args) {
|
||||
return 'Domain is deleted';
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
createForm: {
|
||||
title: 'Delete domain',
|
||||
preFilter: function(args) {
|
||||
title: 'Delete domain',
|
||||
createLabel: 'Delete',
|
||||
preFilter: function(args) {
|
||||
if(isAdmin()) {
|
||||
args.$form.find('.form-item[rel=isForced]').css('display', 'inline-block');
|
||||
}
|
||||
},
|
||||
},
|
||||
fields: {
|
||||
isForced: {
|
||||
label: 'Force delete',
|
||||
@ -43,7 +44,7 @@
|
||||
},
|
||||
|
||||
action: function(args) {
|
||||
var array1 = [];
|
||||
var array1 = [];
|
||||
if(args.$form.find('.form-item[rel=isForced]').css("display") != "none") //uncomment after Brian fix it to include $form in args
|
||||
array1.push("&cleanup=" + (args.data.isForced == "on"));
|
||||
|
||||
@ -58,6 +59,12 @@
|
||||
{jobId: jid}
|
||||
}
|
||||
);
|
||||
|
||||
// Quick fix for proper UI reaction to delete domain
|
||||
var $item = $('.name.selected').closest('li');
|
||||
var $itemParent = $item.closest('li');
|
||||
$itemParent.parent().parent().find('.name:first').click();
|
||||
$item.remove();
|
||||
}
|
||||
});
|
||||
},
|
||||
@ -70,63 +77,63 @@
|
||||
edit: {
|
||||
label: 'Edit domain details',
|
||||
messages: {
|
||||
notification: function(args) {
|
||||
notification: function(args) {
|
||||
return 'Edited domain: ' + args.name;
|
||||
}
|
||||
},
|
||||
action: function(args) {
|
||||
var domainObj;
|
||||
|
||||
action: function(args) {
|
||||
var domainObj;
|
||||
|
||||
$.ajax({
|
||||
url: createURL("updateDomain&id=" + args.context.domains[0].id + "&name=" + todb(args.data.name)),
|
||||
async: false,
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
success: function(json) {
|
||||
domainObj = json.updatedomainresponse.domain;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=0&max=" + args.data.vmLimit),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
domainObj["vmLimit"] = args.data.vmLimit;
|
||||
success: function(json) {
|
||||
domainObj["vmLimit"] = args.data.vmLimit;
|
||||
}
|
||||
});
|
||||
});
|
||||
$.ajax({
|
||||
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=1&max=" + args.data.ipLimit),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
domainObj["ipLimit"] = args.data.ipLimit;
|
||||
success: function(json) {
|
||||
domainObj["ipLimit"] = args.data.ipLimit;
|
||||
}
|
||||
});
|
||||
});
|
||||
$.ajax({
|
||||
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=2&max=" + args.data.volumeLimit),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
domainObj["volumeLimit"] = args.data.volumeLimit;
|
||||
success: function(json) {
|
||||
domainObj["volumeLimit"] = args.data.volumeLimit;
|
||||
}
|
||||
});
|
||||
});
|
||||
$.ajax({
|
||||
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=3&max=" + args.data.snapshotLimit),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
domainObj["snapshotLimit"] = args.data.snapshotLimit;
|
||||
success: function(json) {
|
||||
domainObj["snapshotLimit"] = args.data.snapshotLimit;
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=4&max=" + args.data.templateLimit),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
domainObj["templateLimit"] = args.data.templateLimit;
|
||||
success: function(json) {
|
||||
domainObj["templateLimit"] = args.data.templateLimit;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
args.response.success({data: domainObj});
|
||||
}
|
||||
},
|
||||
@ -181,23 +188,23 @@
|
||||
},
|
||||
{
|
||||
id: { label: 'ID' },
|
||||
vmLimit: {
|
||||
vmLimit: {
|
||||
label: 'Instance limits',
|
||||
isEditable: true
|
||||
},
|
||||
ipLimit: {
|
||||
ipLimit: {
|
||||
label: 'Public IP limits',
|
||||
isEditable: true
|
||||
},
|
||||
volumeLimit: {
|
||||
volumeLimit: {
|
||||
label: 'Volume limits',
|
||||
isEditable: true
|
||||
},
|
||||
snapshotLimit: {
|
||||
snapshotLimit: {
|
||||
label: 'Snapshot limits',
|
||||
isEditable: true
|
||||
},
|
||||
templateLimit: {
|
||||
templateLimit: {
|
||||
label: 'Template limits',
|
||||
isEditable: true
|
||||
},
|
||||
@ -206,90 +213,90 @@
|
||||
volumeTotal: { label: 'Volumes' }
|
||||
}
|
||||
],
|
||||
dataProvider: function(args) {
|
||||
var domainObj = args.context.domains[0];
|
||||
$.ajax({
|
||||
dataProvider: function(args) {
|
||||
var domainObj = args.context.domains[0];
|
||||
$.ajax({
|
||||
url: createURL("listAccounts&domainid=" + domainObj.id),
|
||||
async: false,
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var items = json.listaccountsresponse.account;
|
||||
success: function(json) {
|
||||
var items = json.listaccountsresponse.account;
|
||||
var total;
|
||||
if (items != null)
|
||||
total = items.length;
|
||||
if (items != null)
|
||||
total = items.length;
|
||||
else
|
||||
total = 0;
|
||||
domainObj["accountTotal"] = total;
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
total = 0;
|
||||
domainObj["accountTotal"] = total;
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: createURL("listVirtualMachines&domainid=" + domainObj.id),
|
||||
async: false,
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var items = json.listvirtualmachinesresponse.virtualmachine;
|
||||
success: function(json) {
|
||||
var items = json.listvirtualmachinesresponse.virtualmachine;
|
||||
var total;
|
||||
if (items != null)
|
||||
total = items.length;
|
||||
if (items != null)
|
||||
total = items.length;
|
||||
else
|
||||
total = 0;
|
||||
domainObj["vmTotal"] = total;
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
total = 0;
|
||||
domainObj["vmTotal"] = total;
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: createURL("listVolumes&domainid=" + domainObj.id),
|
||||
async: false,
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var items = json.listvolumesresponse.volume;
|
||||
success: function(json) {
|
||||
var items = json.listvolumesresponse.volume;
|
||||
var total;
|
||||
if (items != null)
|
||||
total = items.length;
|
||||
if (items != null)
|
||||
total = items.length;
|
||||
else
|
||||
total = 0;
|
||||
domainObj["volumeTotal"] = total;
|
||||
}
|
||||
});
|
||||
|
||||
total = 0;
|
||||
domainObj["volumeTotal"] = total;
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: createURL("listResourceLimits&domainid=" + domainObj.id),
|
||||
async: false,
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
var limits = json.listresourcelimitsresponse.resourcelimit;
|
||||
if (limits != null) {
|
||||
var limits = json.listresourcelimitsresponse.resourcelimit;
|
||||
if (limits != null) {
|
||||
for (var i = 0; i < limits.length; i++) {
|
||||
var limit = limits[i];
|
||||
switch (limit.resourcetype) {
|
||||
case "0":
|
||||
domainObj["vmLimit"] = limit.max;
|
||||
case "0":
|
||||
domainObj["vmLimit"] = limit.max;
|
||||
break;
|
||||
case "1":
|
||||
domainObj["ipLimit"] = limit.max;
|
||||
case "1":
|
||||
domainObj["ipLimit"] = limit.max;
|
||||
break;
|
||||
case "2":
|
||||
domainObj["volumeLimit"] = limit.max;
|
||||
case "2":
|
||||
domainObj["volumeLimit"] = limit.max;
|
||||
break;
|
||||
case "3":
|
||||
domainObj["snapshotLimit"] = limit.max;
|
||||
case "3":
|
||||
domainObj["snapshotLimit"] = limit.max;
|
||||
break;
|
||||
case "4":
|
||||
domainObj["templateLimit"] = limit.max;
|
||||
case "4":
|
||||
domainObj["templateLimit"] = limit.max;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
args.response.success({
|
||||
data: domainObj,
|
||||
actionFilter: domainActionfilter
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
labelField: 'name',
|
||||
@ -326,19 +333,19 @@
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var domainActionfilter = function(args) {
|
||||
var jsonObj = args.context.item;
|
||||
var allowedActions = [];
|
||||
if(isAdmin()) {
|
||||
allowedActions.push("create");
|
||||
if(jsonObj.id != 1) { //"ROOT" domain is not allowed to edit or delete
|
||||
var allowedActions = [];
|
||||
if(isAdmin()) {
|
||||
allowedActions.push("create");
|
||||
if(jsonObj.id != 1) { //"ROOT" domain is not allowed to edit or delete
|
||||
allowedActions.push("edit"); //merge updateResourceCount into edit
|
||||
allowedActions.push("delete");
|
||||
}
|
||||
}
|
||||
//allowedActions.push("updateResourceCount");
|
||||
allowedActions.push("delete");
|
||||
}
|
||||
}
|
||||
//allowedActions.push("updateResourceCount");
|
||||
return allowedActions;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})(cloudStack, testData);
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
var $formContainer = $('<div>').addClass('form-container');
|
||||
var $message = $('<span>').addClass('message').appendTo($formContainer).html(args.form.desc);
|
||||
var $form = $('<form>').appendTo($formContainer);
|
||||
var createLabel = args.form.createLabel;
|
||||
|
||||
// Render fields and events
|
||||
$.each(args.form.fields, function(key, field) {
|
||||
@ -297,7 +298,7 @@
|
||||
},
|
||||
buttons: [
|
||||
{
|
||||
text: 'Create',
|
||||
text: createLabel ? createLabel : 'Create',
|
||||
'class': 'ok',
|
||||
click: function() {
|
||||
if (!complete($formContainer)) { return false; }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user