diff --git a/src/sunstone/public/js/plugins/acls-tab.js b/src/sunstone/public/js/plugins/acls-tab.js index 1ac86d68f4..a87447e2fc 100644 --- a/src/sunstone/public/js/plugins/acls-tab.js +++ b/src/sunstone/public/js/plugins/acls-tab.js @@ -27,15 +27,40 @@ var create_acl_tmpl =
\
\
\ -
\ - \ - \ -
\
\ \ - \ +
\ +
\
\
\ +
\ + '+tr("This rule applies to")+'\ +
\ +
\ + \ +
\ +
\ + \ +
\ +
\ + \ +
\ +
\ +
\ +
\ +
\ + \ +
\ +
\ +
\ +
\ + \ +
\ +
\ +
\ +
\ +
\ +
\
\ '+tr("Affected resources")+'\
\ @@ -104,7 +129,8 @@ var create_acl_tmpl =
\
\ \ - \ +
\ +
\
\
\ \ @@ -449,6 +475,10 @@ function setupCreateAclDialog(){ dialog.addClass("reveal-modal large max-height").attr("data-reveal", ""); //Default selected options + $('#applies_all',dialog).attr('checked','checked'); + $('.applies_to_user',dialog).hide(); + $('.applies_to_group',dialog).hide(); + $('#res_subgroup_all',dialog).attr('checked','checked'); $('.res_id',dialog).hide(); $('.belonging_to',dialog).hide(); @@ -456,6 +486,25 @@ function setupCreateAclDialog(){ //$('button',dialog).button(); + //Applies to subset radio buttons + $('.applies',dialog).click(function(){ + var value = $(this).val(); + switch (value) { + case "*": + $('.applies_to_user',dialog).hide(); + $('.applies_to_group',dialog).hide(); + break; + case "applies_to_user": + $('.applies_to_user',dialog).show(); + $('.applies_to_group',dialog).hide(); + break; + case "applies_to_group": + $('.applies_to_user',dialog).hide(); + $('.applies_to_group',dialog).show(); + break; + }; + }); + //Resource subset radio buttons $('.res_subgroup',dialog).click(function(){ var value = $(this).val(); @@ -492,13 +541,20 @@ function setupCreateAclDialog(){ $(dialog).off('change', 'input,select'); $(dialog).on('change', 'input,select', function(){ var context = $('#create_acl_form',$create_acl_dialog); - var user = $('#applies',context).val(); - if ($('#applies :selected',context).hasClass("user")){ - user='#'+user; - } else if ($('#applies :selected',context).hasClass("group")){ - user = '@'+user; - }; + var user=""; + var mode = $('.applies:checked',context).val(); + switch (mode) { + case "*": + user="*"; + break; + case "applies_to_user": + user="#"+$('div#applies_to_user .resource_list_select',context).val(); + break; + case "applies_to_group": + user="@"+$('div#applies_to_group .resource_list_select',context).val(); + break; + } var resources = ""; $('.resource_cb:checked',context).each(function(){ @@ -516,7 +572,7 @@ function setupCreateAclDialog(){ belonging="#"+$('#res_id',context).val(); break; case "belonging_to": - belonging="@"+$('#belonging_to',context).val(); + belonging="@"+$('div#belonging_to .resource_list_select',context).val(); break; case "in_cluster": belonging="%"+$('#in_cluster .resource_list_select',context).val(); @@ -530,9 +586,9 @@ function setupCreateAclDialog(){ }); if (rights.length) { rights = rights.substring(0,rights.length-1) }; - var zone = $('#zones_applies',context).val(); + var zone = $('#zones_applies .resource_list_select',context).val(); - if ($('#zones_applies :selected',context).hasClass("zone")){ + if (zone != "*"){ zone = '#'+zone; } @@ -543,11 +599,23 @@ function setupCreateAclDialog(){ }); $('#create_acl_form',dialog).submit(function(){ - var user = $('#applies',this).val(); - if (!user.length) { - notifyError(tr("Please specify to who this ACL applies")); - return false; - }; + var mode = $('.applies:checked',this).val(); + switch (mode) { + case "applies_to_user": + var l=$('#applies_to_user .resource_list_select',this).val().length; + if (!l){ + notifyError("Please select a user to whom the acl applies"); + return false; + } + break; + case "applies_to_group": + var l=$('#applies_to_group .resource_list_select',this).val().length; + if (!l){ + notifyError("Please select a group to whom the acl applies"); + return false; + } + break; + } var resources = $('.resource_cb:checked',this).length; if (!resources) { @@ -565,7 +633,7 @@ function setupCreateAclDialog(){ } break; case "belonging_to": - var l=$('#belonging_to',this).val().length; + var l=$('#belonging_to .resource_list_select',this).val().length; if (!l){ notifyError("Please select a group to which the selected resources belong to"); return false; @@ -598,34 +666,16 @@ function setupCreateAclDialog(){ // required: we have to put the right options in the // selects. function popUpCreateAclDialog(){ - var users = $(''); - $('.empty_value',users).remove(); - $('option',users).addClass("user"); - users.prepend(''); - - var groups = $(''); - $('.empty_value',groups).remove(); - $('option',groups).addClass("group"); - groups.prepend(''); - var dialog = $create_acl_dialog; - $('#applies',dialog).html(''+ - users.html()+groups.html()); - $('#belonging_to',dialog).html(groups_select); - insertSelectClusters('#in_cluster',dialog, null, true); + insertSelectOptions('div#applies_to_user', dialog, "User", null, true); + insertSelectOptions('div#applies_to_group', dialog, "Group", null, true); - $('#applies',dialog).trigger("change"); - - var zones = $(''); - $('.empty_value',zones).remove(); - $('option',zones).addClass("zone"); - - $('#zones_applies',dialog).html(''+ - zones.html()); - - $('#zones_applies',dialog).trigger("change"); + insertSelectOptions('div#belonging_to', dialog, "Group", null, true); + insertSelectOptions('#in_cluster',dialog, "Cluster", null, true); + insertSelectOptions('div#zones_applies', dialog, "Zone", "*", false, + ''); dialog.foundation().foundation('reveal', 'open'); } diff --git a/src/sunstone/public/js/plugins/datastores-tab.js b/src/sunstone/public/js/plugins/datastores-tab.js index 97742d91da..25759e684c 100644 --- a/src/sunstone/public/js/plugins/datastores-tab.js +++ b/src/sunstone/public/js/plugins/datastores-tab.js @@ -251,7 +251,6 @@ var datastore_image_table_tmpl='\ \ ' -var datastores_select=""; var dataTable_datastores; var $create_datastore_dialog; @@ -470,7 +469,7 @@ var datastore_buttons = { "Datastore.addtocluster" : { type: "confirm_with_select", text: tr("Select cluster"), - select: insertSelectClusters, + select: "Cluster", layout: "more_select", tip: tr("Select the destination cluster:"), condition: mustBeAdmin @@ -478,7 +477,7 @@ var datastore_buttons = { "Datastore.chown" : { type: "confirm_with_select", text: tr("Change owner"), - select: users_sel, + select: "User", layout: "user_select", tip: tr("Select the new owner")+":", condition: mustBeAdmin @@ -486,7 +485,7 @@ var datastore_buttons = { "Datastore.chgrp" : { type: "confirm_with_select", text: tr("Change group"), - select: groups_sel, + select: "Group", layout: "user_select", tip: tr("Select the new group")+":", condition: mustBeAdmin @@ -594,33 +593,20 @@ function datastoreElementArray(element_json){ ]; } -function updateDatastoreSelect(){ - datastores_select = makeSelectOptions(dataTable_datastores, - 1, - 4, - [9],//system ds - ['system'], //filter out sys datastores - true - ); -}; - function updateDatastoreElement(request, element_json){ var id = element_json.DATASTORE.ID; var element = datastoreElementArray(element_json); updateSingleElement(element,dataTable_datastores,'#datastore_'+id) - updateDatastoreSelect(); } function deleteDatastoreElement(request){ deleteElement(dataTable_datastores,'#datastore_'+request.request.data); - updateDatastoreSelect(); } function addDatastoreElement(request,element_json){ var id = element_json.DATASTORE.ID; var element = datastoreElementArray(element_json); addElement(element,dataTable_datastores); - updateDatastoreSelect(); } @@ -632,7 +618,6 @@ function updateDatastoresView(request, list){ }); updateView(list_array,dataTable_datastores); - updateDatastoreSelect(); } @@ -1108,8 +1093,8 @@ function popUpCreateDatastoreDialog(){ if (!cluster_id_raw) cluster_id_raw = "-1"; - insertSelectClusters('div#cluster_id', $create_datastore_dialog, cluster_id, false); - insertSelectClusters('div#datastore_cluster_raw', $create_datastore_dialog, cluster_id_raw, false); + insertSelectOptions('div#cluster_id', $create_datastore_dialog, "Cluster", cluster_id, false); + insertSelectOptions('div#datastore_cluster_raw', $create_datastore_dialog, "Cluster", cluster_id_raw, false); $create_datastore_dialog.foundation().foundation('reveal', 'open'); $("input#name",$create_datastore_dialog).focus(); } diff --git a/src/sunstone/public/js/plugins/files-tab.js b/src/sunstone/public/js/plugins/files-tab.js index 1963ced99a..fec770b922 100644 --- a/src/sunstone/public/js/plugins/files-tab.js +++ b/src/sunstone/public/js/plugins/files-tab.js @@ -69,8 +69,8 @@ var create_file_tmpl ='
\ \ - \ +
\ +
\
\
\
\ @@ -109,7 +109,8 @@ var create_file_tmpl ='
\
\
\ \ - \ +
\ +
\
\
\
\ @@ -311,7 +312,7 @@ var file_buttons = { type: "confirm_with_select", text: tr("Change owner"), layout: "user_select", - select: users_sel, + select: "User", tip: tr("Select the new owner")+":", condition: mustBeAdmin }, @@ -319,7 +320,7 @@ var file_buttons = { type: "confirm_with_select", text: tr("Change group"), layout: "user_select", - select: groups_sel, + select: "Group", tip: tr("Select the new group")+":", condition: mustBeAdmin }, @@ -698,7 +699,7 @@ function setupCreateFileDialog(){ $('#create_file_submit',dialog).click(function(){ var upload = false; - var ds_id = $('#file_datastore',dialog).val(); + var ds_id = $('#file_datastore .resource_list_select',dialog).val(); if (!ds_id){ notifyError(tr("Please select a datastore for this file")); return false; @@ -748,7 +749,7 @@ function setupCreateFileDialog(){ $('#create_file_submit_manual',dialog).click(function(){ var template=$('#template',dialog).val(); - var ds_id = $('#file_datastore_raw',dialog).val(); + var ds_id = $('#file_datastore_raw .resource_list_select',dialog).val(); if (!ds_id){ notifyError(tr("Please select a datastore for this file")); @@ -787,16 +788,21 @@ function popUpCreateFileDialog(){ $('#files_file-uploader input',$create_file_dialog).removeAttr("style"); $('#files_file-uploader input',$create_file_dialog).attr('style','margin:0;width:256px!important'); - datastores_str = makeSelectOptions(dataTable_datastores, - 1, - 4, - [10,10],//system ds - ['image','system'], //filter image & sys datastores - true - ); + var ds_id = $("div#file_datastore .resource_list_select", + $create_file_dialog).val(); - $('#file_datastore',$create_file_dialog).html(datastores_str); - $('#file_datastore_raw',$create_file_dialog).html(datastores_str); + var ds_id_raw = $("div#file_datastore_raw .resource_list_select", + $create_file_dialog).val(); + + // Filter out DS with type image (0) or system (1) + var filter_att = ["TYPE", "TYPE"]; + var filter_val = ["0", "1"]; + + insertSelectOptions('div#file_datastore', $create_file_dialog, "Datastore", + ds_id, false, null, filter_att, filter_val); + + insertSelectOptions('div#file_datastore_raw', $create_file_dialog, "Datastore", + ds_id_raw, false, null, filter_att, filter_val); $create_file_dialog.foundation().foundation('reveal', 'open'); $("input#file_name",$create_file_dialog).focus(); diff --git a/src/sunstone/public/js/plugins/groups-tab.js b/src/sunstone/public/js/plugins/groups-tab.js index 2a3676ec78..9bc1785a76 100644 --- a/src/sunstone/public/js/plugins/groups-tab.js +++ b/src/sunstone/public/js/plugins/groups-tab.js @@ -14,7 +14,6 @@ /* limitations under the License. */ /* -------------------------------------------------------------------------- */ -var groups_select=""; var dataTable_groups; var $create_group_dialog; var $group_quotas_dialog; @@ -496,15 +495,6 @@ function groupElementArray(group_json){ ]; } -function updateGroupSelect(){ - groups_select = makeSelectOptions(dataTable_groups, - 1,//id_col - 2,//name_col - [],//status_cols - []//bad_status_cols - ); -} - function updateGroupElement(request, group_json){ var id = group_json.GROUP.ID; var element = groupElementArray(group_json); @@ -514,14 +504,12 @@ function updateGroupElement(request, group_json){ function deleteGroupElement(request){ deleteElement(dataTable_groups,'#group_'+request.request.data); - updateGroupSelect(); } function addGroupElement(request,group_json){ var id = group_json.GROUP.ID; var element = groupElementArray(group_json); addElement(element,dataTable_groups); - updateGroupSelect(); } //updates the list @@ -542,7 +530,6 @@ function updateGroupsView(request, group_list, quotas_hash){ group_list_array.push(groupElementArray(this)); }); updateView(group_list_array,dataTable_groups); - updateGroupSelect(group_list); // Dashboard info $(".total_groups").text(group_list.length); diff --git a/src/sunstone/public/js/plugins/hosts-tab.js b/src/sunstone/public/js/plugins/hosts-tab.js index 203c9680ce..b2ea5da17f 100644 --- a/src/sunstone/public/js/plugins/hosts-tab.js +++ b/src/sunstone/public/js/plugins/hosts-tab.js @@ -109,7 +109,6 @@ var create_host_tmpl =
\ ×'; -var hosts_select=""; var dataTable_hosts; var $create_host_dialog; @@ -298,7 +297,7 @@ var host_buttons = { "Host.addtocluster" : { type: "confirm_with_select", text: tr("Select cluster"), - select: insertSelectClusters, + select: "Cluster", tip: tr("Select the destination cluster:"), layout: "more_select", condition: mustBeAdmin @@ -487,28 +486,16 @@ function hostElementArray(host_json){ ]; } -//updates the host select by refreshing the options in it -function updateHostSelect(){ - hosts_select = makeSelectOptions(dataTable_hosts, - 1,//id_col - 2,//name_col - [7,7],//status_cols - [tr("ERROR"),tr("OFF"),tr("RETRY")]//bad_st - ); -} - //callback for an action affecting a host element function updateHostElement(request, host_json){ var id = host_json.HOST.ID; var element = hostElementArray(host_json); updateSingleElement(element,dataTable_hosts,'#host_'+id); - updateHostSelect(); } //callback for actions deleting a host element function deleteHostElement(req){ deleteElement(dataTable_hosts,'#host_'+req.request.data); - updateHostSelect(); } //call back for actions creating a host element @@ -516,7 +503,6 @@ function addHostElement(request,host_json){ var id = host_json.HOST.ID; var element = hostElementArray(host_json); addElement(element,dataTable_hosts); - updateHostSelect(); } //callback to update the list of hosts. @@ -593,7 +579,6 @@ function updateHostsView (request,host_list){ } updateView(host_list_array,dataTable_hosts); - updateHostSelect(); $(".total_hosts").text(host_list.length); $(".on_hosts").text(on_hosts); @@ -956,7 +941,7 @@ function popUpCreateHostDialog(){ var cluster_id = $('#host_cluster_id .resource_list_select',$('div#create_host_dialog')).val(); if (!cluster_id) cluster_id = "-1"; - insertSelectClusters('#host_cluster_id',$('div#create_host_dialog'), cluster_id, false); + insertSelectOptions('#host_cluster_id',$('div#create_host_dialog'), "Cluster", cluster_id, false); $('div#create_host_dialog').foundation('reveal', 'open'); $("input#name",$('div#create_host_dialog')).focus(); diff --git a/src/sunstone/public/js/plugins/images-tab.js b/src/sunstone/public/js/plugins/images-tab.js index d50fe2a233..c2fff57c2b 100644 --- a/src/sunstone/public/js/plugins/images-tab.js +++ b/src/sunstone/public/js/plugins/images-tab.js @@ -74,8 +74,8 @@ var create_image_tmpl ='
\ \ - \ +
\ +
\
\
\
\ @@ -215,7 +215,8 @@ var create_image_tmpl ='
\
\
\ \ - \ +
\ +
\
\
\
\ @@ -452,7 +453,7 @@ var image_buttons = { type: "confirm_with_select", text: tr("Change owner"), layout: "user_select", - select: users_sel, + select: "User", tip: tr("Select the new owner")+":", condition: mustBeAdmin }, @@ -460,7 +461,7 @@ var image_buttons = { type: "confirm_with_select", text: tr("Change group"), layout: "user_select", - select: groups_sel, + select: "Group", tip: tr("Select the new group")+":", condition: mustBeAdmin }, @@ -985,38 +986,6 @@ function initialize_create_image_dialog(dialog) { file_input = input; return false; }; - $('#img_type').change(function(){ - enable_all_datastores(); - var choice_str = $(this).val(); - switch(choice_str) - { - case 'OS': - case 'CDROM': - case 'DATABLOCK': - $('select#img_datastore').children('option').each(function() { - $(this).removeAttr('disabled'); - if ($(this).val() == "2") - { - $(this).attr('disabled', 'disabled'); - } - }); - $('select#img_datastore').val("1"); - break; - case 'KERNEL': - case 'RAMDISK': - case 'CONTEXT': - $('select#img_datastore').children('option').each(function() { - $(this).attr('disabled', 'disabled'); - if ($(this).val() == "2") - { - $(this).removeAttr('disabled'); - } - }); - $('select#img_datastore').val("2"); - break; - } - }); - $('#create_image_submit',dialog).click(function(){ var exit = false; var upload = false; @@ -1029,7 +998,7 @@ function initialize_create_image_dialog(dialog) { }); if (exit) { return false; } - var ds_id = $('#img_datastore',dialog).val(); + var ds_id = $('#img_datastore .resource_list_select',dialog).val(); if (!ds_id){ notifyError(tr("Please select a datastore for this image")); return false; @@ -1108,7 +1077,7 @@ function initialize_create_image_dialog(dialog) { $('#create_image_submit_manual',dialog).click(function(){ var template=$('#template',dialog).val(); - var ds_id = $('#img_datastore_raw',dialog).val(); + var ds_id = $('#img_datastore_raw .resource_list_select',dialog).val(); if (!ds_id){ notifyError(tr("Please select a datastore for this image")); @@ -1143,31 +1112,18 @@ function initialize_create_image_dialog(dialog) { } function initialize_datastore_info_create_image_dialog(dialog) { - datastores_str = makeSelectOptions(dataTable_datastores, - 1, - 4, - [10,10],//system ds - ['file','system'], //filter image & sys datastores - true - ); + var ds_id = $('#img_datastore .resource_list_select',dialog).val(); + var ds_id_raw = $('#img_datastore_raw .resource_list_select',dialog).val(); - var selected_datastore = $('#img_datastore',dialog).val(); - var selected_datastore_raw = $('#img_datastore_raw',dialog).val(); + // Filter out DS with type system (1) or file (2) + var filter_att = ["TYPE", "TYPE"]; + var filter_val = ["1", "2"]; - $('#img_datastore',dialog).html(datastores_str); - $('#img_datastore_raw',dialog).html(datastores_str); + insertSelectOptions('div#img_datastore', dialog, "Datastore", + ds_id, false, null, filter_att, filter_val); - if (selected_datastore) - $('#img_datastore',dialog).val(selected_datastore) - - if (selected_datastore_raw) - $('#img_datastore_raw',dialog).val(selected_datastore_raw) - - $('select#img_datastore', dialog).children('option').each(function() { - if ($(this).val() == "2") { - $(this).attr('disabled', 'disabled'); - } - }); + insertSelectOptions('div#img_datastore_raw', dialog, "Datastore", + ds_id_raw, false, null, filter_att, filter_val); $('#file-uploader input',dialog).removeAttr("style"); $('#file-uploader input',dialog).attr('style','margin:0;width:256px!important'); diff --git a/src/sunstone/public/js/plugins/oneflow-services.js b/src/sunstone/public/js/plugins/oneflow-services.js index 569e19da75..ed458c7bb0 100644 --- a/src/sunstone/public/js/plugins/oneflow-services.js +++ b/src/sunstone/public/js/plugins/oneflow-services.js @@ -1007,14 +1007,14 @@ var service_buttons = { "Service.chown" : { type: "confirm_with_select", text: tr("Change owner"), - select: users_sel, + select: "User", tip: tr("Select the new owner")+":", layout: "user_select" }, "Service.chgrp" : { type: "confirm_with_select", text: tr("Change group"), - select: groups_sel, + select: "Group", tip: tr("Select the new group")+":", layout: "user_select" }, diff --git a/src/sunstone/public/js/plugins/oneflow-templates.js b/src/sunstone/public/js/plugins/oneflow-templates.js index 1dc75e4dba..8057109662 100644 --- a/src/sunstone/public/js/plugins/oneflow-templates.js +++ b/src/sunstone/public/js/plugins/oneflow-templates.js @@ -93,7 +93,7 @@ var create_service_template_tmpl = '\ \
\
\ -
\
\
\ @@ -149,7 +149,7 @@ var role_tab_content = '\ \
\
\ -