Commit 5c2fe69f4e0845b660fc4555ccbb03b25118f6a1
1 parent
76cabcde
Suppression d'une expérimentation depuis l'interface web
Showing
5 changed files
with
52 additions
and
3 deletions
Show diff stats
PFE06/src/main/java/com/PFE/ServerManager/MainController.java
1 | 1 | package com.PFE.ServerManager; |
2 | 2 | |
3 | +import org.omg.CORBA.SystemException; | |
3 | 4 | import org.springframework.beans.factory.annotation.Autowired; |
4 | 5 | import org.springframework.http.HttpEntity; |
5 | 6 | import org.springframework.http.HttpStatus; |
... | ... | @@ -440,4 +441,14 @@ public class MainController { |
440 | 441 | yaml.dump(data, writer); |
441 | 442 | } |
442 | 443 | |
444 | + @PostMapping(path="/deleteupdate") | |
445 | + public ResponseEntity deleteUpdate(@RequestParam String majname){ | |
446 | + Update update_c = updateRepository.findByUpdate(majname); | |
447 | + Team t = teamRepository.findByUpdatesContaining(update_c); | |
448 | + t.removeUpdate(update_c); | |
449 | + teamRepository.save(t); | |
450 | + updateRepository.deleteById(update_c.getUpdateId()); | |
451 | + return new ResponseEntity<String>(HttpStatus.OK); | |
452 | + } | |
453 | + | |
443 | 454 | } |
444 | 455 | \ No newline at end of file | ... | ... |
PFE06/src/main/java/com/PFE/ServerManager/Team.java
PFE06/src/main/java/com/PFE/ServerManager/TeamRepository.java
PFE06/src/main/resources/static/js/update.js
... | ... | @@ -34,6 +34,38 @@ $(document).ready(function() { |
34 | 34 | } |
35 | 35 | }) |
36 | 36 | |
37 | + var delMaj = document.getElementById("del_maj"); | |
38 | + | |
39 | + delMaj.addEventListener('click', function() { | |
40 | + var modalContent = document.getElementById("modal-content"); | |
41 | + var modalTitle = document.getElementById("modal-title"); | |
42 | + var majNameSelect = document.getElementById("maj_name").value; | |
43 | + if(majNameSelect !== "" && majNameSelect !== "--") { | |
44 | + var request = new XMLHttpRequest(); | |
45 | + request.open("POST", "/deleteupdate"); | |
46 | + var formData = new FormData(); | |
47 | + formData.append("majname", majNameSelect); | |
48 | + | |
49 | + request.onreadystatechange = function() { | |
50 | + if(this.readyState === XMLHttpRequest.DONE && this.status === 200) { | |
51 | + var modalButton = document.getElementById("modal-button"); | |
52 | + modalButton.addEventListener('click', function() { | |
53 | + location.reload(); | |
54 | + }) | |
55 | + modalTitle.innerHTML = "Félicitations"; | |
56 | + modalContent.innerHTML = "La mise à jour a bien été supprimée"; | |
57 | + $("#warningFilesNumber").modal(); | |
58 | + } | |
59 | + } | |
60 | + request.send(formData); | |
61 | + } | |
62 | + else { | |
63 | + modalTitle.innerHTML = "Attention !"; | |
64 | + modalContent.innerHTML = "Veuillez choisir le nom d'une mise à jour"; | |
65 | + $("#warningFilesNumber").modal(); | |
66 | + } | |
67 | + }) | |
68 | + | |
37 | 69 | /********** Tableau **********/ |
38 | 70 | |
39 | 71 | var tableNodes = $('#nodes-table').DataTable( { |
... | ... | @@ -180,8 +212,5 @@ $(document).ready(function() { |
180 | 212 | document.getElementById("save_maj").addEventListener('click', function() { |
181 | 213 | sendInfoMaj('savemaj'); |
182 | 214 | }); |
183 | - document.getElementById("run_maj").addEventListener('click', function() { | |
184 | - sendInfoMaj('runmaj'); | |
185 | - }); | |
186 | 215 | |
187 | 216 | } ); | ... | ... |
PFE06/src/main/resources/templates/update.html
... | ... | @@ -115,6 +115,7 @@ |
115 | 115 | <option th:each="update : ${customerMaj}" th:value="${update.getUpdate()}" th:utext="${update.getUpdate()}"/> |
116 | 116 | </select> |
117 | 117 | <button id="start_maj" type="submit" class="btn btn-primary" style="margin-top:20px;">Lancer la mise à jour</button> |
118 | + <button id="del_maj" type="submit" class="btn btn-primary" style="margin-top:20px;">Supprimer la mise à jour</button> | |
118 | 119 | </div> |
119 | 120 | <h1 style="margin-bottom:50px; margin-top:50px; border-bottom:1px solid #CCC; padding-bottom:20px;">Créer une mise à jour</h1> |
120 | 121 | ... | ... |