From e9db206189a43f8d75763692743e461492bc1aa2 Mon Sep 17 00:00:00 2001 From: sfeutrie Date: Mon, 25 Feb 2019 22:57:19 +0100 Subject: [PATCH] Ajout de fonctionnalites sur le site --- PFE06/src/main/java/com/PFE/ServerManager/MainController.java | 54 +++++++++++++++++++++++++++++++++++++----------------- PFE06/src/main/java/com/PFE/ServerManager/Team.java | 5 +++++ PFE06/src/main/resources/templates/registration.html | 28 ++++++++++++++++++++++++---- Raspberry/config_experimentation.txt | 3 +-- Raspberry/data | Bin 13296 -> 0 bytes Raspberry/data.c | 85 ------------------------------------------------------------------------------------- Raspberry/data.cpp | 8 -------- Raspberry/listener | Bin 18232 -> 0 bytes Raspberry/listener.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++-------------------------- Raspberry/res/result_exp_mouvement_2.txt | Bin 245793 -> 0 bytes Raspberry/res/result_exp_temperature_1.txt | 1 - Raspberry/res/result_exp_wrong_file.txt | 1 - 12 files changed, 116 insertions(+), 144 deletions(-) delete mode 100644 Raspberry/data delete mode 100644 Raspberry/data.c delete mode 100644 Raspberry/data.cpp delete mode 100644 Raspberry/res/result_exp_mouvement_2.txt delete mode 100644 Raspberry/res/result_exp_temperature_1.txt delete mode 100644 Raspberry/res/result_exp_wrong_file.txt diff --git a/PFE06/src/main/java/com/PFE/ServerManager/MainController.java b/PFE06/src/main/java/com/PFE/ServerManager/MainController.java index 1098e96..450e253 100644 --- a/PFE06/src/main/java/com/PFE/ServerManager/MainController.java +++ b/PFE06/src/main/java/com/PFE/ServerManager/MainController.java @@ -121,6 +121,7 @@ public class MainController { modelAndView.addObject("succeed", succeed); System.out.println("all teams : " + teamRepository.findAll()); modelAndView.addObject("allTeams", teamRepository.findAll()); + modelAndView.addObject("allCustomers", customerRepository.findAll()); modelAndView.setViewName("registration"); return modelAndView; } @@ -130,26 +131,11 @@ public class MainController { return "denied"; } - @PostMapping(path="/addTeam") - public String addNewTeam(@RequestParam String teamName){ - - if(teamRepository.findByTeam(teamName) != null) { - return "redirect:/registration?message=Le groupe&succeed=-1"; - } - else { - Team t = new Team(); - t.setTeam(teamName); - t.setTeamId((int)(teamRepository.count()+1)); - teamRepository.save(t); - return "redirect:/registration?message=Le groupe&succeed=1"; - } - } - @PostMapping(path="/addUser") public String addNewUser(@RequestParam String email, @RequestParam String password, @RequestParam String role, @RequestParam String team) { if(customerRepository.findByEmail(email) != null) { - return "redirect:/registration?message=L'utilisateur&succeed=-1"; + return "redirect:/registration?message=L'utilisateur existe+d%C3%A9j%C3%A0&succeed=-1"; } else { Customer n = new Customer(); @@ -164,9 +150,43 @@ public class MainController { Team temp = teamRepository.findByTeam(team); temp.addCustomer(n); teamRepository.save(temp); - return "redirect:/registration?message=L'utilisateur&succeed=1"; + return "redirect:/registration?message=L'utilisateur a+%C3%A9t%C3%A9+ajout%C3%A9&succeed=1"; } + } + @PostMapping(path="/addTeam") + public String addNewTeam(@RequestParam String teamName){ + + if(teamRepository.findByTeam(teamName) != null) { + return "redirect:/registration?message=Le groupe existe+d%C3%A9j%C3%A0&succeed=-1"; + } + else { + Team t = new Team(); + t.setTeam(teamName); + t.setTeamId((int)(teamRepository.count()+1)); + teamRepository.save(t); + return "redirect:/registration?message=Le groupe a+%C3%A9t%C3%A9+ajout%C3%A9&succeed=1"; + } + } + + @PostMapping(path="/changeCustomerTeam") + public String addCustomerTeam(@RequestParam String teamName, @RequestParam String customerName){ + Team newTeam = teamRepository.findByTeam(teamName); + Customer customer = customerRepository.findByEmail(customerName); + Team oldTeam = teamRepository.findByCustomersContaining(customer); + if( newTeam == null || customer == null) { + return "redirect:/registration?message=le+groupe+ou+l%27utilisateur+n%27existe+plus&succeed=-1"; + } + else if(oldTeam == newTeam){ + return "redirect:/registration?message=l%27utilisateur+appartient+d%C3%A9j%C3%A0+%C3%A0+ce+groupe&succeed=-1"; + } + else { + newTeam.addCustomer(customer); + oldTeam.removeCustomer(customer); + teamRepository.save(newTeam); + teamRepository.save(oldTeam); + return "redirect:/registration?message=le+groupe+de+l%27utilisateur+a+bien+%C3%A9t%C3%A9+chang%C3%A9&succeed=1"; + } } @RequestMapping(value = "/file", method = RequestMethod.POST) diff --git a/PFE06/src/main/java/com/PFE/ServerManager/Team.java b/PFE06/src/main/java/com/PFE/ServerManager/Team.java index b9fc113..04fb29b 100644 --- a/PFE06/src/main/java/com/PFE/ServerManager/Team.java +++ b/PFE06/src/main/java/com/PFE/ServerManager/Team.java @@ -52,6 +52,11 @@ public class Team { } this.customers.add(customer); } + public void removeCustomer(Customer customer){ + if(customers != null){ + customers.remove(customer); + } + } public void setUpdates(Set updates) { this.updates = updates; diff --git a/PFE06/src/main/resources/templates/registration.html b/PFE06/src/main/resources/templates/registration.html index 5f2ea58..2e50357 100644 --- a/PFE06/src/main/resources/templates/registration.html +++ b/PFE06/src/main/resources/templates/registration.html @@ -41,17 +41,17 @@
-

Formulaire d'ajout d'un utilisateur

+

Ajouter un utilisateur