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) {
|
notification: function(args) {
|
||||||
return 'Domain is deleted';
|
return 'Domain is deleted';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
createForm: {
|
createForm: {
|
||||||
title: 'Delete domain',
|
title: 'Delete domain',
|
||||||
preFilter: function(args) {
|
createLabel: 'Delete',
|
||||||
|
preFilter: function(args) {
|
||||||
if(isAdmin()) {
|
if(isAdmin()) {
|
||||||
args.$form.find('.form-item[rel=isForced]').css('display', 'inline-block');
|
args.$form.find('.form-item[rel=isForced]').css('display', 'inline-block');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fields: {
|
fields: {
|
||||||
isForced: {
|
isForced: {
|
||||||
label: 'Force delete',
|
label: 'Force delete',
|
||||||
@ -43,7 +44,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
action: function(args) {
|
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
|
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"));
|
array1.push("&cleanup=" + (args.data.isForced == "on"));
|
||||||
|
|
||||||
@ -58,6 +59,12 @@
|
|||||||
{jobId: jid}
|
{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: {
|
edit: {
|
||||||
label: 'Edit domain details',
|
label: 'Edit domain details',
|
||||||
messages: {
|
messages: {
|
||||||
notification: function(args) {
|
notification: function(args) {
|
||||||
return 'Edited domain: ' + args.name;
|
return 'Edited domain: ' + args.name;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
action: function(args) {
|
action: function(args) {
|
||||||
var domainObj;
|
var domainObj;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: createURL("updateDomain&id=" + args.context.domains[0].id + "&name=" + todb(args.data.name)),
|
url: createURL("updateDomain&id=" + args.context.domains[0].id + "&name=" + todb(args.data.name)),
|
||||||
async: false,
|
async: false,
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
domainObj = json.updatedomainresponse.domain;
|
domainObj = json.updatedomainresponse.domain;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=0&max=" + args.data.vmLimit),
|
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=0&max=" + args.data.vmLimit),
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
async: false,
|
async: false,
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
domainObj["vmLimit"] = args.data.vmLimit;
|
domainObj["vmLimit"] = args.data.vmLimit;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=1&max=" + args.data.ipLimit),
|
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=1&max=" + args.data.ipLimit),
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
async: false,
|
async: false,
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
domainObj["ipLimit"] = args.data.ipLimit;
|
domainObj["ipLimit"] = args.data.ipLimit;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=2&max=" + args.data.volumeLimit),
|
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=2&max=" + args.data.volumeLimit),
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
async: false,
|
async: false,
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
domainObj["volumeLimit"] = args.data.volumeLimit;
|
domainObj["volumeLimit"] = args.data.volumeLimit;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=3&max=" + args.data.snapshotLimit),
|
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=3&max=" + args.data.snapshotLimit),
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
async: false,
|
async: false,
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
domainObj["snapshotLimit"] = args.data.snapshotLimit;
|
domainObj["snapshotLimit"] = args.data.snapshotLimit;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=4&max=" + args.data.templateLimit),
|
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=4&max=" + args.data.templateLimit),
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
async: false,
|
async: false,
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
domainObj["templateLimit"] = args.data.templateLimit;
|
domainObj["templateLimit"] = args.data.templateLimit;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
args.response.success({data: domainObj});
|
args.response.success({data: domainObj});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -181,23 +188,23 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: { label: 'ID' },
|
id: { label: 'ID' },
|
||||||
vmLimit: {
|
vmLimit: {
|
||||||
label: 'Instance limits',
|
label: 'Instance limits',
|
||||||
isEditable: true
|
isEditable: true
|
||||||
},
|
},
|
||||||
ipLimit: {
|
ipLimit: {
|
||||||
label: 'Public IP limits',
|
label: 'Public IP limits',
|
||||||
isEditable: true
|
isEditable: true
|
||||||
},
|
},
|
||||||
volumeLimit: {
|
volumeLimit: {
|
||||||
label: 'Volume limits',
|
label: 'Volume limits',
|
||||||
isEditable: true
|
isEditable: true
|
||||||
},
|
},
|
||||||
snapshotLimit: {
|
snapshotLimit: {
|
||||||
label: 'Snapshot limits',
|
label: 'Snapshot limits',
|
||||||
isEditable: true
|
isEditable: true
|
||||||
},
|
},
|
||||||
templateLimit: {
|
templateLimit: {
|
||||||
label: 'Template limits',
|
label: 'Template limits',
|
||||||
isEditable: true
|
isEditable: true
|
||||||
},
|
},
|
||||||
@ -206,90 +213,90 @@
|
|||||||
volumeTotal: { label: 'Volumes' }
|
volumeTotal: { label: 'Volumes' }
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
dataProvider: function(args) {
|
dataProvider: function(args) {
|
||||||
var domainObj = args.context.domains[0];
|
var domainObj = args.context.domains[0];
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: createURL("listAccounts&domainid=" + domainObj.id),
|
url: createURL("listAccounts&domainid=" + domainObj.id),
|
||||||
async: false,
|
async: false,
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
var items = json.listaccountsresponse.account;
|
var items = json.listaccountsresponse.account;
|
||||||
var total;
|
var total;
|
||||||
if (items != null)
|
if (items != null)
|
||||||
total = items.length;
|
total = items.length;
|
||||||
else
|
else
|
||||||
total = 0;
|
total = 0;
|
||||||
domainObj["accountTotal"] = total;
|
domainObj["accountTotal"] = total;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: createURL("listVirtualMachines&domainid=" + domainObj.id),
|
url: createURL("listVirtualMachines&domainid=" + domainObj.id),
|
||||||
async: false,
|
async: false,
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
var items = json.listvirtualmachinesresponse.virtualmachine;
|
var items = json.listvirtualmachinesresponse.virtualmachine;
|
||||||
var total;
|
var total;
|
||||||
if (items != null)
|
if (items != null)
|
||||||
total = items.length;
|
total = items.length;
|
||||||
else
|
else
|
||||||
total = 0;
|
total = 0;
|
||||||
domainObj["vmTotal"] = total;
|
domainObj["vmTotal"] = total;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: createURL("listVolumes&domainid=" + domainObj.id),
|
url: createURL("listVolumes&domainid=" + domainObj.id),
|
||||||
async: false,
|
async: false,
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
var items = json.listvolumesresponse.volume;
|
var items = json.listvolumesresponse.volume;
|
||||||
var total;
|
var total;
|
||||||
if (items != null)
|
if (items != null)
|
||||||
total = items.length;
|
total = items.length;
|
||||||
else
|
else
|
||||||
total = 0;
|
total = 0;
|
||||||
domainObj["volumeTotal"] = total;
|
domainObj["volumeTotal"] = total;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: createURL("listResourceLimits&domainid=" + domainObj.id),
|
url: createURL("listResourceLimits&domainid=" + domainObj.id),
|
||||||
async: false,
|
async: false,
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
var limits = json.listresourcelimitsresponse.resourcelimit;
|
var limits = json.listresourcelimitsresponse.resourcelimit;
|
||||||
if (limits != null) {
|
if (limits != null) {
|
||||||
for (var i = 0; i < limits.length; i++) {
|
for (var i = 0; i < limits.length; i++) {
|
||||||
var limit = limits[i];
|
var limit = limits[i];
|
||||||
switch (limit.resourcetype) {
|
switch (limit.resourcetype) {
|
||||||
case "0":
|
case "0":
|
||||||
domainObj["vmLimit"] = limit.max;
|
domainObj["vmLimit"] = limit.max;
|
||||||
break;
|
break;
|
||||||
case "1":
|
case "1":
|
||||||
domainObj["ipLimit"] = limit.max;
|
domainObj["ipLimit"] = limit.max;
|
||||||
break;
|
break;
|
||||||
case "2":
|
case "2":
|
||||||
domainObj["volumeLimit"] = limit.max;
|
domainObj["volumeLimit"] = limit.max;
|
||||||
break;
|
break;
|
||||||
case "3":
|
case "3":
|
||||||
domainObj["snapshotLimit"] = limit.max;
|
domainObj["snapshotLimit"] = limit.max;
|
||||||
break;
|
break;
|
||||||
case "4":
|
case "4":
|
||||||
domainObj["templateLimit"] = limit.max;
|
domainObj["templateLimit"] = limit.max;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
args.response.success({
|
args.response.success({
|
||||||
data: domainObj,
|
data: domainObj,
|
||||||
actionFilter: domainActionfilter
|
actionFilter: domainActionfilter
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
labelField: 'name',
|
labelField: 'name',
|
||||||
@ -326,19 +333,19 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var domainActionfilter = function(args) {
|
var domainActionfilter = function(args) {
|
||||||
var jsonObj = args.context.item;
|
var jsonObj = args.context.item;
|
||||||
var allowedActions = [];
|
var allowedActions = [];
|
||||||
if(isAdmin()) {
|
if(isAdmin()) {
|
||||||
allowedActions.push("create");
|
allowedActions.push("create");
|
||||||
if(jsonObj.id != 1) { //"ROOT" domain is not allowed to edit or delete
|
if(jsonObj.id != 1) { //"ROOT" domain is not allowed to edit or delete
|
||||||
allowedActions.push("edit"); //merge updateResourceCount into edit
|
allowedActions.push("edit"); //merge updateResourceCount into edit
|
||||||
allowedActions.push("delete");
|
allowedActions.push("delete");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//allowedActions.push("updateResourceCount");
|
//allowedActions.push("updateResourceCount");
|
||||||
return allowedActions;
|
return allowedActions;
|
||||||
}
|
}
|
||||||
|
|
||||||
})(cloudStack, testData);
|
})(cloudStack, testData);
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
var $formContainer = $('<div>').addClass('form-container');
|
var $formContainer = $('<div>').addClass('form-container');
|
||||||
var $message = $('<span>').addClass('message').appendTo($formContainer).html(args.form.desc);
|
var $message = $('<span>').addClass('message').appendTo($formContainer).html(args.form.desc);
|
||||||
var $form = $('<form>').appendTo($formContainer);
|
var $form = $('<form>').appendTo($formContainer);
|
||||||
|
var createLabel = args.form.createLabel;
|
||||||
|
|
||||||
// Render fields and events
|
// Render fields and events
|
||||||
$.each(args.form.fields, function(key, field) {
|
$.each(args.form.fields, function(key, field) {
|
||||||
@ -297,7 +298,7 @@
|
|||||||
},
|
},
|
||||||
buttons: [
|
buttons: [
|
||||||
{
|
{
|
||||||
text: 'Create',
|
text: createLabel ? createLabel : 'Create',
|
||||||
'class': 'ok',
|
'class': 'ok',
|
||||||
click: function() {
|
click: function() {
|
||||||
if (!complete($formContainer)) { return false; }
|
if (!complete($formContainer)) { return false; }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user