diff --git a/web/js/users.js b/web/js/users.js index b92bd16..53d295e 100644 --- a/web/js/users.js +++ b/web/js/users.js @@ -1,7 +1,8 @@ checkToken(); signOut(); +var param = {} -var nbPages = 20; +param["nbPages"] = 20; instance.get("users/count", { withCredentials: true }).then(function(response){ @@ -42,22 +43,26 @@ instance.get("users/count", { withCredentials: true }).then(function(response){ }); - - -var page = 0; +param["page"] = 0; var pageCurrent = getQuery("page"); if (pageCurrent.length > 0){ - page = Number.parseInt(pageCurrent); - page = page - 1; + param["page"] = Number.parseInt(pageCurrent); + param["page"] = param["page"] - 1; } -instance.get("users", {withCredentials: true, params :{ page:page, nbPages: nbPages}}).then(function(response){ +var listQuery = ["search", "uuid", "roles", "status", "email"]; +for (var i=0; i 0){ + param[listQuery[i]]=query; + } +} + +instance.get("users", {withCredentials: true, params :param}).then(function(response){ listData = response.data; for (var i=0; i 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; + } }); 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; - alert(e.target.value+" "+status+" "+search); -}) + 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; + } +});