diff --git a/src/sunstone/public/js/opennebula.js b/src/sunstone/public/js/opennebula.js index dcd94d3406..bf5caaa4a3 100644 --- a/src/sunstone/public/js/opennebula.js +++ b/src/sunstone/public/js/opennebula.js @@ -772,12 +772,6 @@ var OpenNebula = { "disable": function(params){ OpenNebula.Action.simple_action(params,OpenNebula.Image.resource,"disable"); }, - "publish": function(params){ - OpenNebula.Action.simple_action(params,OpenNebula.Image.resource,"publish"); - }, - "unpublish": function(params){ - OpenNebula.Action.simple_action(params,OpenNebula.Image.resource,"unpublish"); - }, "persistent": function(params){ OpenNebula.Action.simple_action(params,OpenNebula.Image.resource,"persistent"); }, diff --git a/src/sunstone/public/js/plugins/images-tab.js b/src/sunstone/public/js/plugins/images-tab.js index 4a1583ce3a..0b61c2a779 100644 --- a/src/sunstone/public/js/plugins/images-tab.js +++ b/src/sunstone/public/js/plugins/images-tab.js @@ -31,7 +31,6 @@ var images_tab_content = '+tr("Size")+'\ '+tr("Type")+'\ '+tr("Registration time")+'\ - '+tr("Public")+'\ '+tr("Persistent")+'\ '+tr("Status")+'\ '+tr("#VMS")+'\ @@ -74,11 +73,6 @@ var create_image_tmpl = \
'+tr("Type of the image, explained in detail in the following section. If omitted, the default value is the one defined in oned.conf (install default is OS).")+'
\ \ -
\ - \ - \ -
'+tr("Public scope of the image")+'
\ -
\
\ \ \ @@ -185,12 +179,35 @@ var update_image_tmpl = \
\
\ - \ - \ + \ + \
\
\ - \ - \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ +
'+tr("Permissions")+':'+tr("Use")+''+tr("Manage")+''+tr("Admin")+'
'+tr("Owner")+'
'+tr("Group")+'
'+tr("Other")+'
\
\ \
\ @@ -267,6 +284,17 @@ var image_actions = { error: onError }, + "Image.fetch_permissions" : { + type: "single", + call: OpenNebula.Image.show, + callback: function(request,image_json){ + var dialog = $('#image_template_update_dialog form'); + var image = image_json.IMAGE; + setPermissionsTable(image,dialog); + }, + error: onError + }, + "Image.update_dialog" : { type: "custom", call: function() { @@ -327,28 +355,6 @@ var image_actions = { notify: true }, - "Image.publish" : { - type: "multiple", - call: OpenNebula.Image.publish, - callback: function (req) { - Sunstone.runAction("Image.show",req.request.data[0]); - }, - elements: imageElements, - error: onError, - notify: true - }, - - "Image.unpublish" : { - type: "multiple", - call: OpenNebula.Image.unpublish, - callback: function (req) { - Sunstone.runAction("Image.show",req.request.data[0]); - }, - elements: imageElements, - error: onError, - notify: true - }, - "Image.delete" : { type: "multiple", call: OpenNebula.Image.delete, @@ -380,6 +386,14 @@ var image_actions = { notify: true }, + "Image.chmod" : { + type: "multiple", + call: OpenNebula.Image.chmod, +// callback + error: onError, + notify: true + }, + "Image.chtype" : { type: "single", call: OpenNebula.Image.chtype, @@ -390,8 +404,7 @@ var image_actions = { error: onError, notify: true } - -} +}; var image_buttons = { @@ -406,7 +419,7 @@ var image_buttons = { }, "Image.update_dialog" : { type: "action", - text: tr("Update a template"), + text: tr("Update properties"), alwaysActive: true }, "Image.chown" : { @@ -434,14 +447,6 @@ var image_buttons = { type: "action", text: tr("Disable") }, - "Image.publish" : { - type: "action", - text: tr("Publish") - }, - "Image.unpublish" : { - type: "action", - text: tr("Unpublish") - }, "Image.persistent" : { type: "action", text: tr("Make persistent") @@ -489,7 +494,7 @@ function imageElements() { // Returns an array containing the values of the image_json and ready // to be inserted in the dataTable function imageElementArray(image_json){ - //Changing this? It may affect to the is_public() and is_persistent() functions. + //Changing this? It may affect to the is_persistent() functions. var image = image_json.IMAGE; var type = $('', image.ID, @@ -512,8 +515,6 @@ function imageElementArray(image_json){ image.SIZE, '', pretty_time(image.REGTIME), - parseInt(image.PUBLIC) ? '' - : '', parseInt(image.PERSISTENT) ? '' : '', OpenNebula.Helper.resource_state("image",image.STATE), @@ -602,10 +603,6 @@ function updateImageInfo(request,img){ '+tr("Register time")+'\ '+pretty_time(img_info.REGTIME)+'\ \ - \ - '+tr("Public")+'\ - '+(parseInt(img_info.PUBLIC) ? tr("yes") : tr("no"))+'\ - \ \ '+tr("Persistent")+'\ '+(parseInt(img_info.PERSISTENT) ? tr("yes") : tr("no"))+'\ @@ -634,6 +631,19 @@ function updateImageInfo(request,img){ '+tr("Running #VMS")+'\ '+img_info.RUNNING_VMS+'\ \ + \ + \ + '+tr("Owner permissions")+'\ + '+ownerPermStr(img_info)+'\ + \ + \ + '+tr("Group permissions")+'\ + '+groupPermStr(img_info)+'\ + \ + \ + '+tr("Other permissions")+'\ + '+otherPermStr(img_info)+'\ + \ ' } @@ -693,16 +703,6 @@ function setupCreateImageDialog(){ $('#path_img',dialog).attr('checked','checked'); $('#img_path',dialog).parent().addClass("img_man"); - $('#img_public',dialog).click(function(){ - $('#img_persistent',$create_image_dialog).removeAttr('checked'); - }); - - $('#img_persistent',dialog).click(function(){ - $('#img_public',$create_image_dialog).removeAttr('checked'); - }); - - - $('#src_path_select input').click(function(){ var context = $create_image_dialog; var value = $(this).val(); @@ -776,8 +776,6 @@ function setupCreateImageDialog(){ var type = $('#img_type',this).val(); img_json["TYPE"]= type; - img_json["PUBLIC"] = $('#img_public:checked',this).length ? "YES" : "NO"; - img_json["PERSISTENT"] = $('#img_persistent:checked',this).length ? "YES" : "NO"; var dev_prefix = $('#img_dev_prefix',this).val(); @@ -841,18 +839,19 @@ function popUpCreateImageDialog(){ function setupImageTemplateUpdateDialog(){ //Append to DOM - dialogs_context.append('
'); + dialogs_context.append('
'); var dialog = $('#image_template_update_dialog',dialogs_context); //Put HTML in place dialog.html(update_image_tmpl); + var height = Math.floor($(window).height()*0.8); //set height to a percentage of the window //Convert into jQuery dialog.dialog({ autoOpen:false, width:700, modal:true, - height:480, + height:height, resizable:false, }); @@ -860,62 +859,61 @@ function setupImageTemplateUpdateDialog(){ $('#image_template_update_select',dialog).change(function(){ var id = $(this).val(); + $('.permissions_table input',dialog).removeAttr('checked') + $('.permissions_table',dialog).removeAttr('update'); if (id && id.length){ var dialog = $('#image_template_update_dialog'); $('#image_template_update_textarea',dialog).val(tr("Loading")+ "..."); - var img_public = is_public_image(id); - var img_persistent = is_persistent_image(id) - - if (img_public){ - $('#image_template_update_public',dialog).attr('checked','checked') - } else { - $('#image_template_update_public',dialog).removeAttr('checked') - } + var img_persistent = is_persistent_image(id); if (img_persistent){ $('#image_template_update_persistent',dialog).attr('checked','checked') } else { $('#image_template_update_persistent',dialog).removeAttr('checked') - } + }; + Sunstone.runAction("Image.fetch_permissions",id); Sunstone.runAction("Image.fetch_template",id); } else { $('#image_template_update_textarea',dialog).val(""); }; }); - $('#image_template_update_button',dialog).click(function(){ - var dialog = $('#image_template_update_dialog'); + $('.permissions_table input',dialog).change(function(){ + $(this).parents('table').attr('update','update'); + }); + + $('form',dialog).submit(function(){ + var dialog = $(this); var new_template = $('#image_template_update_textarea',dialog).val(); var id = $('#image_template_update_select',dialog).val(); if (!id || !id.length) { - dialog.dialog('close'); + $(this).parents('#image_template_update_dialog').dialog('close'); return false; }; - var old_public = is_public_image(id) var old_persistent = is_persistent_image(id); - - var new_public = $('#image_template_update_public:checked',dialog).length; - var new_persistent = $('#image_template_update_persistent:checked',dialog).length; - - if (old_public != new_public){ - if (new_public) Sunstone.runAction("Image.publish",id); - else Sunstone.runAction("Image.unpublish",id); - }; - + var new_persistent = $('#image_template_update_persistent',dialog).is(':checked'); if (old_persistent != new_persistent){ if (new_persistent) Sunstone.runAction("Image.persistent",id); else Sunstone.runAction("Image.nonpersistent",id); }; + var permissions = $('.permissions_table',dialog); + if (permissions.attr('update')){ + var perms = { + octet : buildOctet(permissions) + }; + Sunstone.runAction("Image.chmod",id,perms); + }; + Sunstone.runAction("Image.update",id,new_template); - dialog.dialog('close'); + $(this).parents('#image_template_update_dialog').dialog('close'); return false; }); -} +}; function popUpImageTemplateUpdateDialog(){ @@ -931,8 +929,10 @@ function popUpImageTemplateUpdateDialog(){ var dialog = $('#image_template_update_dialog'); $('#image_template_update_select',dialog).html(select); $('#image_template_update_textarea',dialog).val(""); - $('#image_template_update_public',dialog).removeAttr('checked') - $('#image_template_update_persistent',dialog).removeAttr('checked') + $('#image_template_update_persistent',dialog).removeAttr('checked'); + $('.permissions_table input',dialog).removeAttr('checked'); + $('.permissions_table',dialog).removeAttr('update'); + if (sel_elems.length >= 1){ //several items in the list are selected //grep them @@ -947,14 +947,12 @@ function popUpImageTemplateUpdateDialog(){ if (sel_elems.length == 1) { $('#image_template_update_select option',dialog).attr('selected','selected'); $('#image_template_update_select',dialog).trigger("change"); - } - + }; }; dialog.dialog('open'); return false; - -} +}; // Set the autorefresh interval for the datatable function setImageAutorefresh() { @@ -968,43 +966,19 @@ function setImageAutorefresh() { },INTERVAL+someTime()); }; -function is_public_image(id){ - var data = getElementData(id,"#image",dataTable_images)[7]; - return $(data).attr('checked'); -}; - function is_persistent_image(id){ var data = getElementData(id,"#image",dataTable_images)[8]; - return $(data).attr('checked'); + return $(data).is(':checked'); }; function setupImageActionCheckboxes(){ - $('input.action_cb#cb_public_image',dataTable_images).live("click",function(){ - var $this = $(this) - var id=$this.attr('elem_id'); - if ($this.attr('checked')){ - if (!is_persistent_image(id)) - Sunstone.runAction("Image.publish",id); - else { - notifyError(tr("Image cannot be public and persistent")); - return false; - }; - } else Sunstone.runAction("Image.unpublish",id); - - return true; - }); - $('input.action_cb#cb_persistent_image',dataTable_images).live("click",function(){ var $this = $(this) var id=$this.attr('elem_id'); - if ($this.attr('checked')){ - if (!is_public_image(id)) - Sunstone.runAction("Image.persistent",id); - else { - notifyError(tr("Image cannot be public and persistent")); - return false; - }; - } else Sunstone.runAction("Image.nonpersistent",id); + if ($this.attr('checked')) + Sunstone.runAction("Image.persistent",id); + else + Sunstone.runAction("Image.nonpersistent",id); return true; }); @@ -1029,21 +1003,21 @@ $(document).ready(function(){ "sPaginationType": "full_numbers", "aoColumnDefs": [ { "bSortable": false, "aTargets": ["check"] }, - { "sWidth": "60px", "aTargets": [0,2,3,8,9,10] }, - { "sWidth": "35px", "aTargets": [1,5,11] }, + { "sWidth": "60px", "aTargets": [0,2,3,8,9] }, + { "sWidth": "35px", "aTargets": [1,5,10] }, { "sWidth": "100px", "aTargets": [6] }, { "sWidth": "150px", "aTargets": [7] } ], "oLanguage": (datatable_lang != "") ? { - sUrl: "locale/"+lang+"/"+datatable_lang + sUrl: "locale/"+lang+"/"+datatable_lang } : "" }); dataTable_images.fnClearTable(); addElement([ spinner, - '','','','','','','','','','',''],dataTable_images); + '','','','','','','','','',''],dataTable_images); Sunstone.runAction("Image.list"); setupCreateImageDialog(); @@ -1055,6 +1029,4 @@ $(document).ready(function(){ initCheckAllBoxes(dataTable_images); tableCheckboxesListener(dataTable_images); imageInfoListener(); - - -}) +}); diff --git a/src/sunstone/public/js/plugins/vnets-tab.js b/src/sunstone/public/js/plugins/vnets-tab.js index a4c9cd4583..486535c640 100644 --- a/src/sunstone/public/js/plugins/vnets-tab.js +++ b/src/sunstone/public/js/plugins/vnets-tab.js @@ -915,7 +915,7 @@ function setupVNetTemplateUpdateDialog(){ var new_template = $('#vnet_template_update_textarea',dialog).val(); var id = $('#vnet_template_update_select',dialog).val(); if (!id || !id.length) { - $(this).parents('#vnet_template_update_dialog').dialog('close'); + $(this).parents('#vnet_template_update_dialog').dialog('close'); return false; };