Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.

Commit

Permalink
j'ai oublié que c'était le template id
Browse files Browse the repository at this point in the history
  • Loading branch information
elouanjef committed Jan 25, 2024
1 parent 9b4eee9 commit f9a7b80
Showing 1 changed file with 2 additions and 31 deletions.
33 changes: 2 additions & 31 deletions templates/professor.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,37 +115,10 @@ <h5 class="modal-title" id="editUserModalLabel">Modifier le mot de passe</h5>
</div>

<script>
function checkIfVmAliveProf(templateId) {
return new Promise(function (resolve, reject) {
showLoadingCardModal(templateId);
$.ajax({
type: 'GET',
url: 'https://api.insa-cvl.com/vm/status/template/' + templateId,
contentType: 'application/json;charset=UTF-8',
xhrFields: {
withCredentials: true
},
success: function (response) {
console.log("VM: " + templateId + ": STATE: " + response.vm_state + " STATUS: " + response.status);
if (response.vm_state == "1" && response.status == "ACTIVE") {
hideLoadingCardModal(templateId);
resolve(1);
} else {
hideLoadingCardModal(templateId);
resolve(0);
}
},
error: function (error) {
reject("Erreur d'obtention d'informations de la VM");
}
});
});
}

async function deleteVmProf(id) {
console.log("Suppresion de "+ id);
try {
var output = await checkIfVmAliveProf(id);
var output = await checkIfVmAlive(id);
if (output == 1) {
showLoadingModal();
$.ajax({
Expand All @@ -157,7 +130,6 @@ <h5 class="modal-title" id="editUserModalLabel">Modifier le mot de passe</h5>
withCredentials: true
},
success: function (response) {
console.log("response:"+response);
hideLoadingModal();
location.reload();
},
Expand All @@ -168,7 +140,6 @@ <h5 class="modal-title" id="editUserModalLabel">Modifier le mot de passe</h5>
});
}
} catch (error) {
console.log("marche pas");
alert(error);
hideLoadingModal();
}
Expand Down Expand Up @@ -215,7 +186,7 @@ <h5 class="modal-title" id="editUserModalLabel">Modifier le mot de passe</h5>
$('<p>').addClass('card-text').text('User ID: ' + vm.users_id),
$('<p>').addClass('card-text').text('Date de création: ' + vm.creationDate),
$('<button>').addClass('btn btn-danger').text('Supprimer').on('click', function () {
deleteVmProf(vm.id);
deleteVmProf(vm.template_id);
console.log('suppression de la VM ' + vm.id);
})
);
Expand Down

0 comments on commit f9a7b80

Please sign in to comment.