remove data-bs-dismiss

This commit is contained in:
Valentin CZERYBA 2022-08-14 19:32:40 +02:00
parent 10180c917f
commit b9aefc1dcd
4 changed files with 41 additions and 18 deletions

View File

@ -120,27 +120,37 @@
<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>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="alert alert-warning alert-dismissible hidden" id="pseudoExistAlert" role="alert">
<div>Pseudo déjà pris</div>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="alert alert-warning alert-dismissible hidden" id="emailExistAlert" role="alert">
<div>Email déjà pris</div>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<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>
<button type="button" class="btn-close" 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>
<button type="button" class="btn-close" 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>
<button type="button" class="btn-close" 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>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>

View File

@ -125,49 +125,49 @@
<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>
<button type="button" class="btn-close" 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>
<button type="button" class="btn-close" 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>
<button type="button" class="btn-close" 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>
<button type="button" class="btn-close" 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>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="pseudoAlert" role="alert">
<div>Champ pseudo vide</div>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="emailAlert" role="alert">
<div>Champ email vide</div>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="firstNameAlert" role="alert">
<div>Champ prenom vide</div>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="alert alert-danger alert-dismissible hidden" id="nameAlert" role="alert">
<div>Champ nom vide</div>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
<button type="button" class="btn-close" aria-label="Close"></button>
</div>
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">

View File

@ -1,5 +1,6 @@
checkToken();
signOut();
closeButton();
document.getElementById("addUser").addEventListener("click", function(){
@ -60,8 +61,15 @@ document.getElementById("addUser").addEventListener("click", function(){
}
document.getElementById(idAlert+"Alert").classList.remove("hidden");
}).catch(function(error){
switch(error.status){
console.log(error);
switch(error.response.status){
case 401:
listExist = [ "pseudo", "email" ];
for(var i=0; i<listExist.length; i++){
if(error.response.data[listExist[i]]){
document.getElementById(listExist[i]+"ExistAlert").classList.remove("hidden");
}
}
idAlert="notAuthorized";
break;
case 403:

View File

@ -11,6 +11,11 @@ function checkToken(){
if(location.pathname != "/"){
location.href="/";
}
if(error.response.status == 406){
instance.delete("token" , {withCredentials:true}).then(function(response){
location.reload();
});
}
});
}
@ -20,11 +25,11 @@ function signOut(){
document.getElementById("signout").addEventListener("click", function(){
instance.delete("token" , {withCredentials:true}).then(function(response){
if(response.status == 200){
location.href="/"
if(response.status == 200) {
location.href="/";
}
});
});
});
}
function closeButton(){