CLOUDSTACK-110: cloudstack UI - domain page - allow root domain to have Edit option, but only network domain field is editable, Resource Limits fields and domain name field is not editable.

This commit is contained in:
Jessica Wang 2012-09-24 16:46:09 -07:00
parent acaa22003d
commit 3a313ee1ff

View File

@ -97,18 +97,28 @@
}, },
action: function(args) { action: function(args) {
var domainObj; var domainObj;
var array1 = [];
array1.push("&name=" + todb(args.data.name)); var data = {
array1.push("&networkdomain=" + todb(args.data.networkdomain)); id: args.context.domains[0].id,
networkdomain: args.data.networkdomain
};
if(args.data.name != null) {
$.extend(data, {
name: args.data.name
});
}
$.ajax({ $.ajax({
url: createURL("updateDomain&id=" + args.context.domains[0].id + array1.join("")), url: createURL("updateDomain"),
async: false, async: false,
dataType: "json", data: data,
success: function(json) { success: function(json) {
domainObj = json.updatedomainresponse.domain; domainObj = json.updatedomainresponse.domain;
} }
}); });
if(args.data.vmLimit != null) {
$.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",
@ -117,6 +127,9 @@
domainObj["vmLimit"] = args.data.vmLimit; domainObj["vmLimit"] = args.data.vmLimit;
} }
}); });
}
if(args.data.ipLimit != null) {
$.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",
@ -125,6 +138,9 @@
domainObj["ipLimit"] = args.data.ipLimit; domainObj["ipLimit"] = args.data.ipLimit;
} }
}); });
}
if(args.data.volumeLimit != null) {
$.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",
@ -133,6 +149,9 @@
domainObj["volumeLimit"] = args.data.volumeLimit; domainObj["volumeLimit"] = args.data.volumeLimit;
} }
}); });
}
if(args.data.snapshotLimit != null) {
$.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",
@ -141,6 +160,9 @@
domainObj["snapshotLimit"] = args.data.snapshotLimit; domainObj["snapshotLimit"] = args.data.snapshotLimit;
} }
}); });
}
if(args.data.templateLimit != null) {
$.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",
@ -149,6 +171,9 @@
domainObj["templateLimit"] = args.data.templateLimit; domainObj["templateLimit"] = args.data.templateLimit;
} }
}); });
}
if(args.data.vpcLimit != null) {
$.ajax({ $.ajax({
url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=7&max=" + args.data.vpcLimit), url: createURL("updateResourceLimit&domainid=" + args.context.domains[0].id + "&resourceType=7&max=" + args.data.vpcLimit),
dataType: "json", dataType: "json",
@ -157,6 +182,7 @@
domainObj["vpcLimit"] = args.data.vpcLimit; domainObj["vpcLimit"] = args.data.vpcLimit;
} }
}); });
}
args.response.success({data: domainObj}); args.response.success({data: domainObj});
} }
@ -243,7 +269,15 @@
title: 'label.details', title: 'label.details',
fields: [ fields: [
{ {
name: { label: 'label.name', isEditable: true } name: {
label: 'label.name',
isEditable: function(context) {
if(context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to change domain name
return true;
else
return false;
}
}
}, },
{ {
id: { label: 'ID' }, id: { label: 'ID' },
@ -256,27 +290,57 @@
}, },
vmLimit: { vmLimit: {
label: 'label.instance.limits', label: 'label.instance.limits',
isEditable: true isEditable: function(context) {
if(context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits
return true;
else
return false;
}
}, },
ipLimit: { ipLimit: {
label: 'label.ip.limits', label: 'label.ip.limits',
isEditable: true isEditable: function(context) {
if(context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits
return true;
else
return false;
}
}, },
volumeLimit: { volumeLimit: {
label: 'label.volume.limits', label: 'label.volume.limits',
isEditable: true isEditable: function(context) {
if(context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits
return true;
else
return false;
}
}, },
snapshotLimit: { snapshotLimit: {
label: 'label.snapshot.limits', label: 'label.snapshot.limits',
isEditable: true isEditable: function(context) {
if(context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits
return true;
else
return false;
}
}, },
templateLimit: { templateLimit: {
label: 'label.template.limits', label: 'label.template.limits',
isEditable: true isEditable: function(context) {
if(context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits
return true;
else
return false;
}
}, },
vpcLimit: { vpcLimit: {
label: 'VPC limits', label: 'VPC limits',
isEditable: true isEditable: function(context) {
if(context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits
return true;
else
return false;
}
}, },
accountTotal: { label: 'label.accounts' }, accountTotal: { label: 'label.accounts' },
vmTotal: { label: 'label.instances' }, vmTotal: { label: 'label.instances' },
@ -412,8 +476,8 @@
var allowedActions = []; var allowedActions = [];
if(isAdmin()) { if(isAdmin()) {
allowedActions.push("create"); allowedActions.push("create");
if(jsonObj.level != 0) { //ROOT domain (whose level is 0) is not allowed to edit or delete
allowedActions.push("edit"); //merge updateResourceLimit into edit allowedActions.push("edit"); //merge updateResourceLimit into edit
if(jsonObj.level != 0) { //ROOT domain (whose level is 0) is not allowed to delete
allowedActions.push("delete"); allowedActions.push("delete");
} }
} }