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

This commit is contained in:
Jessica Wang 2012-10-04 17:16:06 -07:00
parent 8ea0a230e6
commit 7b1b9f8e95
5 changed files with 185 additions and 125 deletions

View File

@ -56,28 +56,36 @@
}); });
} }
}, },
domainid: { domainid: {
label: 'Domain', label: 'Domain',
select: function(args) { select: function(args) {
$.ajax({ if(isAdmin() || isDomainAdmin()) {
url: createURL('listDomains'), $.ajax({
data: { url: createURL('listDomains'),
listAll: true, data: {
details: 'min' listAll: true,
}, details: 'min'
success: function(json) { },
var array1 = [{id: '', description: ''}]; success: function(json) {
var domains = json.listdomainsresponse.domain; var array1 = [{id: '', description: ''}];
if(domains != null && domains.length > 0) { var domains = json.listdomainsresponse.domain;
for(var i = 0; i < domains.length; i++) { if(domains != null && domains.length > 0) {
array1.push({id: domains[i].id, description: domains[i].path}); 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) { isHidden: function(args) {
if(isAdmin() || isDomainAdmin()) if(isAdmin() || isDomainAdmin())
@ -86,6 +94,7 @@
return true; return true;
} }
}, },
account: { account: {
label: 'Account', label: 'Account',
isHidden: function(args) { isHidden: function(args) {

View File

@ -86,25 +86,32 @@
domainid: { domainid: {
label: 'Domain', label: 'Domain',
select: function(args) { select: function(args) {
$.ajax({ if(isAdmin() || isDomainAdmin()) {
url: createURL('listDomains'), $.ajax({
data: { url: createURL('listDomains'),
listAll: true, data: {
details: 'min' listAll: true,
}, details: 'min'
success: function(json) { },
var array1 = [{id: '', description: ''}]; success: function(json) {
var domains = json.listdomainsresponse.domain; var array1 = [{id: '', description: ''}];
if(domains != null && domains.length > 0) { var domains = json.listdomainsresponse.domain;
for(var i = 0; i < domains.length; i++) { if(domains != null && domains.length > 0) {
array1.push({id: domains[i].id, description: domains[i].path}); 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) { isHidden: function(args) {
if(isAdmin() || isDomainAdmin()) if(isAdmin() || isDomainAdmin())

View File

@ -464,28 +464,36 @@
}); });
} }
}, },
domainid: {
domainid: {
label: 'Domain', label: 'Domain',
select: function(args) { select: function(args) {
$.ajax({ if(isAdmin() || isDomainAdmin()) {
url: createURL('listDomains'), $.ajax({
data: { url: createURL('listDomains'),
listAll: true, data: {
details: 'min' listAll: true,
}, details: 'min'
success: function(json) { },
var array1 = [{id: '', description: ''}]; success: function(json) {
var domains = json.listdomainsresponse.domain; var array1 = [{id: '', description: ''}];
if(domains != null && domains.length > 0) { var domains = json.listdomainsresponse.domain;
for(var i = 0; i < domains.length; i++) { if(domains != null && domains.length > 0) {
array1.push({id: domains[i].id, description: domains[i].path}); 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) { isHidden: function(args) {
if(isAdmin() || isDomainAdmin()) if(isAdmin() || isDomainAdmin())
@ -494,6 +502,7 @@
return true; return true;
} }
}, },
account: { account: {
label: 'Account', label: 'Account',
isHidden: function(args) { isHidden: function(args) {
@ -3681,28 +3690,36 @@
}); });
} }
}, },
domainid: {
domainid: {
label: 'Domain', label: 'Domain',
select: function(args) { select: function(args) {
$.ajax({ if(isAdmin() || isDomainAdmin()) {
url: createURL('listDomains'), $.ajax({
data: { url: createURL('listDomains'),
listAll: true, data: {
details: 'min' listAll: true,
}, details: 'min'
success: function(json) { },
var array1 = [{id: '', description: ''}]; success: function(json) {
var domains = json.listdomainsresponse.domain; var array1 = [{id: '', description: ''}];
if(domains != null && domains.length > 0) { var domains = json.listdomainsresponse.domain;
for(var i = 0; i < domains.length; i++) { if(domains != null && domains.length > 0) {
array1.push({id: domains[i].id, description: domains[i].path}); 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) { isHidden: function(args) {
if(isAdmin() || isDomainAdmin()) if(isAdmin() || isDomainAdmin())
@ -3711,6 +3728,7 @@
return true; return true;
} }
}, },
account: { account: {
label: 'Account', label: 'Account',
isHidden: function(args) { isHidden: function(args) {

View File

@ -647,28 +647,36 @@
}); });
} }
}, },
domainid: {
domainid: {
label: 'Domain', label: 'Domain',
select: function(args) { select: function(args) {
$.ajax({ if(isAdmin() || isDomainAdmin()) {
url: createURL('listDomains'), $.ajax({
data: { url: createURL('listDomains'),
listAll: true, data: {
details: 'min' listAll: true,
}, details: 'min'
success: function(json) { },
var array1 = [{id: '', description: ''}]; success: function(json) {
var domains = json.listdomainsresponse.domain; var array1 = [{id: '', description: ''}];
if(domains != null && domains.length > 0) { var domains = json.listdomainsresponse.domain;
for(var i = 0; i < domains.length; i++) { if(domains != null && domains.length > 0) {
array1.push({id: domains[i].id, description: domains[i].path}); 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) { isHidden: function(args) {
if(isAdmin() || isDomainAdmin()) if(isAdmin() || isDomainAdmin())
@ -677,6 +685,7 @@
return true; return true;
} }
}, },
account: { account: {
label: 'Account', label: 'Account',
isHidden: function(args) { isHidden: function(args) {

View File

@ -293,29 +293,36 @@
}); });
} }
}, },
domainid: { domainid: {
label: 'Domain', label: 'Domain',
select: function(args) { select: function(args) {
$.ajax({ if(isAdmin() || isDomainAdmin()) {
url: createURL('listDomains'), $.ajax({
data: { url: createURL('listDomains'),
listAll: true, data: {
details: 'min' listAll: true,
}, details: 'min'
success: function(json) { },
var array1 = [{id: '', description: ''}]; success: function(json) {
var domains = json.listdomainsresponse.domain; var array1 = [{id: '', description: ''}];
if(domains != null && domains.length > 0) { var domains = json.listdomainsresponse.domain;
for(var i = 0; i < domains.length; i++) { if(domains != null && domains.length > 0) {
array1.push({id: domains[i].id, description: domains[i].path}); 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) { isHidden: function(args) {
if(isAdmin() || isDomainAdmin()) if(isAdmin() || isDomainAdmin())
@ -323,7 +330,8 @@
else else
return true; return true;
} }
}, },
account: { account: {
label: 'Account', label: 'Account',
isHidden: function(args) { isHidden: function(args) {
@ -1114,28 +1122,36 @@
advSearchFields: { advSearchFields: {
name: { label: 'Name' }, name: { label: 'Name' },
domainid: {
domainid: {
label: 'Domain', label: 'Domain',
select: function(args) { select: function(args) {
$.ajax({ if(isAdmin() || isDomainAdmin()) {
url: createURL('listDomains'), $.ajax({
data: { url: createURL('listDomains'),
listAll: true, data: {
details: 'min' listAll: true,
}, details: 'min'
success: function(json) { },
var array1 = [{id: '', description: ''}]; success: function(json) {
var domains = json.listdomainsresponse.domain; var array1 = [{id: '', description: ''}];
if(domains != null && domains.length > 0) { var domains = json.listdomainsresponse.domain;
for(var i = 0; i < domains.length; i++) { if(domains != null && domains.length > 0) {
array1.push({id: domains[i].id, description: domains[i].path}); 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) { isHidden: function(args) {
if(isAdmin() || isDomainAdmin()) if(isAdmin() || isDomainAdmin())
@ -1144,6 +1160,7 @@
return true; return true;
} }
}, },
account: { account: {
label: 'Account', label: 'Account',
isHidden: function(args) { isHidden: function(args) {