diff --git a/src/main/java/fr/plil/sio/web/mvc/ApplicationSecurityConfiguration.java b/src/main/java/fr/plil/sio/web/mvc/ApplicationSecurityConfiguration.java index e2c39fe..f55d0e7 100644 --- a/src/main/java/fr/plil/sio/web/mvc/ApplicationSecurityConfiguration.java +++ b/src/main/java/fr/plil/sio/web/mvc/ApplicationSecurityConfiguration.java @@ -31,6 +31,7 @@ public class ApplicationSecurityConfiguration extends WebSecurityConfigurerAdapt .antMatchers("/js/**").permitAll() .antMatchers("/css/**").permitAll() .antMatchers("/bootstrap/**").permitAll() + .antMatchers("/img/**").permitAll() .anyRequest().authenticated() .and() .formLogin() diff --git a/src/main/java/fr/plil/sio/web/mvc/DetteRepository.java b/src/main/java/fr/plil/sio/web/mvc/DetteRepository.java index c497498..5fa132e 100644 --- a/src/main/java/fr/plil/sio/web/mvc/DetteRepository.java +++ b/src/main/java/fr/plil/sio/web/mvc/DetteRepository.java @@ -11,5 +11,7 @@ import org.springframework.data.jpa.repository.JpaRepository; public interface DetteRepository extends JpaRepository{ Dette findById(Long id); List findByBorrower(User borrower); - + + List findByCreditor(User creditor); + } diff --git a/src/main/java/fr/plil/sio/web/mvc/UserRestController.java b/src/main/java/fr/plil/sio/web/mvc/UserRestController.java index 09f0c89..ee8417e 100644 --- a/src/main/java/fr/plil/sio/web/mvc/UserRestController.java +++ b/src/main/java/fr/plil/sio/web/mvc/UserRestController.java @@ -7,6 +7,8 @@ import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.util.List; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.web.bind.annotation.RequestParam; @RestController @@ -20,6 +22,13 @@ public class UserRestController { return userService.findAll(); } + @RequestMapping(value="/api/connectedUser/",method=RequestMethod.GET) + public User connectedUser() { + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + User usr = (User)authentication.getPrincipal(); + return usr; + } + @RequestMapping(value = "/api/users/{username}/", method = RequestMethod.GET) public User listUsers(@PathVariable String username) { return userService.findByUsername(username); @@ -30,6 +39,11 @@ public class UserRestController { return userService.findDettes(); } + @RequestMapping(value = "/api/creances/", method = RequestMethod.GET) + public List listCreances(){ + return userService.findCreances(); + } + @RequestMapping(value = "/api/addDette/", method = RequestMethod.POST) public Dette addDette(@RequestParam(value="username",required=false) String username,@RequestParam(value="sommeDette",required=false) String sommeDette) { return userService.addDette(username,sommeDette); diff --git a/src/main/java/fr/plil/sio/web/mvc/UserService.java b/src/main/java/fr/plil/sio/web/mvc/UserService.java index 43cc53d..b79ec78 100644 --- a/src/main/java/fr/plil/sio/web/mvc/UserService.java +++ b/src/main/java/fr/plil/sio/web/mvc/UserService.java @@ -10,6 +10,8 @@ public interface UserService { User findByUsername(String username); List findDettes(); + + List findCreances(); List findAll(); diff --git a/src/main/java/fr/plil/sio/web/mvc/UserServiceImpl.java b/src/main/java/fr/plil/sio/web/mvc/UserServiceImpl.java index 0bd8b5f..0559a5c 100644 --- a/src/main/java/fr/plil/sio/web/mvc/UserServiceImpl.java +++ b/src/main/java/fr/plil/sio/web/mvc/UserServiceImpl.java @@ -56,6 +56,14 @@ public class UserServiceImpl implements UserService { @Override @Transactional(readOnly = true) + public List findCreances() { + String username = securityService.findLoggedInUsername(); + User user = userRepository.findByUsername(username); + return detteRepository.findByCreditor(user); + } + + @Override + @Transactional(readOnly = true) public List findAll() { return userRepository.findAll(); } diff --git a/src/main/webapp/WEB-INF/pages/viewUsers.jsp b/src/main/webapp/WEB-INF/pages/viewUsers.jsp index 1f484e9..943ebcb 100644 --- a/src/main/webapp/WEB-INF/pages/viewUsers.jsp +++ b/src/main/webapp/WEB-INF/pages/viewUsers.jsp @@ -1,17 +1,35 @@ +<%@page import="org.springframework.security.core.context.SecurityContextHolder"%> +<%@page import="org.springframework.security.core.Authentication"%> <%@ page contentType="text/html" pageEncoding="UTF-8" %> <%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ page session="true" %> - +
- +
-
+
@@ -37,23 +55,41 @@
-
+ + -
- - - - - - - +
EmprunteurSommeAction
+ + - - - - + +
+ + + + + + + + +
CréditeurSomme
+
+ + + + + + + + + +
EmprunteurSommeAction
+
-
+ + + + diff --git a/src/main/webapp/css/kawafile.css b/src/main/webapp/css/kawafile.css index cab7582..df8899b 100644 --- a/src/main/webapp/css/kawafile.css +++ b/src/main/webapp/css/kawafile.css @@ -1,6 +1,7 @@ body{ background-color:#9cd2d2; font-size:22px; + font-family: Montserrat,"Helvetica Neue",Helvetica,Arial,sans-serif; } .signInForm { width:500px; @@ -34,7 +35,7 @@ body{ } .headerSpace { - margin-top: 150px; + margin-top: 90px; } .control-group { @@ -53,10 +54,11 @@ label { .debtsTable { margin-top:30px; - width:65%; - margin-left:auto; - margin-right:auto; + vertical-align:top; text-align:center; + width:99%; + margin:5px; + padding:5px; /*background-color:white;*/ } @@ -70,3 +72,58 @@ label { tbody { background-color:#FFEBDB; } + +.table-container { + width:70%; + margin-right:auto; + margin-left:auto; + text-align:center; +} + +.table-container>tbody { + background-color:transparent; +} + +.navbar-inverse { + background-color:#293c3c; +} + +.navbar-center +{ + position: absolute; + width: 100%; + left: 0; + top: 0; + text-align: center; + vertical-align:top; +} + +.navbar-inverse .navbar-nav>li>a { + color:#cccccc; +} + +.navbar-inverse .navbar-nav>li>p { + margin-top:8px; + vertical-align:top; + color:#cccccc; +} + +.navbar-inverse .navbar-text{ + margin-top:5px; + color:white; +} +.title { + font-size:29px; +} + +.imgTitle { + width:200px; + height:200px; + text-align:center; +} + +img { + display: block; + margin: 0 auto; + margin-bottom:30px; +} \ No newline at end of file diff --git a/src/main/webapp/img/money_icon.png b/src/main/webapp/img/money_icon.png new file mode 100644 index 0000000..3110177 Binary files /dev/null and b/src/main/webapp/img/money_icon.png differ diff --git a/src/main/webapp/js/kawafile.js b/src/main/webapp/js/kawafile.js index 7cc9f4c..b35f38a 100644 --- a/src/main/webapp/js/kawafile.js +++ b/src/main/webapp/js/kawafile.js @@ -1,5 +1,13 @@ var debtsOfUser = []; +function getConnectedUser(){ + var url = '/api/connectedUser/'; + $.getJSON(url,function(d){ + $("#usrCo").html(d.username); + }); + +} + function getDebtsOfUser(){ var url = "/api/debts/"; var html =""; @@ -8,6 +16,23 @@ function getDebtsOfUser(){ $.each(d,function(index,item){ html+=""; html+=""+item.creditor.username+""; + html+=""+item.sommeDette+""; + html+=""; + }); + + $("#dettes").html(html); + }); + +} + +function getCreancesOfUser(){ + var url = "/api/creances/"; + var html =""; + $.getJSON(url,function(d){ + + $.each(d,function(index,item){ + html+=""; + html+=""+item.borrower.username+""; html+=""+item.sommeDette+""; html+='\n\