diff --git a/backend/main.py b/backend/main.py index e348923..448e5a3 100644 --- a/backend/main.py +++ b/backend/main.py @@ -208,13 +208,18 @@ async def api_imprimantes(): @app.post("/api/imprimer") async def api_imprimer(donnees: dict): nom = donnees.get("photo", "") + copies = donnees.get("copies", 1) + # Limiter au max configure + config = charger_config() + copies_max = config.get("impression", {}).get("copies_max", 5) + copies = max(1, min(copies, copies_max)) # Chercher dans exports d'abord, puis photos chemin = DOSSIER_EXPORTS / nom if not chemin.exists(): chemin = DOSSIER_PHOTOS / nom if not chemin.exists(): return JSONResponse({"erreur": "Photo introuvable"}, status_code=404) - ok = imprimer(chemin) + ok = imprimer(chemin, copies=copies) if ok: distribuer_photo(chemin, imprimee=True) return {"succes": ok} diff --git a/data/config.json b/data/config.json index 57266a3..cb837bf 100644 --- a/data/config.json +++ b/data/config.json @@ -45,7 +45,7 @@ }, "impression": { "imprimante": null, - "copies": 1, + "copies_max": 5, "format": "10x15" }, "cadres": { diff --git a/frontend/css/style.css b/frontend/css/style.css index fc8793e..55f1277 100644 --- a/frontend/css/style.css +++ b/frontend/css/style.css @@ -369,6 +369,55 @@ html, body { font-size: 2.5rem; } +/* Choix exemplaires impression */ +.form-impression { + display: flex; + gap: 1rem; + align-items: center; + margin: 1rem 0; +} + +.exemplaires-choix { + display: flex; + align-items: center; + gap: 0.5rem; +} + +.btn-exemplaire { + width: 48px; + height: 48px; + border-radius: 50%; + border: 2px solid var(--primaire); + background: transparent; + color: var(--primaire); + font-size: 1.5rem; + font-weight: 700; + cursor: pointer; + display: flex; + align-items: center; + justify-content: center; + transition: var(--transition); +} + +.btn-exemplaire:active { + background: var(--primaire); + color: #fff; + transform: scale(0.9); +} + +#nb-exemplaires { + font-size: 2.5rem; + font-weight: 700; + color: var(--texte); + min-width: 50px; + text-align: center; +} + +.exemplaires-label { + color: var(--texte-secondaire); + font-size: 1rem; +} + .form-email { display: flex; gap: 0.8rem; diff --git a/frontend/index.html b/frontend/index.html index c46185f..c066878 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -77,7 +77,7 @@ Photo
- @@ -90,6 +90,17 @@ QR Code
+ +
+
+ + 1 + +
+ exemplaire(s) + + +
@@ -156,8 +167,8 @@
- - + +
diff --git a/frontend/js/admin.js b/frontend/js/admin.js index 7b79580..192d0bc 100644 --- a/frontend/js/admin.js +++ b/frontend/js/admin.js @@ -54,7 +54,7 @@ async function chargerMateriel() { // Imprimantes await rafraichirImprimantes(); if (imp.imprimante) document.getElementById('admin-imprimante').value = imp.imprimante; - setValue('admin-copies', imp.copies || 1); + setValue('admin-copies-max', imp.copies_max || 5); } async function rafraichirImprimantes() { @@ -82,7 +82,7 @@ async function sauvegarderMateriel() { }, impression: { imprimante: getValue('admin-imprimante'), - copies: parseInt(getValue('admin-copies')) || 1, + copies_max: parseInt(getValue('admin-copies-max')) || 5, }, }); afficherStatut('Materiel sauvegarde', 'succes'); diff --git a/frontend/js/share.js b/frontend/js/share.js index 0faaf24..2a487a5 100644 --- a/frontend/js/share.js +++ b/frontend/js/share.js @@ -1,11 +1,31 @@ /* Module partage - Impression, email, QR code */ +let nbExemplaires = 1; +let copiesMax = 5; + +function ouvrirImpression() { + copiesMax = config.impression?.copies_max || 5; + nbExemplaires = 1; + document.getElementById('nb-exemplaires').textContent = nbExemplaires; + document.getElementById('form-impression').classList.remove('cache'); +} + +function fermerImpression() { + document.getElementById('form-impression').classList.add('cache'); +} + +function changerExemplaires(delta) { + nbExemplaires = Math.max(1, Math.min(copiesMax, nbExemplaires + delta)); + document.getElementById('nb-exemplaires').textContent = nbExemplaires; +} + async function lancerImpression() { if (!photoFinale) return; - afficherStatut('Impression en cours...', 'succes'); - const resultat = await apiPost('/api/imprimer', { photo: photoFinale }); + fermerImpression(); + afficherStatut(`Impression de ${nbExemplaires} exemplaire(s)...`, 'succes'); + const resultat = await apiPost('/api/imprimer', { photo: photoFinale, copies: nbExemplaires }); if (resultat.succes) { - afficherStatut('Photo envoyee a l\'imprimante !', 'succes'); + afficherStatut(`${nbExemplaires} exemplaire(s) envoye(s) a l'imprimante !`, 'succes'); } else { afficherStatut('Erreur d\'impression', 'erreur'); }