From c6289fa5186ddf78127ddbf1059bbd1f09124eb6 Mon Sep 17 00:00:00 2001 From: Antoine Duquenoy Date: Thu, 7 Feb 2019 13:48:07 +0100 Subject: [PATCH] Modifications mineures --- PFE06/src/main/java/com/PFE/ServerManager/MainController.java | 28 +++++++++++++++++++++++++--- PFE06/src/main/java/com/PFE/ServerManager/Update.java | 10 ++++++++++ PFE06/src/main/resources/application.properties | 6 +++++- PFE06/src/main/resources/static/js/update.js | 16 ++++++++++++++-- PFE06/src/main/resources/templates/update.html | 14 ++++++++++---- PFE06/toflash/pfe_test.yml | 6 ++++-- 6 files changed, 68 insertions(+), 12 deletions(-) diff --git a/PFE06/src/main/java/com/PFE/ServerManager/MainController.java b/PFE06/src/main/java/com/PFE/ServerManager/MainController.java index cdc304b..afa4685 100644 --- a/PFE06/src/main/java/com/PFE/ServerManager/MainController.java +++ b/PFE06/src/main/java/com/PFE/ServerManager/MainController.java @@ -10,6 +10,7 @@ import org.springframework.web.servlet.ModelAndView; import java.io.*; import java.sql.Timestamp; +import java.text.ParseException; import java.util.*; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; @@ -21,8 +22,13 @@ import org.yaml.snakeyaml.constructor.Constructor; import javax.servlet.annotation.MultipartConfig; import com.fasterxml.jackson.databind.ObjectMapper; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; + @Controller -@MultipartConfig(fileSizeThreshold = 20971520) //à changer, taille max des fichiers +@MultipartConfig(fileSizeThreshold = 100000000) //à changer, taille max des fichiers public class MainController { @@ -257,7 +263,7 @@ public class MainController { } @PostMapping(path="/savemaj") - public String saveMaj(@RequestParam String name, @RequestParam String date, @RequestParam String nodes, @RequestParam String file){ + public String saveMaj(@RequestParam String name, @RequestParam String date, @RequestParam String time, @RequestParam String nodes, @RequestParam String file){ Authentication auth = SecurityContextHolder.getContext().getAuthentication(); Customer customer = customerRepository.findByEmail(auth.getName()); @@ -266,10 +272,10 @@ public class MainController { update_c.setDate(date); update_c.setNodes(nodes); update_c.setFile(file); + update_c.setTime(time); updateRepository.save(update_c); // ajouter la mise a jour dans la table - System.out.println("team name : " + (teamRepository.findByCustomersContaining(customer)).getTeam()); Team teamOfCustomer = teamRepository.findByCustomersContaining(customer); teamOfCustomer.addUpdate(update_c); teamRepository.save(teamOfCustomer); // permet de rendre effective la jointure entre customer et maj @@ -277,6 +283,7 @@ public class MainController { return "redirect:/update"; } + /* @PostMapping(path="/runmaj") public String runMaj(@RequestParam String name, @RequestParam String date, @RequestParam String nodes, @RequestParam String file){ Authentication auth = SecurityContextHolder.getContext().getAuthentication(); @@ -304,6 +311,7 @@ public class MainController { return "redirect:/update"; } +*/ @PostMapping(path="/startsavedmaj") @ResponseStatus(value = HttpStatus.OK) @@ -311,9 +319,23 @@ public class MainController { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); Customer customer = customerRepository.findByEmail(auth.getName()); Update update = updateRepository.findByUpdate(majname); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm"); + Date now = new Date(); + Date date = null; + try { + date = sdf.parse(update.getDate()); + } catch (ParseException e) { + e.printStackTrace(); + } + if(date.compareTo(now) < 0) { + update.setDate(sdf.format(now)); + updateRepository.save(update); + } Map data = new HashMap(); data.put("name", update.getUpdate()); + data.put("exp_id", update.getUpdateId()); data.put("date", update.getDate()); + data.put("time", update.getTime()); data.put("file", update.getFile()); data.put("nodes", update.getNodes().split(";")); Yaml yaml = new Yaml(); diff --git a/PFE06/src/main/java/com/PFE/ServerManager/Update.java b/PFE06/src/main/java/com/PFE/ServerManager/Update.java index 64383f3..a357a78 100644 --- a/PFE06/src/main/java/com/PFE/ServerManager/Update.java +++ b/PFE06/src/main/java/com/PFE/ServerManager/Update.java @@ -16,6 +16,9 @@ public class Update { @Column(name = "date") private String date; + @Column(name = "time") + private String time; + @Column(name = "file") private String file; @@ -37,6 +40,13 @@ public class Update { return date; } + public void setTime(String time) { + this.time = time; + } + public String getTime() { + return time; + } + public void setNodes(String nodes) { this.nodes = nodes; } diff --git a/PFE06/src/main/resources/application.properties b/PFE06/src/main/resources/application.properties index 2553936..fe43e06 100644 --- a/PFE06/src/main/resources/application.properties +++ b/PFE06/src/main/resources/application.properties @@ -20,4 +20,8 @@ spring.datasource.password=glopglop spring.jpa.show-sql = true # exécute le fichier data.sql pour préciser le role ADMIN -spring.datasource.initialization-mode=always \ No newline at end of file +spring.datasource.initialization-mode=always + +server.tomcat.max-http-post-size=80000000 +spring.servlet.multipart.max-file-size=80MB +spring.servlet.multipart.max-request-size=80MB \ No newline at end of file diff --git a/PFE06/src/main/resources/static/js/update.js b/PFE06/src/main/resources/static/js/update.js index ad2ae46..5c249a4 100644 --- a/PFE06/src/main/resources/static/js/update.js +++ b/PFE06/src/main/resources/static/js/update.js @@ -104,13 +104,13 @@ $(document).ready(function() { tableNodes.on('select', function (e, dt, type, indexes) { var rowData = tableNodes.rows(indexes).data().toArray()[0]; console.log(rowData); - nodeSet.add(rowData[0] + "@" + rowData[3]); + nodeSet.add(rowData[3] + "@" + rowData[1]); console.log(nodeSet); } ); tableNodes.on('deselect', function (e, dt, type, indexes) { var rowData = tableNodes.rows(indexes).data().toArray()[0]; - nodeSet.delete(rowData[0] + "@" + rowData[3]); + nodeSet.delete(rowData[3] + "@" + rowData[1]); console.log(nodeSet); } ); @@ -123,6 +123,7 @@ $(document).ready(function() { var modalContent = document.getElementById("modal-content"); var majName = document.getElementById("majName").value; var majDate = document.getElementById("majDate").value; + var majTime = document.getElementById("majTime").value; var majFile = document.getElementById("file_choice").value; if(nodeSet.size == 0) { @@ -139,6 +140,11 @@ $(document).ready(function() { $("#warningFilesNumber").modal(); } + else if(majTime === "") { + modalContent.innerHTML = "Veuillez choisir une durée pour la mise à jour" + $("#warningFilesNumber").modal(); + } + else if(majFile === "" || majFile === "--") { modalContent.innerHTML = "Veuillez choisir un fichier pour la mise à jour" $("#warningFilesNumber").modal(); @@ -171,6 +177,12 @@ $(document).ready(function() { inputvar4.setAttribute('value', majFile); form.appendChild(inputvar4); + var inputvar5 = document.createElement('input'); + inputvar5.setAttribute('type', 'hidden'); + inputvar5.setAttribute('name', 'time'); + inputvar5.setAttribute('value', majTime); + form.appendChild(inputvar5); + document.body.appendChild(form); form.submit(); } diff --git a/PFE06/src/main/resources/templates/update.html b/PFE06/src/main/resources/templates/update.html index e456abe..75f9e8c 100644 --- a/PFE06/src/main/resources/templates/update.html +++ b/PFE06/src/main/resources/templates/update.html @@ -149,7 +149,7 @@ nodes: -

Relancer une mise à jour

+

Lancer une mise à jour

+

+

Date de l'expérimentation

- + +
+
+

Durée de l'expérimentation

+
+

- +