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
This commit is contained in:
ncantu 2026-01-26 00:55:26 +01:00
parent 8158f833cf
commit 078b36d404

View File

@ -105,6 +105,59 @@
background: #6c757d; background: #6c757d;
cursor: not-allowed; 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> </style>
</head> </head>
<body> <body>
@ -121,14 +174,25 @@
</div> </div>
</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 id="content">
<div class="loading">Chargement des hash...</div> <div class="loading">Chargement des hash...</div>
</div> </div>
<div id="pagination" class="pagination" style="display: none;"></div>
</div> </div>
</div> </div>
<script> <script>
const API_BASE_URL = window.location.origin; 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 // Charger la liste au chargement de la page
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
@ -150,36 +214,13 @@
} }
const data = await response.json(); const data = await response.json();
const hashes = data.hashes || []; allHashes = data.hashes || [];
document.getElementById('hash-count').textContent = hashes.length.toLocaleString('fr-FR'); document.getElementById('hash-count').textContent = allHashes.length.toLocaleString('fr-FR');
updateLastUpdateTime(); updateLastUpdateTime();
if (hashes.length === 0) { // Appliquer le filtre de recherche s'il existe
contentDiv.innerHTML = '<div class="info-section"><p>Aucun hash ancré pour le moment.</p></div>'; filterHashList();
} else {
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>Confirmations</th>';
tableHTML += '</tr></thead><tbody>';
hashes.forEach((item) => {
const mempoolUrl = 'https://mempool.4nkweb.com/fr';
const txLink = `${mempoolUrl}/tx/${item.txid}`;
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>${item.confirmations.toLocaleString('fr-FR')}</td>`;
tableHTML += '</tr>';
});
tableHTML += '</tbody></table></div>';
contentDiv.innerHTML = tableHTML;
}
} catch (error) { } catch (error) {
console.error('Error loading hash list:', 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>`; contentDiv.innerHTML = `<div class="error">Erreur lors du chargement de la liste des hash : ${error.message}</div>`;
@ -188,6 +229,93 @@
} }
} }
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() { function updateLastUpdateTime() {
const now = new Date(); const now = new Date();
document.getElementById('last-update').textContent = now.toLocaleString('fr-FR'); document.getElementById('last-update').textContent = now.toLocaleString('fr-FR');
@ -196,8 +324,8 @@
<footer> <footer>
<p>Bitcoin Ancrage Dashboard - Équipe 4NK</p> <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"> <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"> <svg class="git-icon" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="currentColor">
<path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/> <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> </svg>
</a> </a>
</footer> </footer>