From 34546b9c5b5a9be2180e8b4801b72a48feb94d1d Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Fri, 18 Jan 2013 16:40:40 +0100 Subject: o timestamp => createdDate in the JSON to be consistent. o Better builds list. o Renaming person-avatar to avatar-xl. --- .../webapp/apps/frontPageApp/frontPageApp.js | 42 +++++++++++++--------- 1 file changed, 25 insertions(+), 17 deletions(-) (limited to 'src/main/resources/webapp/apps/frontPageApp/frontPageApp.js') diff --git a/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js b/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js index fb3c22c..be048d4 100755 --- a/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js +++ b/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js @@ -34,25 +34,26 @@ function groupBy(array, size) { return groups; } -function BadgeListCtrl($scope, Badge, PagingTableService) { - var personsWatcher = function () { - var withDay = _.map($scope.badges.rows, function(badge) { - badge.day = new Date(badge.badge.createdDate).clearTime().getTime(); -// badge.day.clearTime(); - return badge; - }); +function groupByDay(array, accessor) { + var withDay = _.map(array, function(item) { + item.day = new Date(accessor(item)).clearTime().getTime(); + return item; + }); - var byDay = _.groupBy(withDay, 'day'); -// console.log("byDay", byDay); + var byDay = _.groupBy(withDay, 'day'); - byDay = _.map(byDay, function(value, key) { - var o = {}; - o[key] = value; - return o; - }); + byDay = _.map(byDay, function(value, key) { + var o = {}; + o[key] = value; + return o; + }); -// byDay = _.toArray(byDay).reverse(); -// console.log("byDay", byDay); + return byDay; +} + +function BadgeListCtrl($scope, Badge, PagingTableService) { + var personsWatcher = function () { + var byDay = groupByDay($scope.badges.rows, function(badge) { return badge.badge.createdDate}); $scope.badgeGroups = byDay; }; @@ -121,7 +122,14 @@ function PersonCtrl($scope, $routeParams, Person, Build, JenkinsUser, PagingTabl } function BuildListCtrl($scope, Build, PagingTableService) { - $scope.builds = PagingTableService.create($scope, PagingTableService.defaultCallback(Build, {fields: "detailed"})); + var watcher = function () { + $scope.buildGroups = groupByDay($scope.builds.rows, function(build) { return build.build.createdDate}); + }; + + $scope.builds = PagingTableService.create($scope, PagingTableService.defaultCallback(Build, {fields: "detailed"}), + { count: 100, watcher: watcher }); + + $scope.buildGroups = []; } function BuildCtrl($scope, $routeParams, Build, PagingTableService) { -- cgit v1.2.3