search
This commit is contained in:
parent
9fb1413f14
commit
f740138cbc
@ -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<listQuery.length; i++){
|
||||
var query = getQuery(listQuery[i]);
|
||||
if(query.length > 0){
|
||||
param[listQuery[i]]=query;
|
||||
}
|
||||
}
|
||||
|
||||
instance.get("users", {withCredentials: true, params :param}).then(function(response){
|
||||
listData = response.data;
|
||||
for (var i=0; i<listData.length; i++){
|
||||
var trTag = document.querySelector("#users tbody tr").cloneNode(true);
|
||||
console.log(listData[i]);
|
||||
if(i != 0){
|
||||
console.log(i);
|
||||
document.querySelector("#users tbody").append(trTag);
|
||||
}
|
||||
var trAll = document.querySelectorAll("#users tbody tr")
|
||||
@ -104,11 +109,11 @@ document.getElementById("searchUser").addEventListener("keydown", function(ev){
|
||||
if(ev.key === "Enter"){
|
||||
var search = document.getElementById("searchUser").value;
|
||||
if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(search)){
|
||||
alert("mail");
|
||||
location.href="/html/users.html?email="+search;
|
||||
} else if(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(search)){
|
||||
alert("uuid");
|
||||
location.href="/html/users.html?uuid="+search;
|
||||
} else {
|
||||
alert("other");
|
||||
location.href="/html/users.html?search="+search;
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -117,15 +122,23 @@ 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;
|
||||
alert(e.target.value+" "+roles+" "+search);
|
||||
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;
|
||||
}
|
||||
});
|
||||
|
||||
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;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user