Commit c6289fa5186ddf78127ddbf1059bbd1f09124eb6
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é
Showing
6 changed files
with
68 additions
and
12 deletions
Show diff stats
PFE06/src/main/java/com/PFE/ServerManager/MainController.java
... | ... | @@ -10,6 +10,7 @@ import org.springframework.web.servlet.ModelAndView; |
10 | 10 | |
11 | 11 | import java.io.*; |
12 | 12 | import java.sql.Timestamp; |
13 | +import java.text.ParseException; | |
13 | 14 | import java.util.*; |
14 | 15 | |
15 | 16 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
... | ... | @@ -21,8 +22,13 @@ import org.yaml.snakeyaml.constructor.Constructor; |
21 | 22 | import javax.servlet.annotation.MultipartConfig; |
22 | 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 | 30 | @Controller |
25 | -@MultipartConfig(fileSizeThreshold = 20971520) //à changer, taille max des fichiers | |
31 | +@MultipartConfig(fileSizeThreshold = 100000000) //à changer, taille max des fichiers | |
26 | 32 | |
27 | 33 | public class MainController { |
28 | 34 | |
... | ... | @@ -257,7 +263,7 @@ public class MainController { |
257 | 263 | } |
258 | 264 | |
259 | 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 | 267 | Authentication auth = SecurityContextHolder.getContext().getAuthentication(); |
262 | 268 | Customer customer = customerRepository.findByEmail(auth.getName()); |
263 | 269 | |
... | ... | @@ -266,10 +272,10 @@ public class MainController { |
266 | 272 | update_c.setDate(date); |
267 | 273 | update_c.setNodes(nodes); |
268 | 274 | update_c.setFile(file); |
275 | + update_c.setTime(time); | |
269 | 276 | |
270 | 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 | 279 | Team teamOfCustomer = teamRepository.findByCustomersContaining(customer); |
274 | 280 | teamOfCustomer.addUpdate(update_c); |
275 | 281 | teamRepository.save(teamOfCustomer); // permet de rendre effective la jointure entre customer et maj |
... | ... | @@ -277,6 +283,7 @@ public class MainController { |
277 | 283 | return "redirect:/update"; |
278 | 284 | } |
279 | 285 | |
286 | + /* | |
280 | 287 | @PostMapping(path="/runmaj") |
281 | 288 | public String runMaj(@RequestParam String name, @RequestParam String date, @RequestParam String nodes, @RequestParam String file){ |
282 | 289 | Authentication auth = SecurityContextHolder.getContext().getAuthentication(); |
... | ... | @@ -304,6 +311,7 @@ public class MainController { |
304 | 311 | |
305 | 312 | return "redirect:/update"; |
306 | 313 | } |
314 | +*/ | |
307 | 315 | |
308 | 316 | @PostMapping(path="/startsavedmaj") |
309 | 317 | @ResponseStatus(value = HttpStatus.OK) |
... | ... | @@ -311,9 +319,23 @@ public class MainController { |
311 | 319 | Authentication auth = SecurityContextHolder.getContext().getAuthentication(); |
312 | 320 | Customer customer = customerRepository.findByEmail(auth.getName()); |
313 | 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 | 334 | Map<String, Object> data = new HashMap<String, Object>(); |
315 | 335 | data.put("name", update.getUpdate()); |
336 | + data.put("exp_id", update.getUpdateId()); | |
316 | 337 | data.put("date", update.getDate()); |
338 | + data.put("time", update.getTime()); | |
317 | 339 | data.put("file", update.getFile()); |
318 | 340 | data.put("nodes", update.getNodes().split(";")); |
319 | 341 | Yaml yaml = new Yaml(); | ... | ... |
PFE06/src/main/java/com/PFE/ServerManager/Update.java
... | ... | @@ -16,6 +16,9 @@ public class Update { |
16 | 16 | @Column(name = "date") |
17 | 17 | private String date; |
18 | 18 | |
19 | + @Column(name = "time") | |
20 | + private String time; | |
21 | + | |
19 | 22 | @Column(name = "file") |
20 | 23 | private String file; |
21 | 24 | |
... | ... | @@ -37,6 +40,13 @@ public class Update { |
37 | 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 | 50 | public void setNodes(String nodes) { |
41 | 51 | this.nodes = nodes; |
42 | 52 | } | ... | ... |
PFE06/src/main/resources/application.properties
... | ... | @@ -20,4 +20,8 @@ spring.datasource.password=glopglop |
20 | 20 | spring.jpa.show-sql = true |
21 | 21 | |
22 | 22 | # exécute le fichier data.sql pour préciser le role ADMIN |
23 | -spring.datasource.initialization-mode=always | |
24 | 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 | 29 | \ No newline at end of file | ... | ... |
PFE06/src/main/resources/static/js/update.js
... | ... | @@ -104,13 +104,13 @@ $(document).ready(function() { |
104 | 104 | tableNodes.on('select', function (e, dt, type, indexes) { |
105 | 105 | var rowData = tableNodes.rows(indexes).data().toArray()[0]; |
106 | 106 | console.log(rowData); |
107 | - nodeSet.add(rowData[0] + "@" + rowData[3]); | |
107 | + nodeSet.add(rowData[3] + "@" + rowData[1]); | |
108 | 108 | console.log(nodeSet); |
109 | 109 | } ); |
110 | 110 | |
111 | 111 | tableNodes.on('deselect', function (e, dt, type, indexes) { |
112 | 112 | var rowData = tableNodes.rows(indexes).data().toArray()[0]; |
113 | - nodeSet.delete(rowData[0] + "@" + rowData[3]); | |
113 | + nodeSet.delete(rowData[3] + "@" + rowData[1]); | |
114 | 114 | console.log(nodeSet); |
115 | 115 | } ); |
116 | 116 | |
... | ... | @@ -123,6 +123,7 @@ $(document).ready(function() { |
123 | 123 | var modalContent = document.getElementById("modal-content"); |
124 | 124 | var majName = document.getElementById("majName").value; |
125 | 125 | var majDate = document.getElementById("majDate").value; |
126 | + var majTime = document.getElementById("majTime").value; | |
126 | 127 | var majFile = document.getElementById("file_choice").value; |
127 | 128 | |
128 | 129 | if(nodeSet.size == 0) { |
... | ... | @@ -139,6 +140,11 @@ $(document).ready(function() { |
139 | 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 | 148 | else if(majFile === "" || majFile === "--") { |
143 | 149 | modalContent.innerHTML = "Veuillez choisir un fichier pour la mise à jour" |
144 | 150 | $("#warningFilesNumber").modal(); |
... | ... | @@ -171,6 +177,12 @@ $(document).ready(function() { |
171 | 177 | inputvar4.setAttribute('value', majFile); |
172 | 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 | 186 | document.body.appendChild(form); |
175 | 187 | form.submit(); |
176 | 188 | } | ... | ... |
PFE06/src/main/resources/templates/update.html
... | ... | @@ -149,7 +149,7 @@ nodes: |
149 | 149 | </div> |
150 | 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 | 153 | <div class="form-team"> |
154 | 154 | <select multiple id="maj_name" class="form-control"> |
155 | 155 | <option value="--">--</option> |
... | ... | @@ -180,11 +180,17 @@ nodes: |
180 | 180 | </tbody> |
181 | 181 | </table> |
182 | 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 | 184 | </div> |
185 | 185 | <br/> |
186 | + <p>Date de l'expérimentation</p> | |
186 | 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 | 194 | </div> |
189 | 195 | <br/> |
190 | 196 | <select multiple class="form-control" style="margin-bottom:20px;" id="file_choice"> |
... | ... | @@ -192,7 +198,7 @@ nodes: |
192 | 198 | <option th:each="file : ${customerFiles}" th:value="${file}" th:utext="${file}"/> |
193 | 199 | </select> |
194 | 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 | 202 | </div> |
197 | 203 | |
198 | 204 | <div class="modal fade" id="warningFilesNumber" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true"> | ... | ... |