From 115e3f68004a77c08d7e8ccfa5e69002e27283f9 Mon Sep 17 00:00:00 2001 From: sfeutrie Date: Sat, 20 Oct 2018 19:02:55 +0200 Subject: [PATCH] amélioration du frontend --- Front/test.css | 4 ++++ Front/test.html | 36 ++++++++++++++++++++++++++++++++++++ PFE06/src/main/java/com/PFE/ServerManager/CustomerRepository.java | 2 +- PFE06/src/main/java/com/PFE/ServerManager/MainController.java | 37 +++++++++++++++++++++++++++++++------ PFE06/src/main/java/com/PFE/ServerManager/SecurityConfig.java | 1 + PFE06/src/main/resources/application.properties | 4 ++-- PFE06/src/main/resources/static/css/all.css | 5 +++++ PFE06/src/main/resources/static/css/home.css | 21 ++++++++++++++++++++- PFE06/src/main/resources/static/css/registration.css | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ PFE06/src/main/resources/templates/all.html | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ PFE06/src/main/resources/templates/home.html | 86 +++++++++++++++++++++++++++++--------------------------------------------------------- PFE06/src/main/resources/templates/registration.html | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------- 12 files changed, 312 insertions(+), 95 deletions(-) create mode 100644 Front/test.css create mode 100644 Front/test.html create mode 100644 PFE06/src/main/resources/static/css/all.css create mode 100644 PFE06/src/main/resources/static/css/registration.css create mode 100644 PFE06/src/main/resources/templates/all.html diff --git a/Front/test.css b/Front/test.css new file mode 100644 index 0000000..a844b4e --- /dev/null +++ b/Front/test.css @@ -0,0 +1,4 @@ + .inline-form input { + display: inline-block; + width: 100px; + } \ No newline at end of file diff --git a/Front/test.html b/Front/test.html new file mode 100644 index 0000000..01eeeb8 --- /dev/null +++ b/Front/test.html @@ -0,0 +1,36 @@ + + + + Bootstrap template + + + + + + + + + + + + \ No newline at end of file diff --git a/PFE06/src/main/java/com/PFE/ServerManager/CustomerRepository.java b/PFE06/src/main/java/com/PFE/ServerManager/CustomerRepository.java index 7bea20f..be0c204 100644 --- a/PFE06/src/main/java/com/PFE/ServerManager/CustomerRepository.java +++ b/PFE06/src/main/java/com/PFE/ServerManager/CustomerRepository.java @@ -10,7 +10,7 @@ import org.springframework.stereotype.Repository; //This class allows the JPA to know that the Customer class is a table //Need to check if "extends JpaRepository is more useful" @Repository -public interface CustomerRepository extends CrudRepository { +public interface CustomerRepository extends JpaRepository { Customer findByPseudo(String pseudo); diff --git a/PFE06/src/main/java/com/PFE/ServerManager/MainController.java b/PFE06/src/main/java/com/PFE/ServerManager/MainController.java index 1db8cad..92d51a2 100644 --- a/PFE06/src/main/java/com/PFE/ServerManager/MainController.java +++ b/PFE06/src/main/java/com/PFE/ServerManager/MainController.java @@ -3,19 +3,17 @@ package com.PFE.ServerManager; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; -import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; import java.io.*; import java.sql.Timestamp; -import java.util.Arrays; -import java.util.HashSet; +import java.util.*; + import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.Authentication; -import org.springframework.web.context.request.RequestContextHolder; import javax.servlet.annotation.MultipartConfig; @@ -54,6 +52,7 @@ public class MainController { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); Customer customer = customerRepository.findByPseudo(auth.getName()); modelAndView.addObject("customerName", customer.getPseudo()); + modelAndView.addObject("customerRole", customer.getRole()); modelAndView.setViewName("registration"); return modelAndView; } @@ -75,7 +74,13 @@ public class MainController { Customer temp = customerRepository.findByPseudo(pseudo); Role userRole = roleRepository.findByRole(role); n.setRoles(new HashSet(Arrays.asList(userRole))); - + //utilisé uniquement pour continuer à afficher l'utilisateur connecté// + Authentication auth = SecurityContextHolder.getContext().getAuthentication(); + Customer customer = customerRepository.findByPseudo(auth.getName()); + modelAndView.addObject("customerName", customer.getPseudo()); + modelAndView.addObject("customerRole", customer.getRole()); + modelAndView.setViewName("registration"); + /////// if(temp != null) { modelAndView.addObject("ok", "l'utilisateur existe déjà"); } @@ -140,11 +145,31 @@ public class MainController { return modelAndView; } - @GetMapping(path="/all") + /*@GetMapping(path="/all") public @ResponseBody Iterable getAllUsers() { return customerRepository.findAll(); + }*/ + @GetMapping(path="/all") + public ModelAndView getAllUsers() { + ModelAndView modelAndView = new ModelAndView(); + modelAndView.setViewName("all"); + + Authentication auth = SecurityContextHolder.getContext().getAuthentication(); + Customer customer = customerRepository.findByPseudo(auth.getName()); + modelAndView.addObject("customerName", customer.getPseudo()); + modelAndView.addObject("customerRole", customer.getRole()); + + /*List list = new ArrayList(); + Iterator listIterator = customerRepository.findAll().iterator(); + while (listIterator.hasNext()) { + list.add(listIterator.next()); + }*/ + List list = customerRepository.findAll(); // attention : la méthode findAll() de JpaRepository retourne une liste alors que celle de CrudRepository retourne un itérable + modelAndView.addObject("list",list); + return modelAndView; } + @GetMapping(value="/success") public String success(){ return "success"; diff --git a/PFE06/src/main/java/com/PFE/ServerManager/SecurityConfig.java b/PFE06/src/main/java/com/PFE/ServerManager/SecurityConfig.java index 92c8084..dd3ad91 100644 --- a/PFE06/src/main/java/com/PFE/ServerManager/SecurityConfig.java +++ b/PFE06/src/main/java/com/PFE/ServerManager/SecurityConfig.java @@ -36,6 +36,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { .authorizeRequests() .antMatchers("/home").hasAnyAuthority("USER","ADMIN") .antMatchers("/registration").hasAuthority("ADMIN") + .antMatchers("/all").hasAuthority("ADMIN") .antMatchers("/login").permitAll() .antMatchers("/denied").permitAll() .antMatchers("/css/**", "/js/**").permitAll() diff --git a/PFE06/src/main/resources/application.properties b/PFE06/src/main/resources/application.properties index 8940957..08b2821 100644 --- a/PFE06/src/main/resources/application.properties +++ b/PFE06/src/main/resources/application.properties @@ -8,9 +8,9 @@ spring.jpa.hibernate.ddl-auto=create #"update" met à jour la base données #Postgres config : -spring.datasource.url=jdbc:postgresql://localhost:3306/sql_only +spring.datasource.url=jdbc:postgresql://localhost:5432/sql_only spring.datasource.username=postgres -spring.datasource.password=admin +spring.datasource.password=idalurf123 # montre les communications JPA avec la BDD diff --git a/PFE06/src/main/resources/static/css/all.css b/PFE06/src/main/resources/static/css/all.css new file mode 100644 index 0000000..d735088 --- /dev/null +++ b/PFE06/src/main/resources/static/css/all.css @@ -0,0 +1,5 @@ +.dropdown-item.active{ + background-color: #ffffff !important; + color:#212529 !important; + font-weight: bold !important; +} \ No newline at end of file diff --git a/PFE06/src/main/resources/static/css/home.css b/PFE06/src/main/resources/static/css/home.css index f1a3ac6..e4b4bb9 100644 --- a/PFE06/src/main/resources/static/css/home.css +++ b/PFE06/src/main/resources/static/css/home.css @@ -1,5 +1,5 @@ body { background-color: #FFF; } - +/* .upload-drop-zone { height: 200px; border-width: 2px; @@ -9,4 +9,23 @@ body { background-color: #FFF; } border-color: #ccc; line-height: 200px; text-align: center +}*/ +/* +body { + padding-top: 70px; + padding-bottom: 30px; +}*/ + +.theme-dropdown .dropdown-menu { + position: static; + display: block; + margin-bottom: 20px; +} + +.theme-showcase > p > .btn { + margin: 5px 0; +} + +.theme-showcase .navbar .container { + width: auto; } diff --git a/PFE06/src/main/resources/static/css/registration.css b/PFE06/src/main/resources/static/css/registration.css new file mode 100644 index 0000000..9c8cb37 --- /dev/null +++ b/PFE06/src/main/resources/static/css/registration.css @@ -0,0 +1,61 @@ +body { background-color: #E9EEF2; } + +.form-heading { color:#fff; font-size:23px; } + +.panel h2{ color:#444444; font-size:18px; margin:0 0 8px 0; } + +.panel p { color:#777777; font-size:14px; margin-bottom:30px; line-height:24px; } + +.login-form .form-control { + background: #f7f7f7 none repeat scroll 0 0; + border: 1px solid #d4d4d4; + border-radius: 4px; + font-size: 14px; + height: 50px; + line-height: 50px; +} + +.main-div { + background: #ffffff none repeat scroll 0 0; + border-radius: 5px; + margin: 50px auto; + max-width: 38%; + padding: 50px 70px 70px 71px; +} + +.login-form .form-group { + margin-bottom:10px; +} + +.login-form { text-align:center;} + +.forgot a { + color: #777777; + font-size: 14px; + text-decoration: underline; +} +.login-form .btn.btn-primary { + background: #f0ad4e none repeat scroll 0 0; + border-color: #f0ad4e; + color: #ffffff; + font-size: 14px; + width: 100%; + height: 50px; + line-height: 50px; + padding: 0; +} + +.login-form .btn.btn-primary.reset { + background: #ff9900 none repeat scroll 0 0; +} + + +.back { text-align: left; margin-top:10px; } + +.back a {color: #444444; font-size: 13px;text-decoration: none;} + +.dropdown-item.active{ + background-color: #ffffff !important; + color:#212529 !important; + font-weight: bold !important; +} \ No newline at end of file diff --git a/PFE06/src/main/resources/templates/all.html b/PFE06/src/main/resources/templates/all.html new file mode 100644 index 0000000..e1b1801 --- /dev/null +++ b/PFE06/src/main/resources/templates/all.html @@ -0,0 +1,63 @@ + + + + + + + + + + + Listes des utilisateurs dans la base de donnée + + + +
+ + + + + + + + + + + + + + + +
PseudoRoleId
pseudoroleid
+
+ + + + + + + diff --git a/PFE06/src/main/resources/templates/home.html b/PFE06/src/main/resources/templates/home.html index bf8d9b3..ed2f623 100644 --- a/PFE06/src/main/resources/templates/home.html +++ b/PFE06/src/main/resources/templates/home.html @@ -1,67 +1,50 @@ - - - - - - + + - Accueil - +
- - +
-

Choix des noeuds

- @@ -166,31 +149,21 @@ -
Software Engineer London
-

Uploader un fichier

-
-

Choix du fichier

-
Clic ou dépose un fichier ici
-
-
- -
-
- diff --git a/PFE06/src/main/resources/templates/registration.html b/PFE06/src/main/resources/templates/registration.html index 360d46d..222ba08 100644 --- a/PFE06/src/main/resources/templates/registration.html +++ b/PFE06/src/main/resources/templates/registration.html @@ -1,39 +1,70 @@ + - Ajout d'utilisateurs - + Enregistrement de nouveaux utilisateurs + + + + + -
-

est connecté(e) !

-
Ajout d'utilisateurs :
-
-
- - + + + + + + + \ No newline at end of file -- libgit2 0.21.2