diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2013-01-12 18:05:04 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2013-01-12 18:05:04 +0100 |
commit | dfb72423ed82a293eec85b1b36d9e4c895d7b49c (patch) | |
tree | b3a84ac53039e1c46f75e37a875ca3d8081c8bb7 /src/main | |
parent | 4e78dad3ec73a6e342e5f2a0dbfd802810b7d330 (diff) | |
download | esper-testing-dfb72423ed82a293eec85b1b36d9e4c895d7b49c.tar.gz esper-testing-dfb72423ed82a293eec85b1b36d9e4c895d7b49c.tar.bz2 esper-testing-dfb72423ed82a293eec85b1b36d9e4c895d7b49c.tar.xz esper-testing-dfb72423ed82a293eec85b1b36d9e4c895d7b49c.zip |
o Implementing search on people page.
Diffstat (limited to 'src/main')
7 files changed, 62 insertions, 25 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 8d74264..2b74771 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 @@ -96,15 +96,24 @@ public class PersonDao { } } - public List<PersonDto> selectPersons(PageRequest pageRequest) throws SQLException { + public List<PersonDto> selectPersons(PageRequest pageRequest, Option<String> query) throws SQLException { String sql = "SELECT " + PERSON + " FROM person"; + if (query.isSome()) { + sql += " WHERE lower(name) LIKE '%' || ? || '%'"; + } + sql += orderBy(pageRequest.orderBy, "name", "created_date"); sql += " LIMIT ? OFFSET ?"; try (PreparedStatement s = c.prepareStatement(sql)) { int i = 1; + + if (query.isSome()) { + s.setString(i++, query.some()); + } + s.setInt(i++, pageRequest.count.orSome(10)); s.setInt(i, pageRequest.startIndex.orSome(0)); return toList(s, person); 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 83f5144..11935cf 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 @@ -33,11 +33,12 @@ public class CoreResource extends AbstractResource { @GET @Path("/person") - public List<PersonDetailJson> getPersons(@MagicParam final PageRequest pageRequest) throws Exception { + public List<PersonDetailJson> getPersons(@MagicParam final PageRequest pageRequest, + @QueryParam("query") final String query) throws Exception { return da.inTransaction(new CoreDaosCallback<List<PersonDetailJson>>() { protected List<PersonDetailJson> run() throws SQLException { List<PersonDetailJson> list = new ArrayList<>(); - for (PersonDto person : daos.personDao.selectPersons(pageRequest)) { + for (PersonDto person : daos.personDao.selectPersons(pageRequest, fromNull(query))) { list.add(super.getPersonDetailJson.apply(person)); } return list; diff --git a/src/main/resources/webapp/apps/app.js b/src/main/resources/webapp/apps/app.js index 068f454..960f704 100755 --- a/src/main/resources/webapp/apps/app.js +++ b/src/main/resources/webapp/apps/app.js @@ -92,6 +92,8 @@ directives.directive('personAvatar', function () { scope: { person: '=person' }, - template: '<img ng-src="{{person.gravatar}}?default=identicon" class="avatar-image avatar80" title="{{person.name}}"/>' + template: '<a href="#/person/{{person.uuid}}">' + + '<img ng-src="{{person.gravatar}}?default=identicon" class="avatar-image avatar80" title="{{person.name}}"/>' + + '</a>' } }); diff --git a/src/main/resources/webapp/apps/core/PagingTableService.js b/src/main/resources/webapp/apps/core/PagingTableService.js index af593df..f550a39 100755 --- a/src/main/resources/webapp/apps/core/PagingTableService.js +++ b/src/main/resources/webapp/apps/core/PagingTableService.js @@ -4,12 +4,13 @@ function PagingTableService() { var watcher = options.watcher || function(){}; var self = { rows: [], + query: "", startIndex: options.startIndex || 0, count: options.count || 10 }; var update = function(){ - fetchCallback(self.startIndex, self.count, function(data) { + fetchCallback(self.startIndex, self.count, self.query, function(data) { self.rows = data.rows; watcher(); }); @@ -33,6 +34,16 @@ function PagingTableService() { update(); }; + self.onSearch = function () { + console.log("search: " + self.query); + update(); + }; + + self.onSearchChange = function () { + console.log("search: " + self.query); + update(); + }; + // Do an initial fetch update(); @@ -41,13 +52,16 @@ function PagingTableService() { var defaultCallback = function(Resource, args) { args = args || {}; - return function(startIndex, count, cb) { + return function(startIndex, count, query, cb) { if(startIndex) { args.startIndex = startIndex; } if(count) { args.count = count; } + if(query) { + args.query = query; + } console.log("fetching", args); Resource.query(args, function(data, headers) { var totalResults = headers("total-results"); diff --git a/src/main/resources/webapp/apps/frontPageApp/buildList.html b/src/main/resources/webapp/apps/frontPageApp/buildList.html index 13a1dc3..c6196d4 100755 --- a/src/main/resources/webapp/apps/frontPageApp/buildList.html +++ b/src/main/resources/webapp/apps/frontPageApp/buildList.html @@ -16,27 +16,23 @@ } </style> + <div class="row" ng-repeat="build in builds.rows"> + <div class="span12"> + <h3> + {{build.build.timestamp | date:'medium'}}: + <span class="success" ng-show="build.build.success">SUCCESS</span> + <span class="error" ng-hide="build.build.success">FAILURE</span> + </h3> + + <h4>Participants</h4> + <span ng-repeat="p in build.participants"> + <person-avatar person="p"></person-avatar> + </span> + </div> + </div> + <div class="row"> <div class="span12"> - <table class="table"> - <tbody ng-repeat="build in builds.rows"> - <tr class="{{{true: 'success', false: 'error'}[build.build.success]}}"> - <td>{{build.build.timestamp | date:'medium'}}</td> - <td> - <span ng-show="build.build.success">SUCCESS</span> - <span ng-hide="build.build.success">FAILURE</span> - </td> - <td><a class="btn" href="/build/{{build.build.uuid}}"><i class="icon-chevron-right"></i></a></td> - </tr> - <tr> - <td colspan="3"> - <span ng-repeat="p in build.participants"> - <person-avatar person="p"/> - </span> - </td> - </tr> - </tbody> - </table> <ul class="pager"> <li class="previous" ng-show="builds.startIndex > 0"> <a ng-click="builds.prev()">← Prev</a> diff --git a/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js b/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js index e16d96e..de8a7b6 100755 --- a/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js +++ b/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js @@ -9,6 +9,7 @@ var frontPageApp = angular.module('frontPageApp', ['ngGrid', 'person', 'badge', when('/person/:personUuid', {controller: PersonCtrl, templateUrl: '/apps/frontPageApp/person.html?noCache=' + noCache}). when('/build/', {controller: BuildListCtrl, templateUrl: '/apps/frontPageApp/buildList.html?noCache=' + noCache}). when('/build/:buildUuid', {controller: BuildCtrl, templateUrl: '/apps/frontPageApp/build.html?noCache=' + noCache}); + // job/:jobUuid/build/:buildUuid }); function FrontPageCtrl($scope, Person, Badge) { @@ -78,6 +79,9 @@ function PersonListCtrl($scope, Person, PagingTableService) { $scope.persons = PagingTableService.create($scope, PagingTableService.defaultCallback(Person, {orderBy: "name"}), {count: groupSize * 6, watcher: personsWatcher}); + console.log("$scope.persons.searchText", $scope.persons.searchText); + console.log("$scope.persons.rows", $scope.persons.rows); + $scope.personGroups = []; } diff --git a/src/main/resources/webapp/apps/frontPageApp/personList.html b/src/main/resources/webapp/apps/frontPageApp/personList.html index 5d7d8c6..41f2f63 100755 --- a/src/main/resources/webapp/apps/frontPageApp/personList.html +++ b/src/main/resources/webapp/apps/frontPageApp/personList.html @@ -22,6 +22,17 @@ <div class="row"> <div class="span12"> + <form class="form-search well"> + <div class="input-append"> + <input type="text" class="span2 search-query" ng-model="persons.query" ng-change="persons.onSearchChange()"> + <button type="submit" class="btn" ng-click="persons.onSearch()">Search</button> + </div> + </form> + </div> + </div> + + <div class="row"> + <div class="span12"> <div class="row" ng-repeat="group in personGroups"> <div class="span3" ng-repeat="person in group" style="padding-bottom: 1em"> <div class="row"> |