aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-01-17 22:56:32 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2013-01-17 22:56:32 +0100
commit20f0391fc5cc5e87f96f838767bed8b4d707928d (patch)
treea96a11db8d57845ca6b5534453a5a2f9d5c6daa7 /src/main
parent4e75fdc85ff2a9e04d1820a3a2f8dc62e431295b (diff)
downloadesper-testing-20f0391fc5cc5e87f96f838767bed8b4d707928d.tar.gz
esper-testing-20f0391fc5cc5e87f96f838767bed8b4d707928d.tar.bz2
esper-testing-20f0391fc5cc5e87f96f838767bed8b4d707928d.tar.xz
esper-testing-20f0391fc5cc5e87f96f838767bed8b4d707928d.zip
o Adding "jenkins_users" to the JSON representation of a person.
o Showing the avatar on the person page too.
Diffstat (limited to 'src/main')
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/core/db/PersonDao.java9
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/web/resource/CoreResource.java11
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/web/resource/JenkinsResource.java11
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/web/resource/PersonJson.java4
-rwxr-xr-xsrc/main/resources/webapp/WEB-INF/tags/common/head.tagx1
-rwxr-xr-xsrc/main/resources/webapp/apps/core/navbar.html8
-rwxr-xr-xsrc/main/resources/webapp/apps/frontPageApp/frontPageApp.js10
-rwxr-xr-xsrc/main/resources/webapp/apps/frontPageApp/person.html13
-rwxr-xr-x[-rw-r--r--]src/main/resources/webapp/apps/jenkinsApp/JenkinsResources.js8
-rwxr-xr-xsrc/main/resources/webapp/jenkins/index.jspx1
10 files changed, 60 insertions, 16 deletions
diff --git a/src/main/java/io/trygvis/esper/testing/core/db/PersonDao.java b/src/main/java/io/trygvis/esper/testing/core/db/PersonDao.java
index 2b74771..290d6d5 100755
--- a/src/main/java/io/trygvis/esper/testing/core/db/PersonDao.java
+++ b/src/main/java/io/trygvis/esper/testing/core/db/PersonDao.java
@@ -11,6 +11,7 @@ import java.util.List;
import java.util.*;
import static io.trygvis.esper.testing.Util.*;
+import static io.trygvis.esper.testing.util.sql.ResultSetF.getUUID;
import static io.trygvis.esper.testing.util.sql.SqlOption.*;
import static java.lang.System.*;
@@ -147,6 +148,14 @@ public class PersonDao {
}
}
+ public List<UUID> selectJenkinsUserUuidsByPerson(Uuid person) throws SQLException {
+ try (PreparedStatement s = c.prepareStatement("SELECT jenkins_user FROM person_jenkins_user WHERE person=?")) {
+ int i = 1;
+ s.setString(i, person.toUuidString());
+ return toList(s, getUUID);
+ }
+ }
+
public boolean hasPersonJenkinsUser(Uuid person, UUID jenkinsUser) throws SQLException {
try (PreparedStatement s = c.prepareStatement("SELECT 1 FROM person_jenkins_user WHERE person=? AND jenkins_user=?")) {
int i = 1;
diff --git a/src/main/java/io/trygvis/esper/testing/web/resource/CoreResource.java b/src/main/java/io/trygvis/esper/testing/web/resource/CoreResource.java
index e95b7fa..9a69a75 100755
--- a/src/main/java/io/trygvis/esper/testing/web/resource/CoreResource.java
+++ b/src/main/java/io/trygvis/esper/testing/web/resource/CoreResource.java
@@ -35,11 +35,6 @@ public class CoreResource extends AbstractResource {
@Path("/person")
public List<PersonDetailJson> getPersons(@MagicParam final PageRequest pageRequest,
@QueryParam("query") final String query) throws Exception {
-
- int sleep = 1;
- System.out.println("Awesome");
- Thread.sleep(sleep * 1000);
-
return da.inTransaction(new CoreDaosCallback<List<PersonDetailJson>>() {
protected List<PersonDetailJson> run() throws SQLException {
List<PersonDetailJson> list = new ArrayList<>();
@@ -190,11 +185,13 @@ public class CoreResource extends AbstractResource {
badgesInProgress.add(getBadge(progress));
}
+ List<UUID> jenkinsUserUuid = daos.personDao.selectJenkinsUserUuidsByPerson(person.uuid);
+
return new PersonDetailJson(
getPersonJson.apply(person),
badges,
- badgesInProgress
- );
+ badgesInProgress,
+ jenkinsUserUuid);
}
};
diff --git a/src/main/java/io/trygvis/esper/testing/web/resource/JenkinsResource.java b/src/main/java/io/trygvis/esper/testing/web/resource/JenkinsResource.java
index 21bfe19..0c0c6a9 100755
--- a/src/main/java/io/trygvis/esper/testing/web/resource/JenkinsResource.java
+++ b/src/main/java/io/trygvis/esper/testing/web/resource/JenkinsResource.java
@@ -103,6 +103,17 @@ public class JenkinsResource extends AbstractResource {
});
}
+ @GET
+ @Path("/user/{uuid}")
+ @Produces(MediaType.APPLICATION_JSON)
+ public JenkinsUserJson getUser(@MagicParam final UUID user) throws Exception {
+ return sql(new JenkinsDaosCallback<SqlOption<JenkinsUserJson>>() {
+ protected SqlOption<JenkinsUserJson> run() throws SQLException {
+ return daos.jenkinsDao.selectUser(user).map(getJenkinsUserJson);
+ }
+ });
+ }
+
public static UUID parseUuid(String s) {
try {
return UUID.fromString(s);
diff --git a/src/main/java/io/trygvis/esper/testing/web/resource/PersonJson.java b/src/main/java/io/trygvis/esper/testing/web/resource/PersonJson.java
index 285ae8e..21fd110 100755
--- a/src/main/java/io/trygvis/esper/testing/web/resource/PersonJson.java
+++ b/src/main/java/io/trygvis/esper/testing/web/resource/PersonJson.java
@@ -25,10 +25,12 @@ class PersonDetailJson {
public final PersonJson person;
public final List<BadgeJson> badges;
public final List<BadgeJson> badgesInProgress;
+ public final List<UUID> jenkinsUsers;
- public PersonDetailJson(PersonJson person, List<BadgeJson> badges, List<BadgeJson> badgesInProgress) {
+ PersonDetailJson(PersonJson person, List<BadgeJson> badges, List<BadgeJson> badgesInProgress, List<UUID> jenkinsUsers) {
this.person = person;
this.badges = badges;
this.badgesInProgress = badgesInProgress;
+ this.jenkinsUsers = jenkinsUsers;
}
}
diff --git a/src/main/resources/webapp/WEB-INF/tags/common/head.tagx b/src/main/resources/webapp/WEB-INF/tags/common/head.tagx
index 7121fe1..2c060b5 100755
--- a/src/main/resources/webapp/WEB-INF/tags/common/head.tagx
+++ b/src/main/resources/webapp/WEB-INF/tags/common/head.tagx
@@ -31,6 +31,7 @@
{datejs: "/external/datejs-Alpha1/date.js"},
{spin: "/external/spin-1.2.7/spin.js"},
{app: "/apps/app.js"},
+ {JenkinsResources: "/apps/jenkinsApp/JenkinsResources.js"},
{PagingTableService: "/apps/core/PagingTableService.js"}
);
</script>
diff --git a/src/main/resources/webapp/apps/core/navbar.html b/src/main/resources/webapp/apps/core/navbar.html
index 9226f2e..672b1e3 100755
--- a/src/main/resources/webapp/apps/core/navbar.html
+++ b/src/main/resources/webapp/apps/core/navbar.html
@@ -4,10 +4,10 @@
<span class="brand"><a href="/">Wat</a></span>
<div class="nav-collapse collapse">
<ul class="nav">
- <li class=""><a href="#/">Home</a></li>
- <li class=""><a href="#/badge/">Badges</a></li>
- <li class=""><a href="#/person/">People</a></li>
- <li class=""><a href="#/build/">Builds</a></li>
+ <li class=""><a href="/#/">Home</a></li>
+ <li class=""><a href="/#/badge/">Badges</a></li>
+ <li class=""><a href="/#/person/">People</a></li>
+ <li class=""><a href="/#/build/">Builds</a></li>
<li class="divider-vertical"></li>
<li class=""><a href="/jenkins">Jenkins</a></li>
</ul>
diff --git a/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js b/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js
index def1e67..fb3c22c 100755
--- a/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js
+++ b/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js
@@ -1,6 +1,6 @@
'use strict';
-var frontPageApp = angular.module('frontPageApp', ['ngGrid', 'person', 'badge', 'build', 'pagingTableService', 'core.directives']).config(function ($routeProvider) {
+var frontPageApp = angular.module('frontPageApp', ['ngGrid', 'person', 'badge', 'build', 'jenkinsUser', '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}).
@@ -85,7 +85,7 @@ function PersonListCtrl($scope, Person, PagingTableService) {
$scope.personGroups = [];
}
-function PersonCtrl($scope, $routeParams, Person, Build, PagingTableService) {
+function PersonCtrl($scope, $routeParams, Person, Build, JenkinsUser, PagingTableService) {
var personUuid = $routeParams.personUuid;
$scope.mode = 'overview';
@@ -107,6 +107,12 @@ function PersonCtrl($scope, $routeParams, Person, Build, PagingTableService) {
Person.get({uuid: personUuid}, function (person) {
$scope.person = person;
+
+ $scope.jenkinsUsers = person.jenkinsUsers;
+ _.forEach(person.jenkinsUsers, function(uuid, i) {
+ JenkinsUser.get({uuid: uuid}, function(user) {
+ $scope.jenkinsUsers[i] = user;
+ })});
});
Build.query({person: personUuid}, function (builds) {
diff --git a/src/main/resources/webapp/apps/frontPageApp/person.html b/src/main/resources/webapp/apps/frontPageApp/person.html
index 189523c..5da1b20 100755
--- a/src/main/resources/webapp/apps/frontPageApp/person.html
+++ b/src/main/resources/webapp/apps/frontPageApp/person.html
@@ -3,12 +3,13 @@
<navbar/>
<div class="page-header">
- <h1>{{person.person.name}}</h1>
+ <h1><person-avatar person="person.person"></person-avatar> {{person.person.name}}</h1>
</div>
<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>
+ <li ng-class="{active: mode == 'jenkins'}"><a ng-click="setMode('jenkins')">Jenkins</a></li>
</ul>
<div id="overview" ng-show="mode == 'overview'" class="row">
@@ -91,4 +92,14 @@
</tfoot>
</table>
</div>
+
+ <div id="jenkins" ng-show="mode == 'jenkins'">
+ <h3>Jenkins</h3>
+ <ul>
+ <li ng-repeat="user in jenkinsUsers">
+ <span ng-hide="user.uuid != null">Loading user: <code>{{user}}</code> -{{user.uuid != null}}-</span>
+ <span ng-show="user.uuid != null"><a href="{{user.absoluteUrl}}">{{user.absoluteUrl}}</a></span>
+ </li>
+ </ul>
+ </div>
</div>
diff --git a/src/main/resources/webapp/apps/jenkinsApp/JenkinsResources.js b/src/main/resources/webapp/apps/jenkinsApp/JenkinsResources.js
index 89f3139..6d91994 100644..100755
--- a/src/main/resources/webapp/apps/jenkinsApp/JenkinsResources.js
+++ b/src/main/resources/webapp/apps/jenkinsApp/JenkinsResources.js
@@ -23,3 +23,11 @@ function JenkinsBuild($resource) {
angular.
module('jenkinsBuild', ['ngResource']).
factory('JenkinsBuild', JenkinsBuild);
+
+function JenkinsUser($resource) {
+ return $resource('/resource/jenkins/user/:uuid', {uuid: '@uuid'});
+}
+
+angular.
+ module('jenkinsUser', ['ngResource']).
+ factory('JenkinsUser', JenkinsUser);
diff --git a/src/main/resources/webapp/jenkins/index.jspx b/src/main/resources/webapp/jenkins/index.jspx
index 0e8dc22..a26b07d 100755
--- a/src/main/resources/webapp/jenkins/index.jspx
+++ b/src/main/resources/webapp/jenkins/index.jspx
@@ -5,7 +5,6 @@
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<common:head>
- <common:headjs label="JenkinsResources" resource="/apps/jenkinsApp/JenkinsResources.js"/>
<common:headjs label="PagingTableService" resource="/apps/core/PagingTableService.js"/>
<common:headjs label="jenkinsApp" resource="/apps/jenkinsApp/jenkinsApp.js"/>
</common:head>