Commit c6289fa5186ddf78127ddbf1059bbd1f09124eb6

Authored by Antoine Duquenoy
1 parent 3fa7d40b

Modifications mineures

* Suppression du bouton "Lancer la mise à jour", il faut maintenant l'enregistrer avant
* Ajout de l'heure en plus de la date pour l'expérimentation
* Ajout de la durée de l'exp
* Au lancement/relancement d'une exp, la date est vérifiée et changée si elle était dans le passé
PFE06/src/main/java/com/PFE/ServerManager/MainController.java
@@ -10,6 +10,7 @@ import org.springframework.web.servlet.ModelAndView; @@ -10,6 +10,7 @@ import org.springframework.web.servlet.ModelAndView;
10 10
11 import java.io.*; 11 import java.io.*;
12 import java.sql.Timestamp; 12 import java.sql.Timestamp;
  13 +import java.text.ParseException;
13 import java.util.*; 14 import java.util.*;
14 15
15 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 16 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
@@ -21,8 +22,13 @@ import org.yaml.snakeyaml.constructor.Constructor; @@ -21,8 +22,13 @@ import org.yaml.snakeyaml.constructor.Constructor;
21 import javax.servlet.annotation.MultipartConfig; 22 import javax.servlet.annotation.MultipartConfig;
22 import com.fasterxml.jackson.databind.ObjectMapper; 23 import com.fasterxml.jackson.databind.ObjectMapper;
23 24
  25 +
  26 +import java.text.SimpleDateFormat;
  27 +import java.util.Date;
  28 +import java.util.Locale;
  29 +
24 @Controller 30 @Controller
25 -@MultipartConfig(fileSizeThreshold = 20971520) //à changer, taille max des fichiers 31 +@MultipartConfig(fileSizeThreshold = 100000000) //à changer, taille max des fichiers
26 32
27 public class MainController { 33 public class MainController {
28 34
@@ -257,7 +263,7 @@ public class MainController { @@ -257,7 +263,7 @@ public class MainController {
257 } 263 }
258 264
259 @PostMapping(path="/savemaj") 265 @PostMapping(path="/savemaj")
260 - public String saveMaj(@RequestParam String name, @RequestParam String date, @RequestParam String nodes, @RequestParam String file){ 266 + public String saveMaj(@RequestParam String name, @RequestParam String date, @RequestParam String time, @RequestParam String nodes, @RequestParam String file){
261 Authentication auth = SecurityContextHolder.getContext().getAuthentication(); 267 Authentication auth = SecurityContextHolder.getContext().getAuthentication();
262 Customer customer = customerRepository.findByEmail(auth.getName()); 268 Customer customer = customerRepository.findByEmail(auth.getName());
263 269
@@ -266,10 +272,10 @@ public class MainController { @@ -266,10 +272,10 @@ public class MainController {
266 update_c.setDate(date); 272 update_c.setDate(date);
267 update_c.setNodes(nodes); 273 update_c.setNodes(nodes);
268 update_c.setFile(file); 274 update_c.setFile(file);
  275 + update_c.setTime(time);
269 276
270 updateRepository.save(update_c); // ajouter la mise a jour dans la table 277 updateRepository.save(update_c); // ajouter la mise a jour dans la table
271 278
272 - System.out.println("team name : " + (teamRepository.findByCustomersContaining(customer)).getTeam());  
273 Team teamOfCustomer = teamRepository.findByCustomersContaining(customer); 279 Team teamOfCustomer = teamRepository.findByCustomersContaining(customer);
274 teamOfCustomer.addUpdate(update_c); 280 teamOfCustomer.addUpdate(update_c);
275 teamRepository.save(teamOfCustomer); // permet de rendre effective la jointure entre customer et maj 281 teamRepository.save(teamOfCustomer); // permet de rendre effective la jointure entre customer et maj
@@ -277,6 +283,7 @@ public class MainController { @@ -277,6 +283,7 @@ public class MainController {
277 return "redirect:/update"; 283 return "redirect:/update";
278 } 284 }
279 285
  286 + /*
280 @PostMapping(path="/runmaj") 287 @PostMapping(path="/runmaj")
281 public String runMaj(@RequestParam String name, @RequestParam String date, @RequestParam String nodes, @RequestParam String file){ 288 public String runMaj(@RequestParam String name, @RequestParam String date, @RequestParam String nodes, @RequestParam String file){
282 Authentication auth = SecurityContextHolder.getContext().getAuthentication(); 289 Authentication auth = SecurityContextHolder.getContext().getAuthentication();
@@ -304,6 +311,7 @@ public class MainController { @@ -304,6 +311,7 @@ public class MainController {
304 311
305 return "redirect:/update"; 312 return "redirect:/update";
306 } 313 }
  314 +*/
307 315
308 @PostMapping(path="/startsavedmaj") 316 @PostMapping(path="/startsavedmaj")
309 @ResponseStatus(value = HttpStatus.OK) 317 @ResponseStatus(value = HttpStatus.OK)
@@ -311,9 +319,23 @@ public class MainController { @@ -311,9 +319,23 @@ public class MainController {
311 Authentication auth = SecurityContextHolder.getContext().getAuthentication(); 319 Authentication auth = SecurityContextHolder.getContext().getAuthentication();
312 Customer customer = customerRepository.findByEmail(auth.getName()); 320 Customer customer = customerRepository.findByEmail(auth.getName());
313 Update update = updateRepository.findByUpdate(majname); 321 Update update = updateRepository.findByUpdate(majname);
  322 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
  323 + Date now = new Date();
  324 + Date date = null;
  325 + try {
  326 + date = sdf.parse(update.getDate());
  327 + } catch (ParseException e) {
  328 + e.printStackTrace();
  329 + }
  330 + if(date.compareTo(now) < 0) {
  331 + update.setDate(sdf.format(now));
  332 + updateRepository.save(update);
  333 + }
314 Map<String, Object> data = new HashMap<String, Object>(); 334 Map<String, Object> data = new HashMap<String, Object>();
315 data.put("name", update.getUpdate()); 335 data.put("name", update.getUpdate());
  336 + data.put("exp_id", update.getUpdateId());
316 data.put("date", update.getDate()); 337 data.put("date", update.getDate());
  338 + data.put("time", update.getTime());
317 data.put("file", update.getFile()); 339 data.put("file", update.getFile());
318 data.put("nodes", update.getNodes().split(";")); 340 data.put("nodes", update.getNodes().split(";"));
319 Yaml yaml = new Yaml(); 341 Yaml yaml = new Yaml();
PFE06/src/main/java/com/PFE/ServerManager/Update.java
@@ -16,6 +16,9 @@ public class Update { @@ -16,6 +16,9 @@ public class Update {
16 @Column(name = "date") 16 @Column(name = "date")
17 private String date; 17 private String date;
18 18
  19 + @Column(name = "time")
  20 + private String time;
  21 +
19 @Column(name = "file") 22 @Column(name = "file")
20 private String file; 23 private String file;
21 24
@@ -37,6 +40,13 @@ public class Update { @@ -37,6 +40,13 @@ public class Update {
37 return date; 40 return date;
38 } 41 }
39 42
  43 + public void setTime(String time) {
  44 + this.time = time;
  45 + }
  46 + public String getTime() {
  47 + return time;
  48 + }
  49 +
40 public void setNodes(String nodes) { 50 public void setNodes(String nodes) {
41 this.nodes = nodes; 51 this.nodes = nodes;
42 } 52 }
PFE06/src/main/resources/application.properties
@@ -20,4 +20,8 @@ spring.datasource.password=glopglop @@ -20,4 +20,8 @@ spring.datasource.password=glopglop
20 spring.jpa.show-sql = true 20 spring.jpa.show-sql = true
21 21
22 # exécute le fichier data.sql pour préciser le role ADMIN 22 # exécute le fichier data.sql pour préciser le role ADMIN
23 -spring.datasource.initialization-mode=always  
24 \ No newline at end of file 23 \ No newline at end of file
  24 +spring.datasource.initialization-mode=always
  25 +
  26 +server.tomcat.max-http-post-size=80000000
  27 +spring.servlet.multipart.max-file-size=80MB
  28 +spring.servlet.multipart.max-request-size=80MB
25 \ No newline at end of file 29 \ No newline at end of file
PFE06/src/main/resources/static/js/update.js
@@ -104,13 +104,13 @@ $(document).ready(function() { @@ -104,13 +104,13 @@ $(document).ready(function() {
104 tableNodes.on('select', function (e, dt, type, indexes) { 104 tableNodes.on('select', function (e, dt, type, indexes) {
105 var rowData = tableNodes.rows(indexes).data().toArray()[0]; 105 var rowData = tableNodes.rows(indexes).data().toArray()[0];
106 console.log(rowData); 106 console.log(rowData);
107 - nodeSet.add(rowData[0] + "@" + rowData[3]); 107 + nodeSet.add(rowData[3] + "@" + rowData[1]);
108 console.log(nodeSet); 108 console.log(nodeSet);
109 } ); 109 } );
110 110
111 tableNodes.on('deselect', function (e, dt, type, indexes) { 111 tableNodes.on('deselect', function (e, dt, type, indexes) {
112 var rowData = tableNodes.rows(indexes).data().toArray()[0]; 112 var rowData = tableNodes.rows(indexes).data().toArray()[0];
113 - nodeSet.delete(rowData[0] + "@" + rowData[3]); 113 + nodeSet.delete(rowData[3] + "@" + rowData[1]);
114 console.log(nodeSet); 114 console.log(nodeSet);
115 } ); 115 } );
116 116
@@ -123,6 +123,7 @@ $(document).ready(function() { @@ -123,6 +123,7 @@ $(document).ready(function() {
123 var modalContent = document.getElementById("modal-content"); 123 var modalContent = document.getElementById("modal-content");
124 var majName = document.getElementById("majName").value; 124 var majName = document.getElementById("majName").value;
125 var majDate = document.getElementById("majDate").value; 125 var majDate = document.getElementById("majDate").value;
  126 + var majTime = document.getElementById("majTime").value;
126 var majFile = document.getElementById("file_choice").value; 127 var majFile = document.getElementById("file_choice").value;
127 128
128 if(nodeSet.size == 0) { 129 if(nodeSet.size == 0) {
@@ -139,6 +140,11 @@ $(document).ready(function() { @@ -139,6 +140,11 @@ $(document).ready(function() {
139 $("#warningFilesNumber").modal(); 140 $("#warningFilesNumber").modal();
140 } 141 }
141 142
  143 + else if(majTime === "") {
  144 + modalContent.innerHTML = "Veuillez choisir une durée pour la mise à jour"
  145 + $("#warningFilesNumber").modal();
  146 + }
  147 +
142 else if(majFile === "" || majFile === "--") { 148 else if(majFile === "" || majFile === "--") {
143 modalContent.innerHTML = "Veuillez choisir un fichier pour la mise à jour" 149 modalContent.innerHTML = "Veuillez choisir un fichier pour la mise à jour"
144 $("#warningFilesNumber").modal(); 150 $("#warningFilesNumber").modal();
@@ -171,6 +177,12 @@ $(document).ready(function() { @@ -171,6 +177,12 @@ $(document).ready(function() {
171 inputvar4.setAttribute('value', majFile); 177 inputvar4.setAttribute('value', majFile);
172 form.appendChild(inputvar4); 178 form.appendChild(inputvar4);
173 179
  180 + var inputvar5 = document.createElement('input');
  181 + inputvar5.setAttribute('type', 'hidden');
  182 + inputvar5.setAttribute('name', 'time');
  183 + inputvar5.setAttribute('value', majTime);
  184 + form.appendChild(inputvar5);
  185 +
174 document.body.appendChild(form); 186 document.body.appendChild(form);
175 form.submit(); 187 form.submit();
176 } 188 }
PFE06/src/main/resources/templates/update.html
@@ -149,7 +149,7 @@ nodes: @@ -149,7 +149,7 @@ nodes:
149 </div> 149 </div>
150 </div> 150 </div>
151 151
152 - <h1 style="margin-bottom:50px; margin-top:50px; border-bottom:1px solid #CCC; padding-bottom:20px;">Relancer une mise à jour</h1> 152 + <h1 style="margin-bottom:50px; margin-top:50px; border-bottom:1px solid #CCC; padding-bottom:20px;">Lancer une mise à jour</h1>
153 <div class="form-team"> 153 <div class="form-team">
154 <select multiple id="maj_name" class="form-control"> 154 <select multiple id="maj_name" class="form-control">
155 <option value="--">--</option> 155 <option value="--">--</option>
@@ -180,11 +180,17 @@ nodes: @@ -180,11 +180,17 @@ nodes:
180 </tbody> 180 </tbody>
181 </table> 181 </table>
182 <div class="form-team"> 182 <div class="form-team">
183 - <input type="text" class="form-control" id="majName" placeholder="Nom de la update" name="update" style="margin-top:20px;"> 183 + <input type="text" class="form-control" id="majName" placeholder="Nom de la mise à jour" name="update" style="margin-top:20px;">
184 </div> 184 </div>
185 <br/> 185 <br/>
  186 + <p>Date de l'expérimentation</p>
186 <div class="form-team"> 187 <div class="form-team">
187 - <input type="date" class="form-control" id="majDate" placeholder="Date de la mise à jour" name="date"> 188 + <input type="datetime-local" class="form-control" id="majDate" placeholder="Date de la mise à jour" name="date">
  189 + </div>
  190 + <br/>
  191 + <p>Durée de l'expérimentation</p>
  192 + <div class="form-team">
  193 + <input type="time" class="form-control" id="majTime" placeholder="Durée" name="time">
188 </div> 194 </div>
189 <br/> 195 <br/>
190 <select multiple class="form-control" style="margin-bottom:20px;" id="file_choice"> 196 <select multiple class="form-control" style="margin-bottom:20px;" id="file_choice">
@@ -192,7 +198,7 @@ nodes: @@ -192,7 +198,7 @@ nodes:
192 <option th:each="file : ${customerFiles}" th:value="${file}" th:utext="${file}"/> 198 <option th:each="file : ${customerFiles}" th:value="${file}" th:utext="${file}"/>
193 </select> 199 </select>
194 <button id="save_maj" type="submit" class="btn btn-primary">Sauvegarder la mise à jour</button> 200 <button id="save_maj" type="submit" class="btn btn-primary">Sauvegarder la mise à jour</button>
195 - <button id="run_maj" type="submit" class="btn btn-primary">Lancer la mise à jour</button> 201 + <!--<button id="run_maj" type="submit" class="btn btn-primary">Lancer la mise à jour</button>-->
196 </div> 202 </div>
197 203
198 <div class="modal fade" id="warningFilesNumber" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true"> 204 <div class="modal fade" id="warningFilesNumber" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
PFE06/toflash/pfe_test.yml
1 -date: '1212-12-12' 1 +date: 2019-02-07T01:33
2 file: pfelogo.png 2 file: pfelogo.png
3 -nodes: [nom1@c2, nom2@aaaaaaaaaaaaaaaaaaaaaaa, nom2@aa] 3 +nodes: [a@a]
  4 +exp_id: 8
4 name: test 5 name: test
  6 +time: 00:15