fix: gestion correcte des doublons dans le frontend (compteur dédié + message final adapté)

This commit is contained in:
2026-06-25 21:28:04 -04:00
parent 9cabfb526b
commit ce93740a5e
3 changed files with 18 additions and 14 deletions
+3 -3
View File
@@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Changelog — imagod-web v0.2.0+build.28-42eff29-dirty</title> <title>Changelog — imagod-web v0.2.0+build.29-9cabfb5-dirty</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🖼️</text></svg>"> <link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🖼️</text></svg>">
<style> <style>
* { margin:0; padding:0; box-sizing:border-box; } * { margin:0; padding:0; box-sizing:border-box; }
@@ -37,7 +37,7 @@ footer { text-align:center; color:#484f58; font-size:0.8rem; padding:2rem; }
</head> </head>
<body> <body>
<header> <header>
<h1>📋 imagod-web <span class="version-badge">v0.2.0+build.28-42eff29-dirty</span></h1> <h1>📋 imagod-web <span class="version-badge">v0.2.0+build.29-9cabfb5-dirty</span></h1>
<nav> <nav>
<a href="/">🖼️ Galerie</a> <a href="/">🖼️ Galerie</a>
<a href="/changelog" class="active">📋 Changelog</a> <a href="/changelog" class="active">📋 Changelog</a>
@@ -107,6 +107,6 @@ footer { text-align:center; color:#484f58; font-size:0.8rem; padding:2rem; }
<h2>Légende des tags</h2> <h2>Légende des tags</h2>
</main> </main>
<footer>imagod-web v0.2.0+build.28-42eff29-dirty — <a href="https://git.dracodev.net/Projets/imagod-web">Gitea</a></footer> <footer>imagod-web v0.2.0+build.29-9cabfb5-dirty — <a href="https://git.dracodev.net/Projets/imagod-web">Gitea</a></footer>
</body> </body>
</html> </html>
+3 -3
View File
@@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Aide & Roadmap — imagod-web v0.2.0+build.28-42eff29-dirty</title> <title>Aide & Roadmap — imagod-web v0.2.0+build.29-9cabfb5-dirty</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🖼️</text></svg>"> <link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🖼️</text></svg>">
<style> <style>
* { margin:0; padding:0; box-sizing:border-box; } * { margin:0; padding:0; box-sizing:border-box; }
@@ -37,7 +37,7 @@ footer { text-align:center; color:#484f58; font-size:0.8rem; padding:2rem; }
</head> </head>
<body> <body>
<header> <header>
<h1>❓ imagod-web <span class="version-badge">v0.2.0+build.28-42eff29-dirty</span></h1> <h1>❓ imagod-web <span class="version-badge">v0.2.0+build.29-9cabfb5-dirty</span></h1>
<nav> <nav>
<a href="/">🖼️ Galerie</a> <a href="/">🖼️ Galerie</a>
<a href="/changelog">📋 Changelog</a> <a href="/changelog">📋 Changelog</a>
@@ -169,6 +169,6 @@ footer { text-align:center; color:#484f58; font-size:0.8rem; padding:2rem; }
<p>5. <strong>Corriger le backend Imago</strong> (thumbnails, upload, stockage)</p> <p>5. <strong>Corriger le backend Imago</strong> (thumbnails, upload, stockage)</p>
</main> </main>
<footer>imagod-web v0.2.0+build.28-42eff29-dirty — <a href="https://git.dracodev.net/Projets/imagod-web">Gitea</a></footer> <footer>imagod-web v0.2.0+build.29-9cabfb5-dirty — <a href="https://git.dracodev.net/Projets/imagod-web">Gitea</a></footer>
</body> </body>
</html> </html>
+12 -8
View File
@@ -465,7 +465,7 @@
<button class="btn" id="clear-btn" style="display:none">✕</button> <button class="btn" id="clear-btn" style="display:none">✕</button>
</div> </div>
<button class="btn accent" id="header-upload-btn" onclick="document.getElementById('drop-zone').scrollIntoView({behavior:'smooth'}); document.getElementById('file-input').click()">📤 Upload</button> <button class="btn accent" id="header-upload-btn" onclick="document.getElementById('drop-zone').scrollIntoView({behavior:'smooth'}); document.getElementById('file-input').click()">📤 Upload</button>
<span class="version-badge" id="version-badge">v0.2.0+build.28-42eff29-dirty</span> <span class="version-badge" id="version-badge">v0.2.0+build.29-9cabfb5-dirty</span>
</div> </div>
<!-- ─── Navigation ─── --> <!-- ─── Navigation ─── -->
@@ -922,7 +922,7 @@ async function uploadFiles(files) {
isUploading = true; isUploading = true;
const zone = document.getElementById('drop-zone'); const zone = document.getElementById('drop-zone');
let successCount = 0, errorCount = 0; let successCount = 0, duplicatedCount = 0, errorCount = 0;
for (const file of files) { for (const file of files) {
if (!file.type.startsWith('image/')) { if (!file.type.startsWith('image/')) {
@@ -942,10 +942,10 @@ async function uploadFiles(files) {
const data = await r.json(); const data = await r.json();
if (r.ok) { if (r.ok) {
// duplicate = l'image existe déjà → c'est un succès // duplicate = l'image existe déjà → pas un upload, on informe juste
if (data.status === 'duplicate') { if (data.status === 'duplicate') {
successCount++;
showToast(`${file.name} déjà existante (dédoublonnée) ✓`, 'info', 3000); showToast(`${file.name} déjà existante (dédoublonnée) ✓`, 'info', 3000);
duplicatedCount++;
} else { } else {
successCount++; successCount++;
showToast(`${file.name} uploadée !`, 'success', 3000); showToast(`${file.name} uploadée !`, 'success', 3000);
@@ -974,15 +974,19 @@ async function uploadFiles(files) {
zone.classList.remove('uploading'); zone.classList.remove('uploading');
zone.querySelector('.drop-zone-text').textContent = 'Glissez-déposez des images ici'; zone.querySelector('.drop-zone-text').textContent = 'Glissez-déposez des images ici';
if (successCount > 0) { if (successCount > 0 || duplicatedCount > 0) {
document.getElementById('file-input').value = ''; document.getElementById('file-input').value = '';
loadImages(1); loadImages(1);
loadStats(); loadStats();
if (successCount === 1 && files.length === 1 && errorCount === 0) { if (successCount > 0 && duplicatedCount === 0 && errorCount === 0 && files.length === 1) {
showToast('Image uploadée avec succès ! ✨', 'success'); showToast('Image uploadée avec succès ! ✨', 'success');
} else { } else if (successCount > 0) {
showToast(`${successCount} uploadée(s)${errorCount ? `, ${errorCount} échec(s)` : ''}`, errorCount ? 'info' : 'success'); const parts = [`${successCount} uploadée(s)`];
if (duplicatedCount > 0) parts.push(`${duplicatedCount} déjà existante(s)`);
if (errorCount > 0) parts.push(`${errorCount} échec(s)`);
showToast(parts.join(', '), errorCount > 0 ? 'warning' : 'success');
} }
// Si que des doublons : pas de toast supplémentaire (déjà affiché par fichier)
} }
} }