dashboard wip

This commit is contained in:
Valentin CZERYBA 2022-07-28 00:15:57 +02:00
parent e86a4aa0cf
commit 7022508ec0
2 changed files with 13 additions and 12 deletions

View File

@ -1,15 +1,14 @@
checkToken(); checkToken();
axios.interceptors.request.use(function (config) {
checkToken();
return config;
}, function (error) {
// Do something with request error
return Promise.reject(error);
});
instance.get("users/count", { withCredentials: true }).then(function(response){ instance.get("users/count", { withCredentials: true }).then(function(response){
var countTable = document.getElementById("users").querySelector("tbody").querySelectorAll("tr").length; var countTable = document.querySelectorAll("#users tbody tr").length;
var count = response.data / countTable;
var reste = response.data % countTable;
if(reste != 0){
var total = Number.parseInt(count) + 1;
console.log(total);
}
}) })

View File

@ -2,13 +2,15 @@ function checkToken(){
instance.get("token", { withCredentials: true}) instance.get("token", { withCredentials: true})
.then(function(response) { .then(function(response) {
if(location.href.pathname == "/") if(location.pathname == "/")
{ {
location.href="/html/home.html"; location.href="/html/home.html";
} }
}) })
.catch(function(error){ .catch(function(error){
location.href="/"; if(location.pathname != "/"){
location.href="/";
}
}); });
} }