cloudstack UI - advanced search - dropdown field - check API permission before 
making API call.


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

Branch: refs/heads/javelin
Commit: 7b1b9f8e950d572bd4fdc770745199ceebc0ba3b
Parents: 8ea0a23
Author: Jessica Wang <[email protected]>
Authored: Thu Oct 4 17:16:06 2012 -0700
Committer: Jessica Wang <[email protected]>
Committed: Thu Oct 4 17:17:28 2012 -0700

----------------------------------------------------------------------
 ui/scripts/events.js    |   43 ++++++++++++--------
 ui/scripts/instances.js |   41 +++++++++++--------
 ui/scripts/network.js   |   90 +++++++++++++++++++++++++----------------
 ui/scripts/projects.js  |   45 ++++++++++++--------
 ui/scripts/storage.js   |   91 +++++++++++++++++++++++++-----------------
 5 files changed, 185 insertions(+), 125 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7b1b9f8e/ui/scripts/events.js
----------------------------------------------------------------------
diff --git a/ui/scripts/events.js b/ui/scripts/events.js
index a8e7085..820bb70 100644
--- a/ui/scripts/events.js
+++ b/ui/scripts/events.js
@@ -56,28 +56,36 @@
                                                                });
                                                        }
                                                },                              
        
+                                               
                                                domainid: {                     
                
                                                        label: 'Domain',        
                                
                                                        select: function(args) {
-                                                               $.ajax({
-                                                                       url: 
createURL('listDomains'),
-                                                                       data: { 
-                                                                               
listAll: true,
-                                                                               
details: 'min'
-                                                                       },
-                                                                       
success: function(json) {
-                                                                               
var array1 = [{id: '', description: ''}];
-                                                                               
var domains = json.listdomainsresponse.domain;
-                                                                               
if(domains != null && domains.length > 0) {
-                                                                               
        for(var i = 0; i < domains.length; i++) {
-                                                                               
                array1.push({id: domains[i].id, description: domains[i].path});
+                                                               if(isAdmin() || 
isDomainAdmin()) {
+                                                                       $.ajax({
+                                                                               
url: createURL('listDomains'),
+                                                                               
data: { 
+                                                                               
        listAll: true,
+                                                                               
        details: 'min'
+                                                                               
},
+                                                                               
success: function(json) {
+                                                                               
        var array1 = [{id: '', description: ''}];
+                                                                               
        var domains = json.listdomainsresponse.domain;
+                                                                               
        if(domains != null && domains.length > 0) {
+                                                                               
                for(var i = 0; i < domains.length; i++) {
+                                                                               
                        array1.push({id: domains[i].id, description: 
domains[i].path});
+                                                                               
                }
                                                                                
        }
+                                                                               
        args.response.success({
+                                                                               
                data: array1
+                                                                               
        });
                                                                                
}
-                                                                               
args.response.success({
-                                                                               
        data: array1
-                                                                               
});
-                                                                       }
-                                                               });
+                                                                       });
+                                                               }
+                                                               else {
+                                                                       
args.response.success({
+                                                                               
data: null
+                                                                       });
+                                                               }
                                                        },
                                                        isHidden: 
function(args) {
                                                                if(isAdmin() || 
isDomainAdmin())
@@ -86,6 +94,7 @@
                                                                        return 
true;
                                                        }
                                                },              
+                                               
                                                account: { 
                                                        label: 'Account',
                                                        isHidden: 
function(args) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7b1b9f8e/ui/scripts/instances.js
----------------------------------------------------------------------
diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js
index baa4b72..22bbbfd 100644
--- a/ui/scripts/instances.js
+++ b/ui/scripts/instances.js
@@ -86,25 +86,32 @@
                                domainid: {                                     
                                  label: 'Domain',                              
        
                                        select: function(args) {
-                                               $.ajax({
-                                                       url: 
createURL('listDomains'),
-                                                       data: { 
-                                                         listAll: true,
-                                                               details: 'min'
-                                                       },
-                                                       success: function(json) 
{
-                                                         var array1 = [{id: 
'', description: ''}];
-                                                               var domains = 
json.listdomainsresponse.domain;
-                                                               if(domains != 
null && domains.length > 0) {
-                                                                 for(var i = 
0; i < domains.length; i++) {
-                                                                         
array1.push({id: domains[i].id, description: domains[i].path});
+                                         if(isAdmin() || isDomainAdmin()) {
+                                                       $.ajax({
+                                                               url: 
createURL('listDomains'),
+                                                               data: { 
+                                                                       
listAll: true,
+                                                                       
details: 'min'
+                                                               },
+                                                               success: 
function(json) {
+                                                                       var 
array1 = [{id: '', description: ''}];
+                                                                       var 
domains = json.listdomainsresponse.domain;
+                                                                       
if(domains != null && domains.length > 0) {
+                                                                               
for(var i = 0; i < domains.length; i++) {
+                                                                               
        array1.push({id: domains[i].id, description: domains[i].path});
+                                                                               
}
                                                                        }
+                                                                       
args.response.success({
+                                                                               
data: array1
+                                                                       });
                                                                }
-                                                               
args.response.success({
-                                                                       data: 
array1
-                                                               });
-                                                       }
-                                               });
+                                                       });
+                                               }
+                                               else {
+                                                 args.response.success({
+                                                               data: null
+                                                       });
+                                               }
                                        },
                                        isHidden: function(args) {
                                          if(isAdmin() || isDomainAdmin())

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7b1b9f8e/ui/scripts/network.js
----------------------------------------------------------------------
diff --git a/ui/scripts/network.js b/ui/scripts/network.js
index a4f4a4d..49644c2 100644
--- a/ui/scripts/network.js
+++ b/ui/scripts/network.js
@@ -464,28 +464,36 @@
                                                                });
                                                        }                       
                        
                                                },      
-            domainid: {                                        
+                                                       
+                                               domainid: {                     
                
                                                        label: 'Domain',        
                                
                                                        select: function(args) {
-                                                               $.ajax({
-                                                                       url: 
createURL('listDomains'),
-                                                                       data: { 
-                                                                               
listAll: true,
-                                                                               
details: 'min'
-                                                                       },
-                                                                       
success: function(json) {
-                                                                               
var array1 = [{id: '', description: ''}];
-                                                                               
var domains = json.listdomainsresponse.domain;
-                                                                               
if(domains != null && domains.length > 0) {
-                                                                               
        for(var i = 0; i < domains.length; i++) {
-                                                                               
                array1.push({id: domains[i].id, description: domains[i].path});
+                                                               if(isAdmin() || 
isDomainAdmin()) {
+                                                                       $.ajax({
+                                                                               
url: createURL('listDomains'),
+                                                                               
data: { 
+                                                                               
        listAll: true,
+                                                                               
        details: 'min'
+                                                                               
},
+                                                                               
success: function(json) {
+                                                                               
        var array1 = [{id: '', description: ''}];
+                                                                               
        var domains = json.listdomainsresponse.domain;
+                                                                               
        if(domains != null && domains.length > 0) {
+                                                                               
                for(var i = 0; i < domains.length; i++) {
+                                                                               
                        array1.push({id: domains[i].id, description: 
domains[i].path});
+                                                                               
                }
                                                                                
        }
+                                                                               
        args.response.success({
+                                                                               
                data: array1
+                                                                               
        });
                                                                                
}
-                                                                               
args.response.success({
-                                                                               
        data: array1
-                                                                               
});
-                                                                       }
-                                                               });
+                                                                       });
+                                                               }
+                                                               else {
+                                                                       
args.response.success({
+                                                                               
data: null
+                                                                       });
+                                                               }
                                                        },
                                                        isHidden: 
function(args) {
                                                                if(isAdmin() || 
isDomainAdmin())
@@ -494,6 +502,7 @@
                                                                        return 
true;
                                                        }
                                                },              
+                                               
                                                account: { 
                                                        label: 'Account',
                                                        isHidden: 
function(args) {
@@ -3681,28 +3690,36 @@
                                                                });
                                                        }                       
                        
                                                },
-            domainid: {                                        
+            
+                                               domainid: {                     
                
                                                        label: 'Domain',        
                                
                                                        select: function(args) {
-                                                               $.ajax({
-                                                                       url: 
createURL('listDomains'),
-                                                                       data: { 
-                                                                               
listAll: true,
-                                                                               
details: 'min'
-                                                                       },
-                                                                       
success: function(json) {
-                                                                               
var array1 = [{id: '', description: ''}];
-                                                                               
var domains = json.listdomainsresponse.domain;
-                                                                               
if(domains != null && domains.length > 0) {
-                                                                               
        for(var i = 0; i < domains.length; i++) {
-                                                                               
                array1.push({id: domains[i].id, description: domains[i].path});
+                                                               if(isAdmin() || 
isDomainAdmin()) {
+                                                                       $.ajax({
+                                                                               
url: createURL('listDomains'),
+                                                                               
data: { 
+                                                                               
        listAll: true,
+                                                                               
        details: 'min'
+                                                                               
},
+                                                                               
success: function(json) {
+                                                                               
        var array1 = [{id: '', description: ''}];
+                                                                               
        var domains = json.listdomainsresponse.domain;
+                                                                               
        if(domains != null && domains.length > 0) {
+                                                                               
                for(var i = 0; i < domains.length; i++) {
+                                                                               
                        array1.push({id: domains[i].id, description: 
domains[i].path});
+                                                                               
                }
                                                                                
        }
+                                                                               
        args.response.success({
+                                                                               
                data: array1
+                                                                               
        });
                                                                                
}
-                                                                               
args.response.success({
-                                                                               
        data: array1
-                                                                               
});
-                                                                       }
-                                                               });
+                                                                       });
+                                                               }
+                                                               else {
+                                                                       
args.response.success({
+                                                                               
data: null
+                                                                       });
+                                                               }
                                                        },
                                                        isHidden: 
function(args) {
                                                                if(isAdmin() || 
isDomainAdmin())
@@ -3711,6 +3728,7 @@
                                                                        return 
true;
                                                        }
                                                },              
+                                               
                                                account: { 
                                                        label: 'Account',
                                                        isHidden: 
function(args) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7b1b9f8e/ui/scripts/projects.js
----------------------------------------------------------------------
diff --git a/ui/scripts/projects.js b/ui/scripts/projects.js
index ff47ac8..4ad032d 100644
--- a/ui/scripts/projects.js
+++ b/ui/scripts/projects.js
@@ -647,28 +647,36 @@
                                                                });
                                                        }                       
                        
                                                },      
-            domainid: {                                        
+            
+                                               domainid: {                     
                
                                                        label: 'Domain',        
                                
                                                        select: function(args) {
-                                                               $.ajax({
-                                                                       url: 
createURL('listDomains'),
-                                                                       data: { 
-                                                                               
listAll: true,
-                                                                               
details: 'min'
-                                                                       },
-                                                                       
success: function(json) {
-                                                                               
var array1 = [{id: '', description: ''}];
-                                                                               
var domains = json.listdomainsresponse.domain;
-                                                                               
if(domains != null && domains.length > 0) {
-                                                                               
        for(var i = 0; i < domains.length; i++) {
-                                                                               
                array1.push({id: domains[i].id, description: domains[i].path});
+                                                               if(isAdmin() || 
isDomainAdmin()) {
+                                                                       $.ajax({
+                                                                               
url: createURL('listDomains'),
+                                                                               
data: { 
+                                                                               
        listAll: true,
+                                                                               
        details: 'min'
+                                                                               
},
+                                                                               
success: function(json) {
+                                                                               
        var array1 = [{id: '', description: ''}];
+                                                                               
        var domains = json.listdomainsresponse.domain;
+                                                                               
        if(domains != null && domains.length > 0) {
+                                                                               
                for(var i = 0; i < domains.length; i++) {
+                                                                               
                        array1.push({id: domains[i].id, description: 
domains[i].path});
+                                                                               
                }
                                                                                
        }
+                                                                               
        args.response.success({
+                                                                               
                data: array1
+                                                                               
        });
                                                                                
}
-                                                                               
args.response.success({
-                                                                               
        data: array1
-                                                                               
});
-                                                                       }
-                                                               });
+                                                                       });
+                                                               }
+                                                               else {
+                                                                       
args.response.success({
+                                                                               
data: null
+                                                                       });
+                                                               }
                                                        },
                                                        isHidden: 
function(args) {
                                                                if(isAdmin() || 
isDomainAdmin())
@@ -677,6 +685,7 @@
                                                                        return 
true;
                                                        }
                                                },              
+                                               
                                                account: { 
                                                        label: 'Account',
                                                        isHidden: 
function(args) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7b1b9f8e/ui/scripts/storage.js
----------------------------------------------------------------------
diff --git a/ui/scripts/storage.js b/ui/scripts/storage.js
index 827cf4e..5b47b70 100644
--- a/ui/scripts/storage.js
+++ b/ui/scripts/storage.js
@@ -293,29 +293,36 @@
                                                                });
                                                        }                       
                        
                                                },              
-
+                                               
                                                domainid: {                     
                
                                                        label: 'Domain',        
                                
                                                        select: function(args) {
-                                                               $.ajax({
-                                                                       url: 
createURL('listDomains'),
-                                                                       data: { 
-                                                                               
listAll: true,
-                                                                               
details: 'min'
-                                                                       },
-                                                                       
success: function(json) {
-                                                                               
var array1 = [{id: '', description: ''}];
-                                                                               
var domains = json.listdomainsresponse.domain;
-                                                                               
if(domains != null && domains.length > 0) {
-                                                                               
        for(var i = 0; i < domains.length; i++) {
-                                                                               
                array1.push({id: domains[i].id, description: domains[i].path});
+                                                               if(isAdmin() || 
isDomainAdmin()) {
+                                                                       $.ajax({
+                                                                               
url: createURL('listDomains'),
+                                                                               
data: { 
+                                                                               
        listAll: true,
+                                                                               
        details: 'min'
+                                                                               
},
+                                                                               
success: function(json) {
+                                                                               
        var array1 = [{id: '', description: ''}];
+                                                                               
        var domains = json.listdomainsresponse.domain;
+                                                                               
        if(domains != null && domains.length > 0) {
+                                                                               
                for(var i = 0; i < domains.length; i++) {
+                                                                               
                        array1.push({id: domains[i].id, description: 
domains[i].path});
+                                                                               
                }
                                                                                
        }
+                                                                               
        args.response.success({
+                                                                               
                data: array1
+                                                                               
        });
                                                                                
}
-                                                                               
args.response.success({
-                                                                               
        data: array1
-                                                                               
});
-                                                                       }
-                                                               });
+                                                                       });
+                                                               }
+                                                               else {
+                                                                       
args.response.success({
+                                                                               
data: null
+                                                                       });
+                                                               }
                                                        },
                                                        isHidden: 
function(args) {
                                                                if(isAdmin() || 
isDomainAdmin())
@@ -323,7 +330,8 @@
                                                                else
                                                                        return 
true;
                                                        }
-                                               },              
+                                               },                              
                                
+                                               
                                                account: { 
                                                        label: 'Account',
                                                        isHidden: 
function(args) {
@@ -1114,28 +1122,36 @@
 
                                        advSearchFields: {
                                          name: { label: 'Name' },      
-            domainid: {                                        
+            
+                                               domainid: {                     
                
                                                        label: 'Domain',        
                                
                                                        select: function(args) {
-                                                               $.ajax({
-                                                                       url: 
createURL('listDomains'),
-                                                                       data: { 
-                                                                               
listAll: true,
-                                                                               
details: 'min'
-                                                                       },
-                                                                       
success: function(json) {
-                                                                               
var array1 = [{id: '', description: ''}];
-                                                                               
var domains = json.listdomainsresponse.domain;
-                                                                               
if(domains != null && domains.length > 0) {
-                                                                               
        for(var i = 0; i < domains.length; i++) {
-                                                                               
                array1.push({id: domains[i].id, description: domains[i].path});
+                                                               if(isAdmin() || 
isDomainAdmin()) {
+                                                                       $.ajax({
+                                                                               
url: createURL('listDomains'),
+                                                                               
data: { 
+                                                                               
        listAll: true,
+                                                                               
        details: 'min'
+                                                                               
},
+                                                                               
success: function(json) {
+                                                                               
        var array1 = [{id: '', description: ''}];
+                                                                               
        var domains = json.listdomainsresponse.domain;
+                                                                               
        if(domains != null && domains.length > 0) {
+                                                                               
                for(var i = 0; i < domains.length; i++) {
+                                                                               
                        array1.push({id: domains[i].id, description: 
domains[i].path});
+                                                                               
                }
                                                                                
        }
+                                                                               
        args.response.success({
+                                                                               
                data: array1
+                                                                               
        });
                                                                                
}
-                                                                               
args.response.success({
-                                                                               
        data: array1
-                                                                               
});
-                                                                       }
-                                                               });
+                                                                       });
+                                                               }
+                                                               else {
+                                                                       
args.response.success({
+                                                                               
data: null
+                                                                       });
+                                                               }
                                                        },
                                                        isHidden: 
function(args) {
                                                                if(isAdmin() || 
isDomainAdmin())
@@ -1144,6 +1160,7 @@
                                                                        return 
true;
                                                        }
                                                },              
+                                               
                                                account: { 
                                                        label: 'Account',
                                                        isHidden: 
function(args) {

Reply via email to