aboutsummaryrefslogtreecommitdiff
path: root/src/main/webapp/apps
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-01-06 23:57:14 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2013-01-06 23:57:14 +0100
commit7a0db61a0d9ba8e1359f5d14392bc90e6a0872e0 (patch)
tree78f56c88024d8542a0bd567aefeb7c688c75ac77 /src/main/webapp/apps
parenta310ffdce4cd6dcbb6ba8e4fb739412ea9abdca5 (diff)
downloadesper-testing-7a0db61a0d9ba8e1359f5d14392bc90e6a0872e0.tar.gz
esper-testing-7a0db61a0d9ba8e1359f5d14392bc90e6a0872e0.tar.bz2
esper-testing-7a0db61a0d9ba8e1359f5d14392bc90e6a0872e0.tar.xz
esper-testing-7a0db61a0d9ba8e1359f5d14392bc90e6a0872e0.zip
o Creating a recent badges view.
Diffstat (limited to 'src/main/webapp/apps')
-rw-r--r--src/main/webapp/apps/app.js58
-rwxr-xr-xsrc/main/webapp/apps/frontPageApp/badgeList.html46
-rwxr-xr-xsrc/main/webapp/apps/frontPageApp/frontPageApp.js63
-rwxr-xr-xsrc/main/webapp/apps/frontPageApp/personList.html2
4 files changed, 144 insertions, 25 deletions
diff --git a/src/main/webapp/apps/app.js b/src/main/webapp/apps/app.js
index 3d200ec..36736cd 100644
--- a/src/main/webapp/apps/app.js
+++ b/src/main/webapp/apps/app.js
@@ -4,26 +4,32 @@ directives.filter('countBadgeByLevel', function () {
return function (badges) {
// 5 levels
var levels = [0, 0, 0, 0, 0];
- angular.forEach(badges, function(value, key){
+ angular.forEach(badges, function (value, key) {
levels[value.level - 1]++;
});
return levels;
}
});
+directives.filter('isodate', function () {
+ return function (date) {
+ return date.toISOString();
+ }
+});
+
directives.filter('gz', function () {
return function (num) {
- if(angular.isArray(num)) {
+ if (angular.isArray(num)) {
var out = [];
- angular.forEach(num, function(x){
- if(x > 0) {
+ angular.forEach(num, function (x) {
+ if (x > 0) {
out.push(x);
}
});
return out;
}
- else if(angular.isNumber(num)) {
+ else if (angular.isNumber(num)) {
return num > 0;
}
console.log("fail");
@@ -44,9 +50,47 @@ directives.directive('badge', function () {
scope: {
badgeDetail: '=badgeDetail'
},
- template: '<span class="badge-inverse badge-level-{{badgeDetail.badge.level}} badge"><strong style="padding-right: 0.3em">{{badgeDetail.badge.name}}</strong>' +
- '<i class="icon-user"></i></span>' +
+ template: '<span class="badge-inverse badge-level-{{badgeDetail.badge.level}} badge">' +
+ ' <strong style="padding-right: 0.3em">{{badgeDetail.badge.name}}</strong>' +
+ ' <i class="icon-user"></i>' +
+ '</span>' +
' awarded to ' +
'<a href="/#/person/{{badgeDetail.person.uuid}}">{{badgeDetail.person.name}}</a>'
}
});
+
+directives.directive('badgeSpan', function () {
+ var template =
+ '<span class="badge-inverse badge-level-{{badge.level}} badge">' +
+ ' <strong style="padding-right: 0.3em">{{badge.name}}</strong>' +
+ ' <i class="icon-user"></i>' +
+ '</span>';
+
+ return {
+ restrict: 'E',
+ scope: {
+ badge: '=badge'
+ },
+ template: template
+ }
+});
+
+directives.directive('personLink', function () {
+ return {
+ restrict: 'E',
+ scope: {
+ person: '=person'
+ },
+ template: '<a href="/#/person/{{person.uuid}}">{{person.name}}</a>'
+ }
+});
+
+directives.directive('personAvatar', function () {
+ return {
+ restrict: 'E',
+ scope: {
+ person: '=person'
+ },
+ template: '<img ng-src="{{person.gravatar}}?default=identicon" class="avatar-image" title="{{person.name}}"/>'
+ }
+});
diff --git a/src/main/webapp/apps/frontPageApp/badgeList.html b/src/main/webapp/apps/frontPageApp/badgeList.html
new file mode 100755
index 0000000..7671a55
--- /dev/null
+++ b/src/main/webapp/apps/frontPageApp/badgeList.html
@@ -0,0 +1,46 @@
+<div class="container">
+
+ <navbar/>
+
+ <div class="page-header">
+ <h1>Badges Awarded</h1>
+ </div>
+
+ <style>
+ .awarded-badge {
+ text-align: center;
+ margin-bottom: 1em;
+ margin-right: 1em;
+ }
+
+ .avatar-image {
+ margin-bottom: 1em;
+ }
+ </style>
+
+ <div class="row">
+ <div class="span12">
+ <div class="row" ng-repeat="(date, group) in badgeGroups">
+ <div class="span12">
+ <h2>{{date | date:'mediumDate'}}</h2>
+ </div>
+ <div class="span12">
+ <div class="awarded-badge pull-left" ng-repeat="badge in group">
+ <div><person-avatar person="badge.person"></person-avatar></div>
+
+ <badge-span badge="badge.badge" ></badge-span> <br/>
+ <!--was awarded to<br/>-->
+ </div>
+ </div>
+ </div>
+ <ul class="pager">
+ <li class="previous" ng-show="persons.startIndex > 0">
+ <a ng-click="persons.prev()">&larr; Prev</a>
+ </li>
+ <li class="next">
+ <a ng-click="persons.next()">Next &rarr;</a>
+ </li>
+ </ul>
+ </div>
+ </div>
+</div>
diff --git a/src/main/webapp/apps/frontPageApp/frontPageApp.js b/src/main/webapp/apps/frontPageApp/frontPageApp.js
index 39dbc9d..5f1cf2c 100755
--- a/src/main/webapp/apps/frontPageApp/frontPageApp.js
+++ b/src/main/webapp/apps/frontPageApp/frontPageApp.js
@@ -1,8 +1,9 @@
'use strict';
-var frontPageApp = angular.module('frontPageApp', ['ngGrid', 'person', 'badge', 'build', 'pagingTableService', 'core.directives']).config(function ($routeProvider, $locationProvider) {
+var frontPageApp = angular.module('frontPageApp', ['ngGrid', 'person', 'badge', 'build', 'pagingTableService', 'core.directives']).config(function ($routeProvider) {
$routeProvider.
when('/', {controller: FrontPageCtrl, templateUrl: '/apps/frontPageApp/frontPage.html?noCache=' + noCache}).
+ when('/badge/', {controller: BadgeListCtrl, templateUrl: '/apps/frontPageApp/badgeList.html?noCache=' + noCache}).
when('/person/', {controller: PersonListCtrl, templateUrl: '/apps/frontPageApp/personList.html?noCache=' + noCache}).
when('/person/:personUuid', {controller: PersonCtrl, templateUrl: '/apps/frontPageApp/person.html?noCache=' + noCache});
});
@@ -12,28 +13,56 @@ function FrontPageCtrl($scope, Person, Badge) {
$scope.recentBadges = Badge.query();
}
-function PersonListCtrl($scope, Person, PagingTableService) {
+function groupBy(array, size) {
+ var group = [];
+ var groups = [];
+ angular.forEach(array, function (element) {
+ group.push(element);
+ if (group.length == size) {
+ groups.push(group);
+ group = [];
+ }
+ });
+
+ if (group.length != 0) {
+ groups.push(group);
+ }
+ return groups;
+}
+
+function BadgeListCtrl($scope, Badge, PagingTableService) {
+ var groupSize = 6;
+
var personsWatcher = function () {
- var array = $scope.persons.rows;
-
- var group = [];
- var groups = [];
- angular.forEach(array, function(element) {
- group.push(element);
- if(group.length == 4) {
- groups.push(group);
- group = [];
- }
+ var withDay = _.map($scope.badges.rows, function(badge) {
+ badge.day = new Date(badge.badge.createdDate).clearTime().getTime();
+// badge.day.clearTime();
+ return badge;
});
- if(group.length != 0) {
- groups.push(group);
- }
+ var byDay = _.groupBy(withDay, 'day');
+ console.log("byDay", byDay);
+// var dateGroups = _.map(byDay, function(group, date) {
+// return {date: groupBy(group, groupSize)}
+// });
+
+ $scope.badgeGroups = byDay;
+ };
+
+ $scope.badges = PagingTableService.create($scope, PagingTableService.defaultCallback(Badge),
+ {count: groupSize * 6, watcher: personsWatcher});
- $scope.personGroups = groups;
+ $scope.badgeGroups = [];
+}
+
+function PersonListCtrl($scope, Person, PagingTableService) {
+ var groupSize = 4;
+ var personsWatcher = function () {
+ $scope.personGroups = groupBy($scope.persons.rows, groupSize);
};
- $scope.persons = PagingTableService.create($scope, PagingTableService.defaultCallback(Person, {orderBy: "name"}), {count: 4 * 6, watcher: personsWatcher});
+ $scope.persons = PagingTableService.create($scope, PagingTableService.defaultCallback(Person, {orderBy: "name"}),
+ {count: groupSize * 6, watcher: personsWatcher});
$scope.personGroups = [];
}
diff --git a/src/main/webapp/apps/frontPageApp/personList.html b/src/main/webapp/apps/frontPageApp/personList.html
index 5247f29..5d7d8c6 100755
--- a/src/main/webapp/apps/frontPageApp/personList.html
+++ b/src/main/webapp/apps/frontPageApp/personList.html
@@ -25,7 +25,7 @@
<div class="row" ng-repeat="group in personGroups">
<div class="span3" ng-repeat="person in group" style="padding-bottom: 1em">
<div class="row">
- <img ng-src="{{person.person.gravatar}}?default=identicon" class="avatar-image"/>
+ <person-avatar person="person.person"></person-avatar>
<a href="/#/person/{{person.person.uuid}}">{{person.person.name}}</a>
<br/>
<span ng-repeat="level in person.badges | countBadgeByLevel | gz">