forked from v4l3n71n/covas-bo
Compare commits
No commits in common. "2cfda4f43750d49cb312c4af29749230e7cc3789" and "5a7283b92f9f91a972b52e2af1895d1033d8fbce" have entirely different histories.
2cfda4f437
...
5a7283b92f
@ -141,7 +141,7 @@
|
|||||||
|
|
||||||
<div class="row g-3">
|
<div class="row g-3">
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
<label for="inputRoles" class="form-label">Rôle :</label>
|
<label for="inputRoles" class="form-label">Roles</label>
|
||||||
<select class="form-select" id="inputRoles" aria-label="Default select example">
|
<select class="form-select" id="inputRoles" aria-label="Default select example">
|
||||||
<option value="All" selected>Tout</option>
|
<option value="All" selected>Tout</option>
|
||||||
<option value="Admin">Administrateurs</option>
|
<option value="Admin">Administrateurs</option>
|
||||||
@ -149,7 +149,7 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
<label for="inputStatus" class="form-label">Statut :</label>
|
<label for="inputStatus" class="form-label">Statut</label>
|
||||||
<select class="form-select" id="inputStatus" aria-label="Default select example">
|
<select class="form-select" id="inputStatus" aria-label="Default select example">
|
||||||
<option value="-2" selected>Tout</option>
|
<option value="-2" selected>Tout</option>
|
||||||
<option value="-1">En cours de suppression</option>
|
<option value="-1">En cours de suppression</option>
|
||||||
@ -158,29 +158,12 @@
|
|||||||
<option value="2">En cours de validation</option>
|
<option value="2">En cours de validation</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-auto">
|
|
||||||
<label for="inputPages" class="form-label">Page :</label>
|
|
||||||
<select class="form-select" id="inputPages" aria-label="Page">
|
|
||||||
<option value="20" selected>20</option>
|
|
||||||
<option value="40">40</option>
|
|
||||||
<option value="60">60</option>
|
|
||||||
<option value="80">80</option>
|
|
||||||
<option value="100">100</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<br />
|
||||||
<br /><br />
|
|
||||||
<div class="row g-3">
|
|
||||||
<div class="col-auto">
|
|
||||||
<button type="button" class="btn btn-success" id="enableUserButton" data-bs-toggle="modal" data-bs-target="#enableUserModal">Activer l'utilisateur</button>
|
<button type="button" class="btn btn-success" id="enableUserButton" data-bs-toggle="modal" data-bs-target="#enableUserModal">Activer l'utilisateur</button>
|
||||||
</div>
|
|
||||||
<div class="col-auto">
|
|
||||||
<button type="button" class="btn btn-warning " id="disableUserButton" data-bs-toggle="modal" data-bs-target="#disableUserModal">Désactiver l'utilisateur</button>
|
<button type="button" class="btn btn-warning " id="disableUserButton" data-bs-toggle="modal" data-bs-target="#disableUserModal">Désactiver l'utilisateur</button>
|
||||||
</div>
|
|
||||||
<div class="col-auto">
|
|
||||||
<button type="button" class="btn btn-danger" id="removeUserButton" data-bs-toggle="modal" data-bs-target="#removeUserModal">Supprimer l'utilisateur</button>
|
<button type="button" class="btn btn-danger" id="removeUserButton" data-bs-toggle="modal" data-bs-target="#removeUserModal">Supprimer l'utilisateur</button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<br /><br /><br />
|
<br /><br /><br />
|
||||||
<table id=users class="table table-striped table-sm">
|
<table id=users class="table table-striped table-sm">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -21,39 +21,34 @@ function checkToken(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function buildParam(typeInput){
|
function buildParam(e, id){
|
||||||
var search = document.getElementById("searchUser").value;
|
var search = document.getElementById("searchUser").value;
|
||||||
var param = "";
|
var param = "";
|
||||||
var listParam = ["skip"];
|
var listParam = ["page", "nbPages"];
|
||||||
if(typeInput.length > 0){
|
if(id.length > 0){
|
||||||
listId =["inputRoles", "inputStatus", "inputPages"]
|
var select = document.getElementById(id);
|
||||||
for (var i=0; i<listId.length; i++) {
|
|
||||||
var select = document.getElementById(listId[i]);
|
|
||||||
var getId = select.options[select.selectedIndex].value;
|
var getId = select.options[select.selectedIndex].value;
|
||||||
switch (listId[i])
|
if(id == "inputRoles"){
|
||||||
{
|
var status = e.target.value;
|
||||||
case "inputRoles":
|
if(status != "-2"){
|
||||||
if (getId != "All"){
|
param = param + "status="+status+"&";
|
||||||
param = param + "roles=" + getId + "&";
|
|
||||||
}
|
}
|
||||||
break;
|
if(getId != "All"){
|
||||||
case "inputStatus":
|
param = param + "roles="+getId;
|
||||||
if (getId != "-2"){
|
}
|
||||||
param = param + "status=" + getId + "&";
|
}
|
||||||
}
|
if(id == "inputStatus"){
|
||||||
break;
|
var roles = e.target.value;
|
||||||
case "inputPages":
|
if(getId != "-2"){
|
||||||
param = param + "limit=" + getId + "&";
|
param = param + "status="+getId+"&";
|
||||||
break;
|
}
|
||||||
default:
|
if(roles != "All"){
|
||||||
break;
|
param = param + "roles="+roles+"&";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
listParam.push("roles");
|
listParam.push("roles");
|
||||||
listParam.push("status");
|
listParam.push("status");
|
||||||
listParam.push("limit");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(search.length > 0){
|
if(search.length > 0){
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
checkToken();
|
checkToken();
|
||||||
signOut();
|
signOut();
|
||||||
pathURL = document.location.pathname.split("/")[document.location.pathname.split("/").length-1].split(".")[0]
|
|
||||||
|
|
||||||
var param = {}
|
var param = {}
|
||||||
|
|
||||||
param["limit"] = 20;
|
param["limit"] = 20;
|
||||||
@ -14,7 +12,7 @@ for(var i=0; i<listSearch.length; i++){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var listQuery = [{"query": "roles", "id":"inputRoles"}, {"query":"status", "id":"inputStatus"}, {"query":"limit", "id":"inputPages"}]
|
var listQuery = [{"query": "roles", "id":"inputRoles"}, {"query":"status", "id":"inputStatus"}]
|
||||||
|
|
||||||
for (var i=0; i<listQuery.length; i++){
|
for (var i=0; i<listQuery.length; i++){
|
||||||
var query = getQuery(listQuery[i]["query"]);
|
var query = getQuery(listQuery[i]["query"]);
|
||||||
@ -30,7 +28,7 @@ for (var i=0; i<listQuery.length; i++){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
instance.get(pathURL+"/count", { withCredentials: true }).then(function(response){
|
instance.get("users/count", { withCredentials: true }).then(function(response){
|
||||||
|
|
||||||
var count = response.data["count"] / param["limit"];
|
var count = response.data["count"] / param["limit"];
|
||||||
var reste = response.data["count"] % param["limit"];
|
var reste = response.data["count"] % param["limit"];
|
||||||
@ -56,7 +54,7 @@ instance.get(pathURL+"/count", { withCredentials: true }).then(function(respons
|
|||||||
var aPage = document.querySelectorAll(".page-item")[newPage].querySelector("a");
|
var aPage = document.querySelectorAll(".page-item")[newPage].querySelector("a");
|
||||||
aPage.text=newPage;
|
aPage.text=newPage;
|
||||||
var newPage = updateParam("page", newpage);
|
var newPage = updateParam("page", newpage);
|
||||||
aPage.href="/html/"+pathURL+".html?"+newPage;
|
aPage.href="/html/users.html?"+newPage;
|
||||||
}
|
}
|
||||||
document.querySelectorAll(".page-item")[page].classList.add("active");
|
document.querySelectorAll(".page-item")[page].classList.add("active");
|
||||||
if(page != 1){
|
if(page != 1){
|
||||||
@ -85,7 +83,7 @@ for (var i=0; i<listQuery.length; i++){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
instance.get(pathURL, {withCredentials: true, params:param}).then(function(response){
|
instance.get("users", {withCredentials: true, params:param}).then(function(response){
|
||||||
var listData = response.data;
|
var listData = response.data;
|
||||||
if(!Array.isArray(listData)){
|
if(!Array.isArray(listData)){
|
||||||
var listData = []
|
var listData = []
|
||||||
@ -115,15 +113,15 @@ instance.get(pathURL, {withCredentials: true, params:param}).then(function(respo
|
|||||||
switch(e.currentTarget.id){
|
switch(e.currentTarget.id){
|
||||||
case "disableUserButton":
|
case "disableUserButton":
|
||||||
httpMethod = "delete";
|
httpMethod = "delete";
|
||||||
httpUrl = pathURL+"/groups";
|
httpUrl = "users/groups";
|
||||||
break;
|
break;
|
||||||
case "removeUserButton":
|
case "removeUserButton":
|
||||||
httpMethod = "delete";
|
httpMethod = "delete";
|
||||||
httpUrl = pathURL+"/groups?remove=true";
|
httpUrl = "users/groups?remove=true";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
httpMethod = "patch";
|
httpMethod = "patch";
|
||||||
httpUrl = pathURL+"/groups";
|
httpUrl = "users/groups";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
instance({
|
instance({
|
||||||
@ -134,7 +132,7 @@ instance.get(pathURL, {withCredentials: true, params:param}).then(function(respo
|
|||||||
})
|
})
|
||||||
.then(function(response){
|
.then(function(response){
|
||||||
if(response.status == 200){
|
if(response.status == 200){
|
||||||
location.href="/html/"+pathURL+".html";
|
location.href="/html/users.html";
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(function(error){
|
.catch(function(error){
|
||||||
@ -180,7 +178,7 @@ instance.get(pathURL, {withCredentials: true, params:param}).then(function(respo
|
|||||||
|
|
||||||
td[6].querySelector("button").addEventListener("click", function(e){
|
td[6].querySelector("button").addEventListener("click", function(e){
|
||||||
var id = e.currentTarget.getAttribute("userid");
|
var id = e.currentTarget.getAttribute("userid");
|
||||||
location.href="/html/"+pathURL.slice(0, -1)+".html?id="+id;
|
location.href="/html/user.html?id="+id;
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -196,25 +194,25 @@ instance.get(pathURL, {withCredentials: true, params:param}).then(function(respo
|
|||||||
|
|
||||||
|
|
||||||
document.getElementById("addUser").addEventListener("click", function(){
|
document.getElementById("addUser").addEventListener("click", function(){
|
||||||
location.href="/html/add"+pathURL.slice(0, -1)+".html";
|
location.href="/html/adduser.html";
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById("searchUser").addEventListener("keydown", function(ev){
|
document.getElementById("searchUser").addEventListener("keydown", function(ev){
|
||||||
if(ev.key === "Enter"){
|
if(ev.key === "Enter"){
|
||||||
var param = buildParam("");
|
var param = buildParam("", "");
|
||||||
location.href="/html/"+pathURL+".html?"+param;
|
location.href="/html/users.html?"+param;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.getElementById("inputStatus").addEventListener("change", function(e){
|
||||||
|
var param = buildParam(e, "inputRoles");
|
||||||
|
location.href="/html/users.html?"+param;
|
||||||
|
});
|
||||||
|
|
||||||
listInput = ["Status", "Roles", "Pages" ]
|
document.getElementById("inputRoles").addEventListener("change", function(e){
|
||||||
for (var i=0; i<listInput.length; i++){
|
var param = buildParam(e, "inputStatus");
|
||||||
document.getElementById("input"+listInput[i]).addEventListener("change", function(e){
|
location.href="/html/users.html?"+param;
|
||||||
var param = buildParam("inputSelect");
|
});
|
||||||
location.href="/html/"+pathURL+".html?"+param;
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user