forked from v4l3n71n/covas-bo
add variable by URL
This commit is contained in:
parent
4ed38c4940
commit
2cfda4f437
@ -1,5 +1,7 @@
|
||||
checkToken();
|
||||
signOut();
|
||||
pathURL = document.location.pathname.split("/")[document.location.pathname.split("/").length-1].split(".")[0]
|
||||
|
||||
var param = {}
|
||||
|
||||
param["limit"] = 20;
|
||||
@ -28,7 +30,7 @@ for (var i=0; i<listQuery.length; i++){
|
||||
}
|
||||
|
||||
|
||||
instance.get("users/count", { withCredentials: true }).then(function(response){
|
||||
instance.get(pathURL+"/count", { withCredentials: true }).then(function(response){
|
||||
|
||||
var count = response.data["count"] / param["limit"];
|
||||
var reste = response.data["count"] % param["limit"];
|
||||
@ -54,7 +56,7 @@ instance.get("users/count", { withCredentials: true }).then(function(response){
|
||||
var aPage = document.querySelectorAll(".page-item")[newPage].querySelector("a");
|
||||
aPage.text=newPage;
|
||||
var newPage = updateParam("page", newpage);
|
||||
aPage.href="/html/users.html?"+newPage;
|
||||
aPage.href="/html/"+pathURL+".html?"+newPage;
|
||||
}
|
||||
document.querySelectorAll(".page-item")[page].classList.add("active");
|
||||
if(page != 1){
|
||||
@ -83,7 +85,7 @@ for (var i=0; i<listQuery.length; i++){
|
||||
}
|
||||
}
|
||||
|
||||
instance.get("users", {withCredentials: true, params:param}).then(function(response){
|
||||
instance.get(pathURL, {withCredentials: true, params:param}).then(function(response){
|
||||
var listData = response.data;
|
||||
if(!Array.isArray(listData)){
|
||||
var listData = []
|
||||
@ -113,15 +115,15 @@ instance.get("users", {withCredentials: true, params:param}).then(function(respo
|
||||
switch(e.currentTarget.id){
|
||||
case "disableUserButton":
|
||||
httpMethod = "delete";
|
||||
httpUrl = "users/groups";
|
||||
httpUrl = pathURL+"/groups";
|
||||
break;
|
||||
case "removeUserButton":
|
||||
httpMethod = "delete";
|
||||
httpUrl = "users/groups?remove=true";
|
||||
httpUrl = pathURL+"/groups?remove=true";
|
||||
break;
|
||||
default:
|
||||
httpMethod = "patch";
|
||||
httpUrl = "users/groups";
|
||||
httpUrl = pathURL+"/groups";
|
||||
break;
|
||||
}
|
||||
instance({
|
||||
@ -132,7 +134,7 @@ instance.get("users", {withCredentials: true, params:param}).then(function(respo
|
||||
})
|
||||
.then(function(response){
|
||||
if(response.status == 200){
|
||||
location.href="/html/users.html";
|
||||
location.href="/html/"+pathURL+".html";
|
||||
}
|
||||
})
|
||||
.catch(function(error){
|
||||
@ -178,7 +180,7 @@ instance.get("users", {withCredentials: true, params:param}).then(function(respo
|
||||
|
||||
td[6].querySelector("button").addEventListener("click", function(e){
|
||||
var id = e.currentTarget.getAttribute("userid");
|
||||
location.href="/html/user.html?id="+id;
|
||||
location.href="/html/"+pathURL.slice(0, -1)+".html?id="+id;
|
||||
});
|
||||
|
||||
}
|
||||
@ -194,13 +196,13 @@ instance.get("users", {withCredentials: true, params:param}).then(function(respo
|
||||
|
||||
|
||||
document.getElementById("addUser").addEventListener("click", function(){
|
||||
location.href="/html/adduser.html";
|
||||
location.href="/html/add"+pathURL.slice(0, -1)+".html";
|
||||
});
|
||||
|
||||
document.getElementById("searchUser").addEventListener("keydown", function(ev){
|
||||
if(ev.key === "Enter"){
|
||||
var param = buildParam("");
|
||||
location.href="/html/users.html?"+param;
|
||||
location.href="/html/"+pathURL+".html?"+param;
|
||||
}
|
||||
});
|
||||
|
||||
@ -209,7 +211,7 @@ listInput = ["Status", "Roles", "Pages" ]
|
||||
for (var i=0; i<listInput.length; i++){
|
||||
document.getElementById("input"+listInput[i]).addEventListener("change", function(e){
|
||||
var param = buildParam("inputSelect");
|
||||
location.href="/html/users.html?"+param;
|
||||
location.href="/html/"+pathURL+".html?"+param;
|
||||
});
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user