diff options
Diffstat (limited to 'src/main/resources/webapp')
3 files changed, 19 insertions, 8 deletions
diff --git a/src/main/resources/webapp/apps/core/PagingTableService.js b/src/main/resources/webapp/apps/core/PagingTableService.js index b602fbe..802c0c8 100755 --- a/src/main/resources/webapp/apps/core/PagingTableService.js +++ b/src/main/resources/webapp/apps/core/PagingTableService.js @@ -66,6 +66,9 @@ function PagingTableService() { }); }; + /* + * UI actions + */ self.first = function () { self.startIndex = 0; update(); @@ -100,6 +103,7 @@ function PagingTableService() { }; self.onSearchChange = function () { + self.startIndex = 0; update(); }; @@ -127,6 +131,10 @@ function PagingTableService() { return internal.currentlySearching; }; + self.currentPage = function() { + return (self.startIndex / self.count) + 1; + }; + // Do an initial fetch update(); diff --git a/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js b/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js index 5623c18..1004c6f 100755 --- a/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js +++ b/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js @@ -5,11 +5,10 @@ var frontPageApp = angular.module('frontPageApp', ['ngGrid', 'person', 'badge', when('/', {controller: FrontPageCtrl, templateUrl: '/apps/frontPageApp/frontPage.html?noCache=' + noCache}). when('/badge/', {controller: BadgeListCtrl, templateUrl: '/apps/frontPageApp/badgeList.html?noCache=' + noCache}). when('/badge/:badgeUuid', {controller: BadgeCtrl, templateUrl: '/apps/frontPageApp/badge.html?noCache=' + noCache}). - when('/person/', {controller: PersonListCtrl, templateUrl: '/apps/frontPageApp/personList.html?noCache=' + noCache}). + when('/person/', {controller: PersonListCtrl, templateUrl: '/apps/frontPageApp/personList.html?noCache=' + noCache, reloadOnSearch: false}). when('/person/:personUuid', {controller: PersonCtrl, templateUrl: '/apps/frontPageApp/person.html?noCache=' + noCache}). when('/build/', {controller: BuildListCtrl, templateUrl: '/apps/frontPageApp/buildList.html?noCache=' + noCache}). when('/build/:buildUuid', {controller: BuildCtrl, templateUrl: '/apps/frontPageApp/build.html?noCache=' + noCache}); - // job/:jobUuid/build/:buildUuid }); function FrontPageCtrl($scope, Person, Badge) { @@ -53,9 +52,7 @@ function groupByDay(array, accessor) { function BadgeListCtrl($scope, Badge, PagingTableService) { var personsWatcher = function () { - var byDay = groupByDay($scope.badges.rows, function(badge) { return badge.badge.createdDate}); - - $scope.badgeGroups = byDay; + $scope.badgeGroups = groupByDay($scope.badges.rows, function (badge) { return badge.badge.createdDate }); }; $scope.badges = PagingTableService.create($scope, PagingTableService.defaultCallback(Badge, {orderBy: "created_date-"}), @@ -71,15 +68,21 @@ function BadgeCtrl($scope, $routeParams, Badge) { }); } -function PersonListCtrl($scope, Person, PagingTableService) { +function PersonListCtrl($scope, $location, Person, PagingTableService) { var groupSize = 4, rows = 6; var personsWatcher = function () { $scope.personGroups = groupBy($scope.persons.rows, groupSize); }; + var page = $location.search().page || 1; + var count = groupSize * rows; $scope.personGroups = []; $scope.persons = PagingTableService.create($scope, PagingTableService.defaultCallback(Person, {orderBy: "name"}), - {count: groupSize * rows, watcher: personsWatcher}); + {startIndex: (page - 1) * count, count: count, watcher: personsWatcher}); + + $scope.$watch("persons.currentPage()", function(newValue) { + $location.search('page', newValue > 1 ? newValue : null); + }); } function PersonCtrl($scope, $routeParams, Person, Build, JenkinsUser, PagingTableService) { diff --git a/src/main/resources/webapp/apps/frontPageApp/personList.html b/src/main/resources/webapp/apps/frontPageApp/personList.html index f36aba7..e79c90e 100755 --- a/src/main/resources/webapp/apps/frontPageApp/personList.html +++ b/src/main/resources/webapp/apps/frontPageApp/personList.html @@ -22,7 +22,7 @@ <div class="row"> <div class="span12"> - <form class="form-search well"> + <form class="form-search form-inline well"> <div class="input-append"> <input type="text" class="span2 search-query" ng-model="persons.query" ng-change="persons.onSearchChange()"> <button type="submit" class="btn" ng-click="persons.onSearch()">Search</button> |