diff --git a/PFE06/src/main/java/com/PFE/ServerManager/MainController.java b/PFE06/src/main/java/com/PFE/ServerManager/MainController.java index 7a3d2d5..afa8e97 100644 --- a/PFE06/src/main/java/com/PFE/ServerManager/MainController.java +++ b/PFE06/src/main/java/com/PFE/ServerManager/MainController.java @@ -56,6 +56,7 @@ public class MainController { Customer customer = customerRepository.findByEmail(auth.getName()); modelAndView.addObject("customerName", customer.getEmail().split("@")[0]); modelAndView.addObject("customerRole", customer.getRole()); + modelAndView.addObject("customerMaj", customer.getMaj()); modelAndView.setViewName("session"); return modelAndView; } @@ -192,21 +193,20 @@ public class MainController { return "test"; } - @PostMapping(path="/test") - public ModelAndView addNewUser(@RequestParam String maj, @RequestParam String date, @RequestParam String set1, @RequestParam String set2){ - ModelAndView modelAndView = new ModelAndView(); - modelAndView.setViewName("test"); + @PostMapping(path="/savemaj") + public String saveMaj(@RequestParam String name, @RequestParam String date, @RequestParam String nodes){ Authentication auth = SecurityContextHolder.getContext().getAuthentication(); Customer customer = customerRepository.findByEmail(auth.getName()); Maj maj_c = new Maj(); - maj_c.setMaj(maj); + maj_c.setMaj(name); maj_c.setDate(date); - String nodes=set1+';'+set2; maj_c.setNodes(nodes); maj_c.setMaj_id((int)(majRepository.count() + 1)); majRepository.save(maj_c); // ajouter la mise a jour dans la table - customer.setMaj(new HashSet(Arrays.asList(maj_c))); + HashSet majs = new HashSet(Arrays.asList(maj_c)); + majs.addAll(customer.getMaj()); + customer.setMaj(majs); customerRepository.save(customer); // permet de rendre effective la jointure entre customer et maj - return modelAndView; + return "redirect:/session"; } } \ No newline at end of file diff --git a/PFE06/src/main/resources/static/js/session.js b/PFE06/src/main/resources/static/js/session.js new file mode 100644 index 0000000..b2134d2 --- /dev/null +++ b/PFE06/src/main/resources/static/js/session.js @@ -0,0 +1,77 @@ +$(document).ready(function() { + + /********** Tableau **********/ + + var tableNodes = $('#nodes-table').DataTable( { + responsive: true, + select: { + style: 'multi' + } + } ); + + var nodeSet = new Set(); + + tableNodes.on('select', function (e, dt, type, indexes) { + var rowData = tableNodes.rows(indexes).data().toArray()[0]; + nodeSet.add(rowData[0]); + } ); + + tableNodes.on('deselect', function (e, dt, type, indexes) { + var rowData = tableNodes.rows(indexes).data().toArray()[0]; + nodeSet.delete(rowData[0]); + } ); + + document.getElementById("save_maj").addEventListener('click', function() { + + var form = document.createElement('form'); + form.setAttribute('action', 'savemaj'); + form.setAttribute('method', 'post'); + + var modalContent = document.getElementById("modal-content"); + + var majName = document.getElementById("majName").value; + var majDate = document.getElementById("majDate").value; + + if(nodeSet.size == 0) { + $("#warningFilesNumber").modal(); + } + + else if(majName == "") { + modalContent.innerHTML = "Veuillez choisir un nom pour la mise à jour"; + $("#warningFilesNumber").modal(); + } + + else if(majDate == "") { + modalContent.innerHTML = "Veuillez choisir une date pour la mise à jour" + $("#warningFilesNumber").modal(); + } + + else { + var nodes = Array.from(nodeSet); + console.log(nodes); + + var inputvar1 = document.createElement('input'); + inputvar1.setAttribute('type', 'hidden'); + inputvar1.setAttribute('name', 'name'); + inputvar1.setAttribute('value', majName); + form.appendChild(inputvar1); + + var inputvar2 = document.createElement('input'); + inputvar2.setAttribute('type', 'hidden'); + inputvar2.setAttribute('name', 'date'); + inputvar2.setAttribute('value', majDate); + form.appendChild(inputvar2); + + var inputvar3 = document.createElement('input'); + inputvar3.setAttribute('type', 'hidden'); + inputvar3.setAttribute('name', 'nodes'); + inputvar3.setAttribute('value', nodes.join(";")); + form.appendChild(inputvar3); + + document.body.appendChild(form); + form.submit(); + } + + }); + +} ); diff --git a/PFE06/src/main/resources/templates/all.html b/PFE06/src/main/resources/templates/all.html index e46548a..e3a05b7 100644 --- a/PFE06/src/main/resources/templates/all.html +++ b/PFE06/src/main/resources/templates/all.html @@ -14,45 +14,57 @@ - + - - - - - - - - - - - -
PseudoRoleId
pseudoroleid
+ +
+ +

Liste des utilisateurs

+ + + + + + + + + + + + +
EmailRoleID
EmailRoleID
+
+ diff --git a/PFE06/src/main/resources/templates/home.html b/PFE06/src/main/resources/templates/home.html index e66a578..24c607d 100644 --- a/PFE06/src/main/resources/templates/home.html +++ b/PFE06/src/main/resources/templates/home.html @@ -34,7 +34,6 @@ Enregistrer des utilisateurs Listes des utilisateurs Paramétrer une mise à jour - test maj
Paramétrer une mise à jour diff --git a/PFE06/src/main/resources/templates/registration.html b/PFE06/src/main/resources/templates/registration.html index 0e6bd7c..4216d30 100644 --- a/PFE06/src/main/resources/templates/registration.html +++ b/PFE06/src/main/resources/templates/registration.html @@ -10,6 +10,8 @@ +
+