add select

This commit is contained in:
Valentin CZERYBA 2022-08-25 01:41:06 +02:00
parent f740138cbc
commit 8405947254

View File

@ -6,8 +6,8 @@ param["nbPages"] = 20;
instance.get("users/count", { withCredentials: true }).then(function(response){ instance.get("users/count", { withCredentials: true }).then(function(response){
var count = response.data / nbPages; var count = response.data / param["nbPages"];
var reste = response.data % nbPages; var reste = response.data % param["nbPages"];
var total = 0; var total = 0;
if(reste != 0){ if(reste != 0){
total = Number.parseInt(count) + 1; total = Number.parseInt(count) + 1;
@ -92,7 +92,7 @@ instance.get("users", {withCredentials: true, params :param}).then(function(resp
td[4].querySelector(".activeStatus").classList.add("hidden"); td[4].querySelector(".activeStatus").classList.add("hidden");
td[4].querySelector(classTd).classList.remove("hidden"); td[4].querySelector(classTd).classList.remove("hidden");
trAll[i].addEventListener("click", function(e){ trAll[i].addEventListener("click", function(e){
var id = e.currentTarget.querySelector("td").textContent; var id = e.currentTarget.querySelector("td").textContent;
location.href="/html/user.html?id="+id; location.href="/html/user.html?id="+id;
}); });
@ -122,22 +122,57 @@ document.getElementById("inputStatus").addEventListener("change", function(e){
var search = document.getElementById("searchUser").value; var search = document.getElementById("searchUser").value;
var select = document.getElementById("inputRoles"); var select = document.getElementById("inputRoles");
var roles = select.options[select.selectedIndex].value; var roles = select.options[select.selectedIndex].value;
if(search.length > 0){ var param = "";
location.href="/html/users.html?search="+search+"&status="+e.target.value+"&roles="+roles; var page = getQuery("page");
} else { if(page.length > 0){
location.href="/html/users.html?status="+e.target.value+"&roles="+roles; param = param + "page="+page+"&";
} }
var nbPages = getQuery("nbPages");
if(nbPages.length > 0 ){
param = param+ "nbPages="+nbPages+"&";
}
if(search.length > 0){
param = param + "search="+search+"&";
}
var status = e.target.value;
if(status != "-2"){
param = param + "status="+status+"&";
}
if(roles != "All"){
param = param + "roles="+roles;
}
location.href="/html/users.html?"+param;
}); });
document.getElementById("inputRoles").addEventListener("change", function(e){ document.getElementById("inputRoles").addEventListener("change", function(e){
var search = document.getElementById("searchUser").value; var search = document.getElementById("searchUser").value;
var select = document.getElementById("inputStatus"); var select = document.getElementById("inputStatus");
var status = select.options[select.selectedIndex].value; var status = select.options[select.selectedIndex].value;
if(search.length > 0){ var param = "";
location.href="/html/users.html?search="+search+"&roles="+e.target.value+"&status="+status; var page = getQuery("page");
} else { if(page.length > 0){
location.href="/html/users.html?roles="+e.target.value+"&status="+status; param = param + "page="+page+"&";
} }
var nbPages = getQuery("nbPages");
if(nbPages.length > 0 ){
param = param + "nbPages="+nbPages+"&";
}
if(search.length > 0){
param = param + "search="+search+"&";
}
if(status != "-2"){
param = param + "status="+status+"&";
}
var roles = e.target.value;
if(roles != "All"){
param = param + "roles="+roles;
}
console.log(param);
location.href="/html/users.html?"+param;
}); });