list users

This commit is contained in:
Valentin CZERYBA 2022-07-29 23:55:42 +02:00
parent 18529779f4
commit 614a852fe6
5 changed files with 46 additions and 127 deletions

View File

@ -37,7 +37,3 @@ body {
border-top-left-radius: 0;
border-top-right-radius: 0;
}
.hidden {
visibility: hidden;
}

3
web/css/style.css Normal file
View File

@ -0,0 +1,3 @@
.hidden {
visibility: hidden;
}

View File

@ -83,6 +83,7 @@
<!-- Custom styles for this template -->
<link href="../css/dashboard.css" rel="stylesheet">
<link href="../css/style.css" rel="stylesheet">
<header class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow">
@ -151,128 +152,27 @@
<table id=users class="table table-striped table-sm">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Header</th>
<th scope="col">Header</th>
<th scope="col">Header</th>
<th scope="col">ID</th>
<th scope="col">Pseudo</th>
<th scope="col">Mail</th>
<th scope="col">Rôle</th>
<th scope="col">Header</th>
</tr>
</thead>
<tbody>
<tr>
<td>1,001</td>
<td>random</td>
<td>data</td>
<td>placeholder</td>
<td>text</td>
</tr>
<tr>
<td>1,002</td>
<td>placeholder</td>
<td>irrelevant</td>
<td>visual</td>
<td>layout</td>
</tr>
<tr>
<td>1,003</td>
<td>data</td>
<td>rich</td>
<td>dashboard</td>
<td>tabular</td>
</tr>
<tr>
<td>1,003</td>
<td>information</td>
<td>placeholder</td>
<td>illustrative</td>
<td>data</td>
</tr>
<tr>
<td>1,004</td>
<td>text</td>
<td>random</td>
<td>layout</td>
<td>dashboard</td>
</tr>
<tr>
<td>1,005</td>
<td>dashboard</td>
<td>irrelevant</td>
<td>text</td>
<td>placeholder</td>
</tr>
<tr>
<td>1,006</td>
<td>dashboard</td>
<td>illustrative</td>
<td>rich</td>
<td>data</td>
</tr>
<tr>
<td>1,007</td>
<td>placeholder</td>
<td>tabular</td>
<td>information</td>
<td>irrelevant</td>
</tr>
<tr>
<td>1,008</td>
<td>random</td>
<td>data</td>
<td>placeholder</td>
<td>text</td>
</tr>
<tr>
<td>1,009</td>
<td>placeholder</td>
<td>irrelevant</td>
<td>visual</td>
<td>layout</td>
</tr>
<tr>
<td>1,010</td>
<td>data</td>
<td>rich</td>
<td>dashboard</td>
<td>tabular</td>
</tr>
<tr>
<td>1,011</td>
<td>information</td>
<td>placeholder</td>
<td>illustrative</td>
<td>data</td>
</tr>
<tr>
<td>1,012</td>
<td>text</td>
<td>placeholder</td>
<td>layout</td>
<td>dashboard</td>
</tr>
<tr>
<td>1,013</td>
<td>dashboard</td>
<td>irrelevant</td>
<td>text</td>
<td>visual</td>
</tr>
<tr>
<td>1,014</td>
<td>dashboard</td>
<td>illustrative</td>
<td>rich</td>
<td>data</td>
</tr>
<tr>
<td>1,015</td>
<td>random</td>
<td>tabular</td>
<td>information</td>
<td>text</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<div id="page" class="hidden">
<a href="#" id="previous">Précédent</a><span><a href="#"></a>1</span><a href="#" id="next">Suivant</a>
</div>
</div>
</main>
</div>

View File

@ -45,6 +45,7 @@
<!-- Custom styles for this template -->
<link href="css/signin.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
</head>
<body class="text-center">

View File

@ -1,19 +1,38 @@
checkToken();
instance.get("users/count", { withCredentials: true }).then(function(response){
var countTable = document.querySelectorAll("#users tbody tr").length;
var count = response.data / countTable;
var reste = response.data % countTable;
var nbPages = 20;
instance.get("users/count", { withCredentials: true }).then(function(response){
var count = response.data / nbPages;
var reste = response.data % nbPages;
var total = 0;
if(reste != 0){
var total = Number.parseInt(count) + 1;
console.log(total);
total = Number.parseInt(count) + 1;
}
if(total > 1){
document.getElementById("page").classList.remove("hidden");
}
});
instance.get("users", {withCredentials: true, params :{ page:0, nbPages: nbPages}}).then(function(response){
var trTag = document.querySelector("#users tbody tr").cloneNode(true);
listData = response.data;
for (var i=0; i<listData.length; i++){
if(i != 0){
document.querySelector("#users tbody").append(trTag);
}
var trAll = document.querySelectorAll("#users tbody tr")
td = trAll[i].querySelectorAll("td");
td[0].textContent = listData[i].id;
td[1].textContent = listData[i].pseudo
td[2].textContent = listData[i].email
td[3].textContent = listData[i].roles
}
});
instance.get("users", {withCredentials: true}).then(function(response){
console.log(response);
})