fix sort userstat and re-add version without placeholder
This commit is contained in:
+5
-6
@@ -48,12 +48,11 @@
|
|||||||
<p class="mt-3 text-center">Pas de compte? <a href="/register.html">Enregistrez-vous</a></p>
|
<p class="mt-3 text-center">Pas de compte? <a href="/register.html">Enregistrez-vous</a></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Footer Section
|
<!-- Footer Section -->
|
||||||
// Doesn't work on prod, will fix later
|
|
||||||
<footer>
|
<footer>
|
||||||
<p id="footer-text">Loading version information...</p>
|
<p id="footer-text"></p>
|
||||||
</footer>
|
</footer>
|
||||||
-->
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
@@ -97,13 +96,13 @@
|
|||||||
const footerText = `${data.author} - version: ${data.version} - ${data.message}`;
|
const footerText = `${data.author} - version: ${data.version} - ${data.message}`;
|
||||||
document.getElementById('footer-text').textContent = footerText;
|
document.getElementById('footer-text').textContent = footerText;
|
||||||
} else {
|
} else {
|
||||||
document.getElementById('footer-text').textContent = 'Failed to load version info';
|
document.getElementById('footer-text').textContent = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call the function to fetch and display the version info
|
// Call the function to fetch and display the version info
|
||||||
// Doesn't work on prod, will fix later
|
// Doesn't work on prod, will fix later
|
||||||
//fetchVersionInfo();
|
fetchVersionInfo();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
+17
-17
@@ -71,7 +71,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Nom</th>
|
<th scope="col">Nom</th>
|
||||||
<th scope="col">Total des films regardés</th>
|
<th scope="col">Total des films regardés</th>
|
||||||
<th scope="col"></th>
|
<th scope="col">Ratio</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="user-table-body">
|
<tbody id="user-table-body">
|
||||||
@@ -102,33 +102,27 @@
|
|||||||
<script>
|
<script>
|
||||||
window.onload = async function () {
|
window.onload = async function () {
|
||||||
const token = localStorage.getItem('auth_token');
|
const token = localStorage.getItem('auth_token');
|
||||||
// Check if token exists
|
|
||||||
if (token) {
|
if (token) {
|
||||||
try {
|
try {
|
||||||
// Decode the token (using a library like jwt-decode or manually)
|
|
||||||
const decoded = JSON.parse(atob(token.split('.')[1])); // Manually decoding JWT
|
const decoded = JSON.parse(atob(token.split('.')[1])); // Manually decoding JWT
|
||||||
|
|
||||||
// Access the user's name from the decoded token
|
|
||||||
const userName = decoded.name;
|
const userName = decoded.name;
|
||||||
|
|
||||||
// Update the user name in the navbar
|
|
||||||
document.getElementById('user-name').textContent = userName;
|
document.getElementById('user-name').textContent = userName;
|
||||||
|
|
||||||
// Verify JWT Token expiration
|
// Verify JWT expiration
|
||||||
const currentTime = Math.floor(Date.now() / 1000); // Current time in seconds
|
const currentTime = Math.floor(Date.now() / 1000);
|
||||||
if (decoded.exp && decoded.exp < currentTime) {
|
if (decoded.exp && decoded.exp < currentTime) {
|
||||||
console.warn("Token is expired");
|
console.warn("Token is expired");
|
||||||
localStorage.removeItem('auth_token'); // Remove the expired token
|
localStorage.removeItem('auth_token');
|
||||||
window.location.href = '/'; // Redirect to the login page
|
window.location.href = '/';
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error decoding token:", error);
|
console.error("Error decoding token:", error);
|
||||||
localStorage.removeItem('auth_token'); // Remove invalid token
|
localStorage.removeItem('auth_token');
|
||||||
window.location.href = '/'; // Redirect to the login page
|
window.location.href = '/';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Handle case if no token is available
|
window.location.href = '/';
|
||||||
window.location.href = '/'; // Redirect to the login page if no token
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -148,6 +142,12 @@
|
|||||||
const table = document.querySelector('.user-table');
|
const table = document.querySelector('.user-table');
|
||||||
const spinner = document.getElementById('loading-spinner');
|
const spinner = document.getElementById('loading-spinner');
|
||||||
|
|
||||||
|
// Ensure watchedRatio is treated as a number and sort in descending order
|
||||||
|
stats.sort((a, b) => parseFloat(b.watchedRatio) - parseFloat(a.watchedRatio));
|
||||||
|
|
||||||
|
// Clear previous rows to prevent duplication
|
||||||
|
userTableBody.innerHTML = '';
|
||||||
|
|
||||||
stats.forEach(userStat => {
|
stats.forEach(userStat => {
|
||||||
const userRow = document.createElement('tr');
|
const userRow = document.createElement('tr');
|
||||||
userRow.innerHTML = `
|
userRow.innerHTML = `
|
||||||
@@ -168,8 +168,8 @@
|
|||||||
document.querySelectorAll('.user-link').forEach(link => {
|
document.querySelectorAll('.user-link').forEach(link => {
|
||||||
link.addEventListener('click', function (event) {
|
link.addEventListener('click', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const datasetMovies = this.dataset.movies
|
const datasetMovies = this.dataset.movies;
|
||||||
console.log(datasetMovies)
|
console.log(datasetMovies);
|
||||||
const movies = JSON.parse(datasetMovies);
|
const movies = JSON.parse(datasetMovies);
|
||||||
|
|
||||||
// Clear the current movie list in the modal
|
// Clear the current movie list in the modal
|
||||||
|
|||||||
Reference in New Issue
Block a user