From 843762b6d780095865621a1f184285f549f53c27 Mon Sep 17 00:00:00 2001 From: Jules Date: Thu, 4 Jun 2026 21:17:27 +0200 Subject: [PATCH] =?UTF-8?q?Imprimante=20:=20bandeau=20erreur=20tous=20?= =?UTF-8?q?=C3=A9crans=20+=20reset=20USB=20+=20statut=20d=C3=A9taill=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- backend/main.py | 32 ++++++++++++++++++++++++++++++++ frontend/css/style.css | 23 +++++++++++++++++++++++ frontend/index.html | 12 ++++++++++-- frontend/js/admin.js | 6 ++++++ frontend/js/app.js | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 103 insertions(+), 2 deletions(-) diff --git a/backend/main.py b/backend/main.py index 691ef6a..9994676 100644 --- a/backend/main.py +++ b/backend/main.py @@ -566,6 +566,38 @@ async def api_evacuer_bourrage(): return {"succes": True, "message": msg} +@app.post("/api/imprimante/reset-usb") +async def api_reset_usb(): + """Réinitialise la connexion USB de l'imprimante (unbind/rebind driver).""" + import subprocess, glob + try: + # Trouver le device USB Mitsubishi K60 (VID 06d3) + devs = glob.glob("/sys/bus/usb/devices/*/idVendor") + path = None + for f in devs: + if open(f).read().strip() == "06d3": + path = f.replace("/idVendor", "") + break + if not path: + return {"succes": False, "message": "Imprimante USB non trouvée — vérifiez la connexion"} + + dev_id = path.split("/")[-1] + # Annuler les jobs d'abord + nom = charger_config().get("impression", {}).get("imprimante", "Mitsubishi") + subprocess.run(["sudo", "cancel", "-a", nom], capture_output=True) + # Unbind/rebind USB + subprocess.run(["sudo", "sh", "-c", f"echo '{dev_id}' > /sys/bus/usb/drivers/usb/unbind"], + capture_output=True) + await asyncio.sleep(1) + subprocess.run(["sudo", "sh", "-c", f"echo '{dev_id}' > /sys/bus/usb/drivers/usb/bind"], + capture_output=True) + await asyncio.sleep(2) + subprocess.run(["sudo", "cupsenable", nom], capture_output=True) + return {"succes": True, "message": "Imprimante réinitialisée — prête dans quelques secondes"} + except Exception as e: + return {"succes": False, "message": str(e)} + + @app.post("/api/imprimer") async def api_imprimer(donnees: dict): nom = donnees.get("photo", "") diff --git a/frontend/css/style.css b/frontend/css/style.css index 4cb519a..9751e35 100644 --- a/frontend/css/style.css +++ b/frontend/css/style.css @@ -1533,6 +1533,29 @@ h3 { } /* === Erreur camera === */ +.printer-erreur { + position: fixed; + bottom: 0; left: 0; right: 0; + background: #b71c1c; + color: #fff; + display: flex; + align-items: center; + gap: 1rem; + padding: 0.8rem 1.5rem; + z-index: 9999; + font-size: 1rem; +} + +.printer-erreur-icon { font-size: 1.4rem; flex-shrink: 0; } + +.printer-erreur span:nth-child(2) { flex: 1; } + +.printer-erreur button { + background: none; border: 2px solid rgba(255,255,255,0.5); + color: #fff; border-radius: 50%; width: 32px; height: 32px; + cursor: pointer; font-size: 1rem; flex-shrink: 0; +} + .camera-erreur { position: fixed; top: 0; left: 0; diff --git a/frontend/index.html b/frontend/index.html index fe8c736..61c29ae 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -13,6 +13,13 @@
+ +
+ 🖨 + Problème imprimante + +
+
📷
@@ -395,8 +402,9 @@
-
- +
+ +