gestion des erreurs

This commit is contained in:
Valentin CZERYBA 2022-08-14 16:47:24 +02:00
parent 1e7704a1ab
commit 10180c917f
4 changed files with 56 additions and 5 deletions

View File

@ -123,7 +123,7 @@
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="notModifiedAlert" role="alert">
<div class="alert alert-danger alert-dismissible hidden" id="notAuthorizedAlert" role="alert">
<div>Action non autorisée</div>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>

View File

@ -118,6 +118,37 @@
<main class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
<div class="alert alert-warning alert-dismissible hidden" id="notModifiedAlert" role="alert">
<div>Utilisateur non modifié</div>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="notAuthorizedAlert" role="alert">
<div>Création d'utilisateur non autorisée avec ce compte</div>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="forbiddenAlert" role="alert">
<div>Action interdite</div>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="noContentAlert" role="alert">
<div>Utilisateur non modifié</div>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="internalServerAlert" role="alert">
<div>Erreur interne du serveur</div>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="unknownAlert" role="alert">
<div>Erreur inconnue</div>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="pseudoAlert" role="alert">
<div>Champ pseudo vide</div>

View File

@ -129,6 +129,8 @@
</div>
</div>
<h2>Liste d'utilisateur</h2>
<div class="table-responsive">
<table id=users class="table table-striped table-sm">

View File

@ -144,19 +144,37 @@ if(id.length > 0){
withCredentials: true,
data: dataPut
}).then(function(response){
var idAlert = "";
switch(response.status){
case 200:
location.reload();
break;
case 304:
console.log("non modifie");
idAlert="noContent";
break;
default:
console.log("error inconnue");
break
idAlert="unknown";
break;
}
document.getElementById(idAlert+"Alert").classList.remove("hidden");
}).catch(function(error){
console.log(error);
var idAlert = "";
switch(error.status){
case 401:
idAlert="notAuthorized";
break;
case 403:
idAlert="forbidden";
break;
case 500:
idAlert="internalServer";
break;
default:
idAlert="unknown";
break;
}
document.getElementById(idAlert+"Alert").classList.remove("hidden");
});
}