diff --git a/src/sunstone/public/js/plugins/groups-tab.js b/src/sunstone/public/js/plugins/groups-tab.js index 5bf0a0f6b5..4fbe617a1b 100644 --- a/src/sunstone/public/js/plugins/groups-tab.js +++ b/src/sunstone/public/js/plugins/groups-tab.js @@ -395,68 +395,45 @@ Sunstone.addMainTab('groups-tab',groups_tab); Sunstone.addInfoPanel("group_info_panel",group_info_panel); function generateViewTable(views, dialog_name) { - var headers = ""; - var row = ""+tr("Users")+""; - var admin_row = ""+tr("Admins")+""; - var default_row = ""+tr("Users default")+""; - var default_admin_row = ""+tr("Admins default")+""; + var table_str = ''+ + ""+ + ""+ + ""+ + ""+ + ""; $.each(views, function(id, view){ - headers += "'; - - checked = view.id == 'groupadmin' ? "checked" : ""; - - admin_row += ''; - - default_row += '' - - default_admin_row += '' + ' ' + tr("View") + + (view.description ? + ''+view.description+'' + : "") + + ""+ + ''+ + ''; }); - headers += ""; - row += ""; - admin_row += ""; - default_row += ""; - default_admin_row += ""; + table_str += '
"+tr("Group Users")+""+tr("Group Admins")+"
" + + var default_user_checked = view.id == 'cloud' ? "checked" : ""; + var default_admin_checked = view.id == 'groupadmin' ? "checked" : ""; + + table_str += "
" + view.name + - ''+view.description+''+ - ""; - - var checked = view.id == 'cloud' ? "checked" : ""; - - row += '\ - \ - \ - \ - \ - \ - \ - \ - \ + \ + \ + \ +
'; - return ''+ - headers+ - row+ - default_row+ - admin_row+ - default_admin_row+ - "
"; + return table_str; } function insert_views(dialog_name){ var filtered_views = { - advanced : [], cloud : [], + advanced : [], vcenter : [], other : [] } @@ -495,29 +472,35 @@ function insert_views(dialog_name){ }) var str = ""; - $.each(filtered_views, function(view_type, views){ - // todo description - // - + + str += '
'+ + '
'+ + '
'+ + '
'+ + '
'+ + '

'; + + $.each(filtered_views, function(view_type, views){ if (views.length > 0) { str += '
'+ - '
'+ - '

'+view_types[view_type].name+'

'+ + '
'+ + '

'+view_types[view_type].name+ + (view_types[view_type].description ? + '' + view_types[view_type].description + '' + : "")+ + '

'+ + generateViewTable(views, dialog_name) + '
'+ - '
'+ - '

'+view_types[view_type].description+'

'+ - '
'+ - '
'+ + '
'+ (view_types[view_type].preview ? - '' : + '' : '') + '
'+ - '
'; - - str += generateViewTable(views, dialog_name); + '

'; } }) + return str; } @@ -854,6 +837,51 @@ function enableAdminUser(dialog){ $('#custom_auth',dialog).removeAttr("disabled"); }; + +function generateUserViewsSelect(dialog, value) { + var views = []; + var old_value = $("#user_view_default").val(); + + $(".user_view_input:checked", dialog).each(function(){ + views.push({ + value: this.value, + name: (views_info[this.value] ? views_info[this.value].name : this.value)}); + }); + + $(".user_view_default_container", dialog).html( + generateValueSelect({ + id: 'user_view_default', + label: tr("Default Users View"), + options: views, + custom: false + })) + + $("#user_view_default", dialog).val(value ? value : old_value).change(); +}; + +function generateAdminViewsSelect(dialog, value) { + var views = []; + var old_value = value || $("#admin_view_default").val(); + + $(".admin_view_input:checked", dialog).each(function(){ + views.push({ + value: this.value, + name: (views_info[this.value] ? views_info[this.value].name : this.value)}); + }); + + $(".admin_view_default_container", dialog).html( + generateValueSelect({ + id: 'admin_view_default', + label: tr("Default Admins View"), + options: views, + custom: false + })) + + if (old_value) { + $("#admin_view_default", dialog).val(old_value).change(); + } +}; + //Prepares the dialog to create function setupCreateGroupDialog(){ dialogs_context.append('
'); @@ -903,6 +931,18 @@ function setupCreateGroupDialog(){ $("#group_res_net", dialog).prop("checked", false); + generateAdminViewsSelect(dialog, "groupadmin"); + $(dialog).off("change", ".admin_view_input"); + $(dialog).on("change", ".admin_view_input", function(){ + generateAdminViewsSelect(dialog); + }) + + generateUserViewsSelect(dialog, "cloud") + $(dialog).off("change", ".user_view_input") + $(dialog).on("change", ".user_view_input", function(){ + generateUserViewsSelect(dialog) + }) + $('#create_group_form',dialog).submit(function(){ var name = $('#name',this).val(); @@ -947,7 +987,7 @@ function setupCreateGroupDialog(){ group_json['group']['views'].push($(this).val()); }); - var default_view = $('[id^="group_default_view"]:checked', dialog).val(); + var default_view = $('#user_view_default', dialog).val(); if (default_view != undefined){ group_json['group']['default_view'] = default_view; } @@ -958,7 +998,7 @@ function setupCreateGroupDialog(){ group_json['group']['admin_views'].push($(this).val()); }); - var default_view = $('[id^="group_default_admin_view"]:checked', dialog).val(); + var default_view = $('#admin_view_default', dialog).val(); if (default_view != undefined){ group_json['group']['default_admin_view'] = default_view; } @@ -1001,6 +1041,16 @@ function setupUpdateGroupDialog(){ $("a[href='#administrators']", dialog).parents("dd").hide(); $("a[href='#resource_creation']", dialog).parents("dd").hide(); + $(dialog).off("change", ".admin_view_input") + $(dialog).on("change", ".admin_view_input", function(){ + generateAdminViewsSelect(dialog); + }) + + $(dialog).off("change", ".user_view_input") + $(dialog).on("change", ".user_view_input", function(){ + generateUserViewsSelect(dialog) + }) + $update_group_dialog.foundation(); } @@ -1039,15 +1089,16 @@ function popUpUpdateGroupDialog(group, dialog) var views = views_str.split(","); $.each(views, function(){ $('input[id^="group_view"][value="'+this.trim()+'"]', - dialog).attr('checked','checked'); + dialog).attr('checked','checked').change(); }); } $('input[id^="group_default_view"]', dialog).removeAttr('checked'); if (group.TEMPLATE.DEFAULT_VIEW){ - $('input[id^="group_default_view"][value="'+group.TEMPLATE.DEFAULT_VIEW.trim()+'"]', - dialog).attr('checked','checked'); + $('#user_view_default', dialog).val(group.TEMPLATE.DEFAULT_VIEW.trim()).change(); + } else { + $('#user_view_default', dialog).val("").change(); } $('input[id^="group_admin_view"]', dialog).removeAttr('checked'); @@ -1058,15 +1109,16 @@ function popUpUpdateGroupDialog(group, dialog) var views = views_str.split(","); $.each(views, function(){ $('input[id^="group_admin_view"][value="'+this.trim()+'"]', - dialog).attr('checked','checked'); + dialog).attr('checked','checked').change(); }); } $('input[id^="group_default_admin_view"]', dialog).removeAttr('checked'); if (group.TEMPLATE.GROUP_ADMIN_DEFAULT_VIEW){ - $('input[id^="group_default_admin_view"][value="'+group.TEMPLATE.GROUP_ADMIN_DEFAULT_VIEW.trim()+'"]', - dialog).attr('checked','checked'); + $('#admin_view_default', dialog).val(group.TEMPLATE.GROUP_ADMIN_DEFAULT_VIEW.trim()).change(); + } else { + $('#admin_view_default', dialog).val("").change(); } $(dialog).off("click", 'button#update_group_submit'); @@ -1091,7 +1143,7 @@ function popUpUpdateGroupDialog(group, dialog) template_json["SUNSTONE_VIEWS"] = views.join(","); } - var default_view = $('[id^="group_default_view"]:checked', dialog).val(); + var default_view = $('#user_view_default', dialog).val(); if (default_view != undefined){ template_json["DEFAULT_VIEW"] = default_view; @@ -1107,7 +1159,7 @@ function popUpUpdateGroupDialog(group, dialog) template_json["GROUP_ADMIN_VIEWS"] = admin_views.join(","); } - var default_admin_view = $('[id^="group_default_admin_view"]:checked', dialog).val(); + var default_admin_view = $('#admin_view_default', dialog).val(); if (default_admin_view != undefined){ template_json["GROUP_ADMIN_DEFAULT_VIEW"] = default_admin_view; diff --git a/src/sunstone/public/js/sunstone.js b/src/sunstone/public/js/sunstone.js index 90b57dd193..62ae4a0847 100644 --- a/src/sunstone/public/js/sunstone.js +++ b/src/sunstone/public/js/sunstone.js @@ -8413,22 +8413,22 @@ function enableSPICE(vm){ var view_types = { advanced : { - name: 'Advanced', + name: 'Advanced Layout', description : tr("This layout exposes a complete view of the cloud, allowing administrators and advanced users to have full control of any physical or virtual resource of the cloud."), preview: "advanced_layout.png" }, cloud : { - name: 'Cloud', + name: 'Cloud Layout', description : tr("This layout exposes a simplified version of the cloud where group administrators and cloud end-users will be able to manage any virtual resource of the cloud, without taking care of the physical resources management."), preview: "cloud_layout.png" }, vcenter : { - name: 'vCenter', + name: 'vCenter Layout', description : tr("Set of views to present the valid operation against a vCenter infrastructure"), - preview: null + preview: "vcenter_layout.png" }, other : { - name: 'Other', + name: 'Other Layouts', description : '', preview: null }