From 97cb1d2de73fbf8191c9d962057ce9f27257e9dd Mon Sep 17 00:00:00 2001 From: Cedric Date: Mon, 22 Jun 2026 08:49:08 +0200 Subject: [PATCH] Actualiser js/admin.js --- js/admin.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/js/admin.js b/js/admin.js index 44590b1..dde6d6a 100644 --- a/js/admin.js +++ b/js/admin.js @@ -112,7 +112,7 @@ function renderAdminTable() { const tbody = document.getElementById('admin-table-body'); if (!tbody) return; tbody.innerHTML = ''; - + const searchInput = document.getElementById('search-input'); const currentSearch = searchInput ? searchInput.value.toLowerCase() : ''; @@ -157,7 +157,7 @@ function renderAdminTable() { }); renderPagination(totalPages, filtered.length); - + const selectAll = document.getElementById('select-all-checkbox'); if (selectAll) { selectAll.checked = pageItems.length > 0 && pageItems.every(f => selectedIds.has(String(f.id))); @@ -168,6 +168,7 @@ function toggleSingleSelect(id, checkbox) { if (checkbox.checked) selectedIds.add(String(id)); else selectedIds.delete(String(id)); updateBulkBar(); + const filtered = allItems.filter(item => item.type === currentAdminTab); const selectAll = document.getElementById('select-all-checkbox'); if (selectAll) { @@ -210,7 +211,6 @@ function renderPagination(totalPages, totalItems) { container.innerHTML = '

Aucun élément trouvé.

'; return; } - if (totalPages <= 1) return; const info = document.createElement('span'); @@ -369,9 +369,9 @@ function openEditModal(id) { } function closeAdminModal() { document.getElementById('admin-modal').classList.remove('open'); } - -async function openConfigModal() { - document.getElementById('config-modal').classList.add('open'); +async function openConfigModal() { + document.getElementById('config-modal').classList.add('open'); + // Réinitialise les placeholders document.getElementById('tmdb-key-input').placeholder = 'Pour les critiques (réalisateur, streaming)'; document.getElementById('ean-search-key-input').placeholder = 'Recherche par code-barres (Vidéothèque)'; @@ -387,16 +387,12 @@ async function openConfigModal() { if (data.barcode_lookup_key) document.getElementById('barcode-lookup-key-input').placeholder = '✅ Clé configurée (laisser vide pour ne pas changer)'; } catch(e) { console.error(e); } } - function closeConfigModal() { document.getElementById('config-modal').classList.remove('open'); } - function openPasswordModal() { document.getElementById('pwd-error').style.display = 'none'; document.getElementById('password-modal').classList.add('open'); } - function closePasswordModal() { document.getElementById('password-modal').classList.remove('open'); } - function logout() { localStorage.removeItem('token'); window.location.href = 'login.html'; @@ -446,6 +442,7 @@ async function handleCsvUpload(input) { } closeConfigModal(); showProgressModal(allData.length); + const batchSize = 5; let processed = 0; for (let i = 0; i < allData.length; i += batchSize) { @@ -481,6 +478,7 @@ async function saveConfigKeys() { 'ean_search_key': document.getElementById('ean-search-key-input')?.value || '', 'barcode_lookup_key': document.getElementById('barcode-lookup-key-input')?.value || '' }; + let successCount = 0; // Sauvegarde uniquement les champs qui ont été remplis/modifiés for (const [keyName, keyValue] of Object.entries(keys)) { @@ -496,7 +494,7 @@ async function saveConfigKeys() { } catch (err) { console.error(err); } } } - + if (successCount > 0) { alert('✅ Clés API sauvegardées !'); closeConfigModal();