You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ch...@apache.org on 2012/09/25 02:38:40 UTC

[4/13] git commit: CLOUDSTACK-109: cloudstack UI - (1) detailView widget - pass context to isEditable() when calling it. (2) account page - Edit action - allow to update network domain on system-generated default admin account.

CLOUDSTACK-109: cloudstack UI - (1) detailView widget - pass context to isEditable() when calling it.  (2) account page - Edit action - allow to update network domain on system-generated default admin account.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/a3c80ebf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/a3c80ebf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/a3c80ebf

Branch: refs/heads/junit-tests
Commit: a3c80ebf4e56cd2d1b56f1a118f2e71172bca0bd
Parents: 309be01
Author: Jessica Wang <je...@citrix.com>
Authored: Mon Sep 24 16:01:53 2012 -0700
Committer: Jessica Wang <je...@citrix.com>
Committed: Mon Sep 24 16:05:32 2012 -0700

----------------------------------------------------------------------
 ui/scripts/accounts.js              |  162 ++++++++++++++++++-----------
 ui/scripts/ui/widgets/detailView.js |    2 +-
 2 files changed, 101 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a3c80ebf/ui/scripts/accounts.js
----------------------------------------------------------------------
diff --git a/ui/scripts/accounts.js b/ui/scripts/accounts.js
index 03ec799..15da521 100644
--- a/ui/scripts/accounts.js
+++ b/ui/scripts/accounts.js
@@ -282,59 +282,71 @@
  
                   });
 
-                  $.ajax({
-                    url: createURL("updateResourceLimit&resourceType=0&max=" + todb(args.data.vmLimit) + "&account=" + accountObj.name + "&domainid=" + accountObj.domainid),
-                    dataType: "json",
-                    async: false,
-                    success: function(json) {
-                      accountObj["vmLimit"] = args.data.vmLimit;
-                    }
-                  });
-
-                  $.ajax({
-                    url: createURL("updateResourceLimit&resourceType=1&max=" + todb(args.data.ipLimit) + "&account=" + accountObj.name + "&domainid=" + accountObj.domainid),
-                    dataType: "json",
-                    async: false,
-                    success: function(json) {
-                      accountObj["ipLimit"] = args.data.ipLimit;
-                    }
-                  });
+									if(args.data.vmLimit != null) {
+										$.ajax({
+											url: createURL("updateResourceLimit&resourceType=0&max=" + todb(args.data.vmLimit) + "&account=" + accountObj.name + "&domainid=" + accountObj.domainid),
+											dataType: "json",
+											async: false,
+											success: function(json) {
+												accountObj["vmLimit"] = args.data.vmLimit;
+											}
+										});
+									}
 
-                  $.ajax({
-                    url: createURL("updateResourceLimit&resourceType=2&max=" + todb(args.data.volumeLimit) + "&account=" + accountObj.name + "&domainid=" + accountObj.domainid),
-                    dataType: "json",
-                    async: false,
-                    success: function(json) {
-                      accountObj["volumeLimit"] = args.data.volumeLimit;
-                    }
-                  });
+									if(args.data.ipLimit != null) {
+										$.ajax({
+											url: createURL("updateResourceLimit&resourceType=1&max=" + todb(args.data.ipLimit) + "&account=" + accountObj.name + "&domainid=" + accountObj.domainid),
+											dataType: "json",
+											async: false,
+											success: function(json) {
+												accountObj["ipLimit"] = args.data.ipLimit;
+											}
+										});
+									}
 
-                  $.ajax({
-                    url: createURL("updateResourceLimit&resourceType=3&max=" + todb(args.data.snapshotLimit) + "&account=" + accountObj.name + "&domainid=" + accountObj.domainid),
-                    dataType: "json",
-                    async: false,
-                    success: function(json) {
-                      accountObj["snapshotLimit"] = args.data.snapshotLimit;
-                    }
-                  });
+									if(args.data.volumeLimit != null) {
+										$.ajax({
+											url: createURL("updateResourceLimit&resourceType=2&max=" + todb(args.data.volumeLimit) + "&account=" + accountObj.name + "&domainid=" + accountObj.domainid),
+											dataType: "json",
+											async: false,
+											success: function(json) {
+												accountObj["volumeLimit"] = args.data.volumeLimit;
+											}
+										});
+									}
 
-                  $.ajax({
-                    url: createURL("updateResourceLimit&resourceType=4&max=" + todb(args.data.templateLimit) + "&account=" + accountObj.name + "&domainid=" + accountObj.domainid),
-                    dataType: "json",
-                    async: false,
-                    success: function(json) {
-                      accountObj["templateLimit"] = args.data.templateLimit;
-                    }
-                  });
-                  
-                  $.ajax({
-                    url: createURL("updateResourceLimit&resourceType=7&max=" + todb(args.data.vpcLimit) + "&account=" + accountObj.name + "&domainid=" + accountObj.domainid),
-                    dataType: "json",
-                    async: false,
-                    success: function(json) {
-                      accountObj["vpcLimit"] = args.data.vpcLimit;
-                    }
-                  });
+									if(args.data.snapshotLimit != null) {
+										$.ajax({
+											url: createURL("updateResourceLimit&resourceType=3&max=" + todb(args.data.snapshotLimit) + "&account=" + accountObj.name + "&domainid=" + accountObj.domainid),
+											dataType: "json",
+											async: false,
+											success: function(json) {
+												accountObj["snapshotLimit"] = args.data.snapshotLimit;
+											}
+										});
+									}
+ 
+                  if(args.data.templateLimit != null) {
+										$.ajax({
+											url: createURL("updateResourceLimit&resourceType=4&max=" + todb(args.data.templateLimit) + "&account=" + accountObj.name + "&domainid=" + accountObj.domainid),
+											dataType: "json",
+											async: false,
+											success: function(json) {
+												accountObj["templateLimit"] = args.data.templateLimit;
+											}
+										});
+                  }
+									
+									if(args.data.vpcLimit != null) {
+										$.ajax({
+											url: createURL("updateResourceLimit&resourceType=7&max=" + todb(args.data.vpcLimit) + "&account=" + accountObj.name + "&domainid=" + accountObj.domainid),
+											dataType: "json",
+											async: false,
+											success: function(json) {
+												accountObj["vpcLimit"] = args.data.vpcLimit;
+											}
+										});
+									}
 
                   if(errorMsg == "")
                   args.response.success({data: accountObj});
@@ -546,27 +558,57 @@
                     },
                     vmLimit: {
                       label: 'label.instance.limits',
-                      isEditable: true
+                      isEditable: function(context) {											  
+											  if (context.accounts[0].accounttype == roleTypeUser || context.accounts[0].accounttype == roleTypeDomainAdmin) //updateResourceLimits is only allowed on account whose type is user or domain-admin
+												  return true;
+												else
+												  return false;
+											}
                     },
                     ipLimit: {
                       label: 'label.ip.limits',
-                      isEditable: true
+                      isEditable: function(context) {											  
+											  if (context.accounts[0].accounttype == roleTypeUser || context.accounts[0].accounttype == roleTypeDomainAdmin) //updateResourceLimits is only allowed on account whose type is user or domain-admin
+												  return true;
+												else
+												  return false;
+											}
                     },
                     volumeLimit: {
                       label: 'label.volume.limits',
-                      isEditable: true
+                      isEditable: function(context) {											  
+											  if (context.accounts[0].accounttype == roleTypeUser || context.accounts[0].accounttype == roleTypeDomainAdmin) //updateResourceLimits is only allowed on account whose type is user or domain-admin
+												  return true;
+												else
+												  return false;
+											}
                     },
                     snapshotLimit: {
                       label: 'label.snapshot.limits',
-                      isEditable: true
+                      isEditable: function(context) {											  
+											  if (context.accounts[0].accounttype == roleTypeUser || context.accounts[0].accounttype == roleTypeDomainAdmin) //updateResourceLimits is only allowed on account whose type is user or domain-admin
+												  return true;
+												else
+												  return false;
+											}
                     },
                     templateLimit: {
                       label: 'label.template.limits',
-                      isEditable: true
+                      isEditable: function(context) {											  
+											  if (context.accounts[0].accounttype == roleTypeUser || context.accounts[0].accounttype == roleTypeDomainAdmin) //updateResourceLimits is only allowed on account whose type is user or domain-admin
+												  return true;
+												else
+												  return false;
+											}
                     },
                     vpcLimit: {
                       label: 'VPC limits',
-                      isEditable: true
+                      isEditable: function(context) {											  
+											  if (context.accounts[0].accounttype == roleTypeUser || context.accounts[0].accounttype == roleTypeDomainAdmin) //updateResourceLimits is only allowed on account whose type is user or domain-admin
+												  return true;
+												else
+												  return false;
+											}
                     },
 
                     vmtotal: { label: 'label.total.of.vm' },
@@ -1091,12 +1133,8 @@
     if (jsonObj.state == 'Destroyed') return [];
 
     if(isAdmin()) {
-      if(!(jsonObj.domain == "ROOT" && jsonObj.name == "admin" && jsonObj.accounttype == 1)) { //if not system-generated default admin account 
-        //allowedActions.push("edit");
-        if (jsonObj.accounttype == roleTypeUser || jsonObj.accounttype == roleTypeDomainAdmin) {
-          //allowedActions.push("updateResourceLimits");
-          allowedActions.push("edit");
-        }
+		  allowedActions.push("edit"); //updating networkdomain is allowed on any account, including system-generated default admin account 
+      if(!(jsonObj.domain == "ROOT" && jsonObj.name == "admin" && jsonObj.accounttype == 1)) { //if not system-generated default admin account    
         if(jsonObj.state == "enabled") {
           allowedActions.push("disable");
           allowedActions.push("lock");

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a3c80ebf/ui/scripts/ui/widgets/detailView.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui/widgets/detailView.js b/ui/scripts/ui/widgets/detailView.js
index fc2ae45..a51cfcc 100644
--- a/ui/scripts/ui/widgets/detailView.js
+++ b/ui/scripts/ui/widgets/detailView.js
@@ -789,7 +789,7 @@
 
         // Set up editable metadata				
 				if(typeof(value.isEditable) == 'function')
-				  $value.data('detail-view-is-editable', value.isEditable());
+				  $value.data('detail-view-is-editable', value.isEditable(context));
 				else //typeof(value.isEditable) == 'boolean' or 'undefined'
           $value.data('detail-view-is-editable', value.isEditable);
         if (value.select) {