diff --git a/web/js/users.js b/web/js/users.js index 53d295e..a943c7a 100644 --- a/web/js/users.js +++ b/web/js/users.js @@ -6,8 +6,8 @@ param["nbPages"] = 20; instance.get("users/count", { withCredentials: true }).then(function(response){ - var count = response.data / nbPages; - var reste = response.data % nbPages; + var count = response.data / param["nbPages"]; + var reste = response.data % param["nbPages"]; var total = 0; if(reste != 0){ 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(classTd).classList.remove("hidden"); - trAll[i].addEventListener("click", function(e){ + trAll[i].addEventListener("click", function(e){ var id = e.currentTarget.querySelector("td").textContent; 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 select = document.getElementById("inputRoles"); var roles = select.options[select.selectedIndex].value; - if(search.length > 0){ - location.href="/html/users.html?search="+search+"&status="+e.target.value+"&roles="+roles; - } else { - location.href="/html/users.html?status="+e.target.value+"&roles="+roles; + var param = ""; + var page = getQuery("page"); + if(page.length > 0){ + 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){ var search = document.getElementById("searchUser").value; var select = document.getElementById("inputStatus"); var status = select.options[select.selectedIndex].value; - if(search.length > 0){ - location.href="/html/users.html?search="+search+"&roles="+e.target.value+"&status="+status; - } else { - location.href="/html/users.html?roles="+e.target.value+"&status="+status; + var param = ""; + var page = getQuery("page"); + if(page.length > 0){ + 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; });