group button
This commit is contained in:
@@ -72,7 +72,7 @@ if(id.length > 0){
|
||||
break;
|
||||
default:
|
||||
httpMethod = "patch";
|
||||
httpUrl = "users/enable/"+idInput;
|
||||
httpUrl = "users/"+idInput;
|
||||
break;
|
||||
}
|
||||
instance({
|
||||
|
@@ -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){
|
||||
|
Reference in New Issue
Block a user