Actualiser js/admin.js

This commit is contained in:
2026-07-01 10:34:27 +02:00
parent 08f5b9ec40
commit abaf2668b1
+7 -13
View File
@@ -447,23 +447,17 @@ function handleVideothequeUpload(input) {
try {
// ✅ Lots de 1 seul pour éviter le blocage Blu-ray.com
for (let i = 0; i < items.length; i += 1) {
const batch = items.slice(i, i + 1);
const batchSize = 5; // ou 10 selon la puissance du serveur
for (let i = 0; i < items.length; i += batchSize) {
const batch = items.slice(i, i + batchSize);
const res = await fetch(`${API_URL}?action=import_batch`, {
method: 'POST',
headers: { 'Authorization': localStorage.getItem('token'), 'Content-Type': 'application/json' },
body: JSON.stringify({ type: 'videotheque', items: batch })
});
if (!res.ok) throw new Error(`Erreur HTTP ${res.status}`);
const data = await res.json();
if (!data.success) throw new Error(data.error || "Échec API");
totalImp += data.imported || 0;
totalSkp += data.skipped || 0;
processed += batch.length;
updateImportModal(processed, items.length);
await new Promise(r => setTimeout(r, 500)); // Délai de sécurité
// ... traitement de la réponse
// Petit délai optionnel (100 ms) pour éviter de saturer le serveur
await new Promise(r => setTimeout(r, 100));
}
input.value = '';
@@ -479,7 +473,7 @@ function handleVideothequeUpload(input) {
}
};
reader.readAsText(file);
}
}
function showImportModal(total, type) {
document.getElementById('import-modal-title').innerHTML = type === 'critique' ? '<i class="ti ti-star"></i> Import Critiques' : '<i class="ti ti-video"></i> Import Vidéothèque';