group button

This commit is contained in:
Valentin CZERYBA 2023-11-02 17:29:12 +01:00
parent d623d86db0
commit 9a4f17f469
3 changed files with 57 additions and 4 deletions

View File

@ -157,10 +157,10 @@
</div>
</div>
<br />
<button type="button" class="btn btn-success" id="enableUser" data-bs-toggle="modal" data-bs-target="#enableUserModal">Activer l'utilisateur</button>
<button type="button" class="btn btn-success" id="enableUserButton" data-bs-toggle="modal" data-bs-target="#enableUserModal">Activer l'utilisateur</button>
<button type="button" class="btn btn-warning " id="disableUser" data-bs-toggle="modal" data-bs-target="#disableUserModal">Désactiver l'utilisateur</button>
<button type="button" class="btn btn-danger" id="removeUser" data-bs-toggle="modal" data-bs-target="#removeUserModal">Supprimer l'utilisateur</button>
<button type="button" class="btn btn-warning " id="disableUserButton" data-bs-toggle="modal" data-bs-target="#disableUserModal">Désactiver l'utilisateur</button>
<button type="button" class="btn btn-danger" id="removeUserButton" data-bs-toggle="modal" data-bs-target="#removeUserModal">Supprimer l'utilisateur</button>
<br /><br /><br />
<table id=users class="table table-striped table-sm">
<thead>

View File

@ -72,7 +72,7 @@ if(id.length > 0){
break;
default:
httpMethod = "patch";
httpUrl = "users/enable/"+idInput;
httpUrl = "users/"+idInput;
break;
}
instance({

View File

@ -89,6 +89,59 @@ instance.get("users", {withCredentials: true, params:param}).then(function(respo
var listData = []
listData.push(response.data);
}
if(listData.length > 0 ){
var listModalButton = ["disable", "enable", "remove"];
for (var i=0; i<listModalButton.length; i++){
document.getElementById(listModalButton[i]+"UserButton").addEventListener("click", function(e){
var httpMethod = ""
var httpUrl = "";
param = {};
userids= [];
checkboxList = document.getElementsByClassName("checkboxList");
for (var j=0; j<checkboxList.length; j++){
if(checkboxList[j].checked){
userid = checkboxList.getAttribute("userid");
if (userid.length > 0){
userids.push(userid);
}
}
}
param["userids"]=userids;
switch(e.currentTarget.id){
case "disableUserButton":
httpMethod = "delete";
httpUrl = "users/groups";
break;
case "removeUserButton":
httpMethod = "delete";
httpUrl = "users/groups?remove=true";
param["remove"]=true;
break;
default:
httpMethod = "patch";
httpUrl = "users/groups";
break;
}
instance({
method: httpMethod,
url: httpUrl,
params:param,
withCredentials: true
})
.then(function(response){
if(response.status == 200){
location.href="/html/users.html";
}
})
.catch(function(error){
console.log(error);
});
});
}
}
for (var i=0; i<listData.length; i++){
var trTag = document.querySelector("#users tbody tr").cloneNode(true);
if(i != 0){