From f39b6c813dfa8ad97de4f8a35aaf21ee1408b6d4 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Fri, 28 Dec 2012 20:02:07 +0100 Subject: o A custom pageable table with builds. --- src/main/webapp/apps/personApp/person.html | 83 +++++++++++++++++++++-------- src/main/webapp/apps/personApp/personApp.js | 45 +++++++++++++++- 2 files changed, 105 insertions(+), 23 deletions(-) (limited to 'src/main/webapp') diff --git a/src/main/webapp/apps/personApp/person.html b/src/main/webapp/apps/personApp/person.html index 5a8395e..d9524ae 100644 --- a/src/main/webapp/apps/personApp/person.html +++ b/src/main/webapp/apps/personApp/person.html @@ -4,32 +4,71 @@

{{person.name}}

-

Badges

+ -

- {{badge.name}} x {{badge.count}} -

+
+

Badges

-
-
-
{{badge.name}}
+

+ {{badge.name}} x {{badge.count}} +

+ +
+
+
{{badge.name}}
+
+ +

Recent builds

+ + + + + + + + + + + + + +
DateSuccess
{{build.date | date:'medium'}}{{build.success}}
-

Recent builds

- - - - - - - - - - - - - -
DateSuccess
{{build.date | date:'medium'}}{{build.success}}
+
+

Builds

+ + + + + + + + + + + + + + + + + + +
DateSuccess
{{build.date | date:'medium'}}{{build.success}}
+ +
+
diff --git a/src/main/webapp/apps/personApp/personApp.js b/src/main/webapp/apps/personApp/personApp.js index 8323c45..8c13669 100644 --- a/src/main/webapp/apps/personApp/personApp.js +++ b/src/main/webapp/apps/personApp/personApp.js @@ -6,11 +6,54 @@ var personApp = angular.module('personApp', ['person', 'build']).config(function }); function PersonCtrl($scope, $location, Person, Build) { + function queryBuilds() { + var builds = $scope.builds; + Build.query({person: uuid, startIndex: builds.startIndex, count: builds.count}, function (builds) { + $scope.builds.rows = builds; + }); + } + + $scope.mode = 'overview'; + $scope.builds = { + rows: [], + startIndex: 0, + count: 10, + first: function() { + $scope.builds.startIndex = 0; + queryBuilds(); + }, + next: function() { + $scope.builds.startIndex += $scope.builds.count; + queryBuilds(); + }, + prev: function() { + if($scope.builds.startIndex == 0) { + return; + } + $scope.builds.startIndex -= $scope.builds.count; + queryBuilds(); + } + }; + + $scope.setMode = function(mode) { + $scope.mode = mode; + switch(mode) { + case 'builds': + var builds = $scope.builds; + + console.log("$scope.builds.length=" + builds.rows.length); + if (builds.rows.length == 0) { + queryBuilds(builds); + } + break; + } + }; + Person.get({uuid: uuid}, function (person) { $scope.person = person; }); Build.query({person: uuid}, function (builds) { - $scope.builds = builds; + $scope.recentBuilds = builds; }); } -- cgit v1.2.3