1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-24 21:34:01 +03:00
Owner of the elements is now taken into account when adding them to the selects.
If the user is the owner or the status is good (i.e. not disabled or unpublished),
then the elements are added.
This commit is contained in:
Hector Sanjuan 2011-04-29 19:20:54 +02:00 committed by Daniel Molina
parent af70d862ac
commit 2d2dc2cf43
6 changed files with 20 additions and 11 deletions

View File

@ -416,7 +416,7 @@ function hostInfoListener(){
//updates the host select by refreshing the options in it
function updateHostSelect(){
hosts_select = makeSelectOptions(dataTable_hosts,1,2,7,"DISABLED");
hosts_select = makeSelectOptions(dataTable_hosts,1,2,7,"DISABLED",-1);
}

View File

@ -474,7 +474,8 @@ function imageInfoListener(){
//Updates the select input field with an option for each image
function updateImageSelect(){
images_select = makeSelectOptions(dataTable_images,1,3,8,"DISABLED");
images_select =
makeSelectOptions(dataTable_images,1,3,8,"DISABLED",2);
//update static selectors:
//in the VM section
@ -499,8 +500,7 @@ function deleteImageElement(req){
function addImageElement(request, image_json){
var element = imageElementArray(image_json);
addElement(element,dataTable_images);
//NOTE that the select is not updated because newly added images
//are disabled by default
updateImageSelect();
}
// Callback to refresh the list of images

View File

@ -724,7 +724,8 @@ function templateInfoListener(){
//Updates the select input field with an option for each template
function updateTemplateSelect(){
templates_select = makeSelectOptions(dataTable_templates,1,3,5,"No");
templates_select =
makeSelectOptions(dataTable_templates,1,3,5,"no",2);
//update static selectors:
$('#create_vm_dialog #template_id').html(templates_select);
@ -748,8 +749,7 @@ function deleteTemplateElement(req){
function addTemplateElement(request, template_json){
var element = templateElementArray(template_json);
addElement(element,dataTable_templates);
//NOTE that the select is not updated because newly added templates
//are not public
updateTemplateSelect();
}
// Callback to refresh the list of templates

View File

@ -308,7 +308,8 @@ function vNetworkInfoListener(){
//updates the vnet select different options
function updateNetworkSelect(){
vnetworks_select= makeSelectOptions(dataTable_vNetworks,1,3,6,"no")
vnetworks_select=
makeSelectOptions(dataTable_vNetworks,1,3,6,"no",2);
//update static selectors:
//in the VM creation dialog

View File

@ -313,7 +313,7 @@ function waitingNodes(dataTable){
//not defined then it returns "uid UID".
//TODO not very nice to hardcode a dataTable here...
function getUserName(uid){
var user = "uid "+uid;
var user = uid;
if (typeof(dataTable_users) == "undefined") {
return user;
}
@ -382,7 +382,11 @@ function getSelectedNodes(dataTable){
//returns a HTML string with a select input code generated from
//a dataTable
function makeSelectOptions(dataTable,id_col,name_col,status_col,status_bad){
function makeSelectOptions(dataTable,
id_col,name_col,
status_col,
status_bad,
user_col){
var nodes = dataTable.fnGetData();
var select = "<option value=\"\">Please select</option>";
var array;
@ -390,7 +394,11 @@ function makeSelectOptions(dataTable,id_col,name_col,status_col,status_bad){
var id = this[id_col];
var name = this[name_col];
var status = this[status_col];
if (status != status_bad){
var user = user_col > 0 ? this[user_col] : false;
var isMine = user ? (username == user) || (uid == user) : true;
if ((status != status_bad) || isMine ){
select +='<option value="'+id+'">'+name+'</option>';
}
});

Binary file not shown.