diff --git a/src/sunstone/public/app/tabs/settings-tab/panels/user-config.js b/src/sunstone/public/app/tabs/settings-tab/panels/user-config.js index 110771060a..e478163dd8 100644 --- a/src/sunstone/public/app/tabs/settings-tab/panels/user-config.js +++ b/src/sunstone/public/app/tabs/settings-tab/panels/user-config.js @@ -71,6 +71,7 @@ define(function(require) { } function _setup(context) { + var that = this; $(document).foundation('accordion', 'reflow'); var ssh_key = this.element.TEMPLATE.SSH_PUBLIC_KEY; if (ssh_key && ssh_key.length) { @@ -126,18 +127,26 @@ define(function(require) { }); $("#provision_change_view_form").submit(function() { - var template_str = 'DEFAULT_VIEW = "'+$('#provision_user_views_select', this).val()+'"'; - - Sunstone.runAction("User.append_template_refresh", "-1", template_str); + var sunstone_template = {}; + if (that.element.TEMPLATE.SUNSTONE) { + $.extend(sunstone_template, that.element.TEMPLATE.SUNSTONE); + } + sunstone_template.DEFAULT_VIEW = $('#provision_user_views_select', this).val(); + var template_str = TemplateUtils.templateToString({'SUNSTONE': sunstone_template}); + Sunstone.runAction("User.append_template_refresh", that.element.ID, template_str); return false; }); $("#provision_change_language_form").submit(function() { - var template_str = 'LANG = "'+$('#provision_new_language', this).val()+'"'; - - Sunstone.runAction("User.append_template_refresh", "-1", template_str); + var sunstone_template = {}; + if (that.element.TEMPLATE.SUNSTONE) { + $.extend(sunstone_template, that.element.TEMPLATE.SUNSTONE); + } + sunstone_template.LANG = $('#provision_new_language', this).val(); + var template_str = TemplateUtils.templateToString({'SUNSTONE': sunstone_template}); + Sunstone.runAction("User.append_template_refresh", that.element.ID, template_str); return false; }); diff --git a/src/sunstone/public/app/tabs/users-tab/panels/info.js b/src/sunstone/public/app/tabs/users-tab/panels/info.js index c84b763be0..976c68c560 100644 --- a/src/sunstone/public/app/tabs/users-tab/panels/info.js +++ b/src/sunstone/public/app/tabs/users-tab/panels/info.js @@ -83,10 +83,7 @@ define(function(require) { // TODO: simplify interface? var strippedTemplate = $.extend({}, this.element.TEMPLATE); delete strippedTemplate["SSH_PUBLIC_KEY"]; - delete strippedTemplate["LANG"]; - delete strippedTemplate["TABLE_ORDER"]; - delete strippedTemplate["DEFAULT_VIEW"]; - delete strippedTemplate["TABLE_DEFAULT_PAGE_LENGTH"]; + delete strippedTemplate["SUNSTONE"]; var templateTableHTML = TemplateTable.html(strippedTemplate, RESOURCE, Locale.tr("Attributes")); @@ -94,6 +91,7 @@ define(function(require) { return TemplateInfo({ 'element': this.element, + 'sunstone_template': this.element.TEMPLATE.SUNSTONE||{}, 'groupTrHTML': groupTrHTML, 'secondaryGroups': secondaryGroups, 'templateTableHTML': templateTableHTML @@ -107,24 +105,15 @@ define(function(require) { // TODO: simplify interface? var strippedTemplate = $.extend({}, this.element.TEMPLATE); delete strippedTemplate["SSH_PUBLIC_KEY"]; - delete strippedTemplate["LANG"]; - delete strippedTemplate["TABLE_ORDER"]; - delete strippedTemplate["DEFAULT_VIEW"]; - delete strippedTemplate["TABLE_DEFAULT_PAGE_LENGTH"]; + delete strippedTemplate["SUNSTONE"]; var hiddenValues = {}; if (this.element.TEMPLATE.SSH_PUBLIC_KEY != undefined) { hiddenValues.SSH_PUBLIC_KEY = this.element.TEMPLATE.SSH_PUBLIC_KEY; } - if (this.element.TEMPLATE.LANG != undefined) { - hiddenValues.LANG = this.element.TEMPLATE.LANG; - } - if (this.element.TEMPLATE.TABLE_ORDER != undefined) { - hiddenValues.TABLE_ORDER = this.element.TEMPLATE.TABLE_ORDER; - } - if (this.element.TEMPLATE.DEFAULT_VIEW != undefined) { - hiddenValues.DEFAULT_VIEW = this.element.TEMPLATE.DEFAULT_VIEW; + if (this.element.TEMPLATE.SUNSTONE != undefined) { + hiddenValues.SUNSTONE = this.element.TEMPLATE.SUNSTONE; } TemplateTable.setup(strippedTemplate, RESOURCE, this.element.ID, context, hiddenValues); @@ -182,15 +171,20 @@ define(function(require) { '' + ''); - if (that.element.TEMPLATE.TABLE_ORDER) { - $('#table_order_select', context).val(that.element.TEMPLATE.TABLE_ORDER); + if (that.element.TEMPLATE.SUNSTONE && that.element.TEMPLATE.SUNSTONE.TABLE_ORDER) { + $('#table_order_select', context).val(that.element.TEMPLATE.SUNSTONE.TABLE_ORDER); } }); context.off("change", "#table_order_select") context.on("change", "#table_order_select", function() { - var template_str = 'TABLE_ORDER = "'+$(this).val()+'"'; + var sunstone_template = {}; + if (that.element.TEMPLATE.SUNSTONE) { + $.extend(sunstone_template, that.element.TEMPLATE.SUNSTONE); + } + sunstone_template.TABLE_ORDER = $(this).val(); + var template_str = TemplateUtils.templateToString({'SUNSTONE': sunstone_template}); Sunstone.runAction("User.append_template_refresh", that.element.ID, template_str); }); @@ -201,15 +195,20 @@ define(function(require) { Locale.language_options + ''); - if (that.element.TEMPLATE.LANG) { - $('#language_select', context).val(that.element.TEMPLATE.LANG); + if (that.element.TEMPLATE.SUNSTONE && that.element.TEMPLATE.SUNSTONE.LANG) { + $('#language_select', context).val(that.element.TEMPLATE.SUNSTONE.LANG); } }); context.off("change", "#language_select") context.on("change", "#language_select", function() { - var template_str = 'LANG = "'+$(this).val()+'"'; + var sunstone_template = {}; + if (that.element.TEMPLATE.SUNSTONE) { + $.extend(sunstone_template, that.element.TEMPLATE.SUNSTONE); + } + sunstone_template.LANG = $(this).val(); + var template_str = TemplateUtils.templateToString({'SUNSTONE': sunstone_template}); Sunstone.runAction("User.append_template_refresh", that.element.ID, template_str); }); @@ -225,15 +224,20 @@ define(function(require) { options + ''); - if (that.element.TEMPLATE.DEFAULT_VIEW) { - $('#view_select', context).val(that.element.TEMPLATE.DEFAULT_VIEW); + if (that.element.TEMPLATE.SUNSTONE && that.element.TEMPLATE.SUNSTONE.DEFAULT_VIEW) { + $('#view_select', context).val(that.element.TEMPLATE.SUNSTONE.DEFAULT_VIEW); } }); context.off("change", "#view_select") context.on("change", "#view_select", function() { - var template_str = 'DEFAULT_VIEW = "'+$(this).val()+'"'; + var sunstone_template = {}; + if (that.element.TEMPLATE.SUNSTONE) { + $.extend(sunstone_template, that.element.TEMPLATE.SUNSTONE); + } + sunstone_template.DEFAULT_VIEW = $(this).val(); + var template_str = TemplateUtils.templateToString({'SUNSTONE': sunstone_template}); Sunstone.runAction("User.append_template_refresh", that.element.ID, template_str); }); diff --git a/src/sunstone/public/app/tabs/users-tab/panels/info/html.hbs b/src/sunstone/public/app/tabs/users-tab/panels/info/html.hbs index 9f5e8b875a..e412911275 100644 --- a/src/sunstone/public/app/tabs/users-tab/panels/info/html.hbs +++ b/src/sunstone/public/app/tabs/users-tab/panels/info/html.hbs @@ -54,7 +54,7 @@ {{tr "Table Order"}} - {{valOrDefault element.TEMPLATE.TABLE_ORDER "-"}} + {{valOrDefault sunstone_template.TABLE_ORDER "-"}}
@@ -63,7 +63,7 @@ {{tr "Language"}} - {{valOrDefault element.TEMPLATE.LANG "-"}} + {{valOrDefault sunstone_template.LANG "-"}}
@@ -72,7 +72,7 @@ {{tr "View"}} - {{valOrDefault element.TEMPLATE.DEFAULT_VIEW "-"}} + {{valOrDefault sunstone_template.DEFAULT_VIEW "-"}}
diff --git a/src/sunstone/sunstone-server.rb b/src/sunstone/sunstone-server.rb index 1a950b7a50..ea3ebcb6c5 100755 --- a/src/sunstone/sunstone-server.rb +++ b/src/sunstone/sunstone-server.rb @@ -49,7 +49,12 @@ $: << SUNSTONE_ROOT_DIR+'/models' SESSION_EXPIRE_TIME = 60*60 -DISPLAY_NAME_XPATH = 'TEMPLATE/SUNSTONE_DISPLAY_NAME' +DISPLAY_NAME_XPATH = 'TEMPLATE/SUNSTONE/DISPLAY_NAME' +TABLE_ORDER_XPATH = 'TEMPLATE/SUNSTONE/TABLE_ORDER' +DEFAULT_VIEW_XPATH = 'TEMPLATE/SUNSTONE/DEFAULT_VIEW' +GROUP_ADMIN_DEFAULT_VIEW_XPATH = 'TEMPLATE/SUNSTONE/GROUP_ADMIN_DEFAULT_VIEW' +TABLE_DEFAULT_PAGE_LENGTH_XPATH = 'TEMPLATE/SUNSTONE/TABLE_DEFAULT_PAGE_LENGTH' +LANG_XPATH = 'TEMPLATE/SUNSTONE/LANG' ############################################################################## # Required libraries @@ -225,14 +230,14 @@ helpers do # - WSS CONECTION # - TABLE ORDER - if user['TEMPLATE/LANG'] - session[:lang] = user['TEMPLATE/LANG'] + if user[LANG_XPATH] + session[:lang] = user[LANG_XPATH] else session[:lang] = $conf[:lang] end - if user['TEMPLATE/TABLE_DEFAULT_PAGE_LENGTH'] - session[:page_length] = user['TEMPLATE/TABLE_DEFAULT_PAGE_LENGTH'] + if user[TABLE_DEFAULT_PAGE_LENGTH_XPATH] + session[:page_length] = user[TABLE_DEFAULT_PAGE_LENGTH_XPATH] else session[:page_length] = DEFAULT_PAGE_LENGTH end @@ -242,18 +247,18 @@ helpers do session[:vnc_wss] = (wss == true || wss == "yes" || wss == "only" ? "yes" : "no") - if user['TEMPLATE/TABLE_ORDER'] - session[:table_order] = user['TEMPLATE/TABLE_ORDER'] + if user[TABLE_ORDER_XPATH] + session[:table_order] = user[TABLE_ORDER_XPATH] else session[:table_order] = $conf[:table_order] || DEFAULT_TABLE_ORDER end - if user['TEMPLATE/DEFAULT_VIEW'] - session[:default_view] = user['TEMPLATE/DEFAULT_VIEW'] - elsif group.contains_admin(user.id) && group['TEMPLATE/GROUP_ADMIN_DEFAULT_VIEW'] - session[:default_view] = group['TEMPLATE/GROUP_ADMIN_DEFAULT_VIEW'] - elsif group['TEMPLATE/DEFAULT_VIEW'] - session[:default_view] = group['TEMPLATE/DEFAULT_VIEW'] + if user[DEFAULT_VIEW_XPATH] + session[:default_view] = user[DEFAULT_VIEW_XPATH] + elsif group.contains_admin(user.id) && group[GROUP_ADMIN_DEFAULT_VIEW_XPATH] + session[:default_view] = group[GROUP_ADMIN_DEFAULT_VIEW_XPATH] + elsif group[DEFAULT_VIEW_XPATH] + session[:default_view] = group[DEFAULT_VIEW_XPATH] else session[:default_view] = $views_config.available_views(session[:user], session[:user_gname]).first end @@ -458,11 +463,11 @@ post '/config' do error 500, "" end - session[:lang] = user['TEMPLATE/LANG'] if user['TEMPLATE/LANG'] + session[:lang] = user[LANG_XPATH] if user[LANG_XPATH] session[:vnc_wss] = user['TEMPLATE/VNC_WSS'] if user['TEMPLATE/VNC_WSS'] - session[:default_view] = user['TEMPLATE/DEFAULT_VIEW'] if user['TEMPLATE/DEFAULT_VIEW'] - session[:table_order] = user['TEMPLATE/TABLE_ORDER'] if user['TEMPLATE/TABLE_ORDER'] - session[:page_length] = user['TEMPLATE/TABLE_DEFAULT_PAGE_LENGTH'] if user['TEMPLATE/TABLE_DEFAULT_PAGE_LENGTH'] + session[:default_view] = user[DEFAULT_VIEW_XPATH] if user[DEFAULT_VIEW_XPATH] + session[:table_order] = user[TABLE_ORDER_XPATH] if user[TABLE_ORDER_XPATH] + session[:page_length] = user[TABLE_DEFAULT_PAGE_LENGTH_XPATH] if user[TABLE_DEFAULT_PAGE_LENGTH_XPATH] session[:display_name] = user[DISPLAY_NAME_XPATH] || user['NAME'] [204, ""]