Commit 95ea306a1e55141d2f30a36e8ca222a2ff7f8f6b
1 parent
8a362652
Ajout css, img et refonte graphique
Showing
9 changed files
with
173 additions
and
30 deletions
Show diff stats
src/main/java/fr/plil/sio/web/mvc/ApplicationSecurityConfiguration.java
@@ -31,6 +31,7 @@ public class ApplicationSecurityConfiguration extends WebSecurityConfigurerAdapt | @@ -31,6 +31,7 @@ public class ApplicationSecurityConfiguration extends WebSecurityConfigurerAdapt | ||
31 | .antMatchers("/js/**").permitAll() | 31 | .antMatchers("/js/**").permitAll() |
32 | .antMatchers("/css/**").permitAll() | 32 | .antMatchers("/css/**").permitAll() |
33 | .antMatchers("/bootstrap/**").permitAll() | 33 | .antMatchers("/bootstrap/**").permitAll() |
34 | + .antMatchers("/img/**").permitAll() | ||
34 | .anyRequest().authenticated() | 35 | .anyRequest().authenticated() |
35 | .and() | 36 | .and() |
36 | .formLogin() | 37 | .formLogin() |
src/main/java/fr/plil/sio/web/mvc/DetteRepository.java
@@ -11,5 +11,7 @@ import org.springframework.data.jpa.repository.JpaRepository; | @@ -11,5 +11,7 @@ import org.springframework.data.jpa.repository.JpaRepository; | ||
11 | public interface DetteRepository extends JpaRepository<Dette,Long>{ | 11 | public interface DetteRepository extends JpaRepository<Dette,Long>{ |
12 | Dette findById(Long id); | 12 | Dette findById(Long id); |
13 | List<Dette> findByBorrower(User borrower); | 13 | List<Dette> findByBorrower(User borrower); |
14 | - | 14 | + |
15 | + List<Dette> findByCreditor(User creditor); | ||
16 | + | ||
15 | } | 17 | } |
src/main/java/fr/plil/sio/web/mvc/UserRestController.java
@@ -7,6 +7,8 @@ import org.springframework.web.bind.annotation.RestController; | @@ -7,6 +7,8 @@ import org.springframework.web.bind.annotation.RestController; | ||
7 | 7 | ||
8 | import javax.annotation.Resource; | 8 | import javax.annotation.Resource; |
9 | import java.util.List; | 9 | import java.util.List; |
10 | +import org.springframework.security.core.Authentication; | ||
11 | +import org.springframework.security.core.context.SecurityContextHolder; | ||
10 | import org.springframework.web.bind.annotation.RequestParam; | 12 | import org.springframework.web.bind.annotation.RequestParam; |
11 | 13 | ||
12 | @RestController | 14 | @RestController |
@@ -20,6 +22,13 @@ public class UserRestController { | @@ -20,6 +22,13 @@ public class UserRestController { | ||
20 | return userService.findAll(); | 22 | return userService.findAll(); |
21 | } | 23 | } |
22 | 24 | ||
25 | + @RequestMapping(value="/api/connectedUser/",method=RequestMethod.GET) | ||
26 | + public User connectedUser() { | ||
27 | + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); | ||
28 | + User usr = (User)authentication.getPrincipal(); | ||
29 | + return usr; | ||
30 | + } | ||
31 | + | ||
23 | @RequestMapping(value = "/api/users/{username}/", method = RequestMethod.GET) | 32 | @RequestMapping(value = "/api/users/{username}/", method = RequestMethod.GET) |
24 | public User listUsers(@PathVariable String username) { | 33 | public User listUsers(@PathVariable String username) { |
25 | return userService.findByUsername(username); | 34 | return userService.findByUsername(username); |
@@ -30,6 +39,11 @@ public class UserRestController { | @@ -30,6 +39,11 @@ public class UserRestController { | ||
30 | return userService.findDettes(); | 39 | return userService.findDettes(); |
31 | } | 40 | } |
32 | 41 | ||
42 | + @RequestMapping(value = "/api/creances/", method = RequestMethod.GET) | ||
43 | + public List<Dette> listCreances(){ | ||
44 | + return userService.findCreances(); | ||
45 | + } | ||
46 | + | ||
33 | @RequestMapping(value = "/api/addDette/", method = RequestMethod.POST) | 47 | @RequestMapping(value = "/api/addDette/", method = RequestMethod.POST) |
34 | public Dette addDette(@RequestParam(value="username",required=false) String username,@RequestParam(value="sommeDette",required=false) String sommeDette) { | 48 | public Dette addDette(@RequestParam(value="username",required=false) String username,@RequestParam(value="sommeDette",required=false) String sommeDette) { |
35 | return userService.addDette(username,sommeDette); | 49 | return userService.addDette(username,sommeDette); |
src/main/java/fr/plil/sio/web/mvc/UserService.java
@@ -10,6 +10,8 @@ public interface UserService { | @@ -10,6 +10,8 @@ public interface UserService { | ||
10 | User findByUsername(String username); | 10 | User findByUsername(String username); |
11 | 11 | ||
12 | List<Dette> findDettes(); | 12 | List<Dette> findDettes(); |
13 | + | ||
14 | + List<Dette> findCreances(); | ||
13 | 15 | ||
14 | List<User> findAll(); | 16 | List<User> findAll(); |
15 | 17 |
src/main/java/fr/plil/sio/web/mvc/UserServiceImpl.java
@@ -56,6 +56,14 @@ public class UserServiceImpl implements UserService { | @@ -56,6 +56,14 @@ public class UserServiceImpl implements UserService { | ||
56 | 56 | ||
57 | @Override | 57 | @Override |
58 | @Transactional(readOnly = true) | 58 | @Transactional(readOnly = true) |
59 | + public List<Dette> findCreances() { | ||
60 | + String username = securityService.findLoggedInUsername(); | ||
61 | + User user = userRepository.findByUsername(username); | ||
62 | + return detteRepository.findByCreditor(user); | ||
63 | + } | ||
64 | + | ||
65 | + @Override | ||
66 | + @Transactional(readOnly = true) | ||
59 | public List<User> findAll() { | 67 | public List<User> findAll() { |
60 | return userRepository.findAll(); | 68 | return userRepository.findAll(); |
61 | } | 69 | } |
src/main/webapp/WEB-INF/pages/viewUsers.jsp
1 | +<%@page import="org.springframework.security.core.context.SecurityContextHolder"%> | ||
2 | +<%@page import="org.springframework.security.core.Authentication"%> | ||
1 | <%@ page contentType="text/html" pageEncoding="UTF-8" %> | 3 | <%@ page contentType="text/html" pageEncoding="UTF-8" %> |
2 | <%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %> | 4 | <%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %> |
3 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> | 5 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> |
6 | +<%@ page session="true" %> | ||
4 | 7 | ||
5 | <jsp:include page="header.jsp"> | 8 | <jsp:include page="header.jsp"> |
6 | <jsp:param name="pageTitle" value="View users page"/> | 9 | <jsp:param name="pageTitle" value="View users page"/> |
7 | </jsp:include> | 10 | </jsp:include> |
8 | <body> | 11 | <body> |
9 | - | 12 | + <nav class="navbar navbar-inverse navbar-fixed-top"> |
13 | + <div class="container-fluid"> | ||
14 | + <div class="collapse navbar-collapse"> | ||
15 | + <p class="navbar-text navbar-center"><i class="glyphicon glyphicon-euro"></i> <span class="title">Banque</span> </p> | ||
16 | + | ||
17 | + <ul class="nav navbar-nav navbar-right"> | ||
18 | + <li> | ||
19 | + <p id="usrCo"></p> | ||
20 | + </li> | ||
21 | + <li> | ||
22 | + <a href="login?logout"><spring:message code="view.users.main.logout"/></a> | ||
23 | + </li> | ||
24 | + </ul> | ||
25 | + </div> | ||
26 | + </div> | ||
27 | + </nav> | ||
10 | 28 | ||
11 | <div class="row headerSpace"> | 29 | <div class="row headerSpace"> |
12 | - | 30 | + <img class="imgTitle" src="/img/money_icon.png" /> |
13 | </div> | 31 | </div> |
14 | - <div class="row"> | 32 | + |
15 | <div class="addDebt"> | 33 | <div class="addDebt"> |
16 | <form> | 34 | <form> |
17 | <div class="form-group"> | 35 | <div class="form-group"> |
@@ -37,23 +55,41 @@ | @@ -37,23 +55,41 @@ | ||
37 | 55 | ||
38 | </form> | 56 | </form> |
39 | </div> | 57 | </div> |
40 | - </div> | 58 | + |
59 | + | ||
41 | 60 | ||
42 | - <div class="row"> | ||
43 | - <table class="table table-stripped debtsTable"> | ||
44 | - <thead> | ||
45 | - <td>Emprunteur</td> | ||
46 | - <td>Somme</td> | ||
47 | - <td>Action</td> | ||
48 | - </thead> | ||
49 | - <tbody id="dettes"> | 61 | + <table class="table-container"> |
62 | + <tr> | ||
63 | + <td valign="top"> | ||
64 | + <table class="table table-stripped debtsTable"> | ||
65 | + <thead> | ||
66 | + <td>Crรฉditeur</td> | ||
67 | + <td>Somme</td> | ||
68 | + </thead> | ||
69 | + <tbody id="dettes"> | ||
70 | + | ||
71 | + </tbody> | ||
72 | + </table> | ||
73 | + </td> | ||
50 | 74 | ||
51 | - </tbody> | ||
52 | - | ||
53 | - | ||
54 | - | 75 | + <td valign="top"> |
76 | + <table class="table table-stripped debtsTable"> | ||
77 | + <thead> | ||
78 | + <td>Emprunteur</td> | ||
79 | + <td>Somme</td> | ||
80 | + <td>Action</td> | ||
81 | + </thead> | ||
82 | + <tbody id="creances"> | ||
83 | + | ||
84 | + </tbody> | ||
85 | + </table> | ||
86 | + </td> | ||
87 | + </tr> | ||
55 | </table> | 88 | </table> |
56 | - </div> | 89 | + |
90 | + | ||
91 | + | ||
92 | + | ||
57 | 93 | ||
58 | 94 | ||
59 | 95 |
src/main/webapp/css/kawafile.css
1 | body{ | 1 | body{ |
2 | background-color:#9cd2d2; | 2 | background-color:#9cd2d2; |
3 | font-size:22px; | 3 | font-size:22px; |
4 | + font-family: Montserrat,"Helvetica Neue",Helvetica,Arial,sans-serif; | ||
4 | } | 5 | } |
5 | .signInForm { | 6 | .signInForm { |
6 | width:500px; | 7 | width:500px; |
@@ -34,7 +35,7 @@ body{ | @@ -34,7 +35,7 @@ body{ | ||
34 | } | 35 | } |
35 | 36 | ||
36 | .headerSpace { | 37 | .headerSpace { |
37 | - margin-top: 150px; | 38 | + margin-top: 90px; |
38 | } | 39 | } |
39 | 40 | ||
40 | .control-group { | 41 | .control-group { |
@@ -53,10 +54,11 @@ label { | @@ -53,10 +54,11 @@ label { | ||
53 | 54 | ||
54 | .debtsTable { | 55 | .debtsTable { |
55 | margin-top:30px; | 56 | margin-top:30px; |
56 | - width:65%; | ||
57 | - margin-left:auto; | ||
58 | - margin-right:auto; | 57 | + vertical-align:top; |
59 | text-align:center; | 58 | text-align:center; |
59 | + width:99%; | ||
60 | + margin:5px; | ||
61 | + padding:5px; | ||
60 | /*background-color:white;*/ | 62 | /*background-color:white;*/ |
61 | } | 63 | } |
62 | 64 | ||
@@ -70,3 +72,58 @@ label { | @@ -70,3 +72,58 @@ label { | ||
70 | tbody { | 72 | tbody { |
71 | background-color:#FFEBDB; | 73 | background-color:#FFEBDB; |
72 | } | 74 | } |
75 | + | ||
76 | +.table-container { | ||
77 | + width:70%; | ||
78 | + margin-right:auto; | ||
79 | + margin-left:auto; | ||
80 | + text-align:center; | ||
81 | +} | ||
82 | + | ||
83 | +.table-container>tbody { | ||
84 | + background-color:transparent; | ||
85 | +} | ||
86 | + | ||
87 | +.navbar-inverse { | ||
88 | + background-color:#293c3c; | ||
89 | +} | ||
90 | + | ||
91 | +.navbar-center | ||
92 | +{ | ||
93 | + position: absolute; | ||
94 | + width: 100%; | ||
95 | + left: 0; | ||
96 | + top: 0; | ||
97 | + text-align: center; | ||
98 | + vertical-align:top; | ||
99 | +} | ||
100 | + | ||
101 | +.navbar-inverse .navbar-nav>li>a { | ||
102 | + color:#cccccc; | ||
103 | +} | ||
104 | + | ||
105 | +.navbar-inverse .navbar-nav>li>p { | ||
106 | + margin-top:8px; | ||
107 | + vertical-align:top; | ||
108 | + color:#cccccc; | ||
109 | +} | ||
110 | + | ||
111 | +.navbar-inverse .navbar-text{ | ||
112 | + margin-top:5px; | ||
113 | + color:white; | ||
114 | +} | ||
115 | +.title { | ||
116 | + font-size:29px; | ||
117 | +} | ||
118 | + | ||
119 | +.imgTitle { | ||
120 | + width:200px; | ||
121 | + height:200px; | ||
122 | + text-align:center; | ||
123 | +} | ||
124 | + | ||
125 | +img { | ||
126 | + display: block; | ||
127 | + margin: 0 auto; | ||
128 | + margin-bottom:30px; | ||
129 | +} | ||
73 | \ No newline at end of file | 130 | \ No newline at end of file |
192 KB
src/main/webapp/js/kawafile.js
1 | var debtsOfUser = []; | 1 | var debtsOfUser = []; |
2 | 2 | ||
3 | +function getConnectedUser(){ | ||
4 | + var url = '/api/connectedUser/'; | ||
5 | + $.getJSON(url,function(d){ | ||
6 | + $("#usrCo").html(d.username); | ||
7 | + }); | ||
8 | + | ||
9 | +} | ||
10 | + | ||
3 | function getDebtsOfUser(){ | 11 | function getDebtsOfUser(){ |
4 | var url = "/api/debts/"; | 12 | var url = "/api/debts/"; |
5 | var html =""; | 13 | var html =""; |
@@ -8,6 +16,23 @@ function getDebtsOfUser(){ | @@ -8,6 +16,23 @@ function getDebtsOfUser(){ | ||
8 | $.each(d,function(index,item){ | 16 | $.each(d,function(index,item){ |
9 | html+="<tr>"; | 17 | html+="<tr>"; |
10 | html+="<td>"+item.creditor.username+"</td>"; | 18 | html+="<td>"+item.creditor.username+"</td>"; |
19 | + html+="<td>"+item.sommeDette+"</td>"; | ||
20 | + html+="</tr>"; | ||
21 | + }); | ||
22 | + | ||
23 | + $("#dettes").html(html); | ||
24 | + }); | ||
25 | + | ||
26 | +} | ||
27 | + | ||
28 | +function getCreancesOfUser(){ | ||
29 | + var url = "/api/creances/"; | ||
30 | + var html =""; | ||
31 | + $.getJSON(url,function(d){ | ||
32 | + | ||
33 | + $.each(d,function(index,item){ | ||
34 | + html+="<tr>"; | ||
35 | + html+="<td>"+item.borrower.username+"</td>"; | ||
11 | html+="<td>"+item.sommeDette+"</td>"; | 36 | html+="<td>"+item.sommeDette+"</td>"; |
12 | html+='<td>\n\ | 37 | html+='<td>\n\ |
13 | <button class="btn btn-danger" type="submit" onclick="deleteDebt('+item.id+');">\n\ | 38 | <button class="btn btn-danger" type="submit" onclick="deleteDebt('+item.id+');">\n\ |
@@ -17,7 +42,7 @@ function getDebtsOfUser(){ | @@ -17,7 +42,7 @@ function getDebtsOfUser(){ | ||
17 | html+="</tr>"; | 42 | html+="</tr>"; |
18 | }); | 43 | }); |
19 | 44 | ||
20 | - $("#dettes").html(html); | 45 | + $("#creances").html(html); |
21 | }); | 46 | }); |
22 | 47 | ||
23 | } | 48 | } |
@@ -29,7 +54,7 @@ function deleteDebt(id){ | @@ -29,7 +54,7 @@ function deleteDebt(id){ | ||
29 | url:url + $.param({"id":id}), | 54 | url:url + $.param({"id":id}), |
30 | type:"DELETE", | 55 | type:"DELETE", |
31 | success: function(d){ | 56 | success: function(d){ |
32 | - getDebtsOfUser(); | 57 | + getCreancesOfUser(); |
33 | } | 58 | } |
34 | }); | 59 | }); |
35 | 60 | ||
@@ -54,13 +79,10 @@ function updateDebtOfUser(){ | @@ -54,13 +79,10 @@ function updateDebtOfUser(){ | ||
54 | async:false | 79 | async:false |
55 | }).done(function(d){ | 80 | }).done(function(d){ |
56 | console.log(d); | 81 | console.log(d); |
57 | - }).success(function(d){ | ||
58 | - console.log("Succes"); | 82 | + }).success(function(d){ |
59 | console.log(d); | 83 | console.log(d); |
60 | }).fail(function(d){ | 84 | }).fail(function(d){ |
61 | - alert("Erreur"); | ||
62 | - console.log("Fail"); | ||
63 | - console.log(d); | 85 | + alert("Erreur"); |
64 | }); | 86 | }); |
65 | } | 87 | } |
66 | 88 | ||
@@ -68,8 +90,9 @@ function updateDebtOfUser(){ | @@ -68,8 +90,9 @@ function updateDebtOfUser(){ | ||
68 | (function(){ | 90 | (function(){ |
69 | 'use strict'; | 91 | 'use strict'; |
70 | 92 | ||
71 | - | 93 | + getConnectedUser(); |
72 | getDebtsOfUser(); | 94 | getDebtsOfUser(); |
95 | + getCreancesOfUser(); | ||
73 | 96 | ||
74 | 97 | ||
75 | })(); | 98 | })(); |