cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jessicaw...@apache.org
Subject git commit: updated refs/heads/4.2 to a414375
Date Thu, 10 Oct 2013 19:16:58 GMT
Updated Branches:
  refs/heads/4.2 8bcf83698 -> a41437563


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/a4143756
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/a4143756
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/a4143756

Branch: refs/heads/4.2
Commit: a4143756326fc6d57cf97082b199cddcc8eed9d6
Parents: 8bcf836
Author: Jessica Wang <jessicawang@apache.org>
Authored: Thu Oct 10 12:14:50 2013 -0700
Committer: Jessica Wang <jessicawang@apache.org>
Committed: Thu Oct 10 12:15:16 2013 -0700

----------------------------------------------------------------------
 ui/scripts/domains.js | 126 +++++++++++++++++++++++++--------------------
 1 file changed, 71 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a4143756/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;


Mime
View raw message