# HG changeset patch # User ymh # Date 1368528513 -7200 # Node ID aaf55e08827ab02a4e213d30c55bec29f7eba6e8 # Parent aacebeedae7056c06956d4f74a4e145596936d50 Add user admin controller diff -r aacebeedae70 -r aaf55e08827a server/src/main/java/org/iri_research/renkan/controller/admin/UsersAdminController.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/main/java/org/iri_research/renkan/controller/admin/UsersAdminController.java Tue May 14 12:48:33 2013 +0200 @@ -0,0 +1,50 @@ +package org.iri_research.renkan.controller.admin; + +import javax.servlet.http.HttpServletRequest; + +import org.iri_research.renkan.Constants; +import org.iri_research.renkan.controller.Utils; +import org.iri_research.renkan.models.User; +import org.iri_research.renkan.repositories.ProjectsRepository; +import org.iri_research.renkan.repositories.UsersRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort.Direction; +import org.springframework.data.web.PageableDefaults; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +@Controller +@RequestMapping("/admin/users") +public class UsersAdminController { + + @SuppressWarnings("unused") + private final Logger logger = LoggerFactory.getLogger(UsersAdminController.class); + + @Autowired + private UsersRepository usersRepository; + + @Autowired + private ProjectsRepository projectsRepository; + + @RequestMapping(value="/", method = RequestMethod.GET, produces={"text/html;charset=UTF-8"}) + public String usersList( + Model model, + @PageableDefaults(sort={"username"}, sortDir=Direction.DESC, pageNumber=0, value=Constants.PAGINATION_SIZE) Pageable p, + HttpServletRequest request) { + + Page page = this.usersRepository.findAll(p); + + model.addAttribute("page", page); + model.addAttribute("baseUrl", Utils.buildBaseUrl(request)); + model.addAttribute("projectsCount", this.projectsRepository.getCountByUser()); + + return "admin/usersList"; + } + +} diff -r aacebeedae70 -r aaf55e08827a server/src/main/java/org/iri_research/renkan/models/User.java --- a/server/src/main/java/org/iri_research/renkan/models/User.java Fri Apr 26 19:45:37 2013 +0200 +++ b/server/src/main/java/org/iri_research/renkan/models/User.java Tue May 14 12:48:33 2013 +0200 @@ -9,7 +9,6 @@ import org.springframework.security.core.userdetails.UserDetails; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; @Document(collection="users") public class User extends AbstractRenkanModel implements UserDetails { diff -r aacebeedae70 -r aaf55e08827a server/src/main/webapp/WEB-INF/templates/admin/adminIndex.html --- a/server/src/main/webapp/WEB-INF/templates/admin/adminIndex.html Fri Apr 26 19:45:37 2013 +0200 +++ b/server/src/main/webapp/WEB-INF/templates/admin/adminIndex.html Tue May 14 12:48:33 2013 +0200 @@ -32,11 +32,14 @@ Spaces + + Users +
-
© 2013 IRI - Version 0.0
+
© 2013 IRI - Version 0.0
diff -r aacebeedae70 -r aaf55e08827a server/src/main/webapp/WEB-INF/templates/admin/usersList.html --- a/server/src/main/webapp/WEB-INF/templates/admin/usersList.html Fri Apr 26 19:45:37 2013 +0200 +++ b/server/src/main/webapp/WEB-INF/templates/admin/usersList.html Tue May 14 12:48:33 2013 +0200 @@ -39,7 +39,7 @@