diff --git a/src/sunstone/models/OpenNebulaJSON/TemplateJSON.rb b/src/sunstone/models/OpenNebulaJSON/TemplateJSON.rb
index d72041f8a4..0390070add 100644
--- a/src/sunstone/models/OpenNebulaJSON/TemplateJSON.rb
+++ b/src/sunstone/models/OpenNebulaJSON/TemplateJSON.rb
@@ -46,7 +46,7 @@ module OpenNebulaJSON
when "unpublish" then self.unpublish
when "update" then self.update(action_hash['params'])
when "chown" then self.chown(action_hash['params'])
- when "chmod" then self.chmod_octet(action_hash['octet'])
+ when "chmod" then self.chmod_octet(action_hash['params'])
when "instantiate" then self.instantiate(action_hash['params'])
else
error_msg = "#{action_hash['perform']} action not " <<
diff --git a/src/sunstone/public/js/plugins/images-tab.js b/src/sunstone/public/js/plugins/images-tab.js
index 0b61c2a779..cf1e96d6f2 100644
--- a/src/sunstone/public/js/plugins/images-tab.js
+++ b/src/sunstone/public/js/plugins/images-tab.js
@@ -297,9 +297,7 @@ var image_actions = {
"Image.update_dialog" : {
type: "custom",
- call: function() {
- popUpImageTemplateUpdateDialog();
- }
+ call: popUpImageTemplateUpdateDialog,
},
"Image.update" : {
@@ -387,7 +385,7 @@ var image_actions = {
},
"Image.chmod" : {
- type: "multiple",
+ type: "single",
call: OpenNebula.Image.chmod,
// callback
error: onError,
diff --git a/src/sunstone/public/js/plugins/templates-tab.js b/src/sunstone/public/js/plugins/templates-tab.js
index f1d8f97d9c..40b47230cd 100644
--- a/src/sunstone/public/js/plugins/templates-tab.js
+++ b/src/sunstone/public/js/plugins/templates-tab.js
@@ -29,7 +29,6 @@ var templates_tab_content =
\
@@ -592,8 +591,31 @@ var update_template_tmpl =
\
\
\
-
\
-
\
+
\
\
\
\
@@ -664,9 +686,7 @@ var template_actions = {
"Template.update_dialog" : {
type: "custom",
- call: function() {
- popUpTemplateTemplateUpdateDialog();
- }
+ call: popUpTemplateTemplateUpdateDialog
},
"Template.update" : {
@@ -687,32 +707,25 @@ var template_actions = {
error: onError
},
- "Template.publish" : {
+ "Template.fetch_permissions" : {
+ type: "single",
+ call: OpenNebula.Template.show,
+ callback: function(request,template_json){
+ var dialog = $('#template_template_update_dialog form');
+ var template = template_json.VMTEMPLATE;
+ setPermissionsTable(template,dialog);
+ },
+ error: onError
+ },
+
+ "Template.delete" : {
type: "multiple",
- call: OpenNebula.Template.publish,
- callback: templateShow,
+ call: OpenNebula.Template.delete,
+ callback: deleteTemplateElement,
elements: templateElements,
error: onError,
notify: true
- },
-
- "Template.unpublish" : {
- type: "multiple",
- call: OpenNebula.Template.unpublish,
- callback: templateShow,
- elements: templateElements,
- error: onError,
- notify: true
- },
-
- "Template.delete" : {
- type: "multiple",
- call: OpenNebula.Template.delete,
- callback: deleteTemplateElement,
- elements: templateElements,
- error: onError,
- notify: true
- },
+ },
"Template.instantiate" : {
type: "single",
@@ -746,7 +759,13 @@ var template_actions = {
elements: templateElements,
error:onError,
notify: true
- }
+ },
+ "Template.chmod" : {
+ type: "single",
+ call: OpenNebula.Template.chmod,
+ error: onError,
+ notify: true
+ },
}
var template_buttons = {
@@ -761,7 +780,7 @@ var template_buttons = {
},
"Template.update_dialog" : {
type: "action",
- text: tr("Update a template"),
+ text: tr("Update properties"),
alwaysActive: true
},
"Template.instantiate_vms" : {
@@ -838,10 +857,8 @@ function templateElementArray(template_json){
template.UNAME,
template.GNAME,
template.NAME,
- pretty_time(template.REGTIME),
- parseInt(template.PUBLIC) ? ''
- : ''
- ];
+ pretty_time(template.REGTIME)
+ ];
}
// Set up the listener on the table TDs to show the info panel
@@ -936,10 +953,19 @@ function updateTemplateInfo(request,template){
'+tr("Register time")+' | \
'+pretty_time(template_info.REGTIME)+' | \
\
- \
- '+tr("Public")+' | \
- '+(parseInt(template_info.PUBLIC) ? tr("yes") : tr("no"))+' | \
-
\
+ | |
\
+ \
+ '+tr("Owner permissions")+' | \
+ '+ownerPermStr(template_info)+' | \
+
\
+ \
+ '+tr("Group permissions")+' | \
+ '+groupPermStr(template_info)+' | \
+
\
+ \
+ '+tr("Other permissions")+' | \
+ '+otherPermStr(template_info)+' | \
+
\
'
};
var template_tab = {
@@ -2002,18 +2028,20 @@ function popUpCreateTemplateDialog(){
function setupTemplateTemplateUpdateDialog(){
//Append to DOM
- dialogs_context.append('');
+ dialogs_context.append('');
var dialog = $('#template_template_update_dialog',dialogs_context);
//Put HTML in place
dialog.html(update_template_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,
});
@@ -2021,43 +2049,42 @@ function setupTemplateTemplateUpdateDialog(){
$('#template_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 = $('#template_template_update_dialog');
$('#template_template_update_textarea',dialog).val(tr("Loading")+"...");
- var templ_public = is_public_template(id);
-
- if (templ_public){
- $('#template_template_update_public',dialog).attr('checked','checked')
- } else {
- $('#template_template_update_public',dialog).removeAttr('checked')
- }
-
+ Sunstone.runAction("Template.fetch_permissions",id);
Sunstone.runAction("Template.fetch_template",id);
} else {
$('#template_template_update_textarea',dialog).val("");
};
});
- $('#template_template_update_button',dialog).click(function(){
- var dialog = $('#template_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 = $('#template_template_update_textarea',dialog).val();
var id = $('#template_template_update_select',dialog).val();
if (!id || !id.length) {
- dialog.dialog('close');
+ $(this).parents('#template_template_update_dialog').dialog('close');
return false;
};
- var old_public = is_public_template(id);
-
- var new_public = $('#template_template_update_public:checked',dialog).length;
-
- if (old_public != new_public){
- if (new_public) Sunstone.runAction("Template.publish",id);
- else Sunstone.runAction("Template.unpublish",id);
+ var permissions = $('.permissions_table',dialog);
+ if (permissions.attr('update')){
+ var perms = {
+ octet : buildOctet(permissions)
+ };
+ Sunstone.runAction("Template.chmod",id,perms);
};
Sunstone.runAction("Template.update",id,new_template);
+ $(this).parents('#template_template_update_dialog').dialog('close');
dialog.dialog('close');
return false;
});
@@ -2076,7 +2103,8 @@ function popUpTemplateTemplateUpdateDialog(){
var dialog = $('#template_template_update_dialog');
$('#template_template_update_select',dialog).html(select);
$('#template_template_update_textarea',dialog).val("");
- $('#template_template_update_public',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
@@ -2092,7 +2120,6 @@ function popUpTemplateTemplateUpdateDialog(){
$('#template_template_update_select option',dialog).attr('selected','selected');
$('#template_template_update_select',dialog).trigger("change");
};
-
};
dialog.dialog('open');
@@ -2110,25 +2137,8 @@ function setTemplateAutorefresh() {
Sunstone.runAction("Template.autorefresh");
}
},INTERVAL+someTime());
-}
-
-function is_public_template(id){
- var data = getElementData(id,"#template",dataTable_templates)[6];
- return $(data).attr('checked');
};
-function setupTemplateActionCheckboxes(){
- $('input.action_cb#cb_public_template',dataTable_templates).live("click",function(){
- var $this = $(this)
- var id=$this.attr('elem_id');
- if ($this.attr('checked'))
- Sunstone.runAction("Template.publish",id);
- else Sunstone.runAction("Template.unpublish",id);
-
- return true;
- });
-}
-
//The DOM is ready at this point
$(document).ready(function(){
@@ -2139,29 +2149,28 @@ $(document).ready(function(){
"sPaginationType": "full_numbers",
"aoColumnDefs": [
{ "bSortable": false, "aTargets": ["check"] },
- { "sWidth": "60px", "aTargets": [0,6] },
+ { "sWidth": "60px", "aTargets": [0] },
{ "sWidth": "35px", "aTargets": [1] },
{ "sWidth": "150px", "aTargets": [5] },
{ "sWidth": "100px", "aTargets": [2,3] }
],
- "oLanguage": (datatable_lang != "") ?
- {
- sUrl: "locale/"+lang+"/"+datatable_lang
- } : ""
+ "oLanguage": (datatable_lang != "") ?
+ {
+ sUrl: "locale/"+lang+"/"+datatable_lang
+ } : ""
});
dataTable_templates.fnClearTable();
addElement([
spinner,
- '','','','','',''],dataTable_templates);
+ '','','','',''],dataTable_templates);
Sunstone.runAction("Template.list");
setupCreateTemplateDialog();
setupTemplateTemplateUpdateDialog();
- setupTemplateActionCheckboxes();
setTemplateAutorefresh();
initCheckAllBoxes(dataTable_templates);
tableCheckboxesListener(dataTable_templates);
templateInfoListener();
-})
+});
diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js
index d67617974f..609f7ac91b 100644
--- a/src/sunstone/public/js/plugins/vms-tab.js
+++ b/src/sunstone/public/js/plugins/vms-tab.js
@@ -443,7 +443,7 @@ var vm_actions = {
error: onError,
notify: true
},
-}
+};
diff --git a/src/sunstone/public/js/plugins/vnets-tab.js b/src/sunstone/public/js/plugins/vnets-tab.js
index 486535c640..c206a0aae1 100644
--- a/src/sunstone/public/js/plugins/vnets-tab.js
+++ b/src/sunstone/public/js/plugins/vnets-tab.js
@@ -322,7 +322,7 @@ var vnet_actions = {
},
"Network.chmod" : {
- type: "multiple",
+ type: "single",
call: OpenNebula.Network.chmod,
// callback
error: onError,