diff --git a/horizon/static/framework/conf/conf.js b/horizon/static/framework/conf/conf.js index 645f5782d1..8687315ad6 100644 --- a/horizon/static/framework/conf/conf.js +++ b/horizon/static/framework/conf/conf.js @@ -20,5 +20,8 @@ .value('horizon.framework.conf.toastOptions', { 'delay': 3000, 'dimissible': ['alert-success', 'alert-info'] + }) + .value('horizon.framework.conf.tableOptions', { + 'pageSize': 20 }); })(); diff --git a/horizon/static/framework/widgets/table/hz-dynamic-table.directive.spec.js b/horizon/static/framework/widgets/table/hz-dynamic-table.directive.spec.js index 88fe276536..b25c02ad55 100644 --- a/horizon/static/framework/widgets/table/hz-dynamic-table.directive.spec.js +++ b/horizon/static/framework/widgets/table/hz-dynamic-table.directive.spec.js @@ -29,6 +29,17 @@ beforeEach(module('horizon.framework.widgets.magic-search')); beforeEach(module('horizon.framework.widgets.table')); + beforeEach(function() { + horizon.cookies = { + get: function() { + return; + } + }; + + spyOn(horizon.cookies, 'get').and.callThrough(); + + }); + beforeEach(inject(function(_$compile_, _$rootScope_) { $compile = _$compile_; $rootScope = _$rootScope_; diff --git a/horizon/static/framework/widgets/table/hz-dynamic-table.spec.js b/horizon/static/framework/widgets/table/hz-dynamic-table.spec.js index 325746b58f..684f32d82d 100644 --- a/horizon/static/framework/widgets/table/hz-dynamic-table.spec.js +++ b/horizon/static/framework/widgets/table/hz-dynamic-table.spec.js @@ -31,6 +31,17 @@ beforeEach(module('smart-table')); beforeEach(module('horizon.framework')); + beforeEach(function() { + horizon.cookies = { + get: function() { + return; + } + }; + + spyOn(horizon.cookies, 'get').and.callThrough(); + + }); + beforeEach(inject(function ($injector) { $compile = $injector.get('$compile'); $scope = $injector.get('$rootScope').$new(); diff --git a/horizon/static/framework/widgets/table/hz-table-footer.controller.js b/horizon/static/framework/widgets/table/hz-table-footer.controller.js new file mode 100644 index 0000000000..901dabc19c --- /dev/null +++ b/horizon/static/framework/widgets/table/hz-table-footer.controller.js @@ -0,0 +1,33 @@ +/* + * Copyright 2016 IBM Corp. + * Copyright 2016 99Cloud. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +(function () { + 'use strict'; + + angular + .module('horizon.framework.widgets.table') + .controller('HzTableFooterController', HzTableFooterController); + + HzTableFooterController.$inject = [ + 'horizon.framework.conf.tableOptions' + ]; + + function HzTableFooterController(tableOptions) { + var ctrl = this; + ctrl.pageSize = horizon.cookies.get('API_RESULT_PAGE_SIZE') || tableOptions.pageSize; + } + +})(); diff --git a/horizon/static/framework/widgets/table/hz-table-footer.directive.js b/horizon/static/framework/widgets/table/hz-table-footer.directive.js index d02591763f..c8071717c0 100644 --- a/horizon/static/framework/widgets/table/hz-table-footer.directive.js +++ b/horizon/static/framework/widgets/table/hz-table-footer.directive.js @@ -57,6 +57,7 @@ */ function hzTableFooter(basePath, $compile) { var directive = { + controller: 'HzTableFooterController as ctrl', restrict: 'A', scope: { items: '=' diff --git a/horizon/static/framework/widgets/table/hz-table-footer.html b/horizon/static/framework/widgets/table/hz-table-footer.html index 69e24b57ec..9f2be0e97c 100644 --- a/horizon/static/framework/widgets/table/hz-table-footer.html +++ b/horizon/static/framework/widgets/table/hz-table-footer.html @@ -1,12 +1,11 @@