forked from v4l3n71n/covas-bo
gestion des erreurs
This commit is contained in:
parent
1e7704a1ab
commit
10180c917f
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -129,6 +129,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<h2>Liste d'utilisateur</h2>
|
||||
<div class="table-responsive">
|
||||
<table id=users class="table table-striped table-sm">
|
||||
|
@ -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");
|
||||
});
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user