aboutsummaryrefslogtreecommitdiff
path: root/src/main/webapp/apps/frontPageApp/frontPageApp.js
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-12-26 21:45:38 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2012-12-26 21:45:38 +0100
commit422b1caeaa9f7d069a9208ecb0d0249485b1a05e (patch)
tree90ef9e1d0b6f26178f1fae3e3df20226a1d91087 /src/main/webapp/apps/frontPageApp/frontPageApp.js
parent348ec4e14aeaf4e98fcab96f0ae7242d178db69b (diff)
downloadesper-testing-422b1caeaa9f7d069a9208ecb0d0249485b1a05e.tar.gz
esper-testing-422b1caeaa9f7d069a9208ecb0d0249485b1a05e.tar.bz2
esper-testing-422b1caeaa9f7d069a9208ecb0d0249485b1a05e.tar.xz
esper-testing-422b1caeaa9f7d069a9208ecb0d0249485b1a05e.zip
o Adding details page for persons.
o Better front page.
Diffstat (limited to 'src/main/webapp/apps/frontPageApp/frontPageApp.js')
-rw-r--r--src/main/webapp/apps/frontPageApp/frontPageApp.js64
1 files changed, 60 insertions, 4 deletions
diff --git a/src/main/webapp/apps/frontPageApp/frontPageApp.js b/src/main/webapp/apps/frontPageApp/frontPageApp.js
index 4c5df8b..d92a163 100644
--- a/src/main/webapp/apps/frontPageApp/frontPageApp.js
+++ b/src/main/webapp/apps/frontPageApp/frontPageApp.js
@@ -1,12 +1,68 @@
'use strict';
-var frontPageApp = angular.module('frontPageApp', ['personService']).config(function ($routeProvider, $locationProvider) {
+var frontPageApp = angular.module('frontPageApp', ['ngGrid', 'personService']).config(function ($routeProvider, $locationProvider) {
$routeProvider.
when('/', {controller: FrontPageCtrl, templateUrl: '/apps/frontPageApp/frontPage.html?noCache=' + noCache});
});
-function FrontPageCtrl($scope, $location, PersonService) {
- PersonService.query(function (persons) {
- $scope.persons = persons;
+function FrontPageCtrl($scope, $http, PersonService) {
+ $scope.persons = [];
+
+ $scope.pagingOptions = {
+ pageSizes: [10],
+ pageSize: 10,
+ totalServerItems: 0,
+ currentPage: 1
+ };
+
+ $scope.personsGridOptions = {
+ data: 'persons',
+ displayFooter: true,
+ enablePaging: true,
+ showFilter: false,
+ showColumnMenu: false,
+ canSelectRows: false,
+ displaySelectionCheckbox: false,
+ pagingOptions: $scope.pagingOptions,
+ columnDefs: [
+ {
+ field: 'name',
+ displayName: 'Name',
+ cellTemplate: '<a href="/person/{{row.getProperty(\'uuid\')}}">{{row.getProperty(col.field)}}</a>'
+ },
+ {
+ field: 'badges',
+ displayName: 'Badges',
+ cellTemplate: '<div>{{row.getProperty(col.field).length}}</div>'
+ }
+ ]
+ };
+
+ $scope.setPagingData = function(data, page, pageSize){
+// $scope.persons = data.slice((page - 1) * pageSize, page * pageSize);
+ $scope.persons = data;
+ $scope.personsGridOptions.totalServerItems = data.length;
+ if (!$scope.$$phase) {
+ $scope.$apply();
+ }
+ };
+
+ $scope.getPagedDataAsync = function (pageSize, page/*, searchText*/) {
+ setTimeout(function () {
+
+ PersonService.query({startIndex: page * pageSize, count: pageSize}, function (persons) {
+ $scope.setPagingData(persons, page, pageSize);
+ });
+ }, 100);
+ };
+
+ $scope.$watch('pagingOptions', function () {
+ $scope.getPagedDataAsync($scope.pagingOptions.pageSize, $scope.pagingOptions.currentPage);
+ }, true);
+
+ $http.get('/resource/core/person-count').success(function(count) {
+ $scope.pagingOptions.totalServerItems = count;
+
+ $scope.getPagedDataAsync($scope.pagingOptions.pageSize, $scope.pagingOptions.currentPage);
});
}