diff --git a/src/sunstone/public/app/tabs/users-tab/actions.js b/src/sunstone/public/app/tabs/users-tab/actions.js index 7504c626c5..11e354acad 100644 --- a/src/sunstone/public/app/tabs/users-tab/actions.js +++ b/src/sunstone/public/app/tabs/users-tab/actions.js @@ -187,6 +187,28 @@ define(function(require) { } }, + "User.append_sunstone_setting" : { + 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", params.data.id, template_str); + }, + error: Notifier.onError + }); + } + }, + "User.fetch_quotas" : { type: "single", call: OpenNebulaResource.show, diff --git a/src/sunstone/public/app/utils/tab-datatable.js b/src/sunstone/public/app/utils/tab-datatable.js index 4db635f5ba..0d438fdea1 100644 --- a/src/sunstone/public/app/utils/tab-datatable.js +++ b/src/sunstone/public/app/utils/tab-datatable.js @@ -189,7 +189,7 @@ define(function(require) { this.initSelectResourceTableSelect(); } else { - this.dataTableOptions.pageLength = parseInt(config['page_length']); + this.dataTableOptions.pageLength = parseInt(config['user_config']['page_length']); } this.dataTable = $('#' + this.dataTableId).dataTable(this.dataTableOptions); @@ -197,11 +197,9 @@ define(function(require) { // Remember page length only for non selectable datatables if (!this.conf.select) { this.dataTable.on( 'length.dt', function ( e, settings, len ) { - config['page_length'] = len; - - var template_str = 'TABLE_DEFAULT_PAGE_LENGTH = "'+len+'"'; - - Sunstone.runAction("User.append_template", config['user_id'], template_str); + config['user_config']['page_length'] = len; + var sunstone_setting = {'TABLE_DEFAULT_PAGE_LENGTH': len}; + Sunstone.runAction("User.append_sunstone_setting", config['user_id'], sunstone_setting); }); } @@ -403,6 +401,8 @@ define(function(require) { that.preUpdateView(); } + that.dataTable.DataTable().page.len(parseInt(config['user_config']['page_length'])); + var row_id_index = this.dataTable.attr("row_id"); if (row_id_index != undefined) { @@ -530,7 +530,7 @@ define(function(require) { } function _getElementData(id, resource_tag) { - // TODO If the element is not included in the visible rows of + // TODO If the element is not included in the visible rows of // the table, it will not be included in the fnGetNodes response var nodes = this.dataTable.fnGetNodes(); var tr = $('#' + resource_tag + '_' + id, nodes).closest('tr'); diff --git a/src/sunstone/views/index.erb b/src/sunstone/views/index.erb index 6814c93a6e..7841ae9dab 100644 --- a/src/sunstone/views/index.erb +++ b/src/sunstone/views/index.erb @@ -27,7 +27,8 @@ 'lang' : '<%= session[:lang] %>', 'vnc_wss' : '<%= session[:vnc_wss] %>', 'table_order' : '<%= session[:table_order] %>', - 'default_view' : '<%= session[:default_view] %>' + 'default_view' : '<%= session[:default_view] %>', + 'page_length' : '<%= session[:page_length] %>' }, 'system_config' : { 'marketplace_url' : '<%= $conf[:marketplace_url] %>', @@ -42,7 +43,6 @@ 'display_name' : '<%= session[:display_name] %>', 'zone_name' : '<%= session[:zone_name] %>', 'zone_id' : '<%= session[:zone_id] %>', - 'page_length' : '<%= session[:page_length] %>', 'vm_logos' : <%= logos_conf.to_json %>, 'oned_conf' : <%= oned_conf.to_json %> }; @@ -68,7 +68,7 @@