aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-12-28 20:02:07 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2012-12-28 20:02:07 +0100
commitf39b6c813dfa8ad97de4f8a35aaf21ee1408b6d4 (patch)
treee10e366d815f6115dca53742c92342c36f8178fb
parent9e8f4821c1e708ccd868866314111b6f8cc9bc6f (diff)
downloadesper-testing-f39b6c813dfa8ad97de4f8a35aaf21ee1408b6d4.tar.gz
esper-testing-f39b6c813dfa8ad97de4f8a35aaf21ee1408b6d4.tar.bz2
esper-testing-f39b6c813dfa8ad97de4f8a35aaf21ee1408b6d4.tar.xz
esper-testing-f39b6c813dfa8ad97de4f8a35aaf21ee1408b6d4.zip
o A custom pageable table with builds.
-rw-r--r--src/main/java/io/trygvis/esper/testing/Config.java4
-rw-r--r--src/main/webapp/apps/personApp/person.html83
-rw-r--r--src/main/webapp/apps/personApp/personApp.js45
-rw-r--r--src/test/java/io/trygvis/esper/testing/core/badge/UnbreakableBadgeProgressTest.java10
4 files changed, 117 insertions, 25 deletions
diff --git a/src/main/java/io/trygvis/esper/testing/Config.java b/src/main/java/io/trygvis/esper/testing/Config.java
index 5ff579f..d1bc2bd 100644
--- a/src/main/java/io/trygvis/esper/testing/Config.java
+++ b/src/main/java/io/trygvis/esper/testing/Config.java
@@ -4,6 +4,7 @@ import com.jolbox.bonecp.*;
import fj.data.*;
import org.apache.abdera.*;
import org.slf4j.*;
+import org.slf4j.bridge.*;
import java.io.*;
import java.sql.*;
@@ -101,6 +102,9 @@ public class Config {
LoggerFactory.getILoggerFactory();
// LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
// StatusPrinter.print(lc);
+
+ SLF4JBridgeHandler.removeHandlersForRootLogger();
+ SLF4JBridgeHandler.install();
}
public BoneCPDataSource createBoneCp() throws SQLException {
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 @@
<h1>{{person.name}}</h1>
</div>
- <h3>Badges</h3>
+ <ul class="nav nav-tabs">
+ <li ng-class="{active: mode == 'overview'}"><a ng-click="setMode('overview')">Overview</a></li>
+ <li ng-class="{active: mode == 'builds'}"><a ng-click="setMode('builds')">Builds</a></li>
+ </ul>
- <p ng-repeat="badge in person.badges">
- <span class="badge-level-{{badge.level}} badge">{{badge.name}}</span><span ng-show="badge.count > 1"> x {{badge.count}}</span>
- </p>
+ <div id="overview" ng-show="mode == 'overview'">
+ <h3>Badges</h3>
- <div ng-repeat="badge in person.badgesInProgress">
- <div class="progress">
- <div class="bar" style="width: {{badge.progress / badge.goal * 100}}%;">{{badge.name}}</div>
+ <p ng-repeat="badge in person.badges">
+ <span class="badge-level-{{badge.level}} badge">{{badge.name}}</span><span ng-show="badge.count > 1"> x {{badge.count}}</span>
+ </p>
+
+ <div ng-repeat="badge in person.badgesInProgress">
+ <div class="progress">
+ <div class="bar" style="width: {{badge.progress / badge.goal * 100}}%;">{{badge.name}}</div>
+ </div>
</div>
+
+ <h3>Recent builds</h3>
+ <table class="table">
+ <thead>
+ <tr>
+ <th>Date</th>
+ <th>Success</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr ng-repeat="build in recentBuilds" class="{{{true: 'success', false: 'error'}[build.success]}}">
+ <td>{{build.date | date:'medium'}}</td>
+ <td>{{build.success}}</td>
+ </tr>
+ </tbody>
+ </table>
</div>
- <h3>Recent builds</h3>
- <table class="table">
- <thead>
- <tr>
- <th>Date</th>
- <th>Success</th>
- </tr>
- </thead>
- <tbody>
- <tr ng-repeat="build in builds" class="{{{true: 'success', false: 'error'}[build.success]}}">
- <td>{{build.date | date:'medium'}}</td>
- <td>{{build.success}}</td>
- </tr>
- </tbody>
- </table>
+ <div id="builds" ng-show="mode == 'builds'">
+ <h3>Builds</h3>
+ <table class="table .table-bordered">
+ <thead>
+ <tr>
+ <th>Date</th>
+ <th>Success</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr ng-repeat="build in builds.rows" class="{{{true: 'success', false: 'error'}[build.success]}}">
+ <td>{{build.date | date:'medium'}}</td>
+ <td>{{build.success}}</td>
+ </tr>
+ </tbody>
+ <tfoot>
+ <tr>
+ <td colspan="2">
+ <ul class="pager">
+ <li class="previous" ng-class="{disabled: builds.startIndex == 0}">
+ <a ng-click="builds.prev()">&larr; Older</a>
+ </li>
+ <li class="next">
+ <a ng-click="builds.next()">Newer &rarr;</a>
+ </li>
+ </ul>
+ </td>
+ </tr>
+ </tfoot>
+ </table>
+ </div>
</div>
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;
});
}
diff --git a/src/test/java/io/trygvis/esper/testing/core/badge/UnbreakableBadgeProgressTest.java b/src/test/java/io/trygvis/esper/testing/core/badge/UnbreakableBadgeProgressTest.java
index 42ca98d..b50693d 100644
--- a/src/test/java/io/trygvis/esper/testing/core/badge/UnbreakableBadgeProgressTest.java
+++ b/src/test/java/io/trygvis/esper/testing/core/badge/UnbreakableBadgeProgressTest.java
@@ -15,7 +15,8 @@ public class UnbreakableBadgeProgressTest extends TestCase {
UUID uuid = randomUUID();
public void testBadge() {
- BuildDto build = new BuildDto(uuid, new DateTime(), new DateTime(), true, null);
+ BuildDto success = new BuildDto(uuid, new DateTime(), new DateTime(), true, null);
+ BuildDto failure = new BuildDto(uuid, new DateTime(), new DateTime(), false, null);
UUID person = randomUUID();
@@ -24,7 +25,7 @@ public class UnbreakableBadgeProgressTest extends TestCase {
List<UnbreakableBadge> badges = new ArrayList<>();
for (int i = 0; i < 55; i++) {
- P2<UnbreakableBadgeProgress, Option<UnbreakableBadge>> p2 = p.onBuild(build);
+ P2<UnbreakableBadgeProgress, Option<UnbreakableBadge>> p2 = p.onBuild(success);
if (p2._2().isSome()) {
badges.add(p2._2().some());
@@ -38,5 +39,10 @@ public class UnbreakableBadgeProgressTest extends TestCase {
assertEquals(1, badges.get(0).level);
assertEquals(2, badges.get(1).level);
assertEquals(3, badges.get(2).level);
+
+ P2<UnbreakableBadgeProgress, Option<UnbreakableBadge>> p2 = p.onBuild(failure);
+
+ assertEquals(0, p2._1().count);
+ assertFalse(p2._2().isSome());
}
}