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 e478163dd8..bebdc52688 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 @@ -127,26 +127,16 @@ define(function(require) { }); $("#provision_change_view_form").submit(function() { - var sunstone_template = {}; - if (that.element.TEMPLATE.SUNSTONE) { - $.extend(sunstone_template, that.element.TEMPLATE.SUNSTONE); - } + var sunstone_setting = {DEFAULT_VIEW : $('#provision_user_views_select', this).val()}; + Sunstone.runAction("User.append_sunstone_setting_refresh", that.element.ID, sunstone_setting); - 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 sunstone_template = {}; - if (that.element.TEMPLATE.SUNSTONE) { - $.extend(sunstone_template, that.element.TEMPLATE.SUNSTONE); - } + var sunstone_setting = {LANG : $('#provision_new_language', this).val()}; + Sunstone.runAction("User.append_sunstone_setting_refresh", that.element.ID, sunstone_setting); - 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/actions.js b/src/sunstone/public/app/tabs/users-tab/actions.js index 0e1a60eb44..bbacc18cdd 100644 --- a/src/sunstone/public/app/tabs/users-tab/actions.js +++ b/src/sunstone/public/app/tabs/users-tab/actions.js @@ -21,6 +21,7 @@ define(function(require) { var DataTable = require('./datatable'); var OpenNebulaResource = require('opennebula/user'); var CommonActions = require('utils/common-actions'); + var TemplateUtils = require('utils/template-utils'); var TAB_ID = require('./tabId'); var CREATE_DIALOG_ID = require('./form-panels/create/formPanelId'); @@ -163,6 +164,28 @@ define(function(require) { error: Notifier.onError }, + "User.append_sunstone_setting_refresh" : { + type: "single", + call: function(params){ + OpenNebulaResource.show({ + data : { + id: params.data.id + }, + success: function(request, response) { + var sunstone_template = {}; + if (response[XML_ROOT].TEMPLATE.SUNSTONE) { + $.extend(sunstone_template, response[XML_ROOT].TEMPLATE.SUNSTONE); + } + + $.extend(sunstone_template, params.data.extra_param) + var template_str = TemplateUtils.templateToString({'SUNSTONE': sunstone_template}); + Sunstone.runAction("User.append_template_refresh", params.data.id, template_str); + }, + error: Notifier.onError + }); + } + }, + "User.fetch_quotas" : { type: "single", call: OpenNebulaResource.show, 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 ef717cf503..ff0e4673d5 100644 --- a/src/sunstone/public/app/tabs/users-tab/panels/info.js +++ b/src/sunstone/public/app/tabs/users-tab/panels/info.js @@ -170,14 +170,8 @@ define(function(require) { context.off("change", "#table_order_select") context.on("change", "#table_order_select", function() { - 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); + var sunstone_setting = {TABLE_ORDER : $(this).val()}; + Sunstone.runAction("User.append_sunstone_setting_refresh", that.element.ID, sunstone_setting); }); // Change language @@ -194,14 +188,8 @@ define(function(require) { context.off("change", "#language_select") context.on("change", "#language_select", function() { - 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); + var sunstone_setting = {LANG : $(this).val()}; + Sunstone.runAction("User.append_sunstone_setting_refresh", that.element.ID, sunstone_setting); }); // Change view @@ -223,14 +211,8 @@ define(function(require) { context.off("change", "#view_select") context.on("change", "#view_select", function() { - 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); + var sunstone_setting = {DEFAULT_VIEW : $(this).val()}; + Sunstone.runAction("User.append_sunstone_setting_refresh", that.element.ID, sunstone_setting); }); return false;