From 7022508ec0addfacbf2b52f05fccbc2f519010d3 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Thu, 28 Jul 2022 00:15:57 +0200 Subject: [PATCH] dashboard wip --- web/js/home.js | 19 +++++++++---------- web/js/library.js | 6 ++++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/web/js/home.js b/web/js/home.js index 202552d..c4f876d 100644 --- a/web/js/home.js +++ b/web/js/home.js @@ -1,15 +1,14 @@ 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){ - 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); + + } }) \ No newline at end of file diff --git a/web/js/library.js b/web/js/library.js index b78e6b0..5291fae 100644 --- a/web/js/library.js +++ b/web/js/library.js @@ -2,13 +2,15 @@ function checkToken(){ instance.get("token", { withCredentials: true}) .then(function(response) { - if(location.href.pathname == "/") + if(location.pathname == "/") { location.href="/html/home.html"; } }) .catch(function(error){ - location.href="/"; + if(location.pathname != "/"){ + location.href="/"; + } }); } \ No newline at end of file