ncantu 078b36d404 Add pagination and search to hash list page
**Motivations:**
- La liste des hash est très longue (17k+ hash) et difficile à naviguer
- Besoin de rechercher un hash spécifique
- La colonne confirmations prend trop de place

**Root causes:**
- Pas de pagination, tous les hash sont affichés d'un coup
- Pas de fonctionnalité de recherche
- Colonne confirmations affiche un nombre alors qu'une coche suffit

**Correctifs:**
- Ajout de la pagination (50 hash par page)
- Ajout d'un champ de recherche pour filtrer par hash (recherche partielle)
- Remplacement de la colonne Confirmations par Confirmé avec coche ✓ (vert) ou ✗ (rouge)
- Navigation avec boutons Précédent/Suivant et affichage du nombre de pages

**Evolutions:**
- Meilleure navigation dans la liste des hash
- Recherche rapide d'un hash spécifique
- Interface plus compacte et lisible

**Pages affectées:**
- signet-dashboard/public/hash-list.html
2026-01-26 00:55:26 +01:00

334 lines
12 KiB
HTML

<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Liste des Hash Ancrés - Bitcoin Ancrage Dashboard</title>
<link rel="stylesheet" href="styles.css">
<style>
.hash-list-container {
max-width: 1400px;
margin: 0 auto;
padding: 20px;
}
.header-section {
margin-bottom: 30px;
}
.header-section h1 {
margin-bottom: 10px;
}
.header-section .back-link {
display: inline-block;
margin-bottom: 20px;
color: #007bff;
text-decoration: none;
}
.header-section .back-link:hover {
text-decoration: underline;
}
.info-section {
background: #f8f9fa;
padding: 15px;
border-radius: 5px;
margin-bottom: 20px;
}
.info-section p {
margin: 5px 0;
}
.table-container {
overflow-x: auto;
}
table {
width: 100%;
border-collapse: collapse;
background: white;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
th, td {
padding: 12px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background: #007bff;
color: white;
font-weight: bold;
position: sticky;
top: 0;
}
tr:hover {
background: #f5f5f5;
}
.hash-cell {
font-family: monospace;
font-size: 0.9em;
word-break: break-all;
}
.txid-cell {
font-family: monospace;
font-size: 0.9em;
}
.txid-link {
color: #007bff;
text-decoration: none;
}
.txid-link:hover {
text-decoration: underline;
}
.loading {
text-align: center;
padding: 40px;
font-size: 1.2em;
color: #666;
}
.error {
background: #f8d7da;
color: #721c24;
padding: 15px;
border-radius: 5px;
margin: 20px 0;
}
.refresh-button {
background: #28a745;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
font-size: 1em;
margin-top: 10px;
}
.refresh-button:hover {
background: #218838;
}
.refresh-button:disabled {
background: #6c757d;
cursor: not-allowed;
}
.search-section {
margin-bottom: 20px;
padding: 15px;
background: #f8f9fa;
border-radius: 5px;
}
.search-input {
width: 100%;
max-width: 500px;
padding: 10px;
font-size: 1em;
border: 1px solid #ddd;
border-radius: 5px;
font-family: monospace;
}
.pagination {
display: flex;
justify-content: center;
align-items: center;
gap: 10px;
margin-top: 20px;
padding: 15px;
}
.pagination button {
background: #007bff;
color: white;
border: none;
padding: 8px 15px;
border-radius: 5px;
cursor: pointer;
font-size: 0.9em;
}
.pagination button:hover:not(:disabled) {
background: #0056b3;
}
.pagination button:disabled {
background: #6c757d;
cursor: not-allowed;
}
.pagination-info {
padding: 0 15px;
color: #666;
}
.confirmed-check {
text-align: center;
font-size: 1.2em;
}
.confirmed-check.yes {
color: #28a745;
}
.confirmed-check.no {
color: #dc3545;
}
</style>
</head>
<body>
<div class="container">
<div class="hash-list-container">
<div class="header-section">
<a href="/" class="back-link">← Retour au dashboard</a>
<h1>Liste des Hash Ancrés</h1>
<div class="info-section">
<p><strong>Total de hash ancrés :</strong> <span id="hash-count">-</span></p>
<p><strong>Dernière mise à jour :</strong> <span id="last-update">-</span></p>
<button class="refresh-button" onclick="loadHashList()">Actualiser</button>
<a href="/api/hash/list.txt" download="hash_list.txt" style="margin-left: 10px; color: #007bff; text-decoration: none;">📥 Télécharger le fichier texte</a>
</div>
</div>
<div class="search-section">
<label for="hash-search" style="display: block; margin-bottom: 8px; font-weight: bold;">Rechercher un hash :</label>
<input type="text" id="hash-search" class="search-input" placeholder="Entrez un hash (64 caractères hexadécimaux)..." oninput="filterHashList()">
</div>
<div id="content">
<div class="loading">Chargement des hash...</div>
</div>
<div id="pagination" class="pagination" style="display: none;"></div>
</div>
</div>
<script>
const API_BASE_URL = window.location.origin;
const ITEMS_PER_PAGE = 50;
let allHashes = [];
let filteredHashes = [];
let currentPage = 1;
// Charger la liste au chargement de la page
document.addEventListener('DOMContentLoaded', () => {
loadHashList();
});
async function loadHashList() {
const contentDiv = document.getElementById('content');
const refreshButton = document.querySelector('.refresh-button');
refreshButton.disabled = true;
contentDiv.innerHTML = '<div class="loading">Chargement des hash...</div>';
try {
const response = await fetch(`${API_BASE_URL}/api/hash/list`);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
allHashes = data.hashes || [];
document.getElementById('hash-count').textContent = allHashes.length.toLocaleString('fr-FR');
updateLastUpdateTime();
// Appliquer le filtre de recherche s'il existe
filterHashList();
} catch (error) {
console.error('Error loading hash list:', error);
contentDiv.innerHTML = `<div class="error">Erreur lors du chargement de la liste des hash : ${error.message}</div>`;
} finally {
refreshButton.disabled = false;
}
}
function filterHashList() {
const searchInput = document.getElementById('hash-search');
const searchTerm = searchInput ? searchInput.value.trim().toLowerCase() : '';
if (searchTerm === '') {
filteredHashes = allHashes;
} else {
// Filtrer par hash (recherche partielle)
filteredHashes = allHashes.filter((item) => {
return item.hash.toLowerCase().includes(searchTerm);
});
}
currentPage = 1;
renderTable();
}
function renderTable() {
const contentDiv = document.getElementById('content');
const paginationDiv = document.getElementById('pagination');
if (filteredHashes.length === 0) {
contentDiv.innerHTML = '<div class="info-section"><p>Aucun hash trouvé.</p></div>';
paginationDiv.style.display = 'none';
return;
}
// Calculer la pagination
const totalPages = Math.ceil(filteredHashes.length / ITEMS_PER_PAGE);
const startIndex = (currentPage - 1) * ITEMS_PER_PAGE;
const endIndex = Math.min(startIndex + ITEMS_PER_PAGE, filteredHashes.length);
const paginatedHashes = filteredHashes.slice(startIndex, endIndex);
// Générer le tableau
let tableHTML = '<div class="table-container"><table><thead><tr>';
tableHTML += '<th>Hash</th>';
tableHTML += '<th>Transaction ID</th>';
tableHTML += '<th>Hauteur du Bloc</th>';
tableHTML += '<th>Confirmé</th>';
tableHTML += '</tr></thead><tbody>';
paginatedHashes.forEach((item) => {
const mempoolUrl = 'https://mempool.4nkweb.com/fr';
const txLink = `${mempoolUrl}/tx/${item.txid}`;
const isConfirmed = (item.confirmations || 0) > 0;
tableHTML += '<tr>';
tableHTML += `<td class="hash-cell">${item.hash}</td>`;
tableHTML += `<td class="txid-cell"><a href="${txLink}" target="_blank" rel="noopener noreferrer" class="txid-link">${item.txid}</a></td>`;
tableHTML += `<td>${item.blockHeight !== null ? item.blockHeight.toLocaleString('fr-FR') : '-'}</td>`;
tableHTML += `<td class="confirmed-check ${isConfirmed ? 'yes' : 'no'}">${isConfirmed ? '✓' : '✗'}</td>`;
tableHTML += '</tr>';
});
tableHTML += '</tbody></table></div>';
contentDiv.innerHTML = tableHTML;
// Générer la pagination
if (totalPages > 1) {
let paginationHTML = '';
// Bouton précédent
paginationHTML += `<button onclick="changePage(${currentPage - 1})" ${currentPage === 1 ? 'disabled' : ''}>Précédent</button>`;
// Informations de pagination
paginationHTML += `<span class="pagination-info">Page ${currentPage} sur ${totalPages} (${filteredHashes.length.toLocaleString('fr-FR')} hash${filteredHashes.length > 1 ? 'es' : ''})</span>`;
// Bouton suivant
paginationHTML += `<button onclick="changePage(${currentPage + 1})" ${currentPage === totalPages ? 'disabled' : ''}>Suivant</button>`;
paginationDiv.innerHTML = paginationHTML;
paginationDiv.style.display = 'flex';
} else {
paginationDiv.style.display = 'none';
}
}
function changePage(page) {
const totalPages = Math.ceil(filteredHashes.length / ITEMS_PER_PAGE);
if (page >= 1 && page <= totalPages) {
currentPage = page;
renderTable();
// Scroller en haut du tableau
document.getElementById('content').scrollIntoView({ behavior: 'smooth', block: 'start' });
}
}
function updateLastUpdateTime() {
const now = new Date();
document.getElementById('last-update').textContent = now.toLocaleString('fr-FR');
}
</script>
<footer>
<p>Bitcoin Ancrage Dashboard - Équipe 4NK</p>
<a href="https://git.4nkweb.com/4nk/anchorage_layer_simple.git" target="_blank" rel="noopener noreferrer" class="git-link" title="Voir le code source sur Git">
<svg class="git-icon" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="currentColor">
<path d="M23.546 10.93L13.067.452c-.604-.603-1.582-.603-2.188 0L8.708 2.627l2.76 2.76c.645-.215 1.379-.07 1.889.441.516.515.658 1.258.438 1.9l2.658 2.66c.645-.223 1.387-.083 1.9.435.721.72.721 1.884 0 2.604-.719.719-1.881.719-2.6 0-.539-.541-.674-1.337-.404-1.996L12.86 8.955v6.525c.176.086.342.203.488.348.713.721.713 1.883 0 2.6-.719.721-1.884.721-2.599 0-.72-.719-.72-1.879 0-2.598.182-.18.387-.316.605-.406V8.835c-.217-.091-.424-.222-.6-.401-.545-.545-.676-1.342-.396-2.011L7.636 3.7.45 10.881c-.6.605-.6 1.584 0 2.189l10.48 10.477c.604.604 1.582.604 2.186 0l10.43-10.43c.605-.603.605-1.582 0-2.187"/>
</svg>
</a>
</footer>
</body>
</html>