Compare commits
28 Commits
e5e9f763ab
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| abc5d78575 | |||
| d845c2606e | |||
| 6d58fe5d57 | |||
| e6a0b268ff | |||
| 2f32cf2f38 | |||
| 61b9a72f10 | |||
| 4931a29d45 | |||
| 5e8cff7951 | |||
| bb49c2c82d | |||
| 812de8ae53 | |||
| 5f1a96ab8a | |||
| d21d87347d | |||
| 5c774babbb | |||
| 6c45faecdc | |||
| be838a7a48 | |||
| d9c8d9b779 | |||
| 05f78f731d | |||
| 6b2928c9af | |||
| 0e1b951ed4 | |||
| f1299fd6a7 | |||
| 96464ccca1 | |||
| 583b89f0bd | |||
| 4e267492c2 | |||
| a6766f529e | |||
| 3aa3068127 | |||
| 5e482a89e7 | |||
| 3b6f376ded | |||
| 44a9992557 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -17,3 +17,4 @@ data/exports/*
|
||||
*.log
|
||||
.DS_Store
|
||||
printer-driver-*.deb
|
||||
data/config.json
|
||||
|
||||
135
PROCEDURE_VPN_FIX.md
Normal file
135
PROCEDURE_VPN_FIX.md
Normal file
@@ -0,0 +1,135 @@
|
||||
---
|
||||
name: booth-vpn-fix
|
||||
description: Procédure urgente pour rétablir le tunnel WireGuard sur la Surface (booth terrain) et installer un watchdog
|
||||
metadata:
|
||||
node_type: memory
|
||||
type: project
|
||||
originSessionId: 6d8a34f4-db2f-4d5b-92e9-895e3925ccb5
|
||||
---
|
||||
|
||||
## Problème
|
||||
|
||||
Le booth (Surface) est sur un WiFi externe, le tunnel WireGuard ne se connecte pas même après reboot.
|
||||
Dernier handshake : 6+ jours. Aucun accès SSH ni VPN.
|
||||
|
||||
**Why:** Le service wg-quick@wg0 n'est peut-être pas enabled au boot, ou l'Endpoint dans la config WG pointe vers une IP locale (192.168.111.x) au lieu de l'IP publique.
|
||||
|
||||
## Infos serveur WG (LXC 111)
|
||||
|
||||
- IP LXC : 192.168.111.211
|
||||
- Port WG : 51820 (UDP) — écoute OK
|
||||
- Clé publique serveur : `g3s7Gh1Er+LIEI/W91HAVDNIo+gsk/KiajdtoDUQRVo=`
|
||||
- Le port 51820 est redirigé depuis la box vers le LXC
|
||||
|
||||
## Étapes à faire sur la Surface (SSH ou clavier physique)
|
||||
|
||||
### 1. Diagnostic
|
||||
|
||||
```bash
|
||||
sudo systemctl status wg-quick@wg0
|
||||
sudo wg show
|
||||
cat /etc/wireguard/wg0.conf
|
||||
```
|
||||
|
||||
### 2. Vérifier l'Endpoint
|
||||
|
||||
Dans `/etc/wireguard/wg0.conf`, le `[Peer]` doit avoir :
|
||||
```
|
||||
Endpoint = <IP_PUBLIQUE_MAISON>:51820
|
||||
```
|
||||
**PAS** une IP locale type 192.168.111.x — ça ne marche que depuis le LAN.
|
||||
|
||||
Pour trouver l'IP publique depuis le PC fixe :
|
||||
```bash
|
||||
curl -s ifconfig.me
|
||||
```
|
||||
|
||||
### 3. Activer au boot + relancer
|
||||
|
||||
```bash
|
||||
sudo systemctl enable wg-quick@wg0
|
||||
sudo systemctl restart wg-quick@wg0
|
||||
sudo wg show
|
||||
```
|
||||
|
||||
Vérifier que le handshake se fait (latest handshake < 1 minute).
|
||||
|
||||
### 4. Installer le watchdog WG (une fois le tunnel rétabli)
|
||||
|
||||
Créer `/usr/local/bin/wg-watchdog.sh` :
|
||||
```bash
|
||||
#!/bin/bash
|
||||
IFACE=wg0
|
||||
MAX_AGE=180 # 3 minutes sans handshake = relance
|
||||
|
||||
latest=$(sudo wg show $IFACE latest-handshakes 2>/dev/null | awk '{print $2}')
|
||||
if [ -z "$latest" ] || [ "$latest" = "0" ]; then
|
||||
systemctl restart wg-quick@$IFACE
|
||||
exit 0
|
||||
fi
|
||||
|
||||
now=$(date +%s)
|
||||
age=$((now - latest))
|
||||
if [ $age -gt $MAX_AGE ]; then
|
||||
logger "wg-watchdog: handshake age ${age}s > ${MAX_AGE}s, restarting $IFACE"
|
||||
systemctl restart wg-quick@$IFACE
|
||||
fi
|
||||
```
|
||||
|
||||
```bash
|
||||
sudo chmod +x /usr/local/bin/wg-watchdog.sh
|
||||
echo "* * * * * root /usr/local/bin/wg-watchdog.sh" | sudo tee /etc/cron.d/wg-watchdog
|
||||
```
|
||||
|
||||
### 5. Installer reverse SSH en fallback
|
||||
|
||||
```bash
|
||||
sudo apt install -y autossh
|
||||
```
|
||||
|
||||
Créer `/etc/systemd/system/autossh-tunnel.service` :
|
||||
```ini
|
||||
[Unit]
|
||||
Description=Reverse SSH tunnel fallback
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
User=jules
|
||||
ExecStart=/usr/bin/autossh -M 0 -N -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -o "ExitOnForwardFailure yes" -R 2222:localhost:22 root@192.168.111.211
|
||||
Restart=always
|
||||
RestartSec=30
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
```bash
|
||||
sudo systemctl enable autossh-tunnel
|
||||
sudo systemctl start autossh-tunnel
|
||||
```
|
||||
|
||||
Ensuite depuis le LXC 111 : `ssh -p 2222 jules@localhost` pour joindre la Surface même si WG est mort.
|
||||
|
||||
**Prérequis :** la clé SSH de jules@surface doit être dans authorized_keys de root@192.168.111.211 (LXC).
|
||||
|
||||
### 6. Déployer les dernières modifs
|
||||
|
||||
Une fois le tunnel rétabli :
|
||||
```bash
|
||||
cd /home/jules/photobooth && git pull && sudo systemctl restart photobooth
|
||||
```
|
||||
|
||||
Commits non déployés sur Surface :
|
||||
- Flash blanc capture + printer toast CSS + admin galerie + compteur copies
|
||||
- Cache versions bump
|
||||
|
||||
## Changements faits sur LXC 111 (cette session)
|
||||
|
||||
- Landing page vitrine complète (tarifs, formulaire résa, calendrier dispo)
|
||||
- Endpoint `/api/contact` : crée événement + email admin (pas client)
|
||||
- Endpoint `/api/contact/valider/{id}` : valide résa + envoie email client
|
||||
- Endpoint `/api/disponibilites` : dates occupées pour calendrier
|
||||
- ZIP streaming (fix 500 sur gros ZIP)
|
||||
- Barre progression téléchargement ZIP
|
||||
- Admin panel : section "Demandes en attente" avec bouton Valider
|
||||
@@ -88,11 +88,12 @@ class Camera:
|
||||
pass
|
||||
cam.init()
|
||||
self.camera = cam
|
||||
self._desactiver_veille_init()
|
||||
self._activer_viewfinder_init()
|
||||
time.sleep(1)
|
||||
self._configurer_init()
|
||||
self.connectee = True
|
||||
self.mode = "gphoto2"
|
||||
self.preview_dslr_ok = True
|
||||
self._log_reglages()
|
||||
log.info("Camera DSLR connectee (LiveView actif)")
|
||||
return True
|
||||
except Exception as e:
|
||||
@@ -190,23 +191,36 @@ class Camera:
|
||||
vf = cfg.get_child_by_name("viewfinder")
|
||||
vf.set_value(0)
|
||||
self.camera.set_config(cfg)
|
||||
time.sleep(0.8)
|
||||
except Exception:
|
||||
pass
|
||||
log.info(f"Déclenchement capture DSLR (tentative {attempt+1}/3)")
|
||||
t0 = time.time()
|
||||
chemin_camera = self.camera.capture(gp.GP_CAPTURE_IMAGE)
|
||||
t1 = time.time()
|
||||
fichier_camera = gp.CameraFile()
|
||||
self.camera.file_get(
|
||||
chemin_camera.folder, chemin_camera.name, gp.GP_FILE_TYPE_NORMAL, fichier_camera
|
||||
)
|
||||
t2 = time.time()
|
||||
tmp_path = str(chemin_dest) + ".tmp"
|
||||
fichier_camera.save(tmp_path)
|
||||
log.info(f"Capture: shutter={t1-t0:.1f}s download={t2-t1:.1f}s")
|
||||
threading.Thread(target=self._post_capture_warmup, daemon=True).start()
|
||||
from PIL import ImageOps as PILImageOps
|
||||
img = PILImageOps.exif_transpose(PILImage.open(tmp_path))
|
||||
t3 = time.time()
|
||||
pil_img = PILImage.open(tmp_path)
|
||||
exif_data = pil_img.info.get("exif")
|
||||
img = PILImageOps.exif_transpose(pil_img)
|
||||
if img.width > 4000:
|
||||
ratio = 4000 / img.width
|
||||
img = img.resize((4000, int(img.height * ratio)), PILImage.LANCZOS)
|
||||
img.save(str(chemin_dest), "JPEG", quality=92)
|
||||
img = img.resize((4000, int(img.height * ratio)), PILImage.BILINEAR)
|
||||
save_kwargs = {"quality": 92}
|
||||
if exif_data:
|
||||
save_kwargs["exif"] = exif_data
|
||||
img.save(str(chemin_dest), "JPEG", **save_kwargs)
|
||||
t4 = time.time()
|
||||
log.info(f"Post-process: {t4-t3:.1f}s")
|
||||
Path(tmp_path).unlink(missing_ok=True)
|
||||
log.info(f"Photo capturee (DSLR) : {chemin_dest} ({img.width}x{img.height})")
|
||||
return chemin_dest
|
||||
@@ -292,35 +306,49 @@ class Camera:
|
||||
except Exception as e:
|
||||
log.debug(f"configurer_flash : {e}")
|
||||
|
||||
def _desactiver_veille_init(self):
|
||||
"""Desactive la mise en veille auto du boitier (Canon : autopoweroff en minutes, 0=jamais).
|
||||
Sans ca, le DSLR s'eteint seul apres quelques minutes d'inactivite et apparait deconnecte."""
|
||||
candidats = ["autopoweroff", "auto_power_off", "/main/settings/autopoweroff"]
|
||||
def _configurer_init(self):
|
||||
"""Configure le Canon : veille OFF, ISO, drivemode, viewfinder (appels séparés)."""
|
||||
reglages = [
|
||||
("autopoweroff", 0),
|
||||
("viewfinder", 1),
|
||||
("iso", "800"),
|
||||
("aperture", "4"),
|
||||
("drivemode", "Single"),
|
||||
]
|
||||
for nom, valeur in reglages:
|
||||
for tentative in range(3):
|
||||
try:
|
||||
cfg = self.camera.get_config()
|
||||
for nom in candidats:
|
||||
try:
|
||||
widget = cfg.get_child_by_name(nom)
|
||||
widget.set_value(0)
|
||||
w = cfg.get_child_by_name(nom)
|
||||
w.set_value(valeur)
|
||||
self.camera.set_config(cfg)
|
||||
log.info(f"Mise en veille DSLR désactivée ({nom})")
|
||||
return
|
||||
log.info(f"Canon init: {nom} = {valeur}")
|
||||
break
|
||||
except gp.GPhoto2Error as e:
|
||||
if tentative < 2:
|
||||
time.sleep(0.5)
|
||||
else:
|
||||
log.warning(f"Canon init {nom}: {e}")
|
||||
except Exception:
|
||||
continue
|
||||
log.debug("Widget autopoweroff non trouvé sur ce modèle")
|
||||
except Exception as e:
|
||||
log.debug(f"_desactiver_veille_init : {e}")
|
||||
break
|
||||
|
||||
def _activer_viewfinder_init(self):
|
||||
"""Active le LiveView pendant l'init (pas de lock, appelé avant que le thread démarre)."""
|
||||
def _log_reglages(self):
|
||||
"""Log les réglages Canon actuels pour diagnostic."""
|
||||
try:
|
||||
cfg = self.camera.get_config()
|
||||
vf = cfg.get_child_by_name("viewfinder")
|
||||
vf.set_value(1)
|
||||
self.camera.set_config(cfg)
|
||||
log.info("Viewfinder activé (init)")
|
||||
except Exception as e:
|
||||
log.warning(f"Viewfinder non supporté : {e}")
|
||||
vals = {}
|
||||
for nom in ["autoexposuremode", "iso", "shutterspeed", "aperture", "meteringmode"]:
|
||||
try:
|
||||
w = cfg.get_child_by_name(nom)
|
||||
vals[nom] = w.get_value()
|
||||
log.info(f"Canon actuel: {nom} = {vals[nom]}")
|
||||
except Exception:
|
||||
pass
|
||||
mode = vals.get("autoexposuremode", "")
|
||||
if mode in ("Flash Off", "Auto", "Night Portrait", "Landscape", "Portrait", "Sports"):
|
||||
log.warning(f"Canon en mode scène '{mode}' — ISO/vitesse non modifiables. Tourner le dial sur M ou Av.")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def activer_viewfinder(self):
|
||||
"""Active le LiveView (miroir levé) depuis le thread — thread-safe."""
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import ftplib
|
||||
import json
|
||||
import logging
|
||||
import shutil
|
||||
import threading
|
||||
@@ -6,12 +7,15 @@ from pathlib import Path
|
||||
from urllib.request import Request, urlopen
|
||||
from urllib.error import URLError
|
||||
|
||||
from backend.config import charger_config, mettre_a_jour_config
|
||||
from backend.config import charger_config, mettre_a_jour_config, RACINE
|
||||
|
||||
log = logging.getLogger("photobooth.destinations")
|
||||
|
||||
FICHIER_BOOTH_SPOOL = RACINE / "data" / "booth_spool.json"
|
||||
_booth_spool_lock = threading.Lock()
|
||||
|
||||
def distribuer_photo(chemin_photo: Path, imprimee: bool = False, copies: int = 1):
|
||||
|
||||
def distribuer_photo(chemin_photo: Path, imprimee: bool = False, copies: int = 1, format_papier: str | None = None):
|
||||
"""Copie la photo vers toutes les destinations activees."""
|
||||
config = charger_config()
|
||||
dest = config.get("destinations", {})
|
||||
@@ -37,12 +41,21 @@ def distribuer_photo(chemin_photo: Path, imprimee: bool = False, copies: int = 1
|
||||
if dest.get("ftp", False):
|
||||
envoyer_ftp(chemin_photo, dest, sous_dossier)
|
||||
|
||||
# Notifier booth que la photo a ete imprimee
|
||||
if imprimee and booth.get("actif", False):
|
||||
threading.Thread(
|
||||
target=notifier_booth_impression,
|
||||
args=(chemin_photo.name, copies, booth, config),
|
||||
daemon=True,
|
||||
).start()
|
||||
|
||||
# Incrementer le compteur (feuilles 10x15 consommees)
|
||||
if imprimee:
|
||||
compteur = config.get("compteur", {})
|
||||
if compteur.get("actif", False):
|
||||
compteur["photos_prises"] = compteur.get("photos_prises", 0) + copies
|
||||
mettre_a_jour_config({"compteur": compteur})
|
||||
maj_consommables(config, copies, format_papier)
|
||||
|
||||
|
||||
def copier_usb(chemin_photo: Path, chemin_usb: str, sous_dossier: str | None = None):
|
||||
@@ -117,7 +130,7 @@ def _upload_booth(url: str, api_key: str, event_id: str, chemin_photo: Path) ->
|
||||
|
||||
|
||||
def envoyer_booth(chemin_photo: Path, config_booth: dict):
|
||||
"""Envoie une photo vers la galerie live booth."""
|
||||
"""Envoie une photo vers la galerie live booth. En cas d'echec, met en spool."""
|
||||
url = config_booth.get("url", "").rstrip("/")
|
||||
url_tunnel = config_booth.get("url_tunnel", "").rstrip("/")
|
||||
api_key = config_booth.get("api_key", "")
|
||||
@@ -136,9 +149,117 @@ def envoyer_booth(chemin_photo: Path, config_booth: dict):
|
||||
log.error(f"Booth erreur HTTP via {tentative_url}")
|
||||
except (URLError, OSError) as e:
|
||||
log.warning(f"Echec envoi booth via {tentative_url} : {e}")
|
||||
|
||||
_ajouter_booth_spool(str(chemin_photo))
|
||||
return False
|
||||
|
||||
|
||||
def notifier_booth_impression(filename: str, copies: int, config_booth: dict, config: dict):
|
||||
"""Notifie booth.copydev.fr qu'une photo a ete imprimee."""
|
||||
url = config_booth.get("url", "").rstrip("/")
|
||||
url_tunnel = config_booth.get("url_tunnel", "").rstrip("/")
|
||||
api_key = config_booth.get("api_key", "")
|
||||
event_id = config.get("evenement", {}).get("event_id") or config_booth.get("event_id", "default")
|
||||
|
||||
body = json.dumps({"copies": copies}).encode()
|
||||
for tentative_url in [u for u in (url_tunnel, url) if u]:
|
||||
try:
|
||||
req = Request(
|
||||
f"{tentative_url}/admin/gallery/{event_id}/photo/{filename}/imprimee",
|
||||
data=body, method="POST",
|
||||
)
|
||||
req.add_header("Content-Type", "application/json")
|
||||
req.add_header("X-Api-Key", api_key)
|
||||
with urlopen(req, timeout=10) as resp:
|
||||
if resp.status == 200:
|
||||
log.info(f"Booth notifie impression: {filename} x{copies}")
|
||||
return
|
||||
except (URLError, OSError) as e:
|
||||
log.warning(f"Echec notification impression booth: {e}")
|
||||
|
||||
|
||||
# --- Spool galerie booth ---
|
||||
|
||||
def _ajouter_booth_spool(chemin: str):
|
||||
with _booth_spool_lock:
|
||||
spool = _charger_booth_spool()
|
||||
if chemin not in spool:
|
||||
spool.append(chemin)
|
||||
_sauver_booth_spool(spool)
|
||||
log.info(f"Photo mise en spool galerie ({len(spool)} en attente)")
|
||||
|
||||
|
||||
def _charger_booth_spool() -> list:
|
||||
if not FICHIER_BOOTH_SPOOL.exists():
|
||||
return []
|
||||
try:
|
||||
with open(FICHIER_BOOTH_SPOOL, "r") as f:
|
||||
return json.load(f)
|
||||
except (json.JSONDecodeError, OSError):
|
||||
return []
|
||||
|
||||
|
||||
def _sauver_booth_spool(spool: list):
|
||||
try:
|
||||
with open(FICHIER_BOOTH_SPOOL, "w") as f:
|
||||
json.dump(spool, f)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
def taille_booth_spool() -> int:
|
||||
with _booth_spool_lock:
|
||||
return len(_charger_booth_spool())
|
||||
|
||||
|
||||
def traiter_booth_spool() -> int:
|
||||
"""Retente l'envoi des photos en spool. Retourne le nombre envoyees."""
|
||||
with _booth_spool_lock:
|
||||
spool = _charger_booth_spool()
|
||||
if not spool:
|
||||
return 0
|
||||
|
||||
config = charger_config()
|
||||
booth = config.get("booth", {})
|
||||
if not booth.get("actif", False):
|
||||
return 0
|
||||
|
||||
envoyes = 0
|
||||
restants = []
|
||||
for chemin_str in spool:
|
||||
chemin = Path(chemin_str)
|
||||
if not chemin.exists():
|
||||
log.warning(f"Spool booth: photo introuvable {chemin}, ignoree")
|
||||
continue
|
||||
url = booth.get("url", "").rstrip("/")
|
||||
url_tunnel = booth.get("url_tunnel", "").rstrip("/")
|
||||
api_key = booth.get("api_key", "")
|
||||
event_id = config.get("evenement", {}).get("event_id") or booth.get("event_id", "default")
|
||||
ok = False
|
||||
for tentative_url in [u for u in (url_tunnel, url) if u]:
|
||||
try:
|
||||
if _upload_booth(tentative_url, api_key, event_id, chemin):
|
||||
log.info(f"Spool booth: {chemin.name} envoyee via {tentative_url}")
|
||||
ok = True
|
||||
break
|
||||
except (URLError, OSError):
|
||||
pass
|
||||
if ok:
|
||||
envoyes += 1
|
||||
else:
|
||||
restants.append(chemin_str)
|
||||
break
|
||||
|
||||
if envoyes > 0 or len(restants) < len(spool):
|
||||
idx = envoyes + len(restants)
|
||||
restants.extend(spool[idx:])
|
||||
with _booth_spool_lock:
|
||||
_sauver_booth_spool(restants)
|
||||
log.info(f"Spool booth: {envoyes} envoyee(s), {len(restants)} en attente")
|
||||
|
||||
return envoyes
|
||||
|
||||
|
||||
def recuperer_booth_password() -> dict:
|
||||
"""Recupere le mot de passe et l'info de la session booth."""
|
||||
config = charger_config()
|
||||
@@ -202,19 +323,110 @@ def detecter_usb() -> list[str]:
|
||||
|
||||
|
||||
def compteur_restant() -> dict:
|
||||
"""Retourne l'etat du compteur."""
|
||||
"""Retourne l'etat du compteur, basé sur les consommables restants."""
|
||||
config = charger_config()
|
||||
compteur = config.get("compteur", {})
|
||||
limite = compteur.get("limite", 400)
|
||||
conso = config.get("consommables", {})
|
||||
prises = compteur.get("photos_prises", 0)
|
||||
papier_rest = max(0, conso.get("papier_capacite", 320) - conso.get("papier_utilise", 0))
|
||||
ruban_rest = max(0, round(conso.get("ruban_capacite", 320) - conso.get("ruban_utilise", 0), 1))
|
||||
restantes = int(min(papier_rest, ruban_rest))
|
||||
limite_event = compteur.get("limite", 0)
|
||||
if compteur.get("actif") and limite_event > 0:
|
||||
restantes = min(restantes, max(0, limite_event - prises))
|
||||
papier_cap = conso.get("papier_capacite", 320)
|
||||
ruban_cap = conso.get("ruban_capacite", 320)
|
||||
capacite_conso = int(min(papier_cap, ruban_cap))
|
||||
return {
|
||||
"actif": compteur.get("actif", False),
|
||||
"limite": limite,
|
||||
"limite": limite_event,
|
||||
"photos_prises": prises,
|
||||
"restantes": max(0, limite - prises),
|
||||
"restantes": restantes,
|
||||
"capacite": capacite_conso,
|
||||
"papier_restant": papier_rest,
|
||||
"ruban_restant": int(ruban_rest),
|
||||
}
|
||||
|
||||
|
||||
def reset_compteur():
|
||||
"""Remet le compteur a zero."""
|
||||
mettre_a_jour_config({"compteur": {"photos_prises": 0}})
|
||||
|
||||
|
||||
# --- Suivi consommables ---
|
||||
|
||||
RATIO_RUBAN_OPTIMAL = {
|
||||
"10x15": 0.5,
|
||||
"10x15-2up": 1.0,
|
||||
"15x20": 1.0,
|
||||
"15x20-2up": 2.0,
|
||||
}
|
||||
# Poids papier : combien d'unites 10x15 une feuille consomme
|
||||
POIDS_PAPIER = {
|
||||
"10x15": 1, "10x15-2up": 1,
|
||||
"15x20": 2, "15x20-2up": 2,
|
||||
"15x15": 2, "15x15-2up": 2,
|
||||
}
|
||||
|
||||
def maj_consommables(config: dict, copies: int, format_papier: str | None):
|
||||
"""Met a jour le suivi consommables (papier, ruban, photos)."""
|
||||
conso = config.get("consommables", {})
|
||||
fmt = format_papier or config.get("impression", {}).get("format", "15x20")
|
||||
rembobinage = config.get("impression", {}).get("rembobinage_ruban", False)
|
||||
is_2up = "-2up" in fmt
|
||||
|
||||
feuilles = copies if not is_2up else (copies + 1) // 2
|
||||
poids = POIDS_PAPIER.get(fmt, 1)
|
||||
conso["papier_utilise"] = conso.get("papier_utilise", 0) + feuilles * poids
|
||||
conso["photos_imprimees"] = conso.get("photos_imprimees", 0) + copies
|
||||
|
||||
ratio_optimal = RATIO_RUBAN_OPTIMAL.get(fmt, 1.0)
|
||||
ruban_par_feuille = float(poids)
|
||||
if rembobinage:
|
||||
ruban_consomme = feuilles * ratio_optimal
|
||||
else:
|
||||
ruban_consomme = feuilles * ruban_par_feuille
|
||||
|
||||
conso["ruban_utilise"] = round(conso.get("ruban_utilise", 0) + ruban_consomme, 1)
|
||||
|
||||
poses_perdues = feuilles * ruban_par_feuille - feuilles * ratio_optimal if not rembobinage else 0
|
||||
conso["poses_perdues"] = round(conso.get("poses_perdues", 0) + poses_perdues, 1)
|
||||
|
||||
mettre_a_jour_config({"consommables": conso})
|
||||
|
||||
|
||||
def consommables_etat() -> dict:
|
||||
"""Retourne l'etat des consommables."""
|
||||
config = charger_config()
|
||||
conso = config.get("consommables", {})
|
||||
papier_cap = conso.get("papier_capacite", 320)
|
||||
ruban_cap = conso.get("ruban_capacite", 320)
|
||||
papier_used = conso.get("papier_utilise", 0)
|
||||
ruban_used = conso.get("ruban_utilise", 0)
|
||||
photos = conso.get("photos_imprimees", 0)
|
||||
perdues = conso.get("poses_perdues", 0)
|
||||
return {
|
||||
"papier_capacite": papier_cap,
|
||||
"papier_utilise": papier_used,
|
||||
"papier_restant": max(0, papier_cap - papier_used),
|
||||
"ruban_capacite": ruban_cap,
|
||||
"ruban_utilise": ruban_used,
|
||||
"ruban_restant": max(0, round(ruban_cap - ruban_used, 1)),
|
||||
"photos_imprimees": photos,
|
||||
"poses_perdues": perdues,
|
||||
}
|
||||
|
||||
|
||||
def reset_consommables(quoi: str):
|
||||
"""Reinitialise papier, ruban ou tout."""
|
||||
config = charger_config()
|
||||
conso = config.get("consommables", {})
|
||||
if quoi in ("papier", "tout"):
|
||||
conso["papier_utilise"] = 0
|
||||
if quoi in ("ruban", "tout"):
|
||||
conso["ruban_utilise"] = 0
|
||||
conso["poses_perdues"] = 0
|
||||
if quoi == "tout":
|
||||
conso["photos_imprimees"] = 0
|
||||
conso["poses_perdues"] = 0
|
||||
mettre_a_jour_config({"consommables": conso})
|
||||
|
||||
@@ -28,7 +28,7 @@ SEUIL_SOMBRE = 45
|
||||
SEUIL_CORRECT = 65
|
||||
|
||||
_dernier_analyse: float = 0
|
||||
_INTERVALLE = 3.0
|
||||
_INTERVALLE = 1.0
|
||||
_dernier_resultat: dict | None = None
|
||||
|
||||
|
||||
|
||||
@@ -121,18 +121,32 @@ def chroma_key(chemin_photo: Path, nom_fond: str | None = None,
|
||||
return chemin_export
|
||||
|
||||
|
||||
def appliquer_cadre_impression(img: Image.Image, format_papier: str, nom_cadre: str, event_id: str | None = None) -> Image.Image:
|
||||
"""Composite un cadre PNG par-dessus l'image assemblée."""
|
||||
chemin = None
|
||||
def _chercher_cadre(format_papier: str, nom_cadre: str, event_id: str | None = None) -> Path | None:
|
||||
"""Cherche le cadre dans le format demandé, sinon fallback autres formats."""
|
||||
candidats = []
|
||||
if event_id:
|
||||
from backend.evenements import DOSSIER_EVENEMENTS
|
||||
chemin_event = DOSSIER_EVENEMENTS / event_id / "cadres" / format_papier / nom_cadre
|
||||
if chemin_event.exists():
|
||||
chemin = chemin_event
|
||||
base_event = DOSSIER_EVENEMENTS / event_id / "cadres"
|
||||
candidats.append(base_event / format_papier / nom_cadre)
|
||||
for d in sorted(base_event.iterdir()) if base_event.exists() else []:
|
||||
if d.is_dir() and d.name != format_papier:
|
||||
candidats.append(d / nom_cadre)
|
||||
candidats.append(DOSSIER_CADRES / format_papier / nom_cadre)
|
||||
for d in sorted(DOSSIER_CADRES.iterdir()) if DOSSIER_CADRES.exists() else []:
|
||||
if d.is_dir() and d.name != format_papier:
|
||||
candidats.append(d / nom_cadre)
|
||||
for c in candidats:
|
||||
if c.exists():
|
||||
return c
|
||||
return None
|
||||
|
||||
|
||||
def appliquer_cadre_impression(img: Image.Image, format_papier: str, nom_cadre: str, event_id: str | None = None) -> Image.Image:
|
||||
"""Composite un cadre PNG par-dessus l'image assemblée.
|
||||
Si le cadre n'existe pas dans le format demandé, utilise celui d'un autre format (resize)."""
|
||||
chemin = _chercher_cadre(format_papier, nom_cadre, event_id)
|
||||
if chemin is None:
|
||||
chemin = DOSSIER_CADRES / format_papier / nom_cadre
|
||||
if not chemin.exists():
|
||||
log.warning(f"Cadre introuvable : {chemin}")
|
||||
log.warning(f"Cadre introuvable : {nom_cadre} pour {format_papier}")
|
||||
return img
|
||||
cadre = Image.open(chemin).convert("RGBA")
|
||||
img_portrait = img.height > img.width
|
||||
@@ -147,11 +161,16 @@ def appliquer_cadre_impression(img: Image.Image, format_papier: str, nom_cadre:
|
||||
|
||||
|
||||
def lister_cadres(format_papier: str) -> list[str]:
|
||||
"""Liste les cadres disponibles pour un format donné."""
|
||||
"""Liste les cadres disponibles pour un format. Inclut ceux d'autres formats en fallback."""
|
||||
noms = set()
|
||||
dossier = DOSSIER_CADRES / format_papier
|
||||
if not dossier.exists():
|
||||
return []
|
||||
return sorted(f.name for f in dossier.iterdir() if f.suffix.lower() == ".png")
|
||||
if dossier.exists():
|
||||
noms.update(f.name for f in dossier.iterdir() if f.suffix.lower() == ".png")
|
||||
if not noms and DOSSIER_CADRES.exists():
|
||||
for d in DOSSIER_CADRES.iterdir():
|
||||
if d.is_dir():
|
||||
noms.update(f.name for f in d.iterdir() if f.suffix.lower() == ".png")
|
||||
return sorted(noms)
|
||||
|
||||
|
||||
def lister_overlays() -> list[str]:
|
||||
|
||||
@@ -2,6 +2,7 @@ import json
|
||||
import logging
|
||||
import shutil
|
||||
import uuid
|
||||
from datetime import date, datetime
|
||||
from pathlib import Path
|
||||
|
||||
from backend.config import RACINE, DOSSIER_CADRES, FORMATS_CADRES, charger_config, mettre_a_jour_config
|
||||
@@ -37,7 +38,7 @@ def lister_evenements() -> list[dict]:
|
||||
|
||||
|
||||
def creer_evenement(nom: str, **kwargs) -> dict:
|
||||
event_id = uuid.uuid4().hex[:8]
|
||||
event_id = kwargs.get("event_id") or uuid.uuid4().hex[:8]
|
||||
event = {
|
||||
"id": event_id,
|
||||
"nom": nom,
|
||||
@@ -46,6 +47,8 @@ def creer_evenement(nom: str, **kwargs) -> dict:
|
||||
"couleur_secondaire": kwargs.get("couleur_secondaire", "#ffffff"),
|
||||
"media_accueil": kwargs.get("media_accueil"),
|
||||
"formats_actifs": kwargs.get("formats_actifs", ["10x15", "15x20", "strip"]),
|
||||
"date_fin": kwargs.get("date_fin"),
|
||||
"termine": False,
|
||||
"cadres": {},
|
||||
}
|
||||
_chemin_event(event_id).write_text(json.dumps(event, ensure_ascii=False, indent=2), "utf-8")
|
||||
@@ -86,10 +89,46 @@ def supprimer_evenement(event_id: str) -> bool:
|
||||
return True
|
||||
|
||||
|
||||
def terminer_evenement(event_id: str) -> dict | None:
|
||||
event = obtenir_evenement(event_id)
|
||||
if not event:
|
||||
return None
|
||||
event["termine"] = True
|
||||
_chemin_event(event_id).write_text(json.dumps(event, ensure_ascii=False, indent=2), "utf-8")
|
||||
log.info(f"Evenement termine : {event['nom']} ({event_id})")
|
||||
return event
|
||||
|
||||
|
||||
def evenement_est_termine() -> bool:
|
||||
"""Verifie si l'evenement actif est termine (manuellement ou date_fin depassee)."""
|
||||
config = charger_config()
|
||||
event_id = config.get("evenement", {}).get("event_id")
|
||||
if not event_id:
|
||||
return False
|
||||
event = obtenir_evenement(event_id)
|
||||
if not event:
|
||||
return False
|
||||
if event.get("termine"):
|
||||
return True
|
||||
date_fin = event.get("date_fin")
|
||||
if date_fin:
|
||||
try:
|
||||
fin = datetime.strptime(date_fin, "%Y-%m-%d").date()
|
||||
if date.today() > fin:
|
||||
return True
|
||||
except ValueError:
|
||||
pass
|
||||
return False
|
||||
|
||||
|
||||
def activer_evenement(event_id: str) -> dict | None:
|
||||
event = obtenir_evenement(event_id)
|
||||
if not event:
|
||||
return None
|
||||
config = charger_config()
|
||||
booth = config.get("booth", {})
|
||||
if booth.get("actif"):
|
||||
booth["event_id"] = event_id
|
||||
mettre_a_jour_config({
|
||||
"evenement": {
|
||||
"event_id": event_id,
|
||||
@@ -99,7 +138,8 @@ def activer_evenement(event_id: str) -> dict | None:
|
||||
"couleur_secondaire": event.get("couleur_secondaire", "#ffffff"),
|
||||
"media_accueil": event.get("media_accueil"),
|
||||
"formats_actifs": event.get("formats_actifs", ["10x15", "15x20", "strip"]),
|
||||
}
|
||||
},
|
||||
"booth": booth,
|
||||
})
|
||||
log.info(f"Evenement active : {event['nom']} ({event_id})")
|
||||
return event
|
||||
|
||||
@@ -178,45 +178,98 @@ def envoyer_rapport_spool(nb_envoyes: int, destinataires: list[str], nb_echoues:
|
||||
log.error(f"Erreur envoi rapport spool : {e}")
|
||||
|
||||
|
||||
async def tache_spool_demarrage():
|
||||
"""Tente de vider le spool une seule fois au demarrage du serveur."""
|
||||
await asyncio.sleep(10)
|
||||
total = taille_spool()
|
||||
if total > 0:
|
||||
log.info(f"Spool: tentative d'envoi au demarrage ({total} en attente)")
|
||||
nb, dests = await asyncio.get_event_loop().run_in_executor(None, traiter_spool)
|
||||
RETRY_INTERVAL = 300 # 5 minutes
|
||||
WATCHDOG_INTERVAL = 60 # 1 minute
|
||||
|
||||
|
||||
async def _flush_spools():
|
||||
"""Vide les spools email + galerie."""
|
||||
from backend.destinations import traiter_booth_spool, taille_booth_spool
|
||||
loop = asyncio.get_event_loop()
|
||||
total_mail = taille_spool()
|
||||
if total_mail > 0:
|
||||
log.info(f"Spool email: retry ({total_mail} en attente)")
|
||||
nb, dests = await loop.run_in_executor(None, traiter_spool)
|
||||
if nb > 0:
|
||||
echoues = total - nb
|
||||
await asyncio.get_event_loop().run_in_executor(
|
||||
None, envoyer_rapport_spool, nb, dests, echoues
|
||||
)
|
||||
echoues = total_mail - nb
|
||||
await loop.run_in_executor(None, envoyer_rapport_spool, nb, dests, echoues)
|
||||
total_booth = taille_booth_spool()
|
||||
if total_booth > 0:
|
||||
log.info(f"Spool galerie: retry ({total_booth} en attente)")
|
||||
await loop.run_in_executor(None, traiter_booth_spool)
|
||||
|
||||
|
||||
async def tache_spool_periodique():
|
||||
"""Watchdog connectivite (60s) + retry spool (5 min)."""
|
||||
from backend.wifi import watchdog_tick
|
||||
from backend.destinations import taille_booth_spool
|
||||
await asyncio.sleep(15)
|
||||
loop = asyncio.get_event_loop()
|
||||
ticks_depuis_flush = 0
|
||||
while True:
|
||||
result = await loop.run_in_executor(None, watchdog_tick)
|
||||
if result == "restored":
|
||||
await _flush_spools()
|
||||
ticks_depuis_flush = 0
|
||||
else:
|
||||
ticks_depuis_flush += 1
|
||||
if ticks_depuis_flush >= RETRY_INTERVAL // WATCHDOG_INTERVAL:
|
||||
has_spool = taille_spool() > 0 or taille_booth_spool() > 0
|
||||
if has_spool:
|
||||
await _flush_spools()
|
||||
ticks_depuis_flush = 0
|
||||
await asyncio.sleep(WATCHDOG_INTERVAL)
|
||||
|
||||
|
||||
async def tache_spool_demarrage():
|
||||
"""Alias pour compatibilite — lance la boucle periodique."""
|
||||
await tache_spool_periodique()
|
||||
|
||||
|
||||
FICHIER_EMAILS = RACINE / "data" / "emails_history.json"
|
||||
|
||||
|
||||
def _event_id_actif() -> str:
|
||||
return charger_config().get("evenement", {}).get("event_id") or "_sans_evenement"
|
||||
|
||||
|
||||
def _charger_toutes_historiques() -> dict:
|
||||
if not FICHIER_EMAILS.exists():
|
||||
return {}
|
||||
try:
|
||||
with open(FICHIER_EMAILS, "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
# Compatibilite avec l'ancien format (liste globale non cloisonnee)
|
||||
if isinstance(data, list):
|
||||
return {"_sans_evenement": data}
|
||||
return data
|
||||
except (json.JSONDecodeError, OSError):
|
||||
return {}
|
||||
|
||||
|
||||
def _sauvegarder_email_historique(email: str):
|
||||
historique = charger_emails_historique()
|
||||
toutes = _charger_toutes_historiques()
|
||||
event_id = _event_id_actif()
|
||||
historique = toutes.setdefault(event_id, [])
|
||||
email_lower = email.lower().strip()
|
||||
if email_lower not in historique:
|
||||
historique.append(email_lower)
|
||||
try:
|
||||
with open(FICHIER_EMAILS, "w", encoding="utf-8") as f:
|
||||
json.dump(historique, f, ensure_ascii=False)
|
||||
json.dump(toutes, f, ensure_ascii=False)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
def charger_emails_historique() -> list:
|
||||
if not FICHIER_EMAILS.exists():
|
||||
return []
|
||||
try:
|
||||
with open(FICHIER_EMAILS, "r", encoding="utf-8") as f:
|
||||
return json.load(f)
|
||||
except (json.JSONDecodeError, OSError):
|
||||
return []
|
||||
return _charger_toutes_historiques().get(_event_id_actif(), [])
|
||||
|
||||
|
||||
def effacer_emails_historique():
|
||||
if FICHIER_EMAILS.exists():
|
||||
FICHIER_EMAILS.unlink()
|
||||
toutes = _charger_toutes_historiques()
|
||||
toutes.pop(_event_id_actif(), None)
|
||||
try:
|
||||
with open(FICHIER_EMAILS, "w", encoding="utf-8") as f:
|
||||
json.dump(toutes, f, ensure_ascii=False)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
1311
backend/main.py
1311
backend/main.py
File diff suppressed because it is too large
Load Diff
@@ -111,6 +111,13 @@ def _preparer_image(chemin: Path, largeur: int, hauteur: int,
|
||||
if config_imp.get("rotation_180", False) and not skip_rotate:
|
||||
img = img.rotate(180)
|
||||
|
||||
luminosite = config_imp.get("luminosite_impression", 15)
|
||||
if luminosite != 0:
|
||||
from PIL import ImageEnhance
|
||||
facteur = 1.0 + luminosite / 100.0
|
||||
img = ImageEnhance.Brightness(img).enhance(facteur)
|
||||
log.debug(f"Luminosité impression ajustée : {luminosite}% (facteur {facteur:.2f})")
|
||||
|
||||
tmp = tempfile.NamedTemporaryFile(suffix=".jpg", delete=False)
|
||||
img.save(tmp.name, "JPEG", quality=95, dpi=(300, 300))
|
||||
log.debug(f"Image préparée : {orientation} {largeur}x{hauteur}px → {tmp.name}")
|
||||
@@ -249,7 +256,7 @@ def imprimer(
|
||||
conf_imp = config.get("impression", {})
|
||||
|
||||
if imprimante is None:
|
||||
imprimante = conf_imp.get("imprimante", "Mitsubishi")
|
||||
imprimante = conf_imp.get("imprimante") or "Mitsubishi"
|
||||
if copies is None:
|
||||
copies = conf_imp.get("copies", 1)
|
||||
if format_papier is None:
|
||||
@@ -299,25 +306,33 @@ def imprimer(
|
||||
}
|
||||
time.sleep(1)
|
||||
|
||||
rembobinage = conf_imp.get("rembobinage_ruban", False)
|
||||
|
||||
try:
|
||||
jobs = []
|
||||
for copie in range(1, copies + 1):
|
||||
job_ok = False
|
||||
for tentative in range(1, 4):
|
||||
cmd = [
|
||||
"lp",
|
||||
"-d", imprimante,
|
||||
"-n", str(copies),
|
||||
"-o", f"PageSize={page_size}",
|
||||
"-o", "StpiShrinkOutput=Crop",
|
||||
str(chemin_print),
|
||||
]
|
||||
if rembobinage:
|
||||
cmd.extend(["-o", "StpiDecklist=true"])
|
||||
cmd.append(str(chemin_print))
|
||||
|
||||
code, out, err = _run(cmd, timeout=30)
|
||||
|
||||
if code == 0:
|
||||
job = out.strip()
|
||||
log.info(f"Impression lancée : {job} ({format_papier} {largeur}x{hauteur}px, x{copies})")
|
||||
return {"succes": True, "job": job}
|
||||
log.info(f"Impression copie {copie}/{copies} lancée : {job} ({format_papier} {largeur}x{hauteur}px)")
|
||||
jobs.append(job)
|
||||
job_ok = True
|
||||
break
|
||||
|
||||
log.warning(f"Impression échouée (tentative {tentative}/3) : {err.strip()}")
|
||||
log.warning(f"Impression copie {copie}/{copies} échouée (tentative {tentative}/3) : {err.strip()}")
|
||||
|
||||
if tentative < 3:
|
||||
if _statut(imprimante) == "stopped":
|
||||
@@ -337,11 +352,18 @@ def imprimer(
|
||||
_reactiver(imprimante)
|
||||
time.sleep(2)
|
||||
|
||||
if not job_ok:
|
||||
return {
|
||||
"succes": False,
|
||||
"erreur": ERREUR_IMPRESSION,
|
||||
"message": "Impression échouée après 3 tentatives",
|
||||
"message": f"Impression copie {copie}/{copies} échouée après 3 tentatives",
|
||||
}
|
||||
|
||||
if copie < copies:
|
||||
time.sleep(3)
|
||||
|
||||
log.info(f"Impression terminée : {copies} copie(s), jobs={jobs}")
|
||||
return {"succes": True, "job": ", ".join(jobs)}
|
||||
finally:
|
||||
for tmp in tmp_a_supprimer:
|
||||
tmp.unlink(missing_ok=True)
|
||||
|
||||
186
backend/relais.py
Normal file
186
backend/relais.py
Normal file
@@ -0,0 +1,186 @@
|
||||
"""Pilotage module relais USB HID (LCUS 5131:2007).
|
||||
|
||||
4 canaux, protocole LCUS :
|
||||
ON : 0x00 0xA0 <ch> 0x01 <checksum> 0x00 0x00 0x00 0x00
|
||||
OFF : 0x00 0xA0 <ch> 0x00 <checksum> 0x00 0x00 0x00 0x00
|
||||
Status : 0x00 0xD1 ...
|
||||
|
||||
Assignation :
|
||||
1 = Projecteur gauche (NO)
|
||||
2 = Projecteur droit (NO)
|
||||
3 = Canon alim (NF — OFF=alimenté, ON=coupé)
|
||||
4 = Libre
|
||||
"""
|
||||
|
||||
import ctypes
|
||||
import ctypes.util
|
||||
import logging
|
||||
import threading
|
||||
import time
|
||||
|
||||
log = logging.getLogger("photobooth.relais")
|
||||
|
||||
VID = 0x5131
|
||||
PID = 0x2007
|
||||
|
||||
CANAUX = {
|
||||
"projecteur_gauche": {"relay": 1, "mode": "NO"},
|
||||
"projecteur_droit": {"relay": 2, "mode": "NO"},
|
||||
"canon": {"relay": 3, "mode": "NF"}, # dummy battery
|
||||
"canon_usb": {"relay": 4, "mode": "NF"}, # VBUS USB
|
||||
}
|
||||
|
||||
_lib = None
|
||||
_dev = None
|
||||
_lock = threading.Lock()
|
||||
|
||||
|
||||
def _charger_hidapi():
|
||||
global _lib
|
||||
if _lib is not None:
|
||||
return _lib
|
||||
for name in ("hidapi-hidraw", "hidapi-libusb", "hidapi"):
|
||||
path = ctypes.util.find_library(name)
|
||||
if path:
|
||||
_lib = ctypes.CDLL(path)
|
||||
_lib.hid_init()
|
||||
_lib.hid_open.restype = ctypes.c_void_p
|
||||
_lib.hid_read_timeout.restype = ctypes.c_int
|
||||
log.info(f"hidapi chargé : {path}")
|
||||
return _lib
|
||||
try:
|
||||
_lib = ctypes.CDLL("libhidapi-hidraw.so.0")
|
||||
_lib.hid_init()
|
||||
_lib.hid_open.restype = ctypes.c_void_p
|
||||
_lib.hid_read_timeout.restype = ctypes.c_int
|
||||
return _lib
|
||||
except OSError:
|
||||
log.warning("hidapi introuvable — relais désactivés")
|
||||
return None
|
||||
|
||||
|
||||
def connecter():
|
||||
global _dev
|
||||
lib = _charger_hidapi()
|
||||
if not lib:
|
||||
return False
|
||||
with _lock:
|
||||
if _dev:
|
||||
return True
|
||||
_dev = lib.hid_open(VID, PID, None)
|
||||
if not _dev:
|
||||
log.warning("Module relais non trouvé (5131:2007)")
|
||||
_dev = None
|
||||
return False
|
||||
log.info("Module relais connecté")
|
||||
return True
|
||||
|
||||
|
||||
def deconnecter():
|
||||
global _dev
|
||||
with _lock:
|
||||
if _dev and _lib:
|
||||
_lib.hid_close(_dev)
|
||||
_dev = None
|
||||
|
||||
|
||||
def est_connecte():
|
||||
return _dev is not None
|
||||
|
||||
|
||||
def _ecrire(data: list[int]):
|
||||
if not _dev or not _lib:
|
||||
return False
|
||||
buf = (ctypes.c_ubyte * 9)(*data)
|
||||
with _lock:
|
||||
res = _lib.hid_write(_dev, buf, 9)
|
||||
return res > 0
|
||||
|
||||
|
||||
def _relay_set(num: int, on: bool):
|
||||
state = 0x01 if on else 0x00
|
||||
checksum = (0xA0 + num + state) & 0xFF
|
||||
ok = _ecrire([0x00, 0xA0, num, state, checksum, 0x00, 0x00, 0x00, 0x00])
|
||||
if ok:
|
||||
log.info(f"Relais {num} → {'ON' if on else 'OFF'}")
|
||||
else:
|
||||
log.error(f"Échec écriture relais {num}")
|
||||
return ok
|
||||
|
||||
|
||||
def status():
|
||||
if not _dev or not _lib:
|
||||
return None
|
||||
_ecrire([0x00, 0xD1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
|
||||
time.sleep(0.1)
|
||||
rbuf = (ctypes.c_ubyte * 64)()
|
||||
with _lock:
|
||||
n = _lib.hid_read_timeout(_dev, rbuf, 64, 500)
|
||||
if n < 5:
|
||||
return None
|
||||
return {
|
||||
"relay_1": rbuf[1] == 1,
|
||||
"relay_2": rbuf[2] == 1,
|
||||
"relay_3": rbuf[3] == 1,
|
||||
"relay_4": rbuf[4] == 1,
|
||||
}
|
||||
|
||||
|
||||
def activer(nom: str):
|
||||
cfg = CANAUX.get(nom)
|
||||
if not cfg:
|
||||
return False
|
||||
return _relay_set(cfg["relay"], True)
|
||||
|
||||
|
||||
def desactiver(nom: str):
|
||||
cfg = CANAUX.get(nom)
|
||||
if not cfg:
|
||||
return False
|
||||
return _relay_set(cfg["relay"], False)
|
||||
|
||||
|
||||
def projecteurs(on: bool):
|
||||
_relay_set(1, on)
|
||||
_relay_set(2, on)
|
||||
log.info(f"Projecteurs {'allumés' if on else 'éteints'}")
|
||||
|
||||
|
||||
def power_cycle_canon(duree: float = 5.0):
|
||||
"""Cycle complet R3+R4 : coupe dummy battery + VBUS, reboot Canon.
|
||||
Résistance de décharge 470Ω sur le 8V → condensateurs vidés en ~3s."""
|
||||
log.info(f"Power-cycle Canon R3+R4 ({duree}s)")
|
||||
_relay_set(3, True) # R3 ON = coupe dummy battery (NF)
|
||||
_relay_set(4, True) # R4 ON = coupe VBUS USB (NF)
|
||||
time.sleep(duree) # résistance vide les caps en ~3s
|
||||
_relay_set(3, False) # R3 OFF = dummy battery → Canon boot
|
||||
time.sleep(15) # attente boot Canon
|
||||
_relay_set(4, False) # R4 OFF = VBUS → USB enumeration
|
||||
log.info("Canon ré-alimenté — attente USB enumeration")
|
||||
|
||||
|
||||
def hard_reset_canon(duree: float = 10.0):
|
||||
"""Reset prolongé pour freeze PTP sévère.
|
||||
Résistance de décharge 470Ω → 5s suffisent, mais on garde une marge."""
|
||||
log.warning(f"Hard reset Canon — coupure R3+R4 ({duree}s)")
|
||||
_relay_set(3, True) # R3 ON = coupe dummy battery
|
||||
_relay_set(4, True) # R4 ON = coupe VBUS
|
||||
time.sleep(duree) # vidange complète avec résistance
|
||||
_relay_set(3, False) # R3 OFF = dummy battery → Canon boot
|
||||
time.sleep(15) # attente boot Canon
|
||||
_relay_set(4, False) # R4 OFF = VBUS → USB enumeration
|
||||
log.info("Hard reset Canon terminé — attente démarrage")
|
||||
|
||||
|
||||
def etat_complet():
|
||||
raw = status()
|
||||
if raw is None:
|
||||
return {"connecte": False}
|
||||
result = {"connecte": True}
|
||||
for nom, cfg in CANAUX.items():
|
||||
relay_on = raw.get(f"relay_{cfg['relay']}", False)
|
||||
if cfg["mode"] == "NF":
|
||||
result[nom] = not relay_on
|
||||
else:
|
||||
result[nom] = relay_on
|
||||
return result
|
||||
@@ -201,3 +201,62 @@ def wifi_forget(ssid: str) -> dict:
|
||||
|
||||
def wifi_get_password(ssid: str) -> str | None:
|
||||
return _charger_mdp().get(ssid)
|
||||
|
||||
|
||||
# --- Watchdog connectivité ---
|
||||
|
||||
_internet_ok = False
|
||||
|
||||
|
||||
def check_internet(timeout: int = 5) -> bool:
|
||||
"""Teste la connectivité internet (DNS + HTTP rapide)."""
|
||||
import socket
|
||||
try:
|
||||
socket.create_connection(("1.1.1.1", 53), timeout=timeout).close()
|
||||
return True
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
|
||||
def watchdog_tick() -> str | None:
|
||||
"""Vérifie internet. Retourne 'restored' si passage offline→online, None sinon."""
|
||||
global _internet_ok
|
||||
now_ok = check_internet()
|
||||
if now_ok and not _internet_ok:
|
||||
_internet_ok = True
|
||||
log.info("Internet restauré — flush spool")
|
||||
return "restored"
|
||||
_internet_ok = now_ok
|
||||
if not now_ok:
|
||||
_tenter_reconnexion_wifi()
|
||||
return None
|
||||
|
||||
|
||||
def _tenter_reconnexion_wifi():
|
||||
"""Si déconnecté du WiFi, tente de se reconnecter à un réseau enregistré visible."""
|
||||
status = wifi_status()
|
||||
if status["connecte"]:
|
||||
return
|
||||
log.info("Pas de WiFi — scan des réseaux enregistrés")
|
||||
saved = {n["ssid"] for n in wifi_saved_list()}
|
||||
if not saved:
|
||||
return
|
||||
try:
|
||||
r = subprocess.run(
|
||||
["nmcli", "-t", "-f", "SSID,SIGNAL", "dev", "wifi", "list", "--rescan", "yes"],
|
||||
capture_output=True, text=True, timeout=15,
|
||||
)
|
||||
candidates = []
|
||||
for line in r.stdout.strip().split("\n"):
|
||||
p = _nmcli_split(line)
|
||||
if len(p) >= 2 and p[0] in saved and p[1].isdigit():
|
||||
candidates.append((p[0], int(p[1])))
|
||||
candidates.sort(key=lambda x: -x[1])
|
||||
for ssid, sig in candidates:
|
||||
log.info(f"Tentative reconnexion WiFi: {ssid} (signal {sig}%)")
|
||||
result = wifi_connect(ssid)
|
||||
if result.get("succes"):
|
||||
log.info(f"Reconnecté à {ssid}")
|
||||
return
|
||||
except Exception as e:
|
||||
log.warning(f"Reconnexion WiFi échouée: {e}")
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
{
|
||||
"evenement": {
|
||||
"nom": "Mon Evenement",
|
||||
"logo": null,
|
||||
"couleur_primaire": "#e91e63",
|
||||
"couleur_secondaire": "#ffffff",
|
||||
"media_accueil": null
|
||||
},
|
||||
"fonctionnalites": {
|
||||
"photo_simple": true,
|
||||
"multi_shot": true,
|
||||
"filtres": true,
|
||||
"overlays": true,
|
||||
"chroma_key": false,
|
||||
"impression": true,
|
||||
"email": true,
|
||||
"qr_code": true,
|
||||
"galerie": true
|
||||
},
|
||||
"camera": {
|
||||
"appareil": null,
|
||||
"iso": "auto",
|
||||
"balance_blancs": "auto",
|
||||
"compte_a_rebours": 3,
|
||||
"animation_compte_a_rebours": "classique",
|
||||
"animations_css_actives": ["classique"]
|
||||
},
|
||||
"animations_custom": {
|
||||
"actives": []
|
||||
},
|
||||
"compteur": {
|
||||
"actif": true,
|
||||
"limite": 400,
|
||||
"photos_prises": 0
|
||||
},
|
||||
"destinations": {
|
||||
"memoire_interne": true,
|
||||
"cle_usb": false,
|
||||
"chemin_usb": "/media/usb",
|
||||
"ftp": false,
|
||||
"ftp_host": "",
|
||||
"ftp_port": 21,
|
||||
"ftp_user": "",
|
||||
"ftp_password": "",
|
||||
"ftp_chemin": "/photobooth",
|
||||
"site_web": false,
|
||||
"site_web_url": "",
|
||||
"email_auto": false,
|
||||
"sauvegarder_tout": true
|
||||
},
|
||||
"impression": {
|
||||
"imprimante": null,
|
||||
"copies_max": 5,
|
||||
"format": "10x15"
|
||||
},
|
||||
"cadres": {
|
||||
"actifs": []
|
||||
},
|
||||
"email": {
|
||||
"smtp_host": "",
|
||||
"smtp_port": 587,
|
||||
"smtp_user": "",
|
||||
"smtp_password": "",
|
||||
"expediteur": "",
|
||||
"sujet": "Votre photo - {evenement}",
|
||||
"message": "Voici votre photo prise lors de {evenement} ! Merci et a bientot."
|
||||
},
|
||||
"qr_code": {
|
||||
"url_galerie": ""
|
||||
},
|
||||
"multi_shot": {
|
||||
"nombre_photos": 3,
|
||||
"mode": "strip",
|
||||
"delai_entre_photos": 2
|
||||
},
|
||||
"chroma_key": {
|
||||
"couleur": "#00ff00",
|
||||
"tolerance": 40,
|
||||
"fond_par_defaut": null
|
||||
},
|
||||
"serveur": {
|
||||
"host": "0.0.0.0",
|
||||
"port": 8080
|
||||
}
|
||||
}
|
||||
@@ -157,6 +157,107 @@ html, body {
|
||||
color: rgba(255,255,255,0.4);
|
||||
}
|
||||
|
||||
/* Mini menu client */
|
||||
.btn-menu-client {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
left: 12px;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 1.3rem;
|
||||
color: rgba(255,255,255,0.2);
|
||||
cursor: pointer;
|
||||
border-radius: 50%;
|
||||
transition: color 0.3s;
|
||||
z-index: 60;
|
||||
}
|
||||
.btn-menu-client:active {
|
||||
color: rgba(255,255,255,0.5);
|
||||
}
|
||||
.menu-client {
|
||||
position: absolute;
|
||||
top: 60px;
|
||||
left: 12px;
|
||||
background: rgba(0,0,0,0.92);
|
||||
border-radius: 16px;
|
||||
padding: 16px;
|
||||
z-index: 200;
|
||||
min-width: 220px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
.menu-client button {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 14px 16px;
|
||||
font-size: 1rem;
|
||||
text-align: left;
|
||||
background: rgba(255,255,255,0.08);
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.menu-client button:active {
|
||||
background: rgba(255,255,255,0.2);
|
||||
}
|
||||
.menu-client-titre {
|
||||
font-size: .85rem;
|
||||
font-weight: 600;
|
||||
color: rgba(255,255,255,0.5);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
padding: 0 4px 8px;
|
||||
}
|
||||
.popup-wifi {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0,0,0,0.85);
|
||||
z-index: 300;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.popup-wifi-inner {
|
||||
background: rgba(30,30,30,0.98);
|
||||
border-radius: 20px;
|
||||
padding: 24px;
|
||||
width: 90%;
|
||||
max-width: 400px;
|
||||
}
|
||||
.popup-wifi-inner button {
|
||||
padding: 12px;
|
||||
font-size: 1rem;
|
||||
background: rgba(255,255,255,0.1);
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.popup-wifi-inner button:active {
|
||||
background: rgba(255,255,255,0.2);
|
||||
}
|
||||
.wifi-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 12px;
|
||||
margin: 4px 0;
|
||||
background: rgba(255,255,255,0.06);
|
||||
border-radius: 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.wifi-item:active {
|
||||
background: rgba(255,255,255,0.15);
|
||||
}
|
||||
.wifi-item.actif {
|
||||
border-left: 3px solid #4caf50;
|
||||
}
|
||||
|
||||
/* Popup mot de passe */
|
||||
.popup-overlay {
|
||||
position: fixed;
|
||||
@@ -285,6 +386,13 @@ html, body {
|
||||
font-size: 8rem;
|
||||
}
|
||||
|
||||
.mode-detail {
|
||||
font-size: 0.85rem;
|
||||
opacity: 0.6;
|
||||
font-weight: 400;
|
||||
margin-top: -0.3rem;
|
||||
}
|
||||
|
||||
/* === Booth info (code + QR sur accueil) === */
|
||||
.booth-info {
|
||||
position: absolute;
|
||||
@@ -389,13 +497,17 @@ html, body {
|
||||
}
|
||||
|
||||
.compte-a-rebours span {
|
||||
font-size: 14rem;
|
||||
font-size: clamp(2rem, 8vw, 5rem);
|
||||
font-weight: 800;
|
||||
color: #ffffff;
|
||||
text-shadow: 0 0 40px rgba(0,0,0,0.8), 0 0 80px var(--primaire);
|
||||
animation: pop 0.5s ease;
|
||||
}
|
||||
|
||||
.compte-a-rebours span.anim-texte {
|
||||
font-size: clamp(0.8rem, 3vw, 1.5rem);
|
||||
}
|
||||
|
||||
@keyframes pop {
|
||||
0% { transform: scale(0.3); opacity: 0; }
|
||||
60% { transform: scale(1.2); }
|
||||
@@ -417,6 +529,17 @@ html, body {
|
||||
100% { opacity: 0; }
|
||||
}
|
||||
|
||||
.surprise-overlay {
|
||||
position: absolute;
|
||||
top: 0; left: 0;
|
||||
width: 100%; height: 100%;
|
||||
background: #000;
|
||||
z-index: 19;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.capture-en-cours {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
@@ -697,6 +820,13 @@ html, body {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.impression-restant {
|
||||
color: var(--texte-secondaire);
|
||||
font-size: 0.85rem;
|
||||
opacity: 0.7;
|
||||
margin: 0.3rem 0;
|
||||
}
|
||||
|
||||
.form-email {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
@@ -889,6 +1019,30 @@ html, body {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.admin-rubriques {
|
||||
display: flex;
|
||||
gap: 0;
|
||||
background: rgba(0,0,0,0.3);
|
||||
border-bottom: 1px solid rgba(255,255,255,0.08);
|
||||
}
|
||||
.rubrique {
|
||||
flex: 1;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--texte-secondaire);
|
||||
padding: 0.8rem 1rem;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: var(--transition);
|
||||
border-bottom: 3px solid transparent;
|
||||
}
|
||||
.rubrique.actif {
|
||||
color: var(--primaire);
|
||||
border-bottom-color: var(--primaire);
|
||||
background: rgba(255,255,255,0.03);
|
||||
}
|
||||
|
||||
.admin-onglets {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -898,6 +1052,56 @@ html, body {
|
||||
background: var(--fond-carte);
|
||||
overflow-y: auto;
|
||||
}
|
||||
.admin-onglets.cache { display: none; }
|
||||
|
||||
.conso-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 1rem;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
.conso-card {
|
||||
background: rgba(255,255,255,0.04);
|
||||
border-radius: 12px;
|
||||
padding: 1.2rem;
|
||||
text-align: center;
|
||||
}
|
||||
.conso-icon { font-size: 2rem; margin-bottom: 0.3rem; }
|
||||
.conso-titre { font-weight: 600; margin-bottom: 0.8rem; font-size: 0.95rem; }
|
||||
.conso-barre-fond {
|
||||
height: 12px;
|
||||
background: rgba(255,255,255,0.08);
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
.conso-barre {
|
||||
height: 100%;
|
||||
border-radius: 6px;
|
||||
transition: width 0.5s ease, background 0.5s ease;
|
||||
}
|
||||
.conso-chiffres { font-size: 0.85rem; color: var(--texte-secondaire); margin-bottom: 0.8rem; }
|
||||
.conso-gros { font-size: 2.5rem; font-weight: 800; margin: 0.5rem 0; }
|
||||
.conso-diag {
|
||||
background: rgba(255,255,255,0.03);
|
||||
border-radius: 8px;
|
||||
padding: 1rem;
|
||||
font-size: 0.85rem;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.video-situation-bloc {
|
||||
background: rgba(255,255,255,0.03);
|
||||
border-radius: 8px;
|
||||
padding: 1rem;
|
||||
margin-bottom: 0.8rem;
|
||||
}
|
||||
.video-situation-bloc h4 { margin-bottom: 0.5rem; }
|
||||
.video-situation-current {
|
||||
font-size: 0.85rem;
|
||||
color: var(--texte-secondaire);
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.onglet {
|
||||
background: transparent;
|
||||
@@ -1676,11 +1880,18 @@ h3 {
|
||||
}
|
||||
|
||||
.anim-chiffre {
|
||||
font-size: 8rem;
|
||||
font-size: clamp(2rem, 6vw, 4rem);
|
||||
font-weight: 700;
|
||||
color: var(--primaire);
|
||||
}
|
||||
|
||||
.anim-texte {
|
||||
font-size: clamp(0.7rem, 2vw, 1.2rem);
|
||||
max-width: 80vw;
|
||||
text-align: center;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
/* === Animations compte a rebours === */
|
||||
/* Classique */
|
||||
.anim-classique { animation: anim-pop 0.5s ease; }
|
||||
@@ -2161,6 +2372,38 @@ h3 {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* === Diagnostic Panel === */
|
||||
.diag-cards{display:grid;grid-template-columns:repeat(4,1fr);gap:.8rem}
|
||||
.diag-card{background:rgba(255,255,255,.06);border-radius:12px;padding:1rem;text-align:center;border:2px solid transparent;transition:border-color .3s}
|
||||
.diag-card.ok{border-color:#4caf50}
|
||||
.diag-card.warn{border-color:#ff9800}
|
||||
.diag-card.err{border-color:#f44336}
|
||||
.diag-card.off{border-color:#666}
|
||||
.diag-icon{font-size:2rem;margin-bottom:.3rem}
|
||||
.diag-label{font-size:.85rem;color:var(--texte-secondaire)}
|
||||
.diag-status{font-size:.75rem;margin-top:.3rem;font-weight:600}
|
||||
.diag-card.ok .diag-status{color:#4caf50}
|
||||
.diag-card.warn .diag-status{color:#ff9800}
|
||||
.diag-card.err .diag-status{color:#f44336}
|
||||
.diag-card.off .diag-status{color:#888}
|
||||
.diag-actions{display:flex;flex-wrap:wrap;gap:.6rem}
|
||||
.diag-actions button{flex:1;min-width:140px;font-size:.85rem}
|
||||
.diag-logs{font-family:monospace;font-size:.65rem;background:#0a0a0a;color:#0f0;padding:.8rem;border-radius:8px;white-space:pre-wrap;max-height:350px;overflow-y:auto;word-break:break-all;line-height:1.4}
|
||||
.diag-usb{font-family:monospace;font-size:.75rem;background:#0a0a0a;color:#ccc;padding:.6rem;border-radius:6px;white-space:pre-wrap}
|
||||
|
||||
/* === Camera/Printer error overlay (user-facing, full-screen) === */
|
||||
.erreur-overlay{position:fixed;inset:0;z-index:9999;background:rgba(0,0,0,.92);display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:2rem;gap:1.5rem}
|
||||
.erreur-overlay .erreur-icon{font-size:5rem}
|
||||
.erreur-overlay .erreur-titre{font-size:2rem;font-weight:700;color:#fff}
|
||||
.erreur-overlay .erreur-msg{font-size:1.3rem;color:#ccc;max-width:600px;line-height:1.5}
|
||||
.erreur-overlay .erreur-steps{text-align:left;font-size:1.1rem;color:#eee;max-width:500px;line-height:2}
|
||||
.erreur-overlay .erreur-steps li{margin-bottom:.5rem}
|
||||
.erreur-overlay .erreur-spinner{width:60px;height:60px;border:5px solid #333;border-top-color:var(--primaire);border-radius:50%;animation:spin 1s linear infinite}
|
||||
@keyframes spin{to{transform:rotate(360deg)}}
|
||||
.erreur-overlay .erreur-btn{padding:1rem 2.5rem;font-size:1.3rem;border-radius:1rem;border:none;cursor:pointer;margin-top:1rem}
|
||||
.erreur-overlay .erreur-btn-primaire{background:var(--primaire);color:#fff}
|
||||
.erreur-overlay .erreur-btn-secondaire{background:#333;color:#fff}
|
||||
|
||||
/* Responsive tactile */
|
||||
@media (max-width: 800px) {
|
||||
.accueil-contenu h1 { font-size: 2.5rem; }
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
|
||||
<meta name="google" content="notranslate">
|
||||
<meta http-equiv="Content-Language" content="fr">
|
||||
<link rel="stylesheet" href="/css/style.css?v=12">
|
||||
<link rel="stylesheet" href="/css/style.css?v=19">
|
||||
<link rel="stylesheet" href="/css/themes.css?v=2">
|
||||
</head>
|
||||
<body>
|
||||
@@ -20,12 +20,19 @@
|
||||
<button onclick="document.getElementById('printer-erreur').classList.add('cache')">✕</button>
|
||||
</div>
|
||||
|
||||
<!-- Overlay erreur camera -->
|
||||
<div id="camera-erreur" class="camera-erreur cache">
|
||||
<div class="camera-erreur-icon">📷</div>
|
||||
<p>Probleme de communication avec l'appareil photo</p>
|
||||
<span class="camera-erreur-sub">Reconnexion en cours...</span>
|
||||
<button onclick="document.getElementById('camera-erreur').classList.add('cache'); afficherEcran('accueil')" style="margin-top:2rem;padding:1rem 2rem;font-size:1.5rem;border-radius:1rem;border:none;background:#e91e63;color:#fff;cursor:pointer;">Retour accueil</button>
|
||||
<!-- Overlay erreur equipement (camera/imprimante) -->
|
||||
<div id="erreur-equipement" class="erreur-overlay cache">
|
||||
<div class="erreur-icon" id="erreur-equip-icon">📷</div>
|
||||
<div class="erreur-titre" id="erreur-equip-titre">Preparation en cours</div>
|
||||
<div class="erreur-msg" id="erreur-equip-msg">L'appareil photo se prepare, un instant...</div>
|
||||
<div class="erreur-spinner" id="erreur-equip-spinner"></div>
|
||||
<div class="erreur-steps cache" id="erreur-equip-steps"></div>
|
||||
<div id="erreur-equip-actions" style="display:flex;gap:1rem;flex-wrap:wrap;justify-content:center">
|
||||
<button class="erreur-btn erreur-btn-primaire cache" id="erreur-equip-btn-retry" onclick="erreurEquipRetry()">Reessayer</button>
|
||||
<button class="erreur-btn erreur-btn-secondaire cache" id="erreur-equip-btn-video" onclick="erreurEquipVideo()">Voir l'aide video</button>
|
||||
<button class="erreur-btn erreur-btn-secondaire cache" id="erreur-equip-btn-restart" onclick="erreurEquipRestart()">Redemarrer la borne</button>
|
||||
<button class="erreur-btn erreur-btn-secondaire" id="erreur-equip-btn-accueil" onclick="fermerErreurEquipement()">Retour accueil</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Ecran d'accueil -->
|
||||
@@ -52,6 +59,38 @@
|
||||
<div id="btn-admin" class="btn-admin" onclick="ouvrirAdmin()">⚙</div>
|
||||
<!-- Icone photostation coin bas-gauche (visible seulement si installée) -->
|
||||
<div id="btn-photostation" class="btn-photostation cache" onclick="ouvrirPhotostation()">🖼</div>
|
||||
<!-- Mini menu client coin haut-gauche -->
|
||||
<div id="btn-menu-client" class="btn-menu-client" onclick="toggleMenuClient()">☰</div>
|
||||
<div id="menu-client" class="menu-client cache">
|
||||
<div class="menu-client-titre">Maintenance</div>
|
||||
<button onclick="menuClientAction('wifi')">📶 WiFi</button>
|
||||
<button onclick="menuClientAction('exposition')">☀ Luminosite</button>
|
||||
<button onclick="menuClientAction('restart-app')">🔄 Relancer l'appli</button>
|
||||
<button onclick="menuClientAction('reboot')">🔃 Redemarrer</button>
|
||||
<button onclick="menuClientAction('shutdown')">⏻ Eteindre</button>
|
||||
<button onclick="toggleMenuClient()" style="background:transparent;color:var(--text2)">Fermer</button>
|
||||
</div>
|
||||
<!-- Popup WiFi -->
|
||||
<div id="popup-wifi" class="popup-wifi cache">
|
||||
<div class="popup-wifi-inner">
|
||||
<div class="menu-client-titre">WiFi</div>
|
||||
<div id="wifi-status"></div>
|
||||
<div id="wifi-list" style="max-height:300px;overflow-y:auto"></div>
|
||||
<button onclick="scanWifi()" style="margin-top:8px;width:100%">Actualiser</button>
|
||||
<button onclick="document.getElementById('popup-wifi').classList.add('cache')" style="margin-top:4px;width:100%;background:transparent;color:var(--text2)">Fermer</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Popup Exposition -->
|
||||
<div id="popup-exposition" class="popup-wifi cache">
|
||||
<div class="popup-wifi-inner">
|
||||
<div class="menu-client-titre">Luminosite photo</div>
|
||||
<div id="expo-status" style="text-align:center;margin:12px 0;font-size:1.5rem;font-weight:700"></div>
|
||||
<input type="range" id="expo-slider" min="-9" max="9" value="0" style="width:100%" oninput="updateExpoLabel(this.value)">
|
||||
<div id="expo-label" style="text-align:center;margin:8px 0;font-size:.9rem;color:var(--text2)">0</div>
|
||||
<button onclick="appliquerExpo()" style="width:100%">Appliquer</button>
|
||||
<button onclick="document.getElementById('popup-exposition').classList.add('cache')" style="margin-top:4px;width:100%;background:transparent;color:var(--text2)">Fermer</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Choix du mode -->
|
||||
@@ -65,6 +104,7 @@
|
||||
<button class="btn-mode" data-mode="multi" id="btn-multi">
|
||||
<div class="mode-icone mode-icone-large">🎞</div>
|
||||
<span>Pellicule</span>
|
||||
<span class="mode-detail" id="pellicule-detail"></span>
|
||||
</button>
|
||||
</div>
|
||||
<button class="btn-retour" onclick="allerA('accueil')">Retour</button>
|
||||
@@ -98,6 +138,7 @@
|
||||
<span id="chiffre-car">3</span>
|
||||
</div>
|
||||
<div id="flash-blanc" class="flash-blanc cache"></div>
|
||||
<div id="surprise-overlay" class="surprise-overlay cache"></div>
|
||||
<div id="capture-en-cours" class="capture-en-cours cache">
|
||||
<div class="capture-spinner"></div>
|
||||
<span>Capture en cours...</span>
|
||||
@@ -158,6 +199,7 @@
|
||||
<button class="btn-exemplaire" onclick="changerExemplaires(1)">+</button>
|
||||
</div>
|
||||
<span class="exemplaires-label">exemplaire(s)</span>
|
||||
<div id="impression-restant" class="impression-restant"></div>
|
||||
<button class="btn-action" onclick="lancerImpression()">Imprimer</button>
|
||||
<button class="btn-secondaire" onclick="fermerImpression()">Annuler</button>
|
||||
</div>
|
||||
@@ -238,8 +280,7 @@
|
||||
</div>
|
||||
<div id="statut-partage" class="statut-partage cache"></div>
|
||||
<div class="partage-bas">
|
||||
<button class="btn-action" onclick="allerA('accueil')">Terminer</button>
|
||||
<button class="btn-secondaire" onclick="recommencer()">Nouvelle photo</button>
|
||||
<button class="btn-action" id="btn-terminer" onclick="recommencer()">Recommencer</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -371,18 +412,28 @@
|
||||
<button class="btn-fermer" onclick="allerA('accueil')">×</button>
|
||||
</div>
|
||||
<div class="admin-contenu">
|
||||
<div class="admin-onglets">
|
||||
<div class="admin-rubriques">
|
||||
<button class="rubrique actif" data-rubrique="general" onclick="changerRubrique('general')">General</button>
|
||||
<button class="rubrique" data-rubrique="evenement" onclick="changerRubrique('evenement')">Evenement</button>
|
||||
</div>
|
||||
<div class="admin-onglets" id="onglets-general">
|
||||
<button class="onglet actif" data-onglet="materiel">Materiel</button>
|
||||
<button class="onglet" data-onglet="compteur-admin">Compteur</button>
|
||||
<button class="onglet" data-onglet="destinations-admin">Destinations</button>
|
||||
<button class="onglet" data-onglet="personnalisation">Personnalisation</button>
|
||||
<button class="onglet" data-onglet="evenement">Evenement</button>
|
||||
<button class="onglet" data-onglet="consommables-admin" onclick="chargerConsommables()">Consommables</button>
|
||||
<button class="onglet" data-onglet="fonctions">Fonctions</button>
|
||||
<button class="onglet" data-onglet="admin-galerie" onclick="chargerAdminGalerie()">Galerie</button>
|
||||
<button class="onglet" data-onglet="eclairage" onclick="demarrerEclairageLive()">Eclairage</button>
|
||||
<button class="onglet" data-onglet="personnalisation">Personnalisation</button>
|
||||
<button class="onglet" data-onglet="videos-admin" onclick="chargerVideosAdmin()">Videos</button>
|
||||
<button class="onglet" data-onglet="eclairage" onclick="demarrerEclairageLive();demarrerEclairageLiveExt()">Eclairage</button>
|
||||
<button class="onglet" data-onglet="wifi" onclick="chargerWifi()">WiFi</button>
|
||||
<button class="onglet" data-onglet="diagnostic" onclick="chargerDiagnostic()">Diagnostic</button>
|
||||
<button class="onglet" data-onglet="infos" onclick="chargerInfosSysteme()">Infos</button>
|
||||
</div>
|
||||
<div class="admin-onglets cache" id="onglets-evenement">
|
||||
<button class="onglet" data-onglet="evenement">Config</button>
|
||||
<button class="onglet" data-onglet="destinations-admin">Destinations</button>
|
||||
<button class="onglet" data-onglet="surprise-admin">Surprise</button>
|
||||
<button class="onglet" data-onglet="admin-galerie" onclick="chargerAdminGalerie()">Galerie</button>
|
||||
</div>
|
||||
|
||||
<!-- Panneau Materiel (Camera + Imprimante) -->
|
||||
<div class="admin-panneau actif" id="panneau-materiel">
|
||||
@@ -429,6 +480,9 @@
|
||||
<label>Nombre max d'exemplaires</label>
|
||||
<input type="number" id="admin-copies-max" min="1" max="20" value="5">
|
||||
</div>
|
||||
<div class="champ">
|
||||
<label class="toggle"><input type="checkbox" id="tog-rembobinage-ruban"><span class="toggle-slider"></span> Rembobinage ruban (economise le ruban sur les petits formats)</label>
|
||||
</div>
|
||||
<button class="btn-action" onclick="sauvegarderMateriel()">Sauvegarder</button>
|
||||
<div class="champ" style="margin-top:1rem;display:flex;gap:0.8rem;flex-wrap:wrap">
|
||||
<button class="btn-danger" onclick="evacuerBourrage()">⚠ Annuler jobs</button>
|
||||
@@ -453,9 +507,10 @@
|
||||
<span id="admin-compteur-limite-display" class="compteur-nombre petit">400</span>
|
||||
</div>
|
||||
<span class="compteur-label">photos restantes</span>
|
||||
<span id="admin-compteur-detail" class="compteur-label" style="font-size:0.7em;opacity:0.7;margin-top:2px"></span>
|
||||
</div>
|
||||
<div class="champ">
|
||||
<label>Limite totale</label>
|
||||
<label>Limite evenement (0 = pas de limite)</label>
|
||||
<input type="number" id="admin-compteur-limite" min="1" max="9999" value="400">
|
||||
</div>
|
||||
<div class="champ-row">
|
||||
@@ -464,6 +519,54 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Panneau Consommables -->
|
||||
<div class="admin-panneau" id="panneau-consommables-admin">
|
||||
<h3>Suivi consommables</h3>
|
||||
<p class="aide">Suivez l'usure du papier et du ruban. Reinitalisez quand vous changez une bobine.</p>
|
||||
|
||||
<div class="conso-grid">
|
||||
<div class="conso-card">
|
||||
<div class="conso-icon">📄</div>
|
||||
<div class="conso-titre">Papier</div>
|
||||
<div class="conso-barre-fond"><div class="conso-barre conso-barre-papier" id="conso-barre-papier"></div></div>
|
||||
<div class="conso-chiffres"><span id="conso-papier-restant">--</span> / <span id="conso-papier-cap">--</span> feuilles</div>
|
||||
<button class="btn-secondaire btn-petit" onclick="resetConsommable('papier')">Bobine changee</button>
|
||||
</div>
|
||||
<div class="conso-card">
|
||||
<div class="conso-icon">🎨</div>
|
||||
<div class="conso-titre">Ruban</div>
|
||||
<div class="conso-barre-fond"><div class="conso-barre conso-barre-ruban" id="conso-barre-ruban"></div></div>
|
||||
<div class="conso-chiffres"><span id="conso-ruban-restant">--</span> / <span id="conso-ruban-cap">--</span> poses</div>
|
||||
<button class="btn-secondaire btn-petit" onclick="resetConsommable('ruban')">Ruban change</button>
|
||||
</div>
|
||||
<div class="conso-card">
|
||||
<div class="conso-icon">📷</div>
|
||||
<div class="conso-titre">Photos sorties</div>
|
||||
<div class="conso-gros" id="conso-photos">--</div>
|
||||
</div>
|
||||
<div class="conso-card" id="conso-card-perdues">
|
||||
<div class="conso-icon">⚠</div>
|
||||
<div class="conso-titre">Poses perdues</div>
|
||||
<div class="conso-gros" id="conso-perdues" style="color:#fb8c00">--</div>
|
||||
<div class="conso-chiffres">ruban gaspille sans rembobinage</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3 style="margin-top:1.5rem">Capacites</h3>
|
||||
<div class="champ">
|
||||
<label>Capacite papier (feuilles par bobine)</label>
|
||||
<input type="number" id="conso-cap-papier" min="1" max="9999" value="400">
|
||||
</div>
|
||||
<div class="champ">
|
||||
<label>Capacite ruban (poses par bobine)</label>
|
||||
<input type="number" id="conso-cap-ruban" min="1" max="9999" value="400">
|
||||
</div>
|
||||
<button class="btn-action" onclick="sauvegarderCapacites()">Sauvegarder capacites</button>
|
||||
<button class="btn-danger" style="margin-top:0.5rem" onclick="resetConsommable('tout')">Tout reinitialiser</button>
|
||||
|
||||
<div class="conso-diag" id="conso-diagnostic" style="margin-top:1.5rem"></div>
|
||||
</div>
|
||||
|
||||
<!-- Panneau Destinations -->
|
||||
<div class="admin-panneau" id="panneau-destinations-admin">
|
||||
<h3>Ou sauvegarder les photos ?</h3>
|
||||
@@ -632,7 +735,15 @@
|
||||
<label>Couleur secondaire</label>
|
||||
<input type="color" id="admin-couleur-secondaire" value="#ffffff">
|
||||
</div>
|
||||
<div class="champ">
|
||||
<label>Date de fin (impression bloquee apres)</label>
|
||||
<input type="date" id="admin-date-fin">
|
||||
</div>
|
||||
<div class="champ-row">
|
||||
<button class="btn-action" onclick="sauvegarderEvenement()">Sauvegarder</button>
|
||||
<button class="btn-danger" id="btn-terminer-event" onclick="terminerEvenement()">Terminer l'evenement</button>
|
||||
</div>
|
||||
<div id="badge-event-termine" class="cache" style="background:#f44336;color:#fff;padding:8px 16px;border-radius:8px;text-align:center;font-weight:bold;margin-top:8px">Evenement termine — impression desactivee</div>
|
||||
|
||||
<div class="champ" id="lien-galerie-event" style="display:none">
|
||||
<label>Galerie en ligne</label>
|
||||
@@ -829,6 +940,82 @@
|
||||
<div id="eclairage-visages" style="font-size:.9rem;color:#aaa">--</div>
|
||||
</div>
|
||||
</div>
|
||||
<h3 style="margin-top:1.5rem">Relais</h3>
|
||||
<div id="relais-status" style="margin-bottom:1rem;padding:0.5rem;background:#111;border-radius:6px;font-size:0.85rem;color:#aaa">Non connecte</div>
|
||||
<div style="display:flex;gap:0.5rem;flex-wrap:wrap;margin-bottom:1rem">
|
||||
<button class="btn-action btn-petit" onclick="relaisAction('projecteurs','on')">Projecteurs ON</button>
|
||||
<button class="btn-secondaire btn-petit" onclick="relaisAction('projecteurs','off')">Projecteurs OFF</button>
|
||||
<button class="btn-danger btn-petit" onclick="relaisAction('canon/power-cycle','on')">Power-cycle Canon</button>
|
||||
<button class="btn-danger btn-petit" style="background:#b71c1c" onclick="relaisAction('canon/hard-reset','on')">Hard Reset Canon</button>
|
||||
</div>
|
||||
<h4>Eclairage automatique</h4>
|
||||
<div class="champ">
|
||||
<label class="toggle"><input type="checkbox" id="tog-eclairage-auto"><span class="toggle-slider"></span> Allumer les projecteurs automatiquement selon la luminosite</label>
|
||||
</div>
|
||||
<div class="champ">
|
||||
<label>Seuil projecteur 1 (score <)</label>
|
||||
<input type="number" id="relais-seuil-proj1" min="0" max="100" value="45" step="5">
|
||||
<span style="font-size:0.75rem;color:#888">1 seul projecteur s'allume</span>
|
||||
</div>
|
||||
<div class="champ">
|
||||
<label>Seuil projecteur 2 (score <)</label>
|
||||
<input type="number" id="relais-seuil-proj2" min="0" max="100" value="30" step="5">
|
||||
<span style="font-size:0.75rem;color:#888">Les 2 projecteurs s'allument</span>
|
||||
</div>
|
||||
<div class="champ">
|
||||
<label>Seuil extinction (score >)</label>
|
||||
<input type="number" id="relais-seuil-off" min="0" max="100" value="65" step="5">
|
||||
<span style="font-size:0.75rem;color:#888">Projecteurs s'eteignent</span>
|
||||
</div>
|
||||
<h4 style="margin-top:1.5rem">Veille</h4>
|
||||
<div class="champ">
|
||||
<label>Eteindre les projecteurs apres (minutes d'inactivite)</label>
|
||||
<input type="number" id="relais-veille-delai" min="0" max="60" value="0" step="1">
|
||||
<span style="font-size:0.75rem;color:#888">0 = jamais. Les projecteurs se rallument quand un utilisateur touche l'ecran</span>
|
||||
</div>
|
||||
<button class="btn-action" onclick="sauvegarderRelaisConfig()">Sauvegarder</button>
|
||||
</div>
|
||||
|
||||
<!-- Panneau Diagnostic -->
|
||||
<div class="admin-panneau" id="panneau-diagnostic">
|
||||
<h3>Sante du systeme</h3>
|
||||
<div class="diag-cards" id="diag-sante">
|
||||
<div class="diag-card" id="diag-camera">
|
||||
<div class="diag-icon">📷</div>
|
||||
<div class="diag-label">Camera</div>
|
||||
<div class="diag-status" id="diag-camera-status">--</div>
|
||||
</div>
|
||||
<div class="diag-card" id="diag-imprimante">
|
||||
<div class="diag-icon">🖨</div>
|
||||
<div class="diag-label">Imprimante</div>
|
||||
<div class="diag-status" id="diag-imp-status">--</div>
|
||||
</div>
|
||||
<div class="diag-card" id="diag-relais">
|
||||
<div class="diag-icon">🔌</div>
|
||||
<div class="diag-label">Relais</div>
|
||||
<div class="diag-status" id="diag-relais-status">--</div>
|
||||
</div>
|
||||
<div class="diag-card" id="diag-systeme">
|
||||
<div class="diag-icon">💻</div>
|
||||
<div class="diag-label">Systeme</div>
|
||||
<div class="diag-status" id="diag-sys-status">--</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3 style="margin-top:1.5rem">Actions</h3>
|
||||
<div class="diag-actions">
|
||||
<button class="btn-action" onclick="diagReconnecterCamera()">📷 Reconnecter camera</button>
|
||||
<button class="btn-action" onclick="diagReactiverImprimante()">🖨 Reactiver imprimante</button>
|
||||
<button class="btn-secondaire" onclick="diagRedemarrerBackend()">↻ Redemarrer backend</button>
|
||||
<button class="btn-secondaire" onclick="diagRefreshChromium()">🌐 Recharger navigateur</button>
|
||||
<button class="btn-danger" onclick="if(confirm('Redemarrer la borne ?'))diagRedemarrerSysteme()">⚠ Redemarrer la borne</button>
|
||||
</div>
|
||||
|
||||
<h3 style="margin-top:1.5rem">Logs backend <button class="btn-secondaire btn-petit" onclick="chargerLogs()" style="margin-left:0.5rem">↻ Actualiser</button></h3>
|
||||
<div id="diag-logs" class="diag-logs">Appuyer sur Actualiser...</div>
|
||||
|
||||
<h3 style="margin-top:1.5rem">Peripheriques USB <button class="btn-secondaire btn-petit" onclick="chargerUsb()" style="margin-left:0.5rem">↻</button></h3>
|
||||
<div id="diag-usb" class="diag-usb">--</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-panneau" id="panneau-infos">
|
||||
@@ -846,10 +1033,71 @@
|
||||
<div id="diag-camera-contenu" style="font-family:monospace;font-size:0.75rem;background:#111;color:#0f0;padding:0.75rem;border-radius:6px;white-space:pre-wrap;max-height:300px;overflow-y:auto">
|
||||
Appuyer sur Tester...
|
||||
</div>
|
||||
<div class="admin-panneau" id="panneau-videos-admin">
|
||||
<h3>Videos didactiques</h3>
|
||||
<p class="aide">Chaque situation peut contenir plusieurs etapes video. L'operateur verra les videos en sequence : chaque etape boucle jusqu'a validation avant de passer a la suivante.</p>
|
||||
<div id="video-situations-liste"></div>
|
||||
<div style="margin-top:1rem;padding:0.75rem;background:#1a1a2e;border-radius:8px;border:1px dashed #444">
|
||||
<h4 style="margin:0 0 0.5rem">Ajouter une situation</h4>
|
||||
<div style="display:flex;gap:0.5rem;align-items:center;flex-wrap:wrap">
|
||||
<input type="text" id="nouvelle-situation-label" placeholder="Nom de la situation" style="flex:1;min-width:150px;padding:0.4rem 0.6rem;border-radius:6px;border:1px solid #555;background:#111;color:#fff">
|
||||
<button class="btn-action btn-petit" onclick="creerSituation()">+ Ajouter</button>
|
||||
</div>
|
||||
</div>
|
||||
<h4 style="margin-top:1.5rem">Apercu</h4>
|
||||
<video id="video-situation-preview" style="width:100%;max-height:300px;border-radius:8px;background:#111" controls></video>
|
||||
<div style="margin-top:1rem">
|
||||
<button class="btn-action" onclick="lancerWizardDepuisAdmin()">▶ Tester le wizard sur le booth</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-panneau" id="panneau-surprise-admin">
|
||||
<h3>Photo / Video surprise</h3>
|
||||
<p class="aide">Media affiche sur l'ecran ~1 seconde avant la prise de photo pour surprendre et provoquer un sourire.</p>
|
||||
<div class="champ">
|
||||
<label class="toggle"><input type="checkbox" id="tog-surprise-actif"><span class="toggle-slider"></span> Surprise active</label>
|
||||
</div>
|
||||
<div class="champ">
|
||||
<label>Type de surprise</label>
|
||||
<div class="radio-group">
|
||||
<label><input type="radio" name="surprise-type" value="photo" checked> Photo</label>
|
||||
<label><input type="radio" name="surprise-type" value="video"> Video</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="champ">
|
||||
<label>Media actuel</label>
|
||||
<div id="surprise-current">Aucun media configure</div>
|
||||
</div>
|
||||
<div class="champ">
|
||||
<input type="file" id="input-surprise-media" accept=".jpg,.jpeg,.png,.gif,.mp4,.webm" class="input-fichier">
|
||||
<button class="btn-action" onclick="uploaderSurprise()">Importer</button>
|
||||
<button class="btn-danger btn-petit" onclick="supprimerSurprise()">Supprimer</button>
|
||||
</div>
|
||||
<div class="champ">
|
||||
<label>Delai avant capture (ms)</label>
|
||||
<input type="number" id="admin-surprise-delai" min="500" max="3000" value="1000" step="100">
|
||||
</div>
|
||||
<button class="btn-action" onclick="sauvegarderSurprise()">Sauvegarder</button>
|
||||
<h4 style="margin-top:1.5rem">Apercu</h4>
|
||||
<div id="surprise-preview" style="width:100%;max-height:300px;border-radius:8px;background:#111;display:flex;align-items:center;justify-content:center;min-height:150px;color:#666">
|
||||
Aucun apercu
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Wizard video didactique plein ecran -->
|
||||
<div id="wizard-video" class="popup-overlay cache" style="z-index:9999;background:rgba(0,0,0,0.97);display:flex;flex-direction:column;align-items:center;justify-content:center">
|
||||
<div id="wizard-titre" style="color:#fff;font-size:1.8rem;font-weight:700;margin-bottom:0.3rem;text-align:center"></div>
|
||||
<div id="wizard-etape-info" style="color:#aaa;font-size:1rem;margin-bottom:1rem"></div>
|
||||
<video id="wizard-video-player" muted playsinline loop style="width:90%;max-height:65vh;border-radius:12px;background:#000"></video>
|
||||
<div id="wizard-etape-label" style="color:#ccc;font-size:1.1rem;margin-top:0.8rem;text-align:center;min-height:1.5rem"></div>
|
||||
<button id="wizard-btn-ok" onclick="wizardEtapeSuivante()" style="margin-top:1.5rem;padding:1.2rem 3rem;font-size:1.5rem;font-weight:700;border:none;border-radius:16px;background:#4caf50;color:#fff;cursor:pointer;min-width:280px">OK, c'est bon !</button>
|
||||
<button onclick="fermerWizard()" style="margin-top:0.8rem;padding:0.6rem 1.5rem;font-size:0.9rem;border:none;border-radius:8px;background:#333;color:#aaa;cursor:pointer">Quitter</button>
|
||||
</div>
|
||||
|
||||
<!-- Popup sélection cadre impression -->
|
||||
<div id="popup-cadre-impression" class="popup-overlay cache">
|
||||
<div class="popup-box popup-box-cadre">
|
||||
@@ -930,11 +1178,11 @@
|
||||
</style>
|
||||
|
||||
<script src="/js/websocket.js?v=16"></script>
|
||||
<script src="/js/app.js?v=18"></script>
|
||||
<script src="/js/camera.js?v=17"></script>
|
||||
<script src="/js/app.js?v=27"></script>
|
||||
<script src="/js/camera.js?v=26"></script>
|
||||
<script src="/js/effects.js?v=4"></script>
|
||||
<script src="/js/gallery.js?v=4"></script>
|
||||
<script src="/js/share.js?v=8"></script>
|
||||
<script src="/js/admin.js?v=9"></script>
|
||||
<script src="/js/gallery.js?v=5"></script>
|
||||
<script src="/js/share.js?v=12"></script>
|
||||
<script src="/js/admin.js?v=17"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -66,6 +66,7 @@ async function chargerMateriel() {
|
||||
const orient = (imp.orientations || {})[fmt] || 'portrait';
|
||||
document.querySelector(`input[name="admin-orientation"][value="${orient}"]`).checked = true;
|
||||
setValue('admin-copies-max', imp.copies_max || 5);
|
||||
document.getElementById('tog-rembobinage-ruban').checked = imp.rembobinage_ruban || false;
|
||||
}
|
||||
|
||||
async function rafraichirImprimantes() {
|
||||
@@ -149,6 +150,7 @@ async function sauvegarderMateriel() {
|
||||
format: getValue('admin-format-papier'),
|
||||
copies_max: parseInt(getValue('admin-copies-max')) || 5,
|
||||
orientations: _getOrientations(),
|
||||
rembobinage_ruban: document.getElementById('tog-rembobinage-ruban').checked,
|
||||
},
|
||||
});
|
||||
afficherStatut('Materiel sauvegarde', 'succes');
|
||||
@@ -160,8 +162,11 @@ async function chargerCompteur() {
|
||||
const etat = await apiGet('/api/compteur');
|
||||
document.getElementById('tog-compteur-actif').checked = etat.actif;
|
||||
document.getElementById('admin-compteur-restant').textContent = etat.restantes;
|
||||
document.getElementById('admin-compteur-limite-display').textContent = etat.limite;
|
||||
const limiteAff = (etat.actif && etat.limite > 0) ? etat.limite : etat.capacite;
|
||||
document.getElementById('admin-compteur-limite-display').textContent = limiteAff;
|
||||
setValue('admin-compteur-limite', etat.limite);
|
||||
const detail = document.getElementById('admin-compteur-detail');
|
||||
if (detail) detail.textContent = `Papier: ${etat.papier_restant} | Ruban: ${etat.ruban_restant}`;
|
||||
}
|
||||
|
||||
async function sauvegarderCompteur() {
|
||||
@@ -711,10 +716,14 @@ async function chargerListeEvenements() {
|
||||
for (const ev of events) {
|
||||
const div = document.createElement('div');
|
||||
div.className = 'event-item' + (ev.id === actifId ? ' event-actif' : '');
|
||||
const badges = [];
|
||||
if (ev.id === actifId) badges.push('<span class="badge-actif">Actif</span>');
|
||||
if (ev.termine) badges.push('<span style="background:#f44336;color:#fff;padding:2px 6px;border-radius:4px;font-size:0.7em">Termine</span>');
|
||||
div.innerHTML = `
|
||||
<span class="event-nom">${ev.nom}</span>
|
||||
<span class="event-nom">${ev.nom}${ev.date_fin ? ' <small style="opacity:0.5">(' + ev.date_fin + ')</small>' : ''}</span>
|
||||
<span class="event-actions">
|
||||
${ev.id !== actifId ? `<button class="btn-secondaire btn-petit" onclick="activerEventAdmin('${ev.id}')">Activer</button>` : '<span class="badge-actif">Actif</span>'}
|
||||
${ev.id !== actifId ? `<button class="btn-secondaire btn-petit" onclick="activerEventAdmin('${ev.id}')">Activer</button>` : ''}
|
||||
${badges.join(' ')}
|
||||
<button class="btn-secondaire btn-petit" onclick="editerEventAdmin('${ev.id}')">Editer</button>
|
||||
<button class="btn-danger btn-petit" onclick="supprimerEventAdmin('${ev.id}','${ev.nom}')">Suppr</button>
|
||||
</span>`;
|
||||
@@ -758,6 +767,7 @@ function afficherDetailEvent(event) {
|
||||
setValue('admin-nom-event', event.nom);
|
||||
setValue('admin-couleur-primaire', event.couleur_primaire || '#e91e63');
|
||||
setValue('admin-couleur-secondaire', event.couleur_secondaire || '#ffffff');
|
||||
setValue('admin-date-fin', event.date_fin || '');
|
||||
rafraichirMediaAccueil().then(() => {
|
||||
const select = document.getElementById('admin-media-accueil');
|
||||
if (event.media_accueil) select.value = event.media_accueil;
|
||||
@@ -768,6 +778,17 @@ function afficherDetailEvent(event) {
|
||||
document.getElementById('tog-event-fmt-15x20').checked = fmts.includes('15x20');
|
||||
document.getElementById('tog-event-fmt-strip').checked = fmts.includes('strip');
|
||||
|
||||
// Statut termine
|
||||
const btnTerminer = document.getElementById('btn-terminer-event');
|
||||
const badgeTermine = document.getElementById('badge-event-termine');
|
||||
if (event.termine) {
|
||||
btnTerminer.classList.add('cache');
|
||||
badgeTermine.classList.remove('cache');
|
||||
} else {
|
||||
btnTerminer.classList.remove('cache');
|
||||
badgeTermine.classList.add('cache');
|
||||
}
|
||||
|
||||
// Lien galerie en ligne
|
||||
const booth = config.booth || {};
|
||||
const lienBloc = document.getElementById('lien-galerie-event');
|
||||
@@ -785,6 +806,17 @@ function afficherDetailEvent(event) {
|
||||
chargerCadresEvent();
|
||||
}
|
||||
|
||||
async function terminerEvenement() {
|
||||
if (!eventEditId) return;
|
||||
if (!confirm('Terminer cet evenement ? L\'impression sera desactivee.')) return;
|
||||
await apiPost(`/api/evenements/${eventEditId}/terminer`);
|
||||
config = await apiGet('/api/config');
|
||||
const event = await apiGet(`/api/evenements/${eventEditId}`);
|
||||
afficherDetailEvent(event);
|
||||
await chargerListeEvenements();
|
||||
afficherStatut('Evenement termine — impression desactivee', 'succes');
|
||||
}
|
||||
|
||||
async function supprimerEventAdmin(id, nom) {
|
||||
if (!confirm(`Supprimer l'evenement "${nom}" et ses cadres ?`)) return;
|
||||
await fetch(`/api/evenements/${id}`, { method: 'DELETE' });
|
||||
@@ -823,9 +855,23 @@ async function uploaderMediaAccueil() {
|
||||
const formData = new FormData();
|
||||
formData.append('fichier', input.files[0]);
|
||||
await fetch('/api/upload/animation', { method: 'POST', body: formData });
|
||||
const nomFichier = input.files[0].name;
|
||||
input.value = '';
|
||||
await rafraichirMediaAccueil();
|
||||
afficherStatut('Media importe', 'succes');
|
||||
document.getElementById('admin-media-accueil').value = nomFichier;
|
||||
|
||||
// Applique automatiquement la video comme media d'accueil de l'evenement en cours
|
||||
// (sinon il faut la re-selectionner dans le menu ET cliquer sur "Enregistrer" separement)
|
||||
if (eventEditId) {
|
||||
await apiPost('/api/config', { evenement: { media_accueil: nomFichier, event_id: eventEditId } });
|
||||
await fetch(`/api/evenements/${eventEditId}`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ media_accueil: nomFichier }),
|
||||
});
|
||||
appliquerConfig();
|
||||
}
|
||||
afficherStatut('Media importe et applique', 'succes');
|
||||
}
|
||||
|
||||
async function sauvegarderEvenement() {
|
||||
@@ -840,6 +886,7 @@ async function sauvegarderEvenement() {
|
||||
couleur_primaire: getValue('admin-couleur-primaire'),
|
||||
couleur_secondaire: getValue('admin-couleur-secondaire'),
|
||||
media_accueil: getValue('admin-media-accueil') || null,
|
||||
date_fin: getValue('admin-date-fin') || null,
|
||||
formats_actifs,
|
||||
};
|
||||
|
||||
@@ -925,16 +972,19 @@ async function uploaderCadreEvent() {
|
||||
const input = document.getElementById('input-cadre-event');
|
||||
if (!input.files.length) return;
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('fichier', input.files[0]);
|
||||
const nomFichier = input.files[0].name;
|
||||
for (const fmt of FORMATS_CADRE_EVENT) {
|
||||
const fd = new FormData();
|
||||
fd.append('fichier', input.files[0]);
|
||||
await fetch(`/api/evenements/${eventEditId}/upload-cadre/${fmt}`, { method: 'POST', body: fd });
|
||||
}
|
||||
input.value = '';
|
||||
await chargerCadresEvent();
|
||||
afficherStatut('Cadre importe (10x15 + 15x20)', 'succes');
|
||||
|
||||
// Applique automatiquement le cadre importe (sinon il reste inactif tant qu'on ne clique pas sur sa vignette)
|
||||
const modeSelect = document.getElementById('mode-cadre-event');
|
||||
if (modeSelect && modeSelect.value === 'aucun') modeSelect.value = 'impose';
|
||||
await selectionnerCadreEvent(nomFichier);
|
||||
afficherStatut('Cadre importe et applique (10x15 + 15x20)', 'succes');
|
||||
}
|
||||
|
||||
async function supprimerCadreEvent(nom) {
|
||||
@@ -1381,3 +1431,684 @@ async function chargerDiagCamera() {
|
||||
el.textContent = 'ERREUR : ' + e.message;
|
||||
}
|
||||
}
|
||||
|
||||
// === CONSOMMABLES ===
|
||||
|
||||
async function chargerConsommables() {
|
||||
try {
|
||||
const data = await apiGet('/api/consommables');
|
||||
document.getElementById('conso-papier-restant').textContent = data.papier_restant;
|
||||
document.getElementById('conso-papier-cap').textContent = data.papier_capacite;
|
||||
document.getElementById('conso-ruban-restant').textContent = data.ruban_restant;
|
||||
document.getElementById('conso-ruban-cap').textContent = data.ruban_capacite;
|
||||
document.getElementById('conso-photos').textContent = data.photos_imprimees;
|
||||
setValue('conso-cap-papier', data.papier_capacite);
|
||||
setValue('conso-cap-ruban', data.ruban_capacite);
|
||||
|
||||
const pctPapier = data.papier_capacite > 0 ? Math.max(0, (data.papier_restant / data.papier_capacite) * 100) : 0;
|
||||
const pctRuban = data.ruban_capacite > 0 ? Math.max(0, (data.ruban_restant / data.ruban_capacite) * 100) : 0;
|
||||
|
||||
const barrePapier = document.getElementById('conso-barre-papier');
|
||||
const barreRuban = document.getElementById('conso-barre-ruban');
|
||||
barrePapier.style.width = pctPapier + '%';
|
||||
barreRuban.style.width = pctRuban + '%';
|
||||
barrePapier.style.background = pctPapier < 10 ? '#f44336' : pctPapier < 25 ? '#fb8c00' : '#43a047';
|
||||
barreRuban.style.background = pctRuban < 10 ? '#f44336' : pctRuban < 25 ? '#fb8c00' : '#43a047';
|
||||
|
||||
const perdues = data.poses_perdues || 0;
|
||||
document.getElementById('conso-perdues').textContent = perdues;
|
||||
const cardPerdues = document.getElementById('conso-card-perdues');
|
||||
if (perdues > 0) {
|
||||
document.getElementById('conso-perdues').style.color = '#f44336';
|
||||
cardPerdues.style.borderLeft = '3px solid #f44336';
|
||||
} else {
|
||||
document.getElementById('conso-perdues').style.color = '#43a047';
|
||||
cardPerdues.style.borderLeft = '3px solid #43a047';
|
||||
}
|
||||
|
||||
const diag = document.getElementById('conso-diagnostic');
|
||||
const papierUsed = data.papier_utilise;
|
||||
const rubanUsed = data.ruban_utilise;
|
||||
const photos = data.photos_imprimees;
|
||||
let html = '<strong>Diagnostic consommables</strong><br>';
|
||||
html += `Feuilles papier consommees : ${papierUsed}<br>`;
|
||||
html += `Poses ruban consommees : ${rubanUsed}<br>`;
|
||||
html += `Photos imprimees : ${photos}<br>`;
|
||||
html += `Poses perdues (gaspillees) : ${perdues}<br>`;
|
||||
if (papierUsed > 0) {
|
||||
const ratio = (rubanUsed / papierUsed).toFixed(2);
|
||||
html += `<br>Ratio ruban/papier : <strong>${ratio}</strong><br>`;
|
||||
if (parseFloat(ratio) <= 0.75) {
|
||||
html += '✅ <strong>Rembobinage efficace</strong> — le ruban est economise';
|
||||
} else if (parseFloat(ratio) >= 0.95) {
|
||||
html += '⚠ <strong>Pas d\'economie ruban</strong> — activez le rembobinage dans Materiel';
|
||||
} else {
|
||||
html += '🔄 Rembobinage partiel';
|
||||
}
|
||||
if (perdues > 0) {
|
||||
const pctPerdu = ((perdues / (rubanUsed + perdues)) * 100).toFixed(0);
|
||||
html += `<br>🔴 ${pctPerdu}% du ruban gaspille (${perdues} poses pour rien)`;
|
||||
}
|
||||
}
|
||||
if (data.papier_restant <= 20 || data.ruban_restant <= 20) {
|
||||
html += '<br><br>🚨 <strong>Consommable bientot epuise !</strong>';
|
||||
}
|
||||
if (data.ruban_restant < data.papier_restant - 10) {
|
||||
html += '<br>⚠ Le ruban va s\'epuiser avant le papier';
|
||||
}
|
||||
diag.innerHTML = html;
|
||||
} catch (e) {
|
||||
console.warn('Erreur chargement consommables:', e);
|
||||
}
|
||||
}
|
||||
|
||||
async function resetConsommable(quoi) {
|
||||
const labels = { papier: 'Reinitialiser le compteur papier ?', ruban: 'Reinitialiser le compteur ruban ?', tout: 'Reinitialiser tous les compteurs ?' };
|
||||
if (!confirm(labels[quoi] || 'Reinitialiser ?')) return;
|
||||
await apiPost('/api/consommables/reset', { quoi });
|
||||
chargerConsommables();
|
||||
afficherStatut('Consommable reinitialise', 'succes');
|
||||
}
|
||||
|
||||
async function sauvegarderCapacites() {
|
||||
const papier = parseInt(getValue('conso-cap-papier')) || 400;
|
||||
const ruban = parseInt(getValue('conso-cap-ruban')) || 400;
|
||||
await apiPost('/api/consommables/capacite', { papier_capacite: papier, ruban_capacite: ruban });
|
||||
chargerConsommables();
|
||||
afficherStatut('Capacites sauvegardees', 'succes');
|
||||
}
|
||||
|
||||
// === VIDEOS DIDACTIQUES (multi-etapes) ===
|
||||
|
||||
let _videosData = {};
|
||||
|
||||
async function chargerVideosAdmin() {
|
||||
try {
|
||||
const data = await apiGet('/api/videos');
|
||||
_videosData = data.situations || {};
|
||||
const container = document.getElementById('video-situations-liste');
|
||||
if (!container) return;
|
||||
container.innerHTML = '';
|
||||
for (const [sid, sit] of Object.entries(_videosData)) {
|
||||
container.appendChild(_creerBlocSituation(sid, sit));
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('Erreur chargement videos:', e);
|
||||
}
|
||||
}
|
||||
|
||||
function _creerBlocSituation(sid, sit) {
|
||||
const bloc = document.createElement('div');
|
||||
bloc.className = 'video-situation-bloc';
|
||||
bloc.style.cssText = 'margin-bottom:1rem;padding:0.75rem;background:#1a1a2e;border-radius:8px;border:1px solid #333';
|
||||
const header = document.createElement('div');
|
||||
header.style.cssText = 'display:flex;align-items:center;gap:0.75rem;margin-bottom:0.5rem;flex-wrap:wrap';
|
||||
const toggle = document.createElement('label');
|
||||
toggle.className = 'toggle';
|
||||
toggle.style.cssText = 'margin:0;flex-shrink:0';
|
||||
const cb = document.createElement('input');
|
||||
cb.type = 'checkbox';
|
||||
cb.checked = !!sit.actif;
|
||||
cb.onchange = () => toggleSituation(sid, cb.checked);
|
||||
const slider = document.createElement('span');
|
||||
slider.className = 'toggle-slider';
|
||||
toggle.appendChild(cb);
|
||||
toggle.appendChild(slider);
|
||||
const titre = document.createElement('h4');
|
||||
titre.style.cssText = 'margin:0;flex:1;font-size:0.95rem';
|
||||
titre.textContent = sit.label || sid;
|
||||
const nbEtapes = document.createElement('span');
|
||||
nbEtapes.style.cssText = 'color:#888;font-size:0.8rem';
|
||||
nbEtapes.textContent = `${(sit.etapes || []).length} etape(s)`;
|
||||
header.appendChild(toggle);
|
||||
header.appendChild(titre);
|
||||
header.appendChild(nbEtapes);
|
||||
bloc.appendChild(header);
|
||||
|
||||
const etapesDiv = document.createElement('div');
|
||||
etapesDiv.style.cssText = 'margin-left:0.5rem';
|
||||
(sit.etapes || []).forEach((etape, i) => {
|
||||
const row = document.createElement('div');
|
||||
row.style.cssText = 'display:flex;align-items:center;gap:0.5rem;margin-bottom:0.4rem;padding:0.3rem 0.5rem;background:#111;border-radius:6px';
|
||||
const num = document.createElement('span');
|
||||
num.style.cssText = 'color:#888;font-size:0.8rem;min-width:1.5rem';
|
||||
num.textContent = `${i + 1}.`;
|
||||
const labelEtape = document.createElement('input');
|
||||
labelEtape.type = 'text';
|
||||
labelEtape.placeholder = `Etape ${i + 1}`;
|
||||
labelEtape.value = (sit.labels_etapes && sit.labels_etapes[String(i)]) || '';
|
||||
labelEtape.style.cssText = 'flex:1;padding:0.2rem 0.4rem;border-radius:4px;border:1px solid #444;background:#1a1a2e;color:#fff;font-size:0.8rem';
|
||||
labelEtape.onchange = () => labeliserEtape(sid, i, labelEtape.value);
|
||||
const btnPlay = document.createElement('button');
|
||||
btnPlay.className = 'btn-secondaire btn-petit';
|
||||
btnPlay.textContent = '▶';
|
||||
btnPlay.title = 'Apercu';
|
||||
btnPlay.onclick = () => previewEtape(sid, i);
|
||||
const btnUp = document.createElement('button');
|
||||
btnUp.className = 'btn-secondaire btn-petit';
|
||||
btnUp.textContent = '↑';
|
||||
btnUp.disabled = i === 0;
|
||||
btnUp.onclick = () => reordonnerEtape(sid, i, i - 1);
|
||||
const btnDown = document.createElement('button');
|
||||
btnDown.className = 'btn-secondaire btn-petit';
|
||||
btnDown.textContent = '↓';
|
||||
btnDown.disabled = i === (sit.etapes || []).length - 1;
|
||||
btnDown.onclick = () => reordonnerEtape(sid, i, i + 1);
|
||||
const btnDel = document.createElement('button');
|
||||
btnDel.className = 'btn-danger btn-petit';
|
||||
btnDel.textContent = '✕';
|
||||
btnDel.onclick = () => supprimerEtape(sid, i);
|
||||
row.appendChild(num);
|
||||
row.appendChild(labelEtape);
|
||||
row.appendChild(btnPlay);
|
||||
row.appendChild(btnUp);
|
||||
row.appendChild(btnDown);
|
||||
row.appendChild(btnDel);
|
||||
etapesDiv.appendChild(row);
|
||||
});
|
||||
|
||||
const ajoutRow = document.createElement('div');
|
||||
ajoutRow.style.cssText = 'display:flex;align-items:center;gap:0.5rem;margin-top:0.4rem';
|
||||
const inputFile = document.createElement('input');
|
||||
inputFile.type = 'file';
|
||||
inputFile.accept = '.mp4,.webm,.mov';
|
||||
inputFile.className = 'input-fichier';
|
||||
inputFile.id = 'input-etape-' + sid;
|
||||
inputFile.style.cssText = 'flex:1;font-size:0.75rem';
|
||||
const btnAjout = document.createElement('button');
|
||||
btnAjout.className = 'btn-secondaire btn-petit';
|
||||
btnAjout.textContent = '+ Etape';
|
||||
btnAjout.onclick = () => uploaderEtape(sid);
|
||||
ajoutRow.appendChild(inputFile);
|
||||
ajoutRow.appendChild(btnAjout);
|
||||
etapesDiv.appendChild(ajoutRow);
|
||||
|
||||
bloc.appendChild(etapesDiv);
|
||||
return bloc;
|
||||
}
|
||||
|
||||
async function toggleSituation(sid, actif) {
|
||||
try {
|
||||
await fetch(`/api/videos/${sid}/toggle`, {
|
||||
method: 'POST', headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({ actif })
|
||||
});
|
||||
} catch (e) {
|
||||
afficherStatut('Erreur toggle', 'erreur');
|
||||
}
|
||||
}
|
||||
|
||||
async function uploaderEtape(sid) {
|
||||
const input = document.getElementById('input-etape-' + sid);
|
||||
if (!input || !input.files.length) return;
|
||||
const fd = new FormData();
|
||||
fd.append('video', input.files[0]);
|
||||
try {
|
||||
const resp = await fetch(`/api/videos/${sid}/upload`, { method: 'POST', body: fd });
|
||||
if (resp.ok) {
|
||||
input.value = '';
|
||||
chargerVideosAdmin();
|
||||
afficherStatut('Etape ajoutee', 'succes');
|
||||
}
|
||||
} catch (e) {
|
||||
afficherStatut('Erreur upload etape', 'erreur');
|
||||
}
|
||||
}
|
||||
|
||||
async function supprimerEtape(sid, index) {
|
||||
try {
|
||||
await fetch(`/api/videos/${sid}/${index}`, { method: 'DELETE' });
|
||||
chargerVideosAdmin();
|
||||
afficherStatut('Etape supprimee', 'succes');
|
||||
} catch (e) {
|
||||
afficherStatut('Erreur suppression', 'erreur');
|
||||
}
|
||||
}
|
||||
|
||||
async function reordonnerEtape(sid, de, vers) {
|
||||
try {
|
||||
await fetch(`/api/videos/${sid}/reorder`, {
|
||||
method: 'POST', headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({ de, vers })
|
||||
});
|
||||
chargerVideosAdmin();
|
||||
} catch (e) {
|
||||
afficherStatut('Erreur reorder', 'erreur');
|
||||
}
|
||||
}
|
||||
|
||||
async function labeliserEtape(sid, index, label) {
|
||||
try {
|
||||
await fetch(`/api/videos/${sid}/label`, {
|
||||
method: 'POST', headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({ index, label })
|
||||
});
|
||||
} catch (e) {
|
||||
console.warn('Erreur label etape:', e);
|
||||
}
|
||||
}
|
||||
|
||||
function previewEtape(sid, index) {
|
||||
const preview = document.getElementById('video-situation-preview');
|
||||
if (preview) {
|
||||
preview.src = `/api/videos/${sid}/${index}/stream`;
|
||||
preview.load();
|
||||
preview.play();
|
||||
}
|
||||
}
|
||||
|
||||
async function creerSituation() {
|
||||
const input = document.getElementById('nouvelle-situation-label');
|
||||
const label = (input && input.value || '').trim();
|
||||
if (!label) return;
|
||||
const id = label.toLowerCase().replace(/[^a-z0-9]+/g, '_').replace(/^_|_$/g, '');
|
||||
try {
|
||||
await fetch('/api/videos/situation/creer', {
|
||||
method: 'POST', headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({ id, label })
|
||||
});
|
||||
input.value = '';
|
||||
chargerVideosAdmin();
|
||||
afficherStatut('Situation ajoutee', 'succes');
|
||||
} catch (e) {
|
||||
afficherStatut('Erreur creation situation', 'erreur');
|
||||
}
|
||||
}
|
||||
|
||||
// === WIZARD VIDEO DIDACTIQUE ===
|
||||
|
||||
let _wizardSituation = null;
|
||||
let _wizardEtapes = [];
|
||||
let _wizardIndex = 0;
|
||||
|
||||
async function lancerWizard(situationId) {
|
||||
const data = await apiGet('/api/videos');
|
||||
const sit = (data.situations || {})[situationId];
|
||||
if (!sit || !sit.etapes || sit.etapes.length === 0) {
|
||||
afficherStatut('Aucune etape pour cette situation', 'erreur');
|
||||
return;
|
||||
}
|
||||
_wizardSituation = { id: situationId, ...sit };
|
||||
_wizardEtapes = sit.etapes;
|
||||
_wizardIndex = 0;
|
||||
_afficherEtapeWizard();
|
||||
document.getElementById('wizard-video').classList.remove('cache');
|
||||
}
|
||||
|
||||
function _afficherEtapeWizard() {
|
||||
const titre = document.getElementById('wizard-titre');
|
||||
const info = document.getElementById('wizard-etape-info');
|
||||
const video = document.getElementById('wizard-video-player');
|
||||
const label = document.getElementById('wizard-etape-label');
|
||||
const btn = document.getElementById('wizard-btn-ok');
|
||||
titre.textContent = _wizardSituation.label || _wizardSituation.id;
|
||||
info.textContent = `Etape ${_wizardIndex + 1} / ${_wizardEtapes.length}`;
|
||||
const etapeLabel = (_wizardSituation.labels_etapes || {})[String(_wizardIndex)] || '';
|
||||
label.textContent = etapeLabel;
|
||||
video.src = `/api/videos/${_wizardSituation.id}/${_wizardIndex}/stream`;
|
||||
video.load();
|
||||
video.play();
|
||||
if (_wizardIndex === _wizardEtapes.length - 1) {
|
||||
btn.textContent = 'Terminer ✓';
|
||||
btn.style.background = '#2196f3';
|
||||
} else {
|
||||
btn.textContent = "OK, c'est bon !";
|
||||
btn.style.background = '#4caf50';
|
||||
}
|
||||
}
|
||||
|
||||
function wizardEtapeSuivante() {
|
||||
_wizardIndex++;
|
||||
if (_wizardIndex >= _wizardEtapes.length) {
|
||||
fermerWizard();
|
||||
return;
|
||||
}
|
||||
_afficherEtapeWizard();
|
||||
}
|
||||
|
||||
function fermerWizard() {
|
||||
const overlay = document.getElementById('wizard-video');
|
||||
const video = document.getElementById('wizard-video-player');
|
||||
if (video) { video.pause(); video.src = ''; }
|
||||
overlay.classList.add('cache');
|
||||
_wizardSituation = null;
|
||||
_wizardEtapes = [];
|
||||
_wizardIndex = 0;
|
||||
_arreterAutoDetect();
|
||||
}
|
||||
|
||||
let _wizardAutoDetectTimer = null;
|
||||
let _wizardAutoDetectType = null;
|
||||
|
||||
function lancerWizardSituation(situationId, autoDetectType) {
|
||||
_wizardAutoDetectType = autoDetectType || null;
|
||||
lancerWizard(situationId);
|
||||
if (_wizardAutoDetectType) {
|
||||
_demarrerAutoDetect();
|
||||
}
|
||||
}
|
||||
|
||||
function _demarrerAutoDetect() {
|
||||
if (_wizardAutoDetectTimer) clearInterval(_wizardAutoDetectTimer);
|
||||
_wizardAutoDetectTimer = setInterval(async () => {
|
||||
try {
|
||||
const s = await apiGet('/api/systeme/sante');
|
||||
let resolu = false;
|
||||
if (_wizardAutoDetectType === 'camera' && s.camera.status === 'ok') resolu = true;
|
||||
if (_wizardAutoDetectType === 'imprimante' && s.imprimante.status === 'prete') resolu = true;
|
||||
if (resolu) {
|
||||
_arreterAutoDetect();
|
||||
fermerWizard();
|
||||
afficherStatut('Probleme resolu !', 'succes');
|
||||
if (typeof fermerErreurEquipement === 'function') fermerErreurEquipement();
|
||||
}
|
||||
} catch (e) {}
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
function _arreterAutoDetect() {
|
||||
if (_wizardAutoDetectTimer) { clearInterval(_wizardAutoDetectTimer); _wizardAutoDetectTimer = null; }
|
||||
_wizardAutoDetectType = null;
|
||||
}
|
||||
|
||||
function lancerWizardDepuisAdmin() {
|
||||
const actives = Object.entries(_videosData).filter(([_, s]) => s.actif && s.etapes && s.etapes.length > 0);
|
||||
if (actives.length === 0) {
|
||||
afficherStatut('Aucune situation active avec des etapes', 'erreur');
|
||||
return;
|
||||
}
|
||||
lancerWizard(actives[0][0]);
|
||||
}
|
||||
|
||||
// === SURPRISE (photo/video avant capture) ===
|
||||
|
||||
async function chargerSurpriseConfig() {
|
||||
const surprise = config.surprise || {};
|
||||
const tog = document.getElementById('tog-surprise-actif');
|
||||
if (tog) tog.checked = !!surprise.actif;
|
||||
const delai = document.getElementById('admin-surprise-delai');
|
||||
if (delai) delai.value = surprise.delai_ms || 1000;
|
||||
const typeRadios = document.querySelectorAll('input[name="surprise-type"]');
|
||||
typeRadios.forEach(r => r.checked = r.value === (surprise.type || 'photo'));
|
||||
const current = document.getElementById('surprise-current');
|
||||
if (current) current.textContent = surprise.fichier || 'Aucun media configure';
|
||||
majSurprisePreview(surprise);
|
||||
}
|
||||
|
||||
function majSurprisePreview(surprise) {
|
||||
const container = document.getElementById('surprise-preview');
|
||||
if (!container) return;
|
||||
if (!surprise || !surprise.fichier) {
|
||||
container.innerHTML = '<span style="color:#666">Aucun apercu</span>';
|
||||
return;
|
||||
}
|
||||
const url = '/api/surprise/media';
|
||||
if (surprise.type === 'video') {
|
||||
container.innerHTML = `<video src="${url}" style="width:100%;max-height:300px;border-radius:8px" controls></video>`;
|
||||
} else {
|
||||
container.innerHTML = `<img src="${url}" style="width:100%;max-height:300px;border-radius:8px;object-fit:contain">`;
|
||||
}
|
||||
}
|
||||
|
||||
async function uploaderSurprise() {
|
||||
const input = document.getElementById('input-surprise-media');
|
||||
if (!input || !input.files.length) return;
|
||||
const fd = new FormData();
|
||||
fd.append('media', input.files[0]);
|
||||
try {
|
||||
const resp = await fetch('/api/surprise/upload', { method: 'POST', body: fd });
|
||||
if (resp.ok) {
|
||||
const data = await resp.json();
|
||||
input.value = '';
|
||||
config = await apiGet('/api/config');
|
||||
chargerSurpriseConfig();
|
||||
afficherStatut('Media surprise importe', 'succes');
|
||||
}
|
||||
} catch (e) {
|
||||
afficherStatut('Erreur upload surprise', 'erreur');
|
||||
}
|
||||
}
|
||||
|
||||
async function supprimerSurprise() {
|
||||
try {
|
||||
await fetch('/api/surprise/media', { method: 'DELETE' });
|
||||
config = await apiGet('/api/config');
|
||||
chargerSurpriseConfig();
|
||||
afficherStatut('Surprise supprimee', 'succes');
|
||||
} catch (e) {
|
||||
afficherStatut('Erreur suppression surprise', 'erreur');
|
||||
}
|
||||
}
|
||||
|
||||
async function sauvegarderSurprise() {
|
||||
const actif = document.getElementById('tog-surprise-actif')?.checked || false;
|
||||
const delai = parseInt(document.getElementById('admin-surprise-delai')?.value) || 1000;
|
||||
const type = document.querySelector('input[name="surprise-type"]:checked')?.value || 'photo';
|
||||
await apiPost('/api/config', {
|
||||
surprise: { actif, delai_ms: delai, type }
|
||||
});
|
||||
afficherStatut('Surprise sauvegardee', 'succes');
|
||||
}
|
||||
|
||||
// === RELAIS ===
|
||||
|
||||
async function chargerRelaisStatus() {
|
||||
try {
|
||||
const data = await apiGet('/api/relais');
|
||||
const el = document.getElementById('relais-status');
|
||||
if (!el) return;
|
||||
if (!data.connecte) {
|
||||
el.textContent = 'Module relais non connecte';
|
||||
el.style.color = '#f44';
|
||||
return;
|
||||
}
|
||||
const proj_g = data.projecteur_gauche ? '🟢' : '⚫';
|
||||
const proj_d = data.projecteur_droit ? '🟢' : '⚫';
|
||||
const canon = data.canon ? '🟢' : '🔴';
|
||||
el.innerHTML = `Proj G: ${proj_g} | Proj D: ${proj_d} | Canon: ${canon} (alim)`;
|
||||
el.style.color = '#4caf50';
|
||||
} catch (e) {
|
||||
console.warn('Erreur relais status:', e);
|
||||
}
|
||||
}
|
||||
|
||||
async function chargerRelaisConfig() {
|
||||
try {
|
||||
const data = await apiGet('/api/relais/config');
|
||||
const tog = document.getElementById('tog-eclairage-auto');
|
||||
if (tog) tog.checked = !!data.eclairage_auto;
|
||||
const s1 = document.getElementById('relais-seuil-proj1');
|
||||
if (s1) s1.value = data.seuil_proj1 ?? 45;
|
||||
const s2 = document.getElementById('relais-seuil-proj2');
|
||||
if (s2) s2.value = data.seuil_proj2 ?? 30;
|
||||
const soff = document.getElementById('relais-seuil-off');
|
||||
if (soff) soff.value = data.seuil_off ?? 65;
|
||||
const vd = document.getElementById('relais-veille-delai');
|
||||
if (vd) vd.value = data.veille_delai ?? 0;
|
||||
} catch (e) {
|
||||
console.warn('Erreur relais config:', e);
|
||||
}
|
||||
}
|
||||
|
||||
async function sauvegarderRelaisConfig() {
|
||||
const eclairage_auto = document.getElementById('tog-eclairage-auto')?.checked || false;
|
||||
const seuil_proj1 = parseInt(document.getElementById('relais-seuil-proj1')?.value) || 45;
|
||||
const seuil_proj2 = parseInt(document.getElementById('relais-seuil-proj2')?.value) || 30;
|
||||
const seuil_off = parseInt(document.getElementById('relais-seuil-off')?.value) || 65;
|
||||
const veille_delai = parseInt(document.getElementById('relais-veille-delai')?.value) || 0;
|
||||
await apiPost('/api/relais/config', { eclairage_auto, seuil_proj1, seuil_proj2, seuil_off, veille_delai });
|
||||
afficherStatut('Config relais sauvegardee', 'succes');
|
||||
}
|
||||
|
||||
async function relaisAction(nom, action) {
|
||||
try {
|
||||
if (nom === 'canon/hard-reset') {
|
||||
await fetch('/api/relais/canon/hard-reset', {
|
||||
method: 'POST', headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({duree: 5})
|
||||
});
|
||||
afficherStatut('Hard reset Canon lance (trappe + alim)', 'succes');
|
||||
} else if (nom === 'canon/power-cycle') {
|
||||
await fetch('/api/relais/canon/power-cycle', {
|
||||
method: 'POST', headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({duree: 3})
|
||||
});
|
||||
afficherStatut('Power-cycle Canon lance (3s)', 'succes');
|
||||
} else {
|
||||
await fetch(`/api/relais/${nom}/${action}`, { method: 'POST' });
|
||||
afficherStatut(`${nom} ${action}`, 'succes');
|
||||
}
|
||||
setTimeout(chargerRelaisStatus, 500);
|
||||
} catch (e) {
|
||||
afficherStatut('Erreur relais', 'erreur');
|
||||
}
|
||||
}
|
||||
|
||||
function demarrerEclairageLiveExt() {
|
||||
chargerRelaisStatus();
|
||||
chargerRelaisConfig();
|
||||
}
|
||||
|
||||
// === DIAGNOSTIC ===
|
||||
|
||||
let _diagRefreshTimer = null;
|
||||
|
||||
async function chargerDiagnostic() {
|
||||
chargerSante();
|
||||
chargerLogs();
|
||||
chargerUsb();
|
||||
if (_diagRefreshTimer) clearInterval(_diagRefreshTimer);
|
||||
_diagRefreshTimer = setInterval(chargerSante, 10000);
|
||||
}
|
||||
|
||||
async function chargerSante() {
|
||||
try {
|
||||
const s = await apiGet('/api/systeme/sante');
|
||||
|
||||
// Camera
|
||||
const camCard = document.getElementById('diag-camera');
|
||||
const camSt = document.getElementById('diag-camera-status');
|
||||
if (s.camera.status === 'ok') {
|
||||
camCard.className = 'diag-card ok';
|
||||
camSt.textContent = 'Connectee — ' + s.camera.mode;
|
||||
} else if (s.camera.usb) {
|
||||
camCard.className = 'diag-card warn';
|
||||
camSt.textContent = 'USB detecte mais non connectee';
|
||||
} else {
|
||||
camCard.className = 'diag-card err';
|
||||
camSt.textContent = s.camera.status === 'erreur' ? 'Non disponible' : s.camera.mode;
|
||||
}
|
||||
|
||||
// Imprimante
|
||||
const impCard = document.getElementById('diag-imprimante');
|
||||
const impSt = document.getElementById('diag-imp-status');
|
||||
if (s.imprimante.status === 'prete') {
|
||||
impCard.className = 'diag-card ok';
|
||||
impSt.textContent = s.imprimante.nom + ' — Prete';
|
||||
} else if (s.imprimante.status === 'impression') {
|
||||
impCard.className = 'diag-card ok';
|
||||
impSt.textContent = 'En cours d\'impression';
|
||||
} else if (s.imprimante.status === 'arretee') {
|
||||
impCard.className = 'diag-card err';
|
||||
impSt.textContent = s.imprimante.nom + ' — Arretee' + (s.imprimante.usb ? ' (USB ok)' : ' (USB absente)');
|
||||
} else {
|
||||
impCard.className = 'diag-card ' + (s.imprimante.usb ? 'warn' : 'off');
|
||||
impSt.textContent = s.imprimante.usb ? 'USB detectee — CUPS inconnu' : 'Non detectee';
|
||||
}
|
||||
if (s.imprimante.jobs > 0) impSt.textContent += ' — ' + s.imprimante.jobs + ' job(s)';
|
||||
|
||||
// Relais
|
||||
const relCard = document.getElementById('diag-relais');
|
||||
const relSt = document.getElementById('diag-relais-status');
|
||||
if (s.relais.connecte) {
|
||||
relCard.className = 'diag-card ok';
|
||||
relSt.textContent = 'Connecte';
|
||||
} else {
|
||||
relCard.className = 'diag-card off';
|
||||
relSt.textContent = 'Non detecte';
|
||||
}
|
||||
|
||||
// Systeme
|
||||
const sysCard = document.getElementById('diag-systeme');
|
||||
const sysSt = document.getElementById('diag-sys-status');
|
||||
const ramWarn = s.systeme.ram_pct > 85;
|
||||
const diskWarn = s.systeme.disque_pct > 90;
|
||||
const tempWarn = s.systeme.temp && s.systeme.temp > 75;
|
||||
if (ramWarn || diskWarn || tempWarn) {
|
||||
sysCard.className = 'diag-card warn';
|
||||
} else {
|
||||
sysCard.className = 'diag-card ok';
|
||||
}
|
||||
let sysInfo = 'RAM ' + s.systeme.ram_pct + '% — Disque ' + s.systeme.disque_pct + '%';
|
||||
if (s.systeme.temp) sysInfo += ' — ' + s.systeme.temp + '°C';
|
||||
if (s.systeme.uptime) sysInfo += ' — Up ' + s.systeme.uptime;
|
||||
sysSt.textContent = sysInfo;
|
||||
} catch (e) {
|
||||
console.error('Diagnostic sante:', e);
|
||||
}
|
||||
}
|
||||
|
||||
async function chargerLogs() {
|
||||
try {
|
||||
const r = await apiGet('/api/systeme/logs?n=80');
|
||||
const el = document.getElementById('diag-logs');
|
||||
el.textContent = r.lignes.join('\n');
|
||||
el.scrollTop = el.scrollHeight;
|
||||
} catch (e) {
|
||||
document.getElementById('diag-logs').textContent = 'Erreur chargement logs';
|
||||
}
|
||||
}
|
||||
|
||||
async function chargerUsb() {
|
||||
try {
|
||||
const r = await apiGet('/api/systeme/usb');
|
||||
const el = document.getElementById('diag-usb');
|
||||
el.textContent = r.peripheriques.join('\n');
|
||||
} catch (e) {
|
||||
document.getElementById('diag-usb').textContent = 'Erreur';
|
||||
}
|
||||
}
|
||||
|
||||
async function diagReconnecterCamera() {
|
||||
afficherStatut('Reconnexion camera...', 'succes');
|
||||
try {
|
||||
await apiPost('/api/camera/reconnecter', {});
|
||||
await chargerSante();
|
||||
afficherStatut('Reconnexion terminee', 'succes');
|
||||
} catch (e) {
|
||||
afficherStatut('Echec reconnexion', 'erreur');
|
||||
}
|
||||
}
|
||||
|
||||
async function diagReactiverImprimante() {
|
||||
afficherStatut('Reactivation imprimante...', 'succes');
|
||||
try {
|
||||
const r = await apiPost('/api/imprimante/reactiver', {});
|
||||
afficherStatut(r.message || 'OK', r.succes ? 'succes' : 'erreur');
|
||||
await chargerSante();
|
||||
} catch (e) {
|
||||
afficherStatut('Echec reactivation', 'erreur');
|
||||
}
|
||||
}
|
||||
|
||||
async function diagRedemarrerBackend() {
|
||||
afficherStatut('Redemarrage backend...', 'succes');
|
||||
try {
|
||||
await fetch('/api/systeme/redemarrer-backend', { method: 'POST' });
|
||||
afficherStatut('Backend redemarre — rechargement dans 5s...', 'succes');
|
||||
setTimeout(() => location.reload(), 5000);
|
||||
} catch (e) {
|
||||
afficherStatut('Erreur', 'erreur');
|
||||
}
|
||||
}
|
||||
|
||||
async function diagRefreshChromium() {
|
||||
location.reload();
|
||||
}
|
||||
|
||||
async function diagRedemarrerSysteme() {
|
||||
afficherStatut('Redemarrage borne...', 'succes');
|
||||
try {
|
||||
await fetch('/api/systeme/redemarrer', { method: 'POST' });
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,11 @@ let modeActuel = 'simple';
|
||||
let photosSession = []; // Photos de la session en cours
|
||||
let photoFinale = null; // Photo finale (avec effets)
|
||||
let ecranActuel = 'accueil';
|
||||
let _veilleTimer = null;
|
||||
let _enVeille = false;
|
||||
let _spotsAllumes = false;
|
||||
const _shutterSound = new Audio('/sounds/shutter.wav');
|
||||
_shutterSound.volume = 0.8;
|
||||
|
||||
// --- Initialisation ---
|
||||
|
||||
@@ -59,6 +64,9 @@ function appliquerConfig() {
|
||||
|
||||
// Media d'accueil (video/gif en boucle)
|
||||
appliquerMediaAccueil(event.media_accueil);
|
||||
|
||||
// Precharger image surprise
|
||||
if (typeof prechargerSurprise === 'function') prechargerSurprise();
|
||||
}
|
||||
|
||||
function appliquerMediaAccueil(media) {
|
||||
@@ -113,7 +121,13 @@ function allerA(ecran) {
|
||||
photoFinale = null;
|
||||
arreterPreview();
|
||||
majCompteurAccueil();
|
||||
} else if (ecran === 'capture') {
|
||||
eteindreSpots();
|
||||
lancerTimerVeille();
|
||||
} else {
|
||||
arreterTimerVeille();
|
||||
reveillerEclairage();
|
||||
}
|
||||
if (ecran === 'capture') {
|
||||
lancerCapture();
|
||||
} else if (ecran === 'partage') {
|
||||
majBoutonImprimerCompteur();
|
||||
@@ -133,6 +147,9 @@ function arreterTimeoutAdmin() {}
|
||||
function recommencer() {
|
||||
photosSession = [];
|
||||
photoFinale = null;
|
||||
photoImpression = null;
|
||||
formatImpression = null;
|
||||
nbExemplaires = 1;
|
||||
allerA('mode');
|
||||
}
|
||||
|
||||
@@ -145,6 +162,7 @@ function setupEcranAccueil() {
|
||||
accueil.addEventListener('click', (e) => {
|
||||
if (e.target.closest('.btn-admin')) return;
|
||||
if (e.target.closest('.btn-photostation')) return;
|
||||
if (_enVeille) reveillerEclairage();
|
||||
allerA('mode');
|
||||
});
|
||||
}
|
||||
@@ -266,6 +284,14 @@ function setupModes() {
|
||||
allerA('capture');
|
||||
});
|
||||
});
|
||||
majDetailPellicule();
|
||||
}
|
||||
|
||||
function majDetailPellicule() {
|
||||
const el = document.getElementById('pellicule-detail');
|
||||
if (!el) return;
|
||||
const nb = config.multi_shot?.nombre_photos || 4;
|
||||
el.textContent = `${nb} poses = 2 tirages`;
|
||||
}
|
||||
|
||||
async function chargerCadresChoix() {
|
||||
@@ -298,12 +324,28 @@ function lancerSansCadre() {
|
||||
allerA('capture');
|
||||
}
|
||||
|
||||
// --- Onglets admin ---
|
||||
// --- Rubriques + Onglets admin ---
|
||||
|
||||
let rubriqueActive = 'general';
|
||||
|
||||
function changerRubrique(nom) {
|
||||
rubriqueActive = nom;
|
||||
document.querySelectorAll('.rubrique').forEach(r => r.classList.toggle('actif', r.dataset.rubrique === nom));
|
||||
document.querySelectorAll('.admin-onglets').forEach(g => g.classList.toggle('cache', g.id !== 'onglets-' + nom));
|
||||
document.querySelectorAll('.admin-panneau').forEach(p => p.classList.remove('actif'));
|
||||
document.querySelectorAll('.onglet').forEach(o => o.classList.remove('actif'));
|
||||
const groupe = document.getElementById('onglets-' + nom);
|
||||
if (groupe) {
|
||||
const premier = groupe.querySelector('.onglet');
|
||||
if (premier) { premier.click(); }
|
||||
}
|
||||
}
|
||||
|
||||
function setupOnglets() {
|
||||
document.querySelectorAll('.onglet').forEach(onglet => {
|
||||
onglet.addEventListener('click', () => {
|
||||
document.querySelectorAll('.onglet').forEach(o => o.classList.remove('actif'));
|
||||
const groupe = onglet.closest('.admin-onglets');
|
||||
if (groupe) groupe.querySelectorAll('.onglet').forEach(o => o.classList.remove('actif'));
|
||||
document.querySelectorAll('.admin-panneau').forEach(p => p.classList.remove('actif'));
|
||||
onglet.classList.add('actif');
|
||||
const panneau = document.getElementById('panneau-' + onglet.dataset.onglet);
|
||||
@@ -372,24 +414,143 @@ function afficherStatut(message, type = 'succes') {
|
||||
wsOnMessage('config_maj', (msg) => {
|
||||
config = msg.config;
|
||||
appliquerConfig();
|
||||
if (ecranActuel === 'accueil') lancerTimerVeille();
|
||||
});
|
||||
|
||||
// Erreur camera : overlay visible sur tous les ecrans, reconnexion automatique cote backend
|
||||
// === Erreur equipement : overlay intelligent avec escalade ===
|
||||
let _erreurCameraTimer = null;
|
||||
wsOnMessage('camera_erreur', () => {
|
||||
let _erreurCameraCount = 0;
|
||||
let _erreurCameraPhase = 0; // 0=auto-fix, 1=patience, 2=operator, 3=restart
|
||||
|
||||
function _showErreurEquipement(icon, titre, msg, phase) {
|
||||
const el = document.getElementById('erreur-equipement');
|
||||
document.getElementById('erreur-equip-icon').textContent = icon;
|
||||
document.getElementById('erreur-equip-titre').textContent = titre;
|
||||
document.getElementById('erreur-equip-msg').textContent = msg;
|
||||
const spinner = document.getElementById('erreur-equip-spinner');
|
||||
const steps = document.getElementById('erreur-equip-steps');
|
||||
const btnRetry = document.getElementById('erreur-equip-btn-retry');
|
||||
const btnVideo = document.getElementById('erreur-equip-btn-video');
|
||||
const btnRestart = document.getElementById('erreur-equip-btn-restart');
|
||||
|
||||
spinner.classList.toggle('cache', phase >= 2);
|
||||
steps.classList.toggle('cache', phase < 2);
|
||||
btnRetry.classList.toggle('cache', phase < 1);
|
||||
btnVideo.classList.toggle('cache', phase < 2);
|
||||
btnRestart.classList.toggle('cache', phase < 2);
|
||||
|
||||
if (phase >= 2) {
|
||||
steps.innerHTML = '<ol>' +
|
||||
'<li>Verifiez que l\'appareil photo est allume (bouton ON)</li>' +
|
||||
'<li>Verifiez le cable USB entre l\'appareil et la borne</li>' +
|
||||
'<li>Eteignez et rallumez l\'appareil photo</li>' +
|
||||
'<li>Si le probleme persiste, redemarrez la borne</li>' +
|
||||
'</ol>';
|
||||
}
|
||||
el.classList.remove('cache');
|
||||
}
|
||||
|
||||
function fermerErreurEquipement() {
|
||||
document.getElementById('erreur-equipement').classList.add('cache');
|
||||
_erreurCameraCount = 0;
|
||||
_erreurCameraPhase = 0;
|
||||
allerA('accueil');
|
||||
}
|
||||
|
||||
function erreurEquipRetry() {
|
||||
document.getElementById('erreur-equip-titre').textContent = 'Verification en cours...';
|
||||
document.getElementById('erreur-equip-msg').textContent = 'Un instant...';
|
||||
document.getElementById('erreur-equip-spinner').classList.remove('cache');
|
||||
document.getElementById('erreur-equip-steps').classList.add('cache');
|
||||
document.getElementById('erreur-equip-btn-retry').classList.add('cache');
|
||||
if (_erreurEquipType === 'imprimante') {
|
||||
fetch('/api/imprimante/reactiver', { method: 'POST' }).catch(() => {});
|
||||
} else {
|
||||
fetch('/api/camera/reconnecter', { method: 'POST', headers: {'Content-Type':'application/json'}, body: '{}' }).catch(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
let _erreurEquipType = 'camera';
|
||||
|
||||
function erreurEquipVideo() {
|
||||
document.getElementById('erreur-equipement').classList.add('cache');
|
||||
const situationMap = { camera: 'camera_hs', imprimante: window._imprimanteErreurSituation || 'depannage_imprimante' };
|
||||
const situation = situationMap[_erreurEquipType] || 'camera_hs';
|
||||
if (typeof lancerWizardSituation === 'function') {
|
||||
lancerWizardSituation(situation, _erreurEquipType);
|
||||
}
|
||||
}
|
||||
|
||||
function erreurEquipRestart() {
|
||||
_showErreurEquipement('⏳', 'Redemarrage en cours', 'La borne redemarre, patientez 30 secondes...', 0);
|
||||
document.getElementById('erreur-equip-btn-accueil').classList.add('cache');
|
||||
fetch('/api/systeme/redemarrer', { method: 'POST' }).catch(() => {});
|
||||
}
|
||||
|
||||
wsOnMessage('camera_erreur', (data) => {
|
||||
if (window.location.pathname === '/admin') return;
|
||||
document.getElementById('camera-erreur').classList.remove('cache');
|
||||
// Reload de dernier recours si la camera ne revient pas apres 2 min
|
||||
_erreurCameraCount++;
|
||||
_erreurEquipType = 'camera';
|
||||
if (_erreurCameraCount <= 2) {
|
||||
_erreurCameraPhase = 0;
|
||||
_showErreurEquipement('📷', 'Preparation de l\'appareil photo', 'Un instant, reconnexion automatique...', 0);
|
||||
} else if (_erreurCameraCount <= 5) {
|
||||
_erreurCameraPhase = 1;
|
||||
_showErreurEquipement('📷', 'L\'appareil photo ne repond pas', 'Le systeme essaie de le reconnecter. Vous pouvez aussi reessayer manuellement.', 1);
|
||||
} else {
|
||||
_erreurCameraPhase = 2;
|
||||
_showErreurEquipement('📷', 'Appareil photo injoignable', 'Suivez ces etapes pour le remettre en marche :', 2);
|
||||
}
|
||||
if (_erreurCameraTimer) clearTimeout(_erreurCameraTimer);
|
||||
_erreurCameraTimer = setTimeout(() => { location.reload(); }, 120000);
|
||||
_erreurCameraTimer = setTimeout(() => { location.reload(); }, 180000);
|
||||
});
|
||||
|
||||
wsOnMessage('shutter', () => {
|
||||
_shutterSound.currentTime = 0;
|
||||
_shutterSound.play().catch(() => {});
|
||||
});
|
||||
|
||||
wsOnMessage('camera_ok', () => {
|
||||
document.getElementById('camera-erreur').classList.add('cache');
|
||||
document.getElementById('erreur-equipement').classList.add('cache');
|
||||
_erreurCameraCount = 0;
|
||||
_erreurCameraPhase = 0;
|
||||
if (_erreurCameraTimer) { clearTimeout(_erreurCameraTimer); _erreurCameraTimer = null; }
|
||||
});
|
||||
|
||||
// Surveillance imprimante — poll toutes les 30s
|
||||
wsOnMessage('imprimante_erreur', (data) => {
|
||||
if (window.location.pathname === '/admin') return;
|
||||
_erreurEquipType = 'imprimante';
|
||||
const titre = data.titre || 'Probleme imprimante';
|
||||
const msg = data.message || 'L\'imprimante ne fonctionne pas correctement.';
|
||||
const etapes = data.etapes || [];
|
||||
const situation = data.situation || 'depannage_imprimante';
|
||||
_showErreurEquipement('🖨', titre, msg, 2);
|
||||
const steps = document.getElementById('erreur-equip-steps');
|
||||
if (etapes.length) {
|
||||
steps.innerHTML = '<ol>' + etapes.map(e => '<li>' + e + '</li>').join('') + '</ol>';
|
||||
steps.classList.remove('cache');
|
||||
}
|
||||
document.getElementById('erreur-equip-btn-retry').classList.remove('cache');
|
||||
document.getElementById('erreur-equip-btn-retry').textContent = 'Verifier';
|
||||
document.getElementById('erreur-equip-btn-retry').onclick = function() {
|
||||
fetch('/api/imprimante/reactiver', { method: 'POST' }).catch(() => {});
|
||||
_showErreurEquipement('🖨', 'Verification en cours...', 'Un instant...', 0);
|
||||
};
|
||||
document.getElementById('erreur-equip-btn-video').classList.remove('cache');
|
||||
document.getElementById('erreur-equip-btn-video').onclick = function() {
|
||||
document.getElementById('erreur-equipement').classList.add('cache');
|
||||
if (typeof lancerWizardSituation === 'function') lancerWizardSituation(situation, 'imprimante');
|
||||
};
|
||||
window._imprimanteErreurSituation = situation;
|
||||
});
|
||||
|
||||
wsOnMessage('imprimante_ok', () => {
|
||||
if (_erreurEquipType === 'imprimante') {
|
||||
document.getElementById('erreur-equipement').classList.add('cache');
|
||||
}
|
||||
document.getElementById('printer-erreur').classList.add('cache');
|
||||
});
|
||||
|
||||
function _afficherErreurImprimante(msg) {
|
||||
const el = document.getElementById('printer-erreur');
|
||||
document.getElementById('printer-erreur-msg').textContent = msg;
|
||||
@@ -400,21 +561,11 @@ async function _pollStatutImprimante() {
|
||||
try {
|
||||
const r = await apiGet('/api/imprimante/statut-detail');
|
||||
const el = document.getElementById('printer-erreur');
|
||||
if (r.derniere_erreur) {
|
||||
let msg = '';
|
||||
const e = r.derniere_erreur.toLowerCase();
|
||||
if (e.includes('media') && e.includes('match'))
|
||||
msg = '⚠ Imprimante : format papier incorrect — vérifiez la cassette';
|
||||
else if (e.includes('jam'))
|
||||
msg = '⚠ Imprimante : bourrage papier — retirez le papier bloqué';
|
||||
else if (e.includes('cancel'))
|
||||
msg = '⚠ Imprimante : job annulé — ' + r.derniere_erreur.split(']').pop().trim();
|
||||
if (msg) { _afficherErreurImprimante(msg); return; }
|
||||
}
|
||||
if (r.statut && (r.statut.includes('stopped') || r.statut.includes('disabled'))) {
|
||||
_afficherErreurImprimante('⚠ Imprimante arrêtée — utilisez le bouton Évacuer dans l\'admin');
|
||||
} else {
|
||||
if (r.statut && !r.statut.includes('stopped') && !r.statut.includes('disabled')) {
|
||||
el.classList.add('cache');
|
||||
if (_erreurEquipType === 'imprimante') {
|
||||
document.getElementById('erreur-equipement').classList.add('cache');
|
||||
}
|
||||
}
|
||||
} catch(e) {}
|
||||
}
|
||||
@@ -537,6 +688,121 @@ async function wizardTerminer() {
|
||||
allerA('accueil');
|
||||
}
|
||||
|
||||
// --- Veille eclairage ---
|
||||
|
||||
function lancerTimerVeille() {
|
||||
arreterTimerVeille();
|
||||
const delai = (config.relais?.veille_delai || 0) * 60000;
|
||||
if (delai <= 0) return;
|
||||
_veilleTimer = setTimeout(() => {
|
||||
_enVeille = true;
|
||||
_spotsAllumes = false;
|
||||
fetch('/api/relais/veille', { method: 'POST' }).catch(() => {});
|
||||
}, delai);
|
||||
}
|
||||
|
||||
function arreterTimerVeille() {
|
||||
if (_veilleTimer) { clearTimeout(_veilleTimer); _veilleTimer = null; }
|
||||
}
|
||||
|
||||
function reveillerEclairage() {
|
||||
if (!_enVeille && _spotsAllumes) return;
|
||||
_enVeille = false;
|
||||
_spotsAllumes = true;
|
||||
arreterTimerVeille();
|
||||
fetch('/api/relais/reveil', { method: 'POST' }).catch(() => {});
|
||||
}
|
||||
|
||||
function eteindreSpots() {
|
||||
_spotsAllumes = false;
|
||||
fetch('/api/relais/veille', { method: 'POST' }).catch(() => {});
|
||||
}
|
||||
|
||||
// --- Mini menu client ---
|
||||
|
||||
function toggleMenuClient() {
|
||||
document.getElementById('menu-client').classList.toggle('cache');
|
||||
}
|
||||
|
||||
async function menuClientAction(action) {
|
||||
document.getElementById('menu-client').classList.add('cache');
|
||||
if (action === 'wifi') {
|
||||
document.getElementById('popup-wifi').classList.remove('cache');
|
||||
scanWifi();
|
||||
} else if (action === 'exposition') {
|
||||
document.getElementById('popup-exposition').classList.remove('cache');
|
||||
chargerExposition();
|
||||
} else if (action === 'shutdown') {
|
||||
if (confirm('Eteindre la borne ?')) apiPost('/api/systeme/eteindre');
|
||||
} else if (action === 'reboot') {
|
||||
if (confirm('Redemarrer la borne ?')) apiPost('/api/systeme/redemarrer');
|
||||
} else if (action === 'restart-app') {
|
||||
apiPost('/api/systeme/redemarrer-app');
|
||||
setTimeout(() => location.reload(), 3000);
|
||||
}
|
||||
}
|
||||
|
||||
async function scanWifi() {
|
||||
const list = document.getElementById('wifi-list');
|
||||
const status = document.getElementById('wifi-status');
|
||||
list.innerHTML = '<div style="text-align:center;padding:16px;color:var(--text2)">Scan en cours...</div>';
|
||||
try {
|
||||
const s = await apiGet('/api/wifi/status');
|
||||
status.innerHTML = s.connecte
|
||||
? `<div style="padding:8px;color:#4caf50">Connecte a <b>${s.ssid}</b> (${s.signal || '?'}%)</div>`
|
||||
: '<div style="padding:8px;color:#f44336">Non connecte</div>';
|
||||
const nets = await apiGet('/api/wifi/scan');
|
||||
if (!nets.length) { list.innerHTML = '<div style="padding:12px;color:var(--text2)">Aucun reseau</div>'; return; }
|
||||
list.innerHTML = nets.map(n => `
|
||||
<div class="wifi-item${n.actif ? ' actif' : ''}" onclick="connecterWifi('${n.ssid.replace(/'/g,"\\'")}', ${n.enregistre})">
|
||||
<div>
|
||||
<div style="font-weight:600">${n.ssid}</div>
|
||||
<div style="font-size:.75rem;color:var(--text2)">${n.signal}% ${n.securise ? '🔒' : ''} ${n.enregistre ? '(enregistre)' : ''}</div>
|
||||
</div>
|
||||
${n.actif ? '<span style="color:#4caf50;font-weight:700">✓</span>' : ''}
|
||||
</div>
|
||||
`).join('');
|
||||
} catch(e) { list.innerHTML = '<div style="padding:12px;color:#f44336">Erreur: ' + e + '</div>'; }
|
||||
}
|
||||
|
||||
async function connecterWifi(ssid, enregistre) {
|
||||
if (enregistre) {
|
||||
const r = await apiPost('/api/wifi/connect', {ssid});
|
||||
alert(r.message || (r.succes ? 'Connecte' : 'Erreur'));
|
||||
scanWifi();
|
||||
return;
|
||||
}
|
||||
const mdp = prompt('Mot de passe WiFi pour ' + ssid + ' :');
|
||||
if (mdp === null) return;
|
||||
const r = await apiPost('/api/wifi/connect', {ssid, password: mdp});
|
||||
alert(r.message || (r.succes ? 'Connecte' : 'Erreur'));
|
||||
scanWifi();
|
||||
}
|
||||
|
||||
async function chargerExposition() {
|
||||
const cfg = charger_config ? charger_config() : config;
|
||||
const luminosite = (cfg || config).impression?.luminosite_impression || 0;
|
||||
document.getElementById('expo-slider').value = luminosite;
|
||||
document.getElementById('expo-slider').min = -50;
|
||||
document.getElementById('expo-slider').max = 50;
|
||||
document.getElementById('expo-slider').step = 5;
|
||||
updateExpoLabel(luminosite);
|
||||
}
|
||||
|
||||
function updateExpoLabel(val) {
|
||||
const signe = val > 0 ? '+' : '';
|
||||
document.getElementById('expo-label').textContent = `${signe}${val}%`;
|
||||
document.getElementById('expo-status').textContent = val == 0 ? 'Normal' : `${signe}${val}%`;
|
||||
}
|
||||
|
||||
async function appliquerExpo() {
|
||||
const val = parseInt(document.getElementById('expo-slider').value);
|
||||
await apiPost('/api/config', {impression: {luminosite_impression: val}});
|
||||
document.getElementById('popup-exposition').classList.add('cache');
|
||||
afficherStatut('Luminosite impression : ' + (val > 0 ? '+' : '') + val + '%', 'succes');
|
||||
config = await apiGet('/api/config');
|
||||
}
|
||||
|
||||
// Demarrage
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
init().then(() => {
|
||||
|
||||
@@ -9,6 +9,55 @@ let captureEnCours = false; // true pendant tout le flux lancerCapture()
|
||||
|
||||
const EMOJI_CAR = { 3: '🤪', 2: '😱', 1: '🔥' };
|
||||
|
||||
// --- Surprise avant capture ---
|
||||
|
||||
let _surprisePreloaded = null;
|
||||
|
||||
function prechargerSurprise() {
|
||||
const surprise = (config || {}).surprise;
|
||||
if (!surprise || !surprise.actif || !surprise.fichier) return;
|
||||
if (surprise.type === 'video') return;
|
||||
const img = new Image();
|
||||
img.src = '/api/surprise/media?t=' + Date.now();
|
||||
_surprisePreloaded = img;
|
||||
}
|
||||
|
||||
function montrerSurprise() {
|
||||
const surprise = (config || {}).surprise;
|
||||
if (!surprise || !surprise.actif || !surprise.fichier) return false;
|
||||
|
||||
const overlay = document.getElementById('surprise-overlay');
|
||||
if (!overlay) return false;
|
||||
|
||||
if (surprise.type === 'video') {
|
||||
overlay.innerHTML = '<video src="/api/surprise/media" autoplay muted playsinline style="max-width:100%;max-height:100%;object-fit:contain"></video>';
|
||||
} else {
|
||||
if (_surprisePreloaded && _surprisePreloaded.complete) {
|
||||
_surprisePreloaded.style.cssText = 'max-width:100%;max-height:100%;object-fit:contain';
|
||||
overlay.innerHTML = '';
|
||||
overlay.appendChild(_surprisePreloaded);
|
||||
} else {
|
||||
overlay.innerHTML = '<img src="/api/surprise/media" style="max-width:100%;max-height:100%;object-fit:contain">';
|
||||
}
|
||||
}
|
||||
overlay.style.opacity = '0';
|
||||
overlay.classList.remove('cache');
|
||||
overlay.style.transition = 'opacity 0.15s';
|
||||
overlay.style.opacity = '1';
|
||||
return true;
|
||||
}
|
||||
|
||||
function cacherSurprise() {
|
||||
const overlay = document.getElementById('surprise-overlay');
|
||||
if (!overlay) return;
|
||||
overlay.style.opacity = '0';
|
||||
setTimeout(() => {
|
||||
overlay.classList.add('cache');
|
||||
overlay.style.transition = '';
|
||||
overlay.style.opacity = '';
|
||||
}, 200);
|
||||
}
|
||||
|
||||
// --- Preview live ---
|
||||
|
||||
function afficherErreurCapture(titre, detail = '') {
|
||||
@@ -29,8 +78,8 @@ function afficherErreurPreview(visible) {
|
||||
const el = document.getElementById('preview-erreur-camera');
|
||||
if (!el) return;
|
||||
if (visible) {
|
||||
el.querySelector('p').textContent = 'Appareil photo deconnecte';
|
||||
el.querySelector('span').textContent = 'Reconnexion en cours...';
|
||||
el.querySelector('p').textContent = 'Un instant...';
|
||||
el.querySelector('span').textContent = 'L\'appareil photo se reconnecte';
|
||||
el.classList.remove('cache');
|
||||
} else {
|
||||
el.classList.add('cache');
|
||||
@@ -173,7 +222,7 @@ wsOnMessage('camera_erreur', () => {
|
||||
if (!captureEnCours) {
|
||||
captureAbortee = true;
|
||||
if (ecranActuel === 'capture') {
|
||||
afficherErreurCapture('Appareil photo déconnecté', 'Reconnexion en cours...');
|
||||
afficherErreurCapture('Un instant...', 'L\'appareil photo se prepare');
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -228,17 +277,27 @@ async function lancerCapture() {
|
||||
await chargerCadreImpose();
|
||||
majCompteurAccueil();
|
||||
|
||||
// Verifier l'etat de la camera avant de commencer
|
||||
// Verifier l'etat de la camera — attendre si pas prete ou reveil en cours
|
||||
try {
|
||||
const statut = await apiGet('/api/camera/statut');
|
||||
let statut = await apiGet('/api/camera/statut');
|
||||
if (!statut.connectee || statut.mode === 'erreur') {
|
||||
afficherStatut('Preparation de l\'appareil photo...', 'succes');
|
||||
// Attendre jusqu'a 40s que le Canon soit pret (reveil ou reconnexion)
|
||||
for (let att = 0; att < 20; att++) {
|
||||
await pause(2000);
|
||||
statut = await apiGet('/api/camera/statut');
|
||||
if (statut.connectee && statut.mode !== 'erreur') break;
|
||||
}
|
||||
afficherStatut('', '');
|
||||
}
|
||||
if (!statut.connectee || statut.mode === 'erreur') {
|
||||
captureEnCours = false;
|
||||
afficherErreurCapture('Appareil photo non disponible', 'Verifiez la connexion USB du DSLR');
|
||||
afficherErreurCapture('Appareil photo indisponible', 'Touchez l\'ecran et reessayez');
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
captureEnCours = false;
|
||||
afficherErreurCapture('Impossible de joindre le serveur', 'Verifiez que le photobooth est bien demarre');
|
||||
afficherErreurCapture('Preparation en cours', 'Touchez l\'ecran et reessayez');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -248,42 +307,58 @@ async function lancerCapture() {
|
||||
for (let i = 0; i < nbPhotos; i++) {
|
||||
if (nbPhotos > 1) {
|
||||
compteurEl.textContent = `Photo ${i + 1} / ${nbPhotos}`;
|
||||
} else {
|
||||
compteurEl.textContent = '';
|
||||
}
|
||||
|
||||
lancerPreview(); // Miroir live pendant le compte à rebours
|
||||
await compteARebours();
|
||||
wsEnvoyer({type: 'prepare_capture'});
|
||||
const avecPreMessages = (i === 0);
|
||||
await compteARebours(avecPreMessages);
|
||||
|
||||
// Flash blanc immédiat + lancer capture en parallèle
|
||||
// Surprise : seulement en photo simple (pas strip/multi)
|
||||
// S'affiche PAR-DESSUS le preview live (pas besoin de le stopper)
|
||||
const aSurprise = (modeActuel === 'simple') && montrerSurprise();
|
||||
|
||||
// Lancer la capture DSLR pendant que la surprise est visible
|
||||
const capturePromise = apiPost('/api/capturer').catch(() => null);
|
||||
|
||||
// Laisser la surprise visible le temps que le DSLR declenche
|
||||
if (aSurprise) await pause(1000);
|
||||
|
||||
// Flash blanc couvre tout (surprise + preview dessous)
|
||||
const flash = document.getElementById('flash-blanc');
|
||||
flash.classList.remove('cache');
|
||||
flash.style.animation = 'none';
|
||||
flash.offsetHeight;
|
||||
flash.style.animation = '';
|
||||
|
||||
const promesseCapture = apiPost('/api/capturer').catch(() => null);
|
||||
// Pendant que le flash couvre l'ecran, on nettoie derriere
|
||||
arreterPreview();
|
||||
let resultat = await promesseCapture;
|
||||
if (aSurprise) { cacherSurprise(); prechargerSurprise(); }
|
||||
|
||||
let resultat = await capturePromise;
|
||||
|
||||
if (!resultat && !resultat?.erreur) {
|
||||
flash.classList.add('cache');
|
||||
document.getElementById('capture-en-cours').classList.add('cache');
|
||||
let erreurReseau = false;
|
||||
|
||||
if (!resultat) {
|
||||
erreurReseau = true;
|
||||
}
|
||||
|
||||
if (erreurReseau) {
|
||||
captureEnCours = false;
|
||||
afficherErreurCapture('Erreur reseau', 'Le serveur ne repond pas — redemarrez le photobooth');
|
||||
afficherErreurCapture('Oups !', 'La photo n\'a pas pu etre prise, reessayez');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!resultat || resultat.erreur) {
|
||||
if (resultat?.erreur) {
|
||||
flash.classList.add('cache');
|
||||
document.getElementById('capture-en-cours').classList.add('cache');
|
||||
captureEnCours = false;
|
||||
const msg = resultat?.erreur || 'Erreur inconnue';
|
||||
afficherErreurCapture('Echec de la capture', msg.includes('Echec') ? 'Verifiez le DSLR et reessayez' : msg);
|
||||
const msg = resultat.erreur;
|
||||
afficherErreurCapture('Oups !', 'La photo n\'a pas pu etre prise, reessayez');
|
||||
return;
|
||||
}
|
||||
|
||||
flash.classList.add('cache');
|
||||
document.getElementById('capture-en-cours').classList.add('cache');
|
||||
|
||||
if (resultat.nom) {
|
||||
photosSession.push(resultat.nom);
|
||||
}
|
||||
@@ -313,7 +388,7 @@ function choisirAnimationAleatoire() {
|
||||
return pool[Math.floor(Math.random() * pool.length)];
|
||||
}
|
||||
|
||||
async function compteARebours() {
|
||||
async function compteARebours(avecPreMessages = true) {
|
||||
const conteneur = document.getElementById('compte-a-rebours');
|
||||
const chiffre = document.getElementById('chiffre-car');
|
||||
const duree = config.camera?.compte_a_rebours || 3;
|
||||
@@ -329,6 +404,17 @@ async function compteARebours() {
|
||||
// Animation CSS classique
|
||||
conteneur.classList.remove('cache');
|
||||
|
||||
if (avecPreMessages) {
|
||||
const preMessages = ['Attention !', 'Préparez-vous !'];
|
||||
for (const msg of preMessages) {
|
||||
chiffre.textContent = msg;
|
||||
chiffre.className = 'anim-chiffre anim-texte';
|
||||
void chiffre.offsetWidth;
|
||||
chiffre.classList.add('anim-' + anim.id);
|
||||
await pause(1000);
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = duree; i > 0; i--) {
|
||||
if (anim.id === 'emoji') {
|
||||
chiffre.textContent = EMOJI_CAR[i] || i;
|
||||
@@ -400,7 +486,7 @@ let formatImpression = null; // Format CUPS à utiliser (ex: "10x15-2up")
|
||||
|
||||
async function traiterCapture() {
|
||||
if (photosSession.length === 0) {
|
||||
afficherErreurCapture('Aucune photo capturee', 'Une erreur inattendue s\'est produite');
|
||||
afficherErreurCapture('Oups !', 'La photo n\'a pas pu etre prise, reessayez');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -414,7 +500,7 @@ async function traiterCapture() {
|
||||
if (mode === 'strip') {
|
||||
resultat = await apiPost('/api/strip', { photos: photosSession });
|
||||
if (resultat.erreur) {
|
||||
afficherErreurCapture('Erreur creation de la planche', resultat.erreur);
|
||||
afficherErreurCapture('Oups !', 'La planche n\'a pas pu etre creee, reessayez');
|
||||
return;
|
||||
}
|
||||
if (resultat.impression) photoImpression = resultat.impression;
|
||||
@@ -422,12 +508,12 @@ async function traiterCapture() {
|
||||
} else {
|
||||
resultat = await apiPost('/api/collage', { photos: photosSession });
|
||||
if (resultat.erreur) {
|
||||
afficherErreurCapture('Erreur creation du collage', resultat.erreur);
|
||||
afficherErreurCapture('Oups !', 'Le collage n\'a pas pu etre cree, reessayez');
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!resultat.nom) {
|
||||
afficherErreurCapture('Erreur traitement des photos', 'Le fichier final n\'a pas ete genere');
|
||||
afficherErreurCapture('Oups !', 'Un probleme est survenu, reessayez');
|
||||
return;
|
||||
}
|
||||
photoFinale = resultat.nom;
|
||||
@@ -465,20 +551,17 @@ function afficherPreviewPhoto(chemin) {
|
||||
async function majCompteurAccueil() {
|
||||
const etat = await apiGet('/api/compteur');
|
||||
const el = document.getElementById('compteur-accueil');
|
||||
if (etat.actif) {
|
||||
el.classList.remove('cache');
|
||||
document.getElementById('compteur-restant').textContent = etat.restantes;
|
||||
document.getElementById('compteur-limite').textContent = etat.limite;
|
||||
} else {
|
||||
el.classList.add('cache');
|
||||
}
|
||||
document.getElementById('compteur-limite').textContent =
|
||||
(etat.actif && etat.limite > 0) ? etat.limite : etat.capacite;
|
||||
}
|
||||
|
||||
async function majBoutonImprimerCompteur() {
|
||||
const etat = await apiGet('/api/compteur');
|
||||
const btn = document.getElementById('btn-imprimer');
|
||||
if (!btn) return;
|
||||
if (etat.actif && etat.restantes <= 0) {
|
||||
if (etat.restantes <= 0) {
|
||||
btn.classList.add('cache');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,12 +105,18 @@ async function adminGalerieImprimer() {
|
||||
if (noms.length === 0) return;
|
||||
if (!confirm('Imprimer ' + noms.length + ' photo' + (noms.length > 1 ? 's' : '') + ' ?')) return;
|
||||
|
||||
let ok = 0, fail = 0;
|
||||
let ok = 0, fail = 0, termine = false;
|
||||
for (const nom of noms) {
|
||||
try {
|
||||
const r = await apiPost('/api/imprimer', { photo: nom });
|
||||
if (r && r.succes) ok++; else fail++;
|
||||
if (r && r.succes) ok++;
|
||||
else if (r && r.erreur === 'evenement_termine') { termine = true; break; }
|
||||
else fail++;
|
||||
} catch { fail++; }
|
||||
}
|
||||
if (termine) {
|
||||
alert('Evenement termine — impression desactivee. Les photos ne seront pas imprimees.');
|
||||
} else {
|
||||
alert('Impression : ' + ok + ' OK' + (fail > 0 ? ', ' + fail + ' echec' : ''));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,37 @@
|
||||
/* Module partage - Impression, email, QR code */
|
||||
|
||||
let nbExemplaires = 1;
|
||||
let copiesMax = 5;
|
||||
let copiesMax = 2;
|
||||
let _restantActuel = null;
|
||||
|
||||
function _masquerBoutonsBas(masquer) {
|
||||
const bas = document.querySelector('#ecran-partage .partage-bas');
|
||||
if (bas) bas.style.display = masquer ? 'none' : '';
|
||||
}
|
||||
|
||||
async function _majRestantImpression() {
|
||||
const el = document.getElementById('impression-restant');
|
||||
if (!el) return;
|
||||
try {
|
||||
const etat = await apiGet('/api/compteur');
|
||||
_restantActuel = etat.restantes;
|
||||
const apres = Math.max(0, _restantActuel - nbExemplaires);
|
||||
el.textContent = `${apres} photo(s) restante(s) sur le rouleau`;
|
||||
} catch (e) { el.textContent = ''; }
|
||||
}
|
||||
|
||||
async function ouvrirImpression() {
|
||||
copiesMax = config.impression?.copies_max || 5;
|
||||
copiesMax = config.impression?.copies_max || 2;
|
||||
nbExemplaires = 1;
|
||||
document.getElementById('nb-exemplaires').textContent = nbExemplaires;
|
||||
cadreChoisi = null;
|
||||
_masquerBoutonsBas(true);
|
||||
_majRestantImpression();
|
||||
|
||||
if (modeActuel === 'multi') {
|
||||
document.getElementById('form-impression').classList.remove('cache');
|
||||
return;
|
||||
}
|
||||
|
||||
const hasCadres = await chargerCadresChoixImpression();
|
||||
if (hasCadres) {
|
||||
@@ -20,6 +44,7 @@ async function ouvrirImpression() {
|
||||
function fermerImpression() {
|
||||
document.getElementById('form-impression').classList.add('cache');
|
||||
cadreChoisi = null;
|
||||
_masquerBoutonsBas(false);
|
||||
}
|
||||
|
||||
function confirmerCadreImpression() {
|
||||
@@ -30,6 +55,7 @@ function confirmerCadreImpression() {
|
||||
function annulerCadreImpression() {
|
||||
document.getElementById('popup-cadre-impression').classList.add('cache');
|
||||
cadreChoisi = null;
|
||||
_masquerBoutonsBas(false);
|
||||
}
|
||||
|
||||
async function chargerCadresChoixImpression() {
|
||||
@@ -96,11 +122,18 @@ async function chargerCadresChoixImpression() {
|
||||
function changerExemplaires(delta) {
|
||||
nbExemplaires = Math.max(1, Math.min(copiesMax, nbExemplaires + delta));
|
||||
document.getElementById('nb-exemplaires').textContent = nbExemplaires;
|
||||
if (_restantActuel !== null) {
|
||||
const apres = Math.max(0, _restantActuel - nbExemplaires);
|
||||
document.getElementById('impression-restant').textContent = `${apres} photo(s) restante(s) sur le rouleau`;
|
||||
}
|
||||
}
|
||||
|
||||
async function lancerImpression() {
|
||||
if (!photoFinale) return;
|
||||
fermerImpression();
|
||||
document.getElementById('form-impression').classList.add('cache');
|
||||
cadreChoisi = null;
|
||||
const btnTerminer = document.getElementById('btn-terminer');
|
||||
if (btnTerminer) { btnTerminer.disabled = true; btnTerminer.style.opacity = '0.4'; }
|
||||
// Pour les strips, imprimer la version 2 bandes sur 10x15
|
||||
const fichierImpression = photoImpression || photoFinale;
|
||||
afficherStatut(`Impression de ${nbExemplaires} exemplaire(s)...`, 'succes');
|
||||
@@ -110,22 +143,32 @@ async function lancerImpression() {
|
||||
cadre: cadreChoisi || undefined,
|
||||
format_papier: formatImpression || undefined,
|
||||
});
|
||||
if (resultat.succes) {
|
||||
if (btnTerminer) { btnTerminer.disabled = false; btnTerminer.style.opacity = ''; }
|
||||
_masquerBoutonsBas(false);
|
||||
if (resultat.attente) {
|
||||
afficherStatutEco('⏳', resultat.message || 'Votre photo sortira avec la suivante !', 'attente-eco');
|
||||
} else if (resultat.jumeau && resultat.succes) {
|
||||
afficherStatutEco('🎁', 'Vous recevez 2 tirages identiques — gardez-en un, offrez l\'autre !', 'jumeau-eco');
|
||||
} else if (resultat.succes) {
|
||||
afficherStatut(`${nbExemplaires} exemplaire(s) envoye(s) a l'imprimante !`, 'succes');
|
||||
} else if (resultat.erreur === 'evenement_termine') {
|
||||
afficherStatut('L\'impression n\'est plus disponible pour cet evenement', 'erreur');
|
||||
} else {
|
||||
afficherStatut('Erreur d\'impression', 'erreur');
|
||||
afficherStatut('L\'impression a rencontre un probleme, reessayez', 'erreur');
|
||||
}
|
||||
}
|
||||
|
||||
async function ouvrirEmail() {
|
||||
document.getElementById('form-email').classList.remove('cache');
|
||||
document.getElementById('input-email').value = '';
|
||||
_masquerBoutonsBas(true);
|
||||
await chargerSuggestionsEmail();
|
||||
}
|
||||
|
||||
function fermerEmail() {
|
||||
document.getElementById('form-email').classList.add('cache');
|
||||
document.getElementById('input-email').value = '';
|
||||
_masquerBoutonsBas(false);
|
||||
}
|
||||
|
||||
async function chargerSuggestionsEmail() {
|
||||
@@ -171,11 +214,11 @@ async function envoyerEmail() {
|
||||
afficherStatut('Envoi en cours...', 'succes');
|
||||
const resultat = await apiPost('/api/email', { email, photo: photoFinale });
|
||||
if (resultat.spool) {
|
||||
afficherStatut('Vous recevrez votre photo par email dans la semaine', 'succes');
|
||||
afficherStatut('Votre photo sera envoyee par email des que possible', 'succes');
|
||||
} else if (resultat.succes) {
|
||||
afficherStatut('Email envoyé !', 'succes');
|
||||
} else {
|
||||
afficherStatut('Erreur d\'envoi email', 'erreur');
|
||||
afficherStatut('L\'email n\'a pas pu etre envoye, reessayez', 'erreur');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,8 +54,8 @@ function _afficherPause() {
|
||||
function _masquerPause() {
|
||||
const el = document.getElementById('ecran-pause');
|
||||
if (el) { el.style.display = 'none'; }
|
||||
// Relancer le preview si on était sur l'accueil
|
||||
if (typeof lancerPreview === 'function' && document.getElementById('ecran-accueil')?.classList.contains('actif')) {
|
||||
// Relancer le preview seulement si on est sur un ecran de prise de vue (pas l'accueil)
|
||||
if (typeof lancerPreview === 'function' && !document.getElementById('ecran-accueil')?.classList.contains('actif')) {
|
||||
lancerPreview();
|
||||
}
|
||||
}
|
||||
|
||||
0
frontend/sounds/.gitkeep
Normal file
0
frontend/sounds/.gitkeep
Normal file
270
memoire.md
270
memoire.md
@@ -2,7 +2,7 @@
|
||||
|
||||
## Description
|
||||
Photobooth professionnel pour location evenementielle.
|
||||
RPi4 + ecran tactile + DSLR (gphoto2) + imprimante sublimation.
|
||||
Surface 6 + ecran tactile + DSLR Canon (gphoto2) + imprimante sublimation Mitsubishi.
|
||||
|
||||
## Architecture
|
||||
- **Backend** : Python FastAPI + WebSocket
|
||||
@@ -29,10 +29,272 @@ https://git.copydev.fr/jules/photobooth
|
||||
Phase 1-3 terminees (backend complet + frontend complet).
|
||||
Phase 4 : scripts production (install.sh, start.sh, systemd).
|
||||
|
||||
## Matériel reçu
|
||||
- Imprimante sublimation Mitsubishi (reçue le 2026-05-28)
|
||||
|
||||
## Notes
|
||||
- Projet cree le 2026-03-21
|
||||
- Mode simulation camera si gphoto2 non installe (dev sans DSLR)
|
||||
- Config persistante dans data/config.json
|
||||
|
||||
---
|
||||
|
||||
## Infra & réseau
|
||||
|
||||
### Surface (booth terrain)
|
||||
- IP LAN : 192.168.111.39 (DHCP, sujette à changement)
|
||||
- IP VPN : 10.10.0.2
|
||||
- Accès SSH : `ssh surface` (alias ~/.ssh/config, clé ed25519)
|
||||
- User : `jules`, repo : `~/photobooth`
|
||||
- **Pas de clavier physique** — toute intervention SSH uniquement
|
||||
- Déploiement : pas de systemd (photobooth.service disabled, plante exec 203). Le run = `scripts/kiosk-session.sh` lancé au login LightDM autologin : boucle relance backend + boucle Chromium kiosk. Pour déployer : `git push` depuis dev, puis `kill <pid backend.main>` + `pkill -f 'chromium '` → relance auto avec git pull.
|
||||
- Remote debugging Chromium : port 9222
|
||||
- Kernel linux-surface avec iptsd (tactile), scale-factor=3
|
||||
- `data/config.json` = état runtime (compteur, imprimante) — ne jamais écraser par commit/push depuis dev
|
||||
|
||||
### LXC 111 (booth-manager / galerie)
|
||||
- IP : 192.168.111.211
|
||||
- Accès : `ssh root@192.168.111.10` puis `pct exec 111 -- <cmd>`
|
||||
- Code : `/opt/photobooth/backend/booth_admin.py`
|
||||
- Service : `systemctl restart photobooth`
|
||||
- Héberge : booth.copydev.fr (landing, galerie, admin)
|
||||
|
||||
### WireGuard tunnel
|
||||
- Serveur (LXC 111) : wg0, 10.10.0.1/24, port 51820/UDP, enabled
|
||||
- Client (Surface) : 10.10.0.2/24
|
||||
- Clé publique serveur : `g3s7Gh1Er+LIEI/W91HAVDNIo+gsk/KiajdtoDUQRVo=`
|
||||
- Clé privée client : `uH9lesPtezigCDlB6cSCYy87QFxrtLFWcnwi93/YgXM=`
|
||||
- Clé publique client : `p+yIc+slDkKXnogvvuohbWlF8iapbI4LxJPH1RCaUig=`
|
||||
- Port forward routeur : UDP 51820 → 192.168.111.211
|
||||
|
||||
### Proxmox PVE
|
||||
- IP : 192.168.111.10, accès `ssh root@192.168.111.10`
|
||||
|
||||
### NPM (Nginx Proxy Manager)
|
||||
- IP : 192.168.111.5, port 81
|
||||
- Cert wildcard *.copydev.fr ID #2
|
||||
|
||||
---
|
||||
|
||||
## Règles de conduite Claude
|
||||
|
||||
- **Pas de clavier sur la borne** : ne jamais suggérer Ctrl+R, F5, ou actions clavier. Forcer reload via SSH (port 9222) ou restart lightdm/chromium.
|
||||
- **Pas de confirmation sur la Surface** : PC dédié, aucun risque, exécuter directement les commandes SSH.
|
||||
- **Pas de SSH sauvage** : ne jamais SSH sur des serveurs non demandés sans instruction explicite.
|
||||
|
||||
---
|
||||
|
||||
## Matériel
|
||||
|
||||
### Imprimante sublimation Mitsubishi
|
||||
- Reçue le 2026-05-28
|
||||
- Erreur 03/01/01 sur K60 = papier mal chargé (pas fin de rouleau)
|
||||
|
||||
### Module relais USB HID
|
||||
- Commandé le 2026-06-23, livraison estimée ~2026-07-01
|
||||
- Pour piloter alim secteur Canon (power-cycle PTP freeze) + éclairage booth
|
||||
- Intégration via /dev/hidraw* dans le backend Python
|
||||
|
||||
---
|
||||
|
||||
## UX dépannage novices
|
||||
Utilisateurs finaux = novices (événementiel). Erreurs imprimante : prévoir guides imagés (popup plein écran, étapes numérotées, icônes grandes, pas de codes techniques). Cas : cassette mal insérée, bourrage, fin consommable, câble USB.
|
||||
|
||||
---
|
||||
|
||||
## VPN booth (2026-07-04)
|
||||
|
||||
Tunnel WG a eu une panne le 04/07. Cause probable : wg-quick@wg0 pas enabled au boot, ou Endpoint IP locale.
|
||||
|
||||
### Procédure fix (clavier USB temporaire)
|
||||
|
||||
1. `sudo systemctl status wg-quick@wg0 && sudo wg show && cat /etc/wireguard/wg0.conf`
|
||||
2. Vérifier Endpoint = `<IP_PUBLIQUE>:51820` (pas 192.168.111.x). IP publique : `curl -s ifconfig.me`
|
||||
3. `sudo systemctl enable wg-quick@wg0 && sudo systemctl restart wg-quick@wg0`
|
||||
4. Installer watchdog + reverse SSH — voir PROCEDURE_VPN_FIX.md
|
||||
|
||||
---
|
||||
|
||||
## LXC 111 — booth.copydev.fr (état au 2026-07-04)
|
||||
|
||||
Code sur le serveur : `/opt/photobooth/` (PAS dans le repo git local).
|
||||
Backup local des fichiers modifiés : `lxc111_backup/` dans ce dossier projet.
|
||||
|
||||
### Fichiers modifiés sur LXC 111
|
||||
- `backend/main.py` (1126 lignes) — endpoints galerie + réservation
|
||||
- `backend/booth_admin.py` (808 lignes) — admin panel API + ZIP streaming
|
||||
- `frontend/landing.html` (900 lignes) — page vitrine complète
|
||||
- `frontend/admin.html` (930 lignes) — panel admin avec validation résa
|
||||
- `frontend/gallery.html` (414 lignes) — galerie publique + modal ZIP progress
|
||||
|
||||
### Endpoints ajoutés
|
||||
- `GET /api/disponibilites` → retourne dates réservées (statut "valide" ou "demande")
|
||||
- `POST /api/contact` → crée événement + envoie email admin (pas client). Champs : nom, email, telephone, nom_evenement, type, date, formule, theme, nb_invites, impressions, opt_livraison, message
|
||||
- `POST /api/contact/valider/{event_id}` → passe statut "valide" + envoie email confirmation au client avec URL galerie + code accès
|
||||
|
||||
### Landing page (frontend/landing.html)
|
||||
- Vitrine commerciale booth.copydev.fr, couleur indigo #5c6bc0
|
||||
- 6 cartes prestations (Canon 18Mpx, Mitsubishi sublimation, galerie live, personnalisation, écran tactile, partage)
|
||||
- 3 tarifs : Pack 300 (300€), Pack 600 (450€), Livraison & installation (sur devis)
|
||||
- Formulaire réservation → crée événement auto → email admin
|
||||
- Calendrier dispo : WE = sam+dim (un bloc), semaine = lun→ven (un bloc), même prix. Dates réservées bloquées.
|
||||
- Modal accès galerie (code 4 digits)
|
||||
- Lien admin caché (coin bas-droit, opacity:0 → hover 0.3)
|
||||
|
||||
### Admin panel (frontend/admin.html)
|
||||
- Section "Demandes en attente" (orange) avec boutons Valider/Refuser
|
||||
- Section "Galeries en ligne" séparée
|
||||
- `validerReservation()` → `POST /api/contact/valider/{id}` avec `credentials: 'include'`
|
||||
|
||||
### ZIP galerie
|
||||
- Corrigé crash mémoire (648 Mo in-memory → temp file + streaming 1 Mo chunks)
|
||||
- Barre de progression dans modal (ReadableStream, affiche Mo reçus + %)
|
||||
- Restreint admin only (pas guest)
|
||||
|
||||
### SMTP
|
||||
- Corrigé pour port 587 : STARTTLS (pas SMTP_SSL qui est pour 465)
|
||||
- Config OVH : ssl0.ovh.net port 587
|
||||
|
||||
### Compteur photos
|
||||
- `distribuer_photo()` accepte paramètre `copies` et incrémente par ce nombre (pas toujours +1)
|
||||
|
||||
---
|
||||
|
||||
## Historique développement (juin-juillet 2026)
|
||||
|
||||
### Kiosk & production (3-4 juin)
|
||||
- Kiosk boucle infinie : backend + Chromium relancés automatiquement, plus d'écran login
|
||||
- Impression Mitsubishi K60 + cadres + interface admin distante
|
||||
- Chromium : désactivation Translate (--lang=fr + prefs FR), meta notranslate
|
||||
- Verrou instance unique kiosk (anti-clignotement)
|
||||
- Intégration station d'impression photo (photostation) — popup accueil
|
||||
- USB automount avec udiskie dans kiosk-session
|
||||
- Détection USB 2 niveaux /media/<user>/<label> + filtre fstype
|
||||
- Cadres : choix avec zoom 2.5x + fond photo simulé
|
||||
|
||||
### Caméra & preview (5-10 juin)
|
||||
- Viewfinder permanent + preview live pendant compte à rebours
|
||||
- Fix preview + miroir : thread continu, grace period, lock gphoto2
|
||||
- Fix caméra : kill gvfsd-gphoto2, race condition viewfinder, exif_transpose
|
||||
- Fix strip K60 coupe auto, diagnostic preview
|
||||
- Caméra déconnectée : retour accueil automatique + abort capture
|
||||
- Bullet-proof caméra : reconnexion auto + fix crash capture + AF LiveView
|
||||
- Capture : viewfinder=0 avant prise (AF phase-détection), timeout 20s, spinner UI
|
||||
- surveiller_dslr : reset USB auto après 3 échecs → retiré (contre-productif)
|
||||
- Fix preview live : position:absolute sur img
|
||||
- Remote debugging Chromium port 9222
|
||||
- Kiosk : git pull auto + diagnostic caméra dans admin
|
||||
|
||||
### Imprimante & impression (4-23 juin)
|
||||
- Statut détaillé imprimante + message erreur CUPS traduit
|
||||
- Bandeau erreur imprimante tous écrans + reset USB
|
||||
- Bouton Couper papier (micro-job blanc déclenche le cutter K60)
|
||||
- Cadres : preview coin haut-gauche + compteur bloque impression pas capture
|
||||
- Pellicule : marge de coupe plus large + warmup LiveView après capture
|
||||
- Fix impression pellicule (portrait vs paysage, taille pleine, rotation)
|
||||
- Cadre de visée live correspondant au recadrage final pellicule/collage
|
||||
- Calibration impression : offsets coupe (mm) + rotation 180° configurable
|
||||
- Fix impression paysage : inverser largeur/hauteur
|
||||
|
||||
### DSLR robustesse (21-28 juin)
|
||||
- Flash Canon configurable dans admin
|
||||
- DSLR anti-veille : autopoweroff Canon + udev no-autosuspend
|
||||
- Keepalive Canon : get_config() toutes les 10s quand preview KO
|
||||
- DSLR auto-recovery : USB reset + cadre overlay non-mirroré
|
||||
- USB rebind Canon : unbind/rebind sysfs pour recovery hard PTP freeze
|
||||
- Escalade recovery : uhubctl power cycle + backoff 60s après 10 échecs
|
||||
- Viewfinder off avant capture pour AF phase-detect
|
||||
- Viewfinder warmup en arrière-plan (accélération capture)
|
||||
|
||||
### Email (22 juin)
|
||||
- Email plein écran avec suggestions d'adresses précédentes
|
||||
- Fermer formulaire avant envoi + raccourcis domaines FR
|
||||
- Email spool : file d'attente quand envoi échoue, retry 60s
|
||||
- Spool envoi au démarrage uniquement, message "dans la semaine"
|
||||
- Rapport email à contact@copydev.fr après vidage du spool
|
||||
|
||||
### Événements & galerie (22-23 juin)
|
||||
- Galerie booth : QR avec auto-login, event_id aléatoire, flyer imprimable
|
||||
- Admin : galerie en ligne dans Destinations + booth envoie toutes les photos
|
||||
- Gestion événements + cadres par event + fix cadre paysage + dossier non-imprimées
|
||||
- Thème Viking Celte : bois sculpté, bronze, entrelacs
|
||||
- Cadre imposé visible en overlay sur live + preview + partage
|
||||
- Formats activables par événement + cadre imposé exclut strips
|
||||
- Lien galerie événement dans admin
|
||||
|
||||
### Résilience & réseau (26-27 juin)
|
||||
- Écran pause, reconnexion WS auto, watchdog systemd, WiFi monitor
|
||||
- Admin WiFi : scan réseaux, connexion, mots de passe mémorisés
|
||||
- Kiosk : flag maintenance + anti-doublon backend
|
||||
- Watchdog systemd + fix stabilité kiosk/backend
|
||||
- QR code par photo : popup QR dynamique + page vue photo sur booth
|
||||
- Fix QR code URL (routes publiques /g/)
|
||||
- Fix QR après photo : corriger share.js qui écrasait afficherQR()
|
||||
- Masquer popup QR à chaque changement d'écran
|
||||
- Supprimer le timeout auto-retour du menu admin
|
||||
|
||||
### Admin galerie & copies (30 juin)
|
||||
- Admin galerie + compteur copies + flash capture + erreur imprimante toast
|
||||
- Bump cache versions (style v12, camera v17, gallery v4)
|
||||
|
||||
### Admin backoffice (9 juillet)
|
||||
- Rubriques Général / Événement dans admin
|
||||
- Vidéos situation (tutoriels visuels)
|
||||
- Mode surprise
|
||||
- Rembobinage ruban (instruction Mitsubishi)
|
||||
|
||||
### Suivi consommables (12 juillet)
|
||||
- Compteur papier, ruban et photos avec diagnostic ratio
|
||||
- Compteur poses perdues + ratio corrigé 0.5 (10 poses par feuille, 20 feuilles par rouleau)
|
||||
|
||||
### Module relais HID + éclairage auto (1-2 août)
|
||||
- Module LCUS 4 canaux (5131:2007) piloté via hidapi/ctypes (`backend/relais.py`)
|
||||
- Assignation : R1=Proj gauche (NO), R2=Proj droit (NO), R3=Canon alim (NF), R4=libre
|
||||
- udev rule `/etc/udev/rules.d/99-usbrelay.rules` pour accès sans sudo
|
||||
- 5 endpoints API relais + admin éclairage avec status relais + boutons ON/OFF
|
||||
- Éclairage auto : analyse luminosité visage → allume projecteurs selon 3 seuils configurables
|
||||
- Power cycle Canon : relais NF = OFF=alimenté, ON=coupé ; intégré en niveau 10 de l'escalade recovery DSLR
|
||||
- Bug fix : byte 4 du status LCUS = bruit (0x4F), seuls bytes 1-3 valides
|
||||
|
||||
### Vidéos didactiques multi-étapes (1 août)
|
||||
- Système complet : situations avec N étapes vidéo, chaque étape boucle jusqu'à validation opérateur
|
||||
- 6 situations par défaut (montage, démontage, bourrage, rouleau, wifi, calibration)
|
||||
- Wizard overlay plein écran avec bouton "OK c'est bon" + navigation étapes
|
||||
- Storage `data/videos/{situation}/etape_XX.mp4`, config.json pour toggles/labels
|
||||
- 8 endpoints API vidéos + migration ancien format plat
|
||||
|
||||
### Panneau diagnostic + auto-recovery + overlays erreur (3 août)
|
||||
- Onglet "Diagnostic" dans admin : 4 cartes santé (camera/imprimante/relais/système), actions (reconnecter/réactiver/redémarrer), logs live, USB
|
||||
- Endpoints : `/api/systeme/sante`, `/api/systeme/logs`, `/api/systeme/redemarrer-backend`, `/api/imprimante/reactiver`, `/api/systeme/usb`
|
||||
- Auto-recovery imprimante : `_surveiller_imprimante` toutes les 30s, cupsenable si disabled
|
||||
- Overlay erreur utilisateur avec escalade : auto-fix → patience → opérateur → aide vidéo → redémarrage
|
||||
- Wizard vidéo connecté aux erreurs avec auto-détection résolution (poll sante)
|
||||
- Situation `camera_hs` ajoutée aux vidéos didactiques par défaut
|
||||
|
||||
### Fix impression galerie + robustesse (2 août)
|
||||
- Bug: `imprimante: null` dans config.json → TypeError: subprocess recevait None en argument
|
||||
- Cause: `.get("imprimante", "Mitsubishi")` retourne None si la clé existe avec valeur null
|
||||
- Fix: pattern `or "Mitsubishi"` dans 5 endroits (printer.py + main.py)
|
||||
- statut-detail endpoint: ajout try/except pour ne plus retourner 500
|
||||
- api_imprimer: ajout try/except global pour erreurs inattendues
|
||||
- Config Surface corrigée : `imprimante` passé de null à "Mitsubishi"
|
||||
|
||||
### Canon DSLR restart — problème ouvert (2 août)
|
||||
- Canon ne redémarre pas après coupure alim secteur (bouton power doit être pressé)
|
||||
- Interrupteur doit être laissé sur ON pour que le power cycle fonctionne
|
||||
- Si ça ne suffit pas : bypass physique du bouton power (soudure pont ou optocoupler sur canal 4)
|
||||
- Camera fixée au plancher, trappe batterie inaccessible
|
||||
|
||||
---
|
||||
|
||||
## Commits non pushés (au 2 août 2026)
|
||||
|
||||
Incluent relais HID, vidéos didactiques, consommables, admin backoffice.
|
||||
Push Gitea bloqué (pas de credentials SSH/HTTPS configurés sur Surface).
|
||||
|
||||
---
|
||||
|
||||
## Tâches Trello du projet
|
||||
|
||||
- [📋 À faire] faire essaie avec mon dslr et imprimante ricoh et installer sur ecran tactile terra
|
||||
(card_id: 69c1122fec1b558a76e207b0)
|
||||
|
||||
Utilise `claude-trello` pour mettre à jour les cartes pendant le travail.
|
||||
Labels: green=fait, yellow=en cours, red=bloqué, (aucun)=à faire
|
||||
|
||||
@@ -4,6 +4,18 @@
|
||||
exec 9>/tmp/photobooth-kiosk.lock
|
||||
flock -n 9 || { echo "[kiosk] Déjà en cours, abandon."; exit 0; }
|
||||
|
||||
PHOTOBOOTH_DIR=/home/jules/photobooth
|
||||
|
||||
# Port du backend (lu depuis config.json, fallback 8080)
|
||||
BACKEND_PORT=$(python3 -c "
|
||||
import json, sys
|
||||
try:
|
||||
d = json.load(open('$PHOTOBOOTH_DIR/data/config.json'))
|
||||
print(d.get('serveur', {}).get('port', 8080))
|
||||
except: print(8080)
|
||||
" 2>/dev/null)
|
||||
BACKEND_URL="http://localhost:${BACKEND_PORT}"
|
||||
|
||||
# Tuer tout backend orphelin d'une session precedente
|
||||
pkill -f 'python.*backend.main' 2>/dev/null || true
|
||||
sleep 1
|
||||
@@ -23,8 +35,7 @@ pkill -f gvfs-gphoto2-volume-monitor 2>/dev/null || true
|
||||
_backend_loop() {
|
||||
while true; do
|
||||
while [ -f /tmp/photobooth-maintenance ]; do sleep 2; done
|
||||
cd /home/jules/photobooth
|
||||
git pull --ff-only 2>&1 | logger -t photobooth-git
|
||||
cd "$PHOTOBOOTH_DIR"
|
||||
source .venv/bin/activate
|
||||
authbind --deep python -m backend.main 2>&1 | tee -a /tmp/photobooth-backend.log
|
||||
echo "[kiosk] backend terminé, redémarrage dans 3s..."
|
||||
@@ -37,9 +48,9 @@ BACKEND_LOOP_PID=$!
|
||||
# Nettoyer le backend si le kiosk est tue
|
||||
trap "kill $BACKEND_LOOP_PID 2>/dev/null; pkill -f 'python.*backend.main' 2>/dev/null" EXIT
|
||||
|
||||
# Attendre que le backend soit pret (max 15s)
|
||||
for i in $(seq 1 15); do
|
||||
curl -sf http://localhost/ > /dev/null 2>&1 && break
|
||||
# Attendre que le backend soit pret (max 30s)
|
||||
for i in $(seq 1 30); do
|
||||
curl -sf "${BACKEND_URL}/api/config" > /dev/null 2>&1 && break
|
||||
sleep 1
|
||||
done
|
||||
|
||||
@@ -64,7 +75,7 @@ while true; do
|
||||
--password-store=basic \
|
||||
--lang=fr \
|
||||
--remote-debugging-port=9222 \
|
||||
http://localhost
|
||||
"${BACKEND_URL}"
|
||||
echo "[kiosk] Chromium terminé, redémarrage dans 2s..."
|
||||
sleep 2
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user