You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bf...@apache.org on 2013/10/14 19:17:56 UTC
[64/81] [abbrv] git commit: updated refs/heads/ui-restyle to e901b82
CLOUDSTACK-1888: UI > Domains > allow domain-admin to update resource limits on its sub-domains (but disallow on its own domain).
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/506520a9
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/506520a9
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/506520a9
Branch: refs/heads/ui-restyle
Commit: 506520a9d6586da7f7dff41c94b4427179a450de
Parents: 1f85124
Author: Jessica Wang <je...@apache.org>
Authored: Thu Oct 10 12:14:50 2013 -0700
Committer: Jessica Wang <je...@apache.org>
Committed: Thu Oct 10 12:17:05 2013 -0700
----------------------------------------------------------------------
ui/scripts/domains.js | 126 +++++++++++++++++++++++++--------------------
1 file changed, 71 insertions(+), 55 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/506520a9/ui/scripts/domains.js
----------------------------------------------------------------------
diff --git a/ui/scripts/domains.js b/ui/scripts/domains.js
index 139412d..7306a38 100644
--- a/ui/scripts/domains.js
+++ b/ui/scripts/domains.js
@@ -99,24 +99,31 @@
var domainObj;
var data = {
- id: args.context.domains[0].id,
- networkdomain: args.data.networkdomain
+ id: args.context.domains[0].id
};
- if (args.data.name != null) {
+ if (args.data.name != null) { //args.data.name == undefined means name field is not editable (when log in as normal user or domain admin)
$.extend(data, {
name: args.data.name
});
}
-
- $.ajax({
- url: createURL("updateDomain"),
- async: false,
- data: data,
- success: function(json) {
- domainObj = json.updatedomainresponse.domain;
- }
- });
+
+ if (args.data.networkdomain != null) { //args.data.networkdomain == undefined means networkdomain field is not editable (when log in as normal user or domain admin)
+ $.extend(data, {
+ networkdomain: args.data.networkdomain
+ });
+ }
+
+ if('name' in data || 'networkdomain' in data) {
+ $.ajax({
+ url: createURL("updateDomain"),
+ async: false,
+ data: data,
+ success: function(json) {
+ domainObj = json.updatedomainresponse.domain;
+ }
+ });
+ }
if (args.data.vmLimit != null) {
$.ajax({
@@ -328,8 +335,8 @@
fields: [{
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
+ isEditable: function(args) {
+ if (isAdmin() && args.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to change domain name
return true;
else
return false;
@@ -346,96 +353,101 @@
networkdomain: {
label: 'label.network.domain',
- isEditable: true
+ isEditable: function(args) {
+ if (isAdmin())
+ return true;
+ else
+ return false;
+ }
},
vmLimit: {
label: 'label.instance.limits',
- isEditable: function(context) {
- if (context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits
- return true;
- else
+ isEditable: function(args) {
+ if (args.domains[0].id == g_domainid) //disallow to update the field on the domain you log in as
return false;
+ else
+ return true;
}
},
ipLimit: {
label: 'label.ip.limits',
- isEditable: function(context) {
- if (context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits
- return true;
- else
+ isEditable: function(args) {
+ if (args.domains[0].id == g_domainid) //disallow to update the field on the domain you log in as
return false;
+ else
+ return true;
}
},
volumeLimit: {
label: 'label.volume.limits',
- isEditable: function(context) {
- if (context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits
- return true;
- else
+ isEditable: function(args) {
+ if (args.domains[0].id == g_domainid) //disallow to update the field on the domain you log in as
return false;
+ else
+ return true;
}
},
snapshotLimit: {
label: 'label.snapshot.limits',
- isEditable: function(context) {
- if (context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits
- return true;
- else
+ isEditable: function(args) {
+ if (args.domains[0].id == g_domainid) //disallow to update the field on the domain you log in as
return false;
+ else
+ return true;
}
},
templateLimit: {
label: 'label.template.limits',
- isEditable: function(context) {
- if (context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits
- return true;
- else
+ isEditable: function(args) {
+ if (args.domains[0].id == g_domainid) //disallow to update the field on the domain you log in as
return false;
+ else
+ return true;
}
},
vpcLimit: {
label: 'VPC limits',
- isEditable: function(context) {
- if (context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits
- return true;
- else
+ isEditable: function(args) {
+ if (args.domains[0].id == g_domainid) //disallow to update the field on the domain you log in as
return false;
+ else
+ return true;
}
},
cpuLimit: {
label: 'label.cpu.limits',
- isEditable: function(context) {
- if (context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits
- return true;
- else
+ isEditable: function(args) {
+ if (args.domains[0].id == g_domainid) //disallow to update the field on the domain you log in as
return false;
+ else
+ return true;
}
},
memoryLimit: {
label: 'label.memory.limits',
- isEditable: function(context) {
- if (context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits
- return true;
- else
+ isEditable: function(args) {
+ if (args.domains[0].id == g_domainid) //disallow to update the field on the domain you log in as
return false;
+ else
+ return true;
}
},
primaryStorageLimit: {
label: 'label.primary.storage.limits',
- isEditable: function(context) {
- if (context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits
- return true;
- else
+ isEditable: function(args) {
+ if (args.domains[0].id == g_domainid) //disallow to update the field on the domain you log in as
return false;
+ else
+ return true;
}
},
secondaryStorageLimit: {
label: 'label.secondary.storage.limits',
- isEditable: function(context) {
- if (context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits
- return true;
- else
+ isEditable: function(args) {
+ if (args.domains[0].id == g_domainid) //disallow to update the field on the domain you log in as
return false;
+ else
+ return true;
}
},
accountTotal: {
@@ -620,6 +632,10 @@
if (jsonObj.level != 0) { //ROOT domain (whose level is 0) is not allowed to delete
allowedActions.push("delete");
}
+ } else if (isDomainAdmin()) {
+ if (args.context.domains[0].id != g_domainid) {
+ allowedActions.push("edit"); //merge updateResourceLimit into edit
+ }
}
allowedActions.push("updateResourceCount");
return allowedActions;