Spaces:
Sleeping
Sleeping
FastAPI app
Browse files- Dockerfile +13 -0
- README.md +6 -40
- main.py +478 -0
- requirements.txt +4 -2
- sample_words.csv +2 -2
- static/app.js +591 -0
- static/index.html +536 -0
Dockerfile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
+
|
| 3 |
+
RUN apt-get update && apt-get install -y ffmpeg && rm -rf /var/lib/apt/lists/*
|
| 4 |
+
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
COPY requirements.txt .
|
| 7 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 8 |
+
|
| 9 |
+
COPY . .
|
| 10 |
+
RUN mkdir -p data/audio
|
| 11 |
+
|
| 12 |
+
EXPOSE 7860
|
| 13 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
README.md
CHANGED
|
@@ -3,61 +3,27 @@ title: Mimba NNH Collecte
|
|
| 3 |
emoji: ๐๏ธ
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: blue
|
| 6 |
-
sdk:
|
| 7 |
-
sdk_version: 5.25.0
|
| 8 |
-
python_version: "3.11"
|
| 9 |
-
app_file: app.py
|
| 10 |
pinned: true
|
| 11 |
license: other
|
| 12 |
---
|
| 13 |
|
| 14 |
# ๐ Mimba โ Collecte de traductions NNH
|
| 15 |
|
| 16 |
-
Application de collecte de traductions et enregistrements audio Ngiemboon (NNH).
|
| 17 |
-
Dรฉployรฉe sur HuggingFace Space dans le cadre du projet Mimba.
|
| 18 |
-
|
| 19 |
-
---
|
| 20 |
-
|
| 21 |
## ๐ Licence
|
| 22 |
|
| 23 |
Copyright ยฉ 2026 Mimba (baounabaouna@gmail.com)
|
| 24 |
|
| 25 |
-
|
| 26 |
-
(traductions NNH, enregistrements audio) sont protรฉgรฉs par le droit d'auteur.
|
| 27 |
-
|
| 28 |
-
**Toute utilisation, reproduction, distribution ou modification nรฉcessite
|
| 29 |
-
l'approbation รฉcrite explicite de l'auteur.**
|
| 30 |
|
| 31 |
### โ
Autorisรฉ sans approbation
|
| 32 |
- Consultation personnelle et recherche non publiรฉe
|
| 33 |
- Citation avec attribution dans des travaux acadรฉmiques
|
| 34 |
|
| 35 |
-
### โ Interdit sans approbation รฉcrite
|
| 36 |
-
- Utilisation commerciale
|
| 37 |
-
- Entraรฎnement de modรจles
|
| 38 |
- Redistribution des donnรฉes, du code ou des audios
|
| 39 |
- Intรฉgration dans des produits ou services tiers
|
| 40 |
-
- Modification et republication
|
| 41 |
-
|
| 42 |
-
### ๐ฌ Demande d'autorisation
|
| 43 |
-
Pour toute demande d'utilisation, contactez :
|
| 44 |
-
**baounabaouna@gmail.com**
|
| 45 |
-
|
| 46 |
-
Prรฉcisez dans votre demande :
|
| 47 |
-
- L'usage prรฉvu (recherche, commercial, รฉducatif...)
|
| 48 |
-
- L'organisation ou l'institution concernรฉe
|
| 49 |
-
- La durรฉe et l'รฉtendue de l'utilisation souhaitรฉe
|
| 50 |
-
|
| 51 |
-
---
|
| 52 |
-
|
| 53 |
-
## ๐ ๏ธ ร propos du projet
|
| 54 |
-
|
| 55 |
-
**Mimba** est un projet de traitement du langage naturel pour le **Ngiemboon (NNH)**,
|
| 56 |
-
une langue Bantu du Cameroun parlรฉe dans la rรฉgion de l'Ouest.
|
| 57 |
-
|
| 58 |
-
Cette application permet de :
|
| 59 |
-
- Collecter des traductions NNH ร partir d'une liste de mots/phrases franรงais
|
| 60 |
-
- Enregistrer des voix multiples pour chaque traduction
|
| 61 |
-
- Constituer un dataset de qualitรฉ pour le fine-tuning de modรจles NLP et TTS
|
| 62 |
|
| 63 |
-
**Contact :** baounabaouna@gmail.com
|
|
|
|
| 3 |
emoji: ๐๏ธ
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: blue
|
| 6 |
+
sdk: docker
|
|
|
|
|
|
|
|
|
|
| 7 |
pinned: true
|
| 8 |
license: other
|
| 9 |
---
|
| 10 |
|
| 11 |
# ๐ Mimba โ Collecte de traductions NNH
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
## ๐ Licence
|
| 14 |
|
| 15 |
Copyright ยฉ 2026 Mimba (baounabaouna@gmail.com)
|
| 16 |
|
| 17 |
+
**Toute utilisation nรฉcessite l'approbation รฉcrite explicite de l'auteur.**
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
### โ
Autorisรฉ sans approbation
|
| 20 |
- Consultation personnelle et recherche non publiรฉe
|
| 21 |
- Citation avec attribution dans des travaux acadรฉmiques
|
| 22 |
|
| 23 |
+
### โ Interdit sans approbation รฉcrite
|
| 24 |
+
- Utilisation commerciale
|
| 25 |
+
- Entraรฎnement de modรจles distribuรฉs publiquement
|
| 26 |
- Redistribution des donnรฉes, du code ou des audios
|
| 27 |
- Intรฉgration dans des produits ou services tiers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
๐ฌ **Contact :** baounabaouna@gmail.com
|
main.py
ADDED
|
@@ -0,0 +1,478 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Mimba NNH Collecte โ Backend FastAPI
|
| 3 |
+
"""
|
| 4 |
+
import bcrypt, csv, io, json, os, secrets, shutil, tempfile, zipfile
|
| 5 |
+
import datetime
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
from typing import Optional
|
| 8 |
+
|
| 9 |
+
from fastapi import FastAPI, Request, HTTPException, UploadFile, File, Depends
|
| 10 |
+
from fastapi.responses import JSONResponse, FileResponse, StreamingResponse
|
| 11 |
+
from fastapi.staticfiles import StaticFiles
|
| 12 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 13 |
+
|
| 14 |
+
# โโ Config โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 15 |
+
DATA_DIR = Path("data")
|
| 16 |
+
AUDIO_DIR = DATA_DIR / "audio"
|
| 17 |
+
USERS_FILE = DATA_DIR / "users.json"
|
| 18 |
+
TRANS_FILE = DATA_DIR / "translations.json"
|
| 19 |
+
DATA_DIR.mkdir(exist_ok=True)
|
| 20 |
+
AUDIO_DIR.mkdir(exist_ok=True)
|
| 21 |
+
|
| 22 |
+
HF_TOKEN = os.environ.get("HF_TOKEN", "")
|
| 23 |
+
HF_REPO_ID = os.environ.get("HF_BACKUP_REPO", "")
|
| 24 |
+
ADMIN_PASSWORD = os.environ.get("ADMIN_PASSWORD", "")
|
| 25 |
+
|
| 26 |
+
# Sessions en mรฉmoire {token: {username, role, mode}}
|
| 27 |
+
SESSIONS: dict = {}
|
| 28 |
+
|
| 29 |
+
# โโ Pydub optionnel โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 30 |
+
try:
|
| 31 |
+
from pydub import AudioSegment
|
| 32 |
+
HAS_PYDUB = True
|
| 33 |
+
except ImportError:
|
| 34 |
+
HAS_PYDUB = False
|
| 35 |
+
|
| 36 |
+
app = FastAPI(title="Mimba NNH Collecte")
|
| 37 |
+
app.add_middleware(CORSMiddleware, allow_origins=["*"],
|
| 38 |
+
allow_methods=["*"], allow_headers=["*"])
|
| 39 |
+
|
| 40 |
+
# ================================================================
|
| 41 |
+
# ๐พ DONNรES
|
| 42 |
+
# ================================================================
|
| 43 |
+
|
| 44 |
+
def load_users() -> dict:
|
| 45 |
+
if not USERS_FILE.exists():
|
| 46 |
+
default = {"admin": {
|
| 47 |
+
"password_hash": bcrypt.hashpw(ADMIN_PASSWORD.encode(), bcrypt.gensalt()).decode(),
|
| 48 |
+
"role": "admin", "mode": "edit",
|
| 49 |
+
"created_at": str(datetime.date.today()),
|
| 50 |
+
}}
|
| 51 |
+
save_users(default)
|
| 52 |
+
return default
|
| 53 |
+
return json.loads(USERS_FILE.read_text(encoding="utf-8"))
|
| 54 |
+
|
| 55 |
+
def save_users(u: dict):
|
| 56 |
+
USERS_FILE.write_text(json.dumps(u, ensure_ascii=False, indent=2), encoding="utf-8")
|
| 57 |
+
|
| 58 |
+
def load_trans() -> dict:
|
| 59 |
+
if not TRANS_FILE.exists():
|
| 60 |
+
return {}
|
| 61 |
+
return json.loads(TRANS_FILE.read_text(encoding="utf-8"))
|
| 62 |
+
|
| 63 |
+
def save_trans(t: dict):
|
| 64 |
+
TRANS_FILE.write_text(json.dumps(t, ensure_ascii=False, indent=2), encoding="utf-8")
|
| 65 |
+
|
| 66 |
+
def backup():
|
| 67 |
+
if not HF_TOKEN or not HF_REPO_ID:
|
| 68 |
+
return
|
| 69 |
+
try:
|
| 70 |
+
from huggingface_hub import HfApi, create_repo
|
| 71 |
+
api = HfApi()
|
| 72 |
+
try: create_repo(HF_REPO_ID, repo_type="dataset", token=HF_TOKEN,
|
| 73 |
+
exist_ok=True, private=True)
|
| 74 |
+
except Exception: pass
|
| 75 |
+
for f in [USERS_FILE, TRANS_FILE]:
|
| 76 |
+
if f.exists():
|
| 77 |
+
api.upload_file(path_or_fileobj=str(f), path_in_repo=f.name,
|
| 78 |
+
repo_id=HF_REPO_ID, repo_type="dataset", token=HF_TOKEN)
|
| 79 |
+
except Exception as e:
|
| 80 |
+
print(f"Backup error: {e}")
|
| 81 |
+
|
| 82 |
+
# ================================================================
|
| 83 |
+
# ๐ AUTH
|
| 84 |
+
# ================================================================
|
| 85 |
+
|
| 86 |
+
def get_session(request: Request) -> Optional[dict]:
|
| 87 |
+
token = request.cookies.get("session_token") or request.headers.get("X-Token")
|
| 88 |
+
return SESSIONS.get(token)
|
| 89 |
+
|
| 90 |
+
def require_auth(request: Request) -> dict:
|
| 91 |
+
s = get_session(request)
|
| 92 |
+
if not s:
|
| 93 |
+
raise HTTPException(401, "Non authentifiรฉ")
|
| 94 |
+
if s.get("mode") == "blocked":
|
| 95 |
+
raise HTTPException(403, "Compte bloquรฉ")
|
| 96 |
+
return s
|
| 97 |
+
|
| 98 |
+
def require_admin(request: Request) -> dict:
|
| 99 |
+
s = require_auth(request)
|
| 100 |
+
if s.get("role") != "admin":
|
| 101 |
+
raise HTTPException(403, "Rรฉservรฉ ร l'admin")
|
| 102 |
+
return s
|
| 103 |
+
|
| 104 |
+
# ================================================================
|
| 105 |
+
# ๐ AUDIO
|
| 106 |
+
# ================================================================
|
| 107 |
+
|
| 108 |
+
def to_mp3_mono(src_path: str) -> bytes:
|
| 109 |
+
if HAS_PYDUB:
|
| 110 |
+
try:
|
| 111 |
+
audio = AudioSegment.from_file(src_path)
|
| 112 |
+
audio = audio.set_channels(1).set_frame_rate(22050)
|
| 113 |
+
buf = io.BytesIO()
|
| 114 |
+
audio.export(buf, format="mp3", bitrate="64k")
|
| 115 |
+
return buf.getvalue()
|
| 116 |
+
except Exception as e:
|
| 117 |
+
print(f"Audio conv error: {e}")
|
| 118 |
+
with open(src_path, "rb") as f:
|
| 119 |
+
return f.read()
|
| 120 |
+
|
| 121 |
+
# ================================================================
|
| 122 |
+
# ๐ก ROUTES API
|
| 123 |
+
# ================================================================
|
| 124 |
+
|
| 125 |
+
# โโ Auth โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 126 |
+
|
| 127 |
+
@app.post("/api/login")
|
| 128 |
+
async def login(request: Request):
|
| 129 |
+
body = await request.json()
|
| 130 |
+
username = body.get("username", "").strip()
|
| 131 |
+
password = body.get("password", "")
|
| 132 |
+
users = load_users()
|
| 133 |
+
if username not in users:
|
| 134 |
+
raise HTTPException(401, "Identifiants incorrects")
|
| 135 |
+
u = users[username]
|
| 136 |
+
if u.get("mode") == "blocked":
|
| 137 |
+
raise HTTPException(403, "Compte bloquรฉ")
|
| 138 |
+
if not bcrypt.checkpw(password.encode(), u["password_hash"].encode()):
|
| 139 |
+
raise HTTPException(401, "Identifiants incorrects")
|
| 140 |
+
token = secrets.token_hex(32)
|
| 141 |
+
SESSIONS[token] = {"username": username, "role": u["role"], "mode": u["mode"]}
|
| 142 |
+
resp = JSONResponse({"ok": True, "username": username,
|
| 143 |
+
"role": u["role"], "mode": u["mode"]})
|
| 144 |
+
resp.set_cookie("session_token", token, httponly=True, samesite="lax")
|
| 145 |
+
return resp
|
| 146 |
+
|
| 147 |
+
@app.post("/api/logout")
|
| 148 |
+
async def logout(request: Request):
|
| 149 |
+
token = request.cookies.get("session_token")
|
| 150 |
+
if token and token in SESSIONS:
|
| 151 |
+
del SESSIONS[token]
|
| 152 |
+
resp = JSONResponse({"ok": True})
|
| 153 |
+
resp.delete_cookie("session_token")
|
| 154 |
+
return resp
|
| 155 |
+
|
| 156 |
+
@app.get("/api/me")
|
| 157 |
+
async def me(request: Request):
|
| 158 |
+
s = get_session(request)
|
| 159 |
+
if not s:
|
| 160 |
+
return JSONResponse({"authenticated": False})
|
| 161 |
+
return JSONResponse({"authenticated": True, **s})
|
| 162 |
+
|
| 163 |
+
# โโ Mots โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 164 |
+
|
| 165 |
+
@app.get("/api/words")
|
| 166 |
+
async def get_words(request: Request, filter: str = "all", page: int = 0,
|
| 167 |
+
per_page: int = 20):
|
| 168 |
+
s = require_auth(request)
|
| 169 |
+
username = s["username"]
|
| 170 |
+
trans = load_trans()
|
| 171 |
+
|
| 172 |
+
items = []
|
| 173 |
+
for wid, w in trans.items():
|
| 174 |
+
nnh = w.get("nnh_clean", "")
|
| 175 |
+
asgn = w.get("assigned_to")
|
| 176 |
+
auds = w.get("audio", {})
|
| 177 |
+
if filter == "mine" and asgn != username: continue
|
| 178 |
+
if filter == "free" and asgn is not None: continue
|
| 179 |
+
if filter == "done" and not nnh: continue
|
| 180 |
+
if filter == "audio" and auds: continue
|
| 181 |
+
items.append({"id": wid, **w})
|
| 182 |
+
|
| 183 |
+
total = len(items)
|
| 184 |
+
start = page * per_page
|
| 185 |
+
page_items = items[start:start + per_page]
|
| 186 |
+
return JSONResponse({"items": page_items, "total": total,
|
| 187 |
+
"page": page, "per_page": per_page,
|
| 188 |
+
"total_pages": max(1, (total + per_page - 1) // per_page)})
|
| 189 |
+
|
| 190 |
+
@app.post("/api/words/{wid}/take")
|
| 191 |
+
async def take_word(wid: str, request: Request):
|
| 192 |
+
s = require_auth(request)
|
| 193 |
+
if s["mode"] != "edit":
|
| 194 |
+
raise HTTPException(403, "Mode lecture seule")
|
| 195 |
+
username = s["username"]
|
| 196 |
+
trans = load_trans()
|
| 197 |
+
if wid not in trans:
|
| 198 |
+
raise HTTPException(404, "Mot introuvable")
|
| 199 |
+
w = trans[wid]
|
| 200 |
+
if w.get("assigned_to") and w["assigned_to"] != username:
|
| 201 |
+
raise HTTPException(409, f"Dรฉjร assignรฉ ร {w['assigned_to']}")
|
| 202 |
+
trans[wid]["assigned_to"] = username
|
| 203 |
+
trans[wid]["status"] = "assigned"
|
| 204 |
+
save_trans(trans)
|
| 205 |
+
return JSONResponse({"ok": True, "word": trans[wid]})
|
| 206 |
+
|
| 207 |
+
@app.put("/api/words/{wid}/text")
|
| 208 |
+
async def save_text(wid: str, request: Request):
|
| 209 |
+
s = require_auth(request)
|
| 210 |
+
if s["mode"] != "edit":
|
| 211 |
+
raise HTTPException(403, "Mode lecture seule")
|
| 212 |
+
username = s["username"]
|
| 213 |
+
body = await request.json()
|
| 214 |
+
nnh_text = body.get("nnh_clean", "").strip()
|
| 215 |
+
trans = load_trans()
|
| 216 |
+
if wid not in trans:
|
| 217 |
+
raise HTTPException(404, "Mot introuvable")
|
| 218 |
+
w = trans[wid]
|
| 219 |
+
if w.get("assigned_to") and w["assigned_to"] != username:
|
| 220 |
+
raise HTTPException(403, f"Assignรฉ ร {w['assigned_to']}")
|
| 221 |
+
if not w.get("assigned_to"):
|
| 222 |
+
trans[wid]["assigned_to"] = username
|
| 223 |
+
trans[wid]["nnh_clean"] = nnh_text
|
| 224 |
+
trans[wid]["status"] = "translated" if nnh_text else "assigned"
|
| 225 |
+
trans[wid]["translated_at"] = datetime.datetime.now().isoformat()
|
| 226 |
+
save_trans(trans)
|
| 227 |
+
backup()
|
| 228 |
+
return JSONResponse({"ok": True})
|
| 229 |
+
|
| 230 |
+
@app.post("/api/words/{wid}/audio")
|
| 231 |
+
async def save_audio(wid: str, request: Request,
|
| 232 |
+
file: UploadFile = File(...)):
|
| 233 |
+
s = require_auth(request)
|
| 234 |
+
if s["mode"] != "edit":
|
| 235 |
+
raise HTTPException(403, "Mode lecture seule")
|
| 236 |
+
username = s["username"]
|
| 237 |
+
trans = load_trans()
|
| 238 |
+
if wid not in trans:
|
| 239 |
+
raise HTTPException(404, "Mot introuvable")
|
| 240 |
+
if not trans[wid].get("nnh_clean"):
|
| 241 |
+
raise HTTPException(400, "Texte NNH requis avant l'audio")
|
| 242 |
+
|
| 243 |
+
# Sauvegarder temporairement
|
| 244 |
+
with tempfile.NamedTemporaryFile(delete=False,
|
| 245 |
+
suffix=Path(file.filename or "audio.wav").suffix) as tmp:
|
| 246 |
+
tmp.write(await file.read())
|
| 247 |
+
tmp_path = tmp.name
|
| 248 |
+
|
| 249 |
+
# Convertir en MP3 mono
|
| 250 |
+
mp3_bytes = to_mp3_mono(tmp_path)
|
| 251 |
+
os.unlink(tmp_path)
|
| 252 |
+
|
| 253 |
+
filename = f"word_{wid}_{username}.mp3"
|
| 254 |
+
dest = AUDIO_DIR / filename
|
| 255 |
+
dest.write_bytes(mp3_bytes)
|
| 256 |
+
|
| 257 |
+
if "audio" not in trans[wid]:
|
| 258 |
+
trans[wid]["audio"] = {}
|
| 259 |
+
trans[wid]["audio"][username] = f"audio/{filename}"
|
| 260 |
+
trans[wid]["status"] = "audio_ready"
|
| 261 |
+
save_trans(trans)
|
| 262 |
+
backup()
|
| 263 |
+
return JSONResponse({"ok": True, "file": filename})
|
| 264 |
+
|
| 265 |
+
@app.get("/api/words/{wid}/audio/{username}")
|
| 266 |
+
async def get_audio(wid: str, username: str, request: Request):
|
| 267 |
+
require_auth(request)
|
| 268 |
+
trans = load_trans()
|
| 269 |
+
if wid not in trans:
|
| 270 |
+
raise HTTPException(404)
|
| 271 |
+
apath = trans[wid].get("audio", {}).get(username)
|
| 272 |
+
if not apath:
|
| 273 |
+
raise HTTPException(404, "Audio introuvable")
|
| 274 |
+
fp = DATA_DIR / apath
|
| 275 |
+
if not fp.exists():
|
| 276 |
+
raise HTTPException(404, "Fichier manquant")
|
| 277 |
+
return FileResponse(str(fp), media_type="audio/mpeg")
|
| 278 |
+
|
| 279 |
+
@app.get("/api/stats")
|
| 280 |
+
async def stats(request: Request):
|
| 281 |
+
s = require_auth(request)
|
| 282 |
+
username = s["username"]
|
| 283 |
+
trans = load_trans()
|
| 284 |
+
total = len(trans)
|
| 285 |
+
translated = sum(1 for w in trans.values() if w.get("nnh_clean"))
|
| 286 |
+
with_audio = sum(1 for w in trans.values() if w.get("audio"))
|
| 287 |
+
my_words = sum(1 for w in trans.values() if w.get("assigned_to") == username)
|
| 288 |
+
my_done = sum(1 for w in trans.values()
|
| 289 |
+
if w.get("assigned_to") == username and w.get("nnh_clean"))
|
| 290 |
+
my_audio = sum(1 for w in trans.values() if username in w.get("audio", {}))
|
| 291 |
+
return JSONResponse({"total": total, "translated": translated,
|
| 292 |
+
"with_audio": with_audio, "my_words": my_words,
|
| 293 |
+
"my_done": my_done, "my_audio": my_audio})
|
| 294 |
+
|
| 295 |
+
# โโ Admin โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 296 |
+
|
| 297 |
+
@app.get("/api/admin/users")
|
| 298 |
+
async def admin_users(request: Request):
|
| 299 |
+
require_admin(request)
|
| 300 |
+
users = load_users()
|
| 301 |
+
trans = load_trans()
|
| 302 |
+
result = []
|
| 303 |
+
for uname, u in users.items():
|
| 304 |
+
n_a = sum(1 for w in trans.values() if w.get("assigned_to") == uname)
|
| 305 |
+
n_t = sum(1 for w in trans.values()
|
| 306 |
+
if w.get("assigned_to") == uname and w.get("nnh_clean"))
|
| 307 |
+
n_au= sum(1 for w in trans.values() if uname in w.get("audio", {}))
|
| 308 |
+
result.append({"username": uname, "role": u["role"],
|
| 309 |
+
"mode": u["mode"], "created_at": u.get("created_at",""),
|
| 310 |
+
"assigned": n_a, "translated": n_t, "audio": n_au})
|
| 311 |
+
return JSONResponse(result)
|
| 312 |
+
|
| 313 |
+
@app.post("/api/admin/users")
|
| 314 |
+
async def create_user(request: Request):
|
| 315 |
+
require_admin(request)
|
| 316 |
+
body = await request.json()
|
| 317 |
+
uname = body.get("username","").strip()
|
| 318 |
+
upass = body.get("password","")
|
| 319 |
+
umode = body.get("mode","edit")
|
| 320 |
+
if not uname or not upass:
|
| 321 |
+
raise HTTPException(400, "Nom et mot de passe requis")
|
| 322 |
+
if uname == "admin":
|
| 323 |
+
raise HTTPException(400, "Impossible de modifier admin ici")
|
| 324 |
+
users = load_users()
|
| 325 |
+
users[uname] = {
|
| 326 |
+
"password_hash": bcrypt.hashpw(upass.encode(), bcrypt.gensalt()).decode(),
|
| 327 |
+
"role": "user", "mode": umode,
|
| 328 |
+
"created_at": str(datetime.date.today()),
|
| 329 |
+
}
|
| 330 |
+
save_users(users)
|
| 331 |
+
return JSONResponse({"ok": True})
|
| 332 |
+
|
| 333 |
+
@app.put("/api/admin/users/{uname}")
|
| 334 |
+
async def update_user(uname: str, request: Request):
|
| 335 |
+
require_admin(request)
|
| 336 |
+
if uname == "admin":
|
| 337 |
+
raise HTTPException(400, "Impossible de modifier admin")
|
| 338 |
+
body = await request.json()
|
| 339 |
+
users = load_users()
|
| 340 |
+
if uname not in users:
|
| 341 |
+
raise HTTPException(404, "Utilisateur introuvable")
|
| 342 |
+
if "mode" in body:
|
| 343 |
+
users[uname]["mode"] = body["mode"]
|
| 344 |
+
# Invalider les sessions de cet utilisateur si bloquรฉ
|
| 345 |
+
if body["mode"] == "blocked":
|
| 346 |
+
for tok, sess in list(SESSIONS.items()):
|
| 347 |
+
if sess.get("username") == uname:
|
| 348 |
+
del SESSIONS[tok]
|
| 349 |
+
if "password" in body and body["password"]:
|
| 350 |
+
users[uname]["password_hash"] = bcrypt.hashpw(
|
| 351 |
+
body["password"].encode(), bcrypt.gensalt()).decode()
|
| 352 |
+
save_users(users)
|
| 353 |
+
return JSONResponse({"ok": True})
|
| 354 |
+
|
| 355 |
+
@app.post("/api/admin/import")
|
| 356 |
+
async def import_csv(request: Request, file: UploadFile = File(...)):
|
| 357 |
+
require_admin(request)
|
| 358 |
+
content = (await file.read()).decode("utf-8-sig")
|
| 359 |
+
reader = csv.DictReader(io.StringIO(content))
|
| 360 |
+
trans = load_trans()
|
| 361 |
+
count = 0
|
| 362 |
+
for row in reader:
|
| 363 |
+
wid = str(row.get("id","")).strip().zfill(3)
|
| 364 |
+
if not wid or not row.get("fr_clean"): continue
|
| 365 |
+
if wid not in trans:
|
| 366 |
+
trans[wid] = {
|
| 367 |
+
"fr_clean": row.get("fr_clean","").strip(),
|
| 368 |
+
"fr_original": row.get("fr_original","").strip(),
|
| 369 |
+
"nnh_original": row.get("nnh_original","").strip(),
|
| 370 |
+
"nnh_clean": "", "assigned_to": None,
|
| 371 |
+
"translated_at": None, "status": "pending", "audio": {},
|
| 372 |
+
}
|
| 373 |
+
count += 1
|
| 374 |
+
save_trans(trans)
|
| 375 |
+
backup()
|
| 376 |
+
return JSONResponse({"ok": True, "imported": count})
|
| 377 |
+
|
| 378 |
+
@app.post("/api/admin/words")
|
| 379 |
+
async def add_word(request: Request):
|
| 380 |
+
require_admin(request)
|
| 381 |
+
body = await request.json()
|
| 382 |
+
if not body.get("fr_clean"):
|
| 383 |
+
raise HTTPException(400, "fr_clean requis")
|
| 384 |
+
trans = load_trans()
|
| 385 |
+
ids = [int(k) for k in trans if k.isdigit()]
|
| 386 |
+
new_id= str(max(ids)+1 if ids else 1).zfill(3)
|
| 387 |
+
trans[new_id] = {
|
| 388 |
+
"fr_clean": body["fr_clean"].strip(),
|
| 389 |
+
"fr_original": body.get("fr_original","").strip(),
|
| 390 |
+
"nnh_original": body.get("nnh_original","").strip(),
|
| 391 |
+
"nnh_clean":"", "assigned_to":None,
|
| 392 |
+
"translated_at":None, "status":"pending", "audio":{},
|
| 393 |
+
}
|
| 394 |
+
save_trans(trans)
|
| 395 |
+
return JSONResponse({"ok": True, "id": new_id})
|
| 396 |
+
|
| 397 |
+
@app.get("/api/admin/words")
|
| 398 |
+
async def admin_words(request: Request, page: int = 0, per_page: int = 50):
|
| 399 |
+
require_admin(request)
|
| 400 |
+
trans = load_trans()
|
| 401 |
+
items = [{"id": k, **v} for k, v in trans.items()]
|
| 402 |
+
total = len(items)
|
| 403 |
+
start = page * per_page
|
| 404 |
+
return JSONResponse({
|
| 405 |
+
"items": items[start:start+per_page],
|
| 406 |
+
"total": total, "page": page,
|
| 407 |
+
"total_pages": max(1, (total+per_page-1)//per_page)
|
| 408 |
+
})
|
| 409 |
+
|
| 410 |
+
@app.get("/api/admin/stats")
|
| 411 |
+
async def admin_stats(request: Request):
|
| 412 |
+
require_admin(request)
|
| 413 |
+
trans = load_trans()
|
| 414 |
+
users = load_users()
|
| 415 |
+
total = len(trans)
|
| 416 |
+
translated = sum(1 for w in trans.values() if w.get("nnh_clean"))
|
| 417 |
+
with_audio = sum(1 for w in trans.values() if w.get("audio"))
|
| 418 |
+
per_user = []
|
| 419 |
+
for uname, u in users.items():
|
| 420 |
+
if u.get("role") == "admin": continue
|
| 421 |
+
n_a = sum(1 for w in trans.values() if w.get("assigned_to") == uname)
|
| 422 |
+
n_t = sum(1 for w in trans.values()
|
| 423 |
+
if w.get("assigned_to") == uname and w.get("nnh_clean"))
|
| 424 |
+
n_au = sum(1 for w in trans.values() if uname in w.get("audio",{}))
|
| 425 |
+
per_user.append({"username": uname, "mode": u.get("mode"),
|
| 426 |
+
"assigned": n_a, "translated": n_t, "audio": n_au})
|
| 427 |
+
return JSONResponse({"total": total, "translated": translated,
|
| 428 |
+
"with_audio": with_audio, "per_user": per_user})
|
| 429 |
+
|
| 430 |
+
@app.get("/api/admin/export/csv")
|
| 431 |
+
async def export_csv(request: Request):
|
| 432 |
+
require_admin(request)
|
| 433 |
+
trans = load_trans()
|
| 434 |
+
buf = io.StringIO()
|
| 435 |
+
w = csv.writer(buf)
|
| 436 |
+
w.writerow(["id","fr_clean","fr_original","nnh_original","nnh_clean",
|
| 437 |
+
"assigned_to","translated_at","audio_files"])
|
| 438 |
+
for wid, wd in trans.items():
|
| 439 |
+
w.writerow([wid, wd.get("fr_clean",""), wd.get("fr_original",""),
|
| 440 |
+
wd.get("nnh_original",""), wd.get("nnh_clean",""),
|
| 441 |
+
wd.get("assigned_to",""), wd.get("translated_at",""),
|
| 442 |
+
";".join(wd.get("audio",{}).values())])
|
| 443 |
+
buf.seek(0)
|
| 444 |
+
return StreamingResponse(
|
| 445 |
+
io.BytesIO(buf.getvalue().encode("utf-8-sig")),
|
| 446 |
+
media_type="text/csv",
|
| 447 |
+
headers={"Content-Disposition": "attachment; filename=nnh_dataset.csv"}
|
| 448 |
+
)
|
| 449 |
+
|
| 450 |
+
@app.get("/api/admin/export/zip")
|
| 451 |
+
async def export_zip(request: Request):
|
| 452 |
+
require_admin(request)
|
| 453 |
+
trans = load_trans()
|
| 454 |
+
zip_buf = io.BytesIO()
|
| 455 |
+
with zipfile.ZipFile(zip_buf, "w", zipfile.ZIP_DEFLATED) as zf:
|
| 456 |
+
# CSV
|
| 457 |
+
csv_buf = io.StringIO()
|
| 458 |
+
w = csv.writer(csv_buf)
|
| 459 |
+
w.writerow(["id","fr_clean","nnh_clean","user","audio_file"])
|
| 460 |
+
for wid, wd in trans.items():
|
| 461 |
+
for uname, apath in wd.get("audio",{}).items():
|
| 462 |
+
w.writerow([wid, wd.get("fr_clean",""), wd.get("nnh_clean",""),
|
| 463 |
+
uname, Path(apath).name])
|
| 464 |
+
zf.writestr("translations.csv",
|
| 465 |
+
csv_buf.getvalue().encode("utf-8-sig"))
|
| 466 |
+
# Audio
|
| 467 |
+
if AUDIO_DIR.exists():
|
| 468 |
+
for mp3 in AUDIO_DIR.glob("*.mp3"):
|
| 469 |
+
zf.write(mp3, f"audio/{mp3.name}")
|
| 470 |
+
zip_buf.seek(0)
|
| 471 |
+
return StreamingResponse(
|
| 472 |
+
zip_buf,
|
| 473 |
+
media_type="application/zip",
|
| 474 |
+
headers={"Content-Disposition": "attachment; filename=nnh_export.zip"}
|
| 475 |
+
)
|
| 476 |
+
|
| 477 |
+
# โโ Fichiers statiques โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 478 |
+
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
requirements.txt
CHANGED
|
@@ -1,4 +1,6 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
bcrypt
|
|
|
|
| 3 |
pydub
|
| 4 |
-
huggingface_hub
|
|
|
|
| 1 |
+
fastapi
|
| 2 |
+
uvicorn[standard]
|
| 3 |
bcrypt
|
| 4 |
+
python-multipart
|
| 5 |
pydub
|
| 6 |
+
huggingface_hub
|
sample_words.csv
CHANGED
|
@@ -9,7 +9,7 @@
|
|
| 9 |
008,De rien,De rien,
|
| 10 |
009,S'il vous plaรฎt,S'il vous plaรฎt,
|
| 11 |
010,Pardon,Pardon,
|
| 12 |
-
011,Je m'appelle,Je m'appelle,
|
| 13 |
012,Comment tu t'appelles ?,Comment tu t'appelles ?,
|
| 14 |
013,D'oรน viens-tu ?,D'oรน viens-tu ?,
|
| 15 |
014,Quel รขge as-tu ?,Quel รขge as-tu ?,
|
|
@@ -48,7 +48,7 @@
|
|
| 48 |
047,Je ne comprends pas,Je ne comprends pas,
|
| 49 |
048,Tu peux rรฉpรฉter ?,Tu peux rรฉpรฉter ?,
|
| 50 |
049,Qu'est-ce que c'est ?,Qu'est-ce que c'est ?,
|
| 51 |
-
050,Comment dit-on
|
| 52 |
051,Mon pรจre,Mon pรจre,
|
| 53 |
052,Ma mรจre,Ma mรจre,
|
| 54 |
053,Mon frรจre,Mon frรจre,
|
|
|
|
| 9 |
008,De rien,De rien,
|
| 10 |
009,S'il vous plaรฎt,S'il vous plaรฎt,
|
| 11 |
010,Pardon,Pardon,
|
| 12 |
+
011,Je m'appelle...,Je m'appelle...,
|
| 13 |
012,Comment tu t'appelles ?,Comment tu t'appelles ?,
|
| 14 |
013,D'oรน viens-tu ?,D'oรน viens-tu ?,
|
| 15 |
014,Quel รขge as-tu ?,Quel รขge as-tu ?,
|
|
|
|
| 48 |
047,Je ne comprends pas,Je ne comprends pas,
|
| 49 |
048,Tu peux rรฉpรฉter ?,Tu peux rรฉpรฉter ?,
|
| 50 |
049,Qu'est-ce que c'est ?,Qu'est-ce que c'est ?,
|
| 51 |
+
050,Comment dit-on en Ngiemboon ?,Comment dit-on en Ngiemboon ?,
|
| 52 |
051,Mon pรจre,Mon pรจre,
|
| 53 |
052,Ma mรจre,Ma mรจre,
|
| 54 |
053,Mon frรจre,Mon frรจre,
|
static/app.js
ADDED
|
@@ -0,0 +1,591 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* ================================================================
|
| 2 |
+
Mimba NNH Collecte โ Frontend
|
| 3 |
+
================================================================ */
|
| 4 |
+
|
| 5 |
+
// โโ รtat global โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 6 |
+
const State = {
|
| 7 |
+
user: null, // {username, role, mode}
|
| 8 |
+
filter: "all",
|
| 9 |
+
page: 0,
|
| 10 |
+
totalPages: 1,
|
| 11 |
+
selectedWid: null,
|
| 12 |
+
adminPage: 0,
|
| 13 |
+
mediaRec: null,
|
| 14 |
+
audioBlobs: [],
|
| 15 |
+
recordedBlob:null,
|
| 16 |
+
};
|
| 17 |
+
|
| 18 |
+
// โโ Utilitaires โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 19 |
+
const $ = id => document.getElementById(id);
|
| 20 |
+
|
| 21 |
+
function showPage(name) {
|
| 22 |
+
document.querySelectorAll('.page').forEach(p => p.classList.remove('active'));
|
| 23 |
+
$(`page-${name}`).classList.add('active');
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
function notify(elId, msg, type = 'ok') {
|
| 27 |
+
const el = $(elId);
|
| 28 |
+
if (!el) return;
|
| 29 |
+
el.className = `notif notif-${type} show`;
|
| 30 |
+
el.textContent = msg;
|
| 31 |
+
if (type === 'ok') setTimeout(() => el.classList.remove('show'), 3000);
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
function progressBar(current, total) {
|
| 35 |
+
if (!total) return '<span style="color:var(--text-dim)">โ</span>';
|
| 36 |
+
const pct = Math.round(current / total * 100);
|
| 37 |
+
return `
|
| 38 |
+
<div style="display:flex;align-items:center;gap:8px;">
|
| 39 |
+
<div class="progress-wrap" style="flex:1;">
|
| 40 |
+
<div class="progress-fill" style="width:${pct}%"></div>
|
| 41 |
+
</div>
|
| 42 |
+
<span style="font-size:12px;color:var(--text-dim);white-space:nowrap;">
|
| 43 |
+
${current}/${total} (${pct}%)
|
| 44 |
+
</span>
|
| 45 |
+
</div>`;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
async function api(method, path, body = null, isForm = false) {
|
| 49 |
+
const opts = { method, credentials: 'include', headers: {} };
|
| 50 |
+
if (body) {
|
| 51 |
+
if (isForm) {
|
| 52 |
+
opts.body = body;
|
| 53 |
+
} else {
|
| 54 |
+
opts.headers['Content-Type'] = 'application/json';
|
| 55 |
+
opts.body = JSON.stringify(body);
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
const r = await fetch(path, opts);
|
| 59 |
+
if (r.status === 401) { doLogout(); return null; }
|
| 60 |
+
return r;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
// ================================================================
|
| 64 |
+
// ๐ AUTH
|
| 65 |
+
// ================================================================
|
| 66 |
+
|
| 67 |
+
async function init() {
|
| 68 |
+
const r = await fetch('/api/me', { credentials: 'include' });
|
| 69 |
+
const data = await r.json();
|
| 70 |
+
if (data.authenticated) {
|
| 71 |
+
State.user = data;
|
| 72 |
+
enterApp();
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
async function doLogin() {
|
| 77 |
+
const username = $('login-user').value.trim();
|
| 78 |
+
const password = $('login-pass').value;
|
| 79 |
+
if (!username || !password) { notify('login-msg', 'โ Remplissez tous les champs', 'err'); return; }
|
| 80 |
+
|
| 81 |
+
const r = await fetch('/api/login', {
|
| 82 |
+
method: 'POST', credentials: 'include',
|
| 83 |
+
headers: { 'Content-Type': 'application/json' },
|
| 84 |
+
body: JSON.stringify({ username, password })
|
| 85 |
+
});
|
| 86 |
+
const data = await r.json();
|
| 87 |
+
if (!r.ok) {
|
| 88 |
+
notify('login-msg', `โ ${data.detail || 'Erreur'}`, 'err');
|
| 89 |
+
return;
|
| 90 |
+
}
|
| 91 |
+
State.user = data;
|
| 92 |
+
enterApp();
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
async function doLogout() {
|
| 96 |
+
await fetch('/api/logout', { method: 'POST', credentials: 'include' });
|
| 97 |
+
State.user = null;
|
| 98 |
+
$('topbar-right').style.display = 'none';
|
| 99 |
+
$('login-user').value = '';
|
| 100 |
+
$('login-pass').value = '';
|
| 101 |
+
showPage('login');
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
function enterApp() {
|
| 105 |
+
$('topbar-right').style.display = 'flex';
|
| 106 |
+
$('topbar-user').textContent = `๐ ${State.user.username} | ${State.user.mode}`;
|
| 107 |
+
if (State.user.role === 'admin') {
|
| 108 |
+
showPage('admin');
|
| 109 |
+
loadAdminUsers();
|
| 110 |
+
loadAdminWords();
|
| 111 |
+
loadAdminStats();
|
| 112 |
+
} else {
|
| 113 |
+
showPage('user');
|
| 114 |
+
loadWords();
|
| 115 |
+
loadUserStats();
|
| 116 |
+
}
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
// ================================================================
|
| 120 |
+
// ๐ LISTE DES MOTS
|
| 121 |
+
// ================================================================
|
| 122 |
+
|
| 123 |
+
async function loadWords() {
|
| 124 |
+
const r = await api('GET',
|
| 125 |
+
`/api/words?filter=${State.filter}&page=${State.page}&per_page=20`);
|
| 126 |
+
if (!r) return;
|
| 127 |
+
const data = await r.json();
|
| 128 |
+
State.totalPages = data.total_pages;
|
| 129 |
+
$('page-info').textContent = `Page ${data.page + 1}/${data.total_pages} โ ${data.total} mots`;
|
| 130 |
+
renderWordList(data.items);
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
function renderWordList(items) {
|
| 134 |
+
const container = $('word-list');
|
| 135 |
+
if (!items.length) {
|
| 136 |
+
container.innerHTML = '<p style="color:var(--text-dim);text-align:center;padding:20px;">Aucun mot pour ce filtre.</p>';
|
| 137 |
+
return;
|
| 138 |
+
}
|
| 139 |
+
container.innerHTML = items.map(w => {
|
| 140 |
+
const nnh = w.nnh_clean || '';
|
| 141 |
+
const asgn = w.assigned_to;
|
| 142 |
+
let statusClass, badgeClass, badgeText;
|
| 143 |
+
if (nnh) {
|
| 144 |
+
statusClass = 'translated'; badgeClass = 'badge-done'; badgeText = 'โ
Traduit';
|
| 145 |
+
} else if (asgn) {
|
| 146 |
+
statusClass = 'assigned'; badgeClass = 'badge-assigned'; badgeText = `โ๏ธ ${asgn}`;
|
| 147 |
+
} else {
|
| 148 |
+
statusClass = 'pending'; badgeClass = 'badge-pending'; badgeText = 'โณ Libre';
|
| 149 |
+
}
|
| 150 |
+
const audioCount = Object.keys(w.audio || {}).length;
|
| 151 |
+
const audioInfo = audioCount ? `๐ ${audioCount} voix` : '';
|
| 152 |
+
return `
|
| 153 |
+
<div class="word-card ${statusClass} ${State.selectedWid === w.id ? 'selected' : ''}"
|
| 154 |
+
onclick="selectWord('${w.id}')">
|
| 155 |
+
<div class="card-header">
|
| 156 |
+
<span class="card-id">#${w.id}</span>
|
| 157 |
+
<span class="badge ${badgeClass}">${badgeText}</span>
|
| 158 |
+
</div>
|
| 159 |
+
<div class="card-fr">${escHtml(w.fr_clean)}</div>
|
| 160 |
+
${nnh ? `<div class="card-nnh">${escHtml(nnh)}</div>` : ''}
|
| 161 |
+
${audioInfo ? `<div class="card-meta">${audioInfo}</div>` : ''}
|
| 162 |
+
</div>`;
|
| 163 |
+
}).join('');
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
function escHtml(s) {
|
| 167 |
+
return (s || '').replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
function setFilter(f) {
|
| 171 |
+
State.filter = f;
|
| 172 |
+
State.page = 0;
|
| 173 |
+
// Highlight bouton actif
|
| 174 |
+
['all','mine','free','done','audio'].forEach(id => {
|
| 175 |
+
$(`f-${id}`).classList.toggle('btn-primary', id === f);
|
| 176 |
+
$(`f-${id}`).classList.toggle('btn-secondary', id !== f);
|
| 177 |
+
});
|
| 178 |
+
loadWords();
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
function changePage(delta) {
|
| 182 |
+
const newPage = State.page + delta;
|
| 183 |
+
if (newPage < 0 || newPage >= State.totalPages) return;
|
| 184 |
+
State.page = newPage;
|
| 185 |
+
loadWords();
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
// ================================================================
|
| 189 |
+
// โ๏ธ รDITEUR DE MOT
|
| 190 |
+
// ================================================================
|
| 191 |
+
|
| 192 |
+
async function selectWord(wid) {
|
| 193 |
+
State.selectedWid = wid;
|
| 194 |
+
|
| 195 |
+
// Mettre ร jour la sรฉlection visuelle
|
| 196 |
+
document.querySelectorAll('.word-card').forEach(c => c.classList.remove('selected'));
|
| 197 |
+
const cards = document.querySelectorAll('.word-card');
|
| 198 |
+
cards.forEach(c => { if (c.onclick.toString().includes(wid)) c.classList.add('selected'); });
|
| 199 |
+
|
| 200 |
+
// Charger le mot
|
| 201 |
+
const r = await api('GET', `/api/words?filter=all&page=0&per_page=9999`);
|
| 202 |
+
if (!r) return;
|
| 203 |
+
const data = await r.json();
|
| 204 |
+
const word = data.items.find(w => w.id === wid);
|
| 205 |
+
if (!word) return;
|
| 206 |
+
|
| 207 |
+
// Prendre le mot si libre
|
| 208 |
+
if (!word.assigned_to) {
|
| 209 |
+
await api('POST', `/api/words/${wid}/take`);
|
| 210 |
+
word.assigned_to = State.user.username;
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
// Remplir l'รฉditeur
|
| 214 |
+
$('editor-placeholder').style.display = 'none';
|
| 215 |
+
$('editor').style.display = 'block';
|
| 216 |
+
|
| 217 |
+
$('ed-id').textContent = `#${wid}`;
|
| 218 |
+
$('ed-fr').value = word.fr_clean || '';
|
| 219 |
+
$('ed-fr-orig').value = word.fr_original || '';
|
| 220 |
+
$('ed-nnh-orig').value = word.nnh_original || '';
|
| 221 |
+
$('ed-nnh').value = word.nnh_clean || '';
|
| 222 |
+
|
| 223 |
+
const badge = $('ed-badge');
|
| 224 |
+
if (word.nnh_clean) {
|
| 225 |
+
badge.className = 'badge badge-done'; badge.textContent = 'โ
Traduit';
|
| 226 |
+
} else if (word.assigned_to) {
|
| 227 |
+
badge.className = 'badge badge-assigned'; badge.textContent = 'โ๏ธ En cours';
|
| 228 |
+
} else {
|
| 229 |
+
badge.className = 'badge badge-pending'; badge.textContent = 'โณ Libre';
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
// Audio
|
| 233 |
+
updateAudioSection(word);
|
| 234 |
+
|
| 235 |
+
// Rรฉinitialiser messages
|
| 236 |
+
$('save-text-msg').classList.remove('show');
|
| 237 |
+
$('save-audio-msg').classList.remove('show');
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
function updateAudioSection(word) {
|
| 241 |
+
const hasNNH = !!(word.nnh_clean && word.nnh_clean.trim());
|
| 242 |
+
$('audio-info').style.display = hasNNH ? 'none' : 'block';
|
| 243 |
+
$('audio-section').style.display = hasNNH ? 'block' : 'none';
|
| 244 |
+
|
| 245 |
+
// Voix existantes
|
| 246 |
+
const auds = word.audio || {};
|
| 247 |
+
const existEl = $('existing-audio');
|
| 248 |
+
if (Object.keys(auds).length === 0) {
|
| 249 |
+
existEl.innerHTML = '<p style="color:var(--text-dim);font-size:13px;">Aucun audio enregistrรฉ.</p>';
|
| 250 |
+
} else {
|
| 251 |
+
existEl.innerHTML = Object.entries(auds).map(([uname, apath]) => `
|
| 252 |
+
<div class="audio-entry">
|
| 253 |
+
<div class="audio-entry-user">๐ ${escHtml(uname)}</div>
|
| 254 |
+
<audio controls src="/api/words/${word.id}/audio/${uname}"></audio>
|
| 255 |
+
</div>`).join('');
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
// Reset enregistrement
|
| 259 |
+
State.recordedBlob = null;
|
| 260 |
+
$('audio-preview').style.display = 'none';
|
| 261 |
+
$('btn-save-audio').style.display = 'none';
|
| 262 |
+
$('btn-stop').style.display = 'none';
|
| 263 |
+
$('btn-record').style.display = 'block';
|
| 264 |
+
$('btn-record').textContent = '๐ด Enregistrer';
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
async function saveText() {
|
| 268 |
+
const wid = State.selectedWid;
|
| 269 |
+
const nnh = $('ed-nnh').value.trim();
|
| 270 |
+
if (!wid) return;
|
| 271 |
+
const r = await api('PUT', `/api/words/${wid}/text`, { nnh_clean: nnh });
|
| 272 |
+
if (!r) return;
|
| 273 |
+
if (r.ok) {
|
| 274 |
+
notify('save-text-msg', 'โ
Texte sauvegardรฉ !', 'ok');
|
| 275 |
+
// Dรฉbloquer section audio
|
| 276 |
+
$('audio-info').style.display = nnh ? 'none' : 'block';
|
| 277 |
+
$('audio-section').style.display = nnh ? 'block' : 'none';
|
| 278 |
+
loadWords(); // rafraรฎchir la liste
|
| 279 |
+
loadUserStats();
|
| 280 |
+
} else {
|
| 281 |
+
const e = await r.json();
|
| 282 |
+
notify('save-text-msg', `โ ${e.detail}`, 'err');
|
| 283 |
+
}
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
// ================================================================
|
| 287 |
+
// ๐ค ENREGISTREMENT AUDIO
|
| 288 |
+
// ================================================================
|
| 289 |
+
|
| 290 |
+
function kbInsert(ch) {
|
| 291 |
+
const ta = $('ed-nnh');
|
| 292 |
+
if (!ta) return;
|
| 293 |
+
const s = ta.selectionStart, e = ta.selectionEnd;
|
| 294 |
+
ta.value = ta.value.substring(0, s) + ch + ta.value.substring(e);
|
| 295 |
+
ta.selectionStart = ta.selectionEnd = s + ch.length;
|
| 296 |
+
ta.focus();
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
async function startRecord() {
|
| 300 |
+
try {
|
| 301 |
+
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
| 302 |
+
State.audioBlobs = [];
|
| 303 |
+
State.mediaRec = new MediaRecorder(stream);
|
| 304 |
+
State.mediaRec.ondataavailable = e => State.audioBlobs.push(e.data);
|
| 305 |
+
State.mediaRec.onstop = () => {
|
| 306 |
+
const blob = new Blob(State.audioBlobs, { type: 'audio/webm' });
|
| 307 |
+
State.recordedBlob = blob;
|
| 308 |
+
const url = URL.createObjectURL(blob);
|
| 309 |
+
const prev = $('audio-preview');
|
| 310 |
+
prev.src = url;
|
| 311 |
+
prev.style.display = 'block';
|
| 312 |
+
$('btn-save-audio').style.display = 'block';
|
| 313 |
+
stream.getTracks().forEach(t => t.stop());
|
| 314 |
+
};
|
| 315 |
+
State.mediaRec.start();
|
| 316 |
+
$('btn-record').style.display = 'none';
|
| 317 |
+
$('btn-stop').style.display = 'block';
|
| 318 |
+
} catch (e) {
|
| 319 |
+
notify('save-audio-msg', 'โ Microphone non accessible: ' + e.message, 'err');
|
| 320 |
+
}
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
function stopRecord() {
|
| 324 |
+
if (State.mediaRec && State.mediaRec.state !== 'inactive') {
|
| 325 |
+
State.mediaRec.stop();
|
| 326 |
+
}
|
| 327 |
+
$('btn-stop').style.display = 'none';
|
| 328 |
+
$('btn-record').style.display = 'block';
|
| 329 |
+
$('btn-record').textContent = '๐ด Rรฉ-enregistrer';
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
function previewAudio(input) {
|
| 333 |
+
const file = input.files[0];
|
| 334 |
+
if (!file) return;
|
| 335 |
+
State.recordedBlob = file;
|
| 336 |
+
const prev = $('audio-preview');
|
| 337 |
+
prev.src = URL.createObjectURL(file);
|
| 338 |
+
prev.style.display = 'block';
|
| 339 |
+
$('btn-save-audio').style.display = 'block';
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
async function saveAudio() {
|
| 343 |
+
const wid = State.selectedWid;
|
| 344 |
+
const blob = State.recordedBlob;
|
| 345 |
+
if (!wid || !blob) return;
|
| 346 |
+
|
| 347 |
+
const form = new FormData();
|
| 348 |
+
form.append('file', blob, `audio_${wid}.webm`);
|
| 349 |
+
const r = await api('POST', `/api/words/${wid}/audio`, form, true);
|
| 350 |
+
if (!r) return;
|
| 351 |
+
if (r.ok) {
|
| 352 |
+
notify('save-audio-msg', 'โ
Audio sauvegardรฉ !', 'ok');
|
| 353 |
+
// Rafraรฎchir les voix existantes
|
| 354 |
+
const rWords = await api('GET', `/api/words?filter=all&page=0&per_page=9999`);
|
| 355 |
+
if (rWords) {
|
| 356 |
+
const data = await rWords.json();
|
| 357 |
+
const word = data.items.find(w => w.id === wid);
|
| 358 |
+
if (word) updateAudioSection(word);
|
| 359 |
+
}
|
| 360 |
+
loadWords();
|
| 361 |
+
loadUserStats();
|
| 362 |
+
} else {
|
| 363 |
+
const e = await r.json();
|
| 364 |
+
notify('save-audio-msg', `โ ${e.detail}`, 'err');
|
| 365 |
+
}
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
// ================================================================
|
| 369 |
+
// ๐ STATS UTILISATEUR
|
| 370 |
+
// ================================================================
|
| 371 |
+
|
| 372 |
+
async function loadUserStats() {
|
| 373 |
+
const r = await api('GET', '/api/stats');
|
| 374 |
+
if (!r) return;
|
| 375 |
+
const d = await r.json();
|
| 376 |
+
$('user-stats').innerHTML = `
|
| 377 |
+
<div class="stat-box">
|
| 378 |
+
<div class="stat-num">${d.my_words}</div>
|
| 379 |
+
<div class="stat-lbl">Mes mots</div>
|
| 380 |
+
</div>
|
| 381 |
+
<div class="stat-box">
|
| 382 |
+
<div class="stat-num">${d.my_done}</div>
|
| 383 |
+
<div class="stat-lbl">Traduits</div>
|
| 384 |
+
</div>
|
| 385 |
+
<div class="stat-box">
|
| 386 |
+
<div class="stat-num">${d.my_audio}</div>
|
| 387 |
+
<div class="stat-lbl">Mes audios</div>
|
| 388 |
+
</div>`;
|
| 389 |
+
}
|
| 390 |
+
|
| 391 |
+
// ================================================================
|
| 392 |
+
// ๐ ADMIN โ UTILISATEURS
|
| 393 |
+
// ================================================================
|
| 394 |
+
|
| 395 |
+
async function loadAdminUsers() {
|
| 396 |
+
const r = await api('GET', '/api/admin/users');
|
| 397 |
+
if (!r) return;
|
| 398 |
+
const users = await r.json();
|
| 399 |
+
$('admin-users-table').innerHTML = `
|
| 400 |
+
<table>
|
| 401 |
+
<thead><tr>
|
| 402 |
+
<th>Utilisateur</th><th>Rรดle</th><th>Mode</th>
|
| 403 |
+
<th>Assignรฉs</th><th>Traduits</th><th>Audios</th>
|
| 404 |
+
</tr></thead>
|
| 405 |
+
<tbody>
|
| 406 |
+
${users.map(u => {
|
| 407 |
+
const modeIcon = {edit:'โ
',read:'๐๏ธ',blocked:'๐ซ'}[u.mode] || '?';
|
| 408 |
+
return `<tr>
|
| 409 |
+
<td>${escHtml(u.username)}</td>
|
| 410 |
+
<td style="color:var(--purple-m)">${u.role}</td>
|
| 411 |
+
<td>${modeIcon} ${u.mode}</td>
|
| 412 |
+
<td>${u.assigned}</td>
|
| 413 |
+
<td style="color:var(--green)">${u.translated}</td>
|
| 414 |
+
<td style="color:var(--yellow)">${u.audio}</td>
|
| 415 |
+
</tr>`;
|
| 416 |
+
}).join('')}
|
| 417 |
+
</tbody>
|
| 418 |
+
</table>`;
|
| 419 |
+
}
|
| 420 |
+
|
| 421 |
+
async function createUser() {
|
| 422 |
+
const uname = $('new-uname').value.trim();
|
| 423 |
+
const upass = $('new-upass').value;
|
| 424 |
+
const umode = $('new-umode').value;
|
| 425 |
+
if (!uname) { notify('create-user-msg','โ Nom requis','err'); return; }
|
| 426 |
+
|
| 427 |
+
// Vรฉrifier si l'utilisateur existe dรฉjร
|
| 428 |
+
const rList = await api('GET', '/api/admin/users');
|
| 429 |
+
const users = rList ? await rList.json() : [];
|
| 430 |
+
const exists = users.find(u => u.username === uname);
|
| 431 |
+
|
| 432 |
+
if (exists) {
|
| 433 |
+
// Mise ร jour du mode
|
| 434 |
+
const body = { mode: umode };
|
| 435 |
+
if (upass) body.password = upass;
|
| 436 |
+
const r = await api('PUT', `/api/admin/users/${uname}`, body);
|
| 437 |
+
if (r && r.ok) {
|
| 438 |
+
notify('create-user-msg', `โ
${uname} mis ร jour`, 'ok');
|
| 439 |
+
loadAdminUsers();
|
| 440 |
+
} else {
|
| 441 |
+
const e = r ? await r.json() : {};
|
| 442 |
+
notify('create-user-msg', `โ ${e.detail || 'Erreur'}`, 'err');
|
| 443 |
+
}
|
| 444 |
+
} else {
|
| 445 |
+
if (!upass) { notify('create-user-msg','โ Mot de passe requis pour nouveau compte','err'); return; }
|
| 446 |
+
const r = await api('POST', '/api/admin/users', { username:uname, password:upass, mode:umode });
|
| 447 |
+
if (r && r.ok) {
|
| 448 |
+
notify('create-user-msg', `โ
Utilisateur ${uname} crรฉรฉ`, 'ok');
|
| 449 |
+
$('new-uname').value = ''; $('new-upass').value = '';
|
| 450 |
+
loadAdminUsers();
|
| 451 |
+
} else {
|
| 452 |
+
const e = r ? await r.json() : {};
|
| 453 |
+
notify('create-user-msg', `โ ${e.detail || 'Erreur'}`, 'err');
|
| 454 |
+
}
|
| 455 |
+
}
|
| 456 |
+
}
|
| 457 |
+
|
| 458 |
+
// ================================================================
|
| 459 |
+
// ๐ ADMIN โ MOTS
|
| 460 |
+
// ================================================================
|
| 461 |
+
|
| 462 |
+
async function loadAdminWords() {
|
| 463 |
+
const r = await api('GET', `/api/admin/words?page=${State.adminPage}&per_page=50`);
|
| 464 |
+
if (!r) return;
|
| 465 |
+
const data = await r.json();
|
| 466 |
+
$('admin-page-info').textContent = `Page ${data.page+1}/${data.total_pages} โ ${data.total} mots`;
|
| 467 |
+
$('admin-words-table').innerHTML = `
|
| 468 |
+
<table>
|
| 469 |
+
<thead><tr>
|
| 470 |
+
<th>ID</th><th>FR</th><th>NNH</th><th>Assignรฉ ร </th><th>Audio</th>
|
| 471 |
+
</tr></thead>
|
| 472 |
+
<tbody>
|
| 473 |
+
${data.items.map(w => `<tr>
|
| 474 |
+
<td style="color:var(--text-dim)">${w.id}</td>
|
| 475 |
+
<td>${escHtml(w.fr_clean)}</td>
|
| 476 |
+
<td style="color:var(--purple-m);font-family:'Noto Sans',serif;">
|
| 477 |
+
${escHtml((w.nnh_clean||'โ').substring(0,40))}
|
| 478 |
+
</td>
|
| 479 |
+
<td style="color:var(--yellow)">${w.assigned_to || 'โ'}</td>
|
| 480 |
+
<td style="color:var(--green)">${Object.keys(w.audio||{}).length} ๐</td>
|
| 481 |
+
</tr>`).join('')}
|
| 482 |
+
</tbody>
|
| 483 |
+
</table>`;
|
| 484 |
+
}
|
| 485 |
+
|
| 486 |
+
function changeAdminPage(delta) {
|
| 487 |
+
State.adminPage = Math.max(0, State.adminPage + delta);
|
| 488 |
+
loadAdminWords();
|
| 489 |
+
}
|
| 490 |
+
|
| 491 |
+
async function importCSV() {
|
| 492 |
+
const fileInput = $('csv-file');
|
| 493 |
+
if (!fileInput.files.length) {
|
| 494 |
+
notify('import-msg', 'โ Sรฉlectionnez un fichier CSV', 'err'); return;
|
| 495 |
+
}
|
| 496 |
+
const form = new FormData();
|
| 497 |
+
form.append('file', fileInput.files[0]);
|
| 498 |
+
const r = await api('POST', '/api/admin/import', form, true);
|
| 499 |
+
if (!r) return;
|
| 500 |
+
const data = await r.json();
|
| 501 |
+
if (r.ok) {
|
| 502 |
+
notify('import-msg', `โ
${data.imported} mots importรฉs`, 'ok');
|
| 503 |
+
loadAdminWords();
|
| 504 |
+
loadAdminStats();
|
| 505 |
+
} else {
|
| 506 |
+
notify('import-msg', `โ ${data.detail}`, 'err');
|
| 507 |
+
}
|
| 508 |
+
}
|
| 509 |
+
|
| 510 |
+
async function addWord() {
|
| 511 |
+
const fr_clean = $('add-fr-clean').value.trim();
|
| 512 |
+
const fr_original = $('add-fr-orig').value.trim();
|
| 513 |
+
const nnh_original= $('add-nnh-orig').value.trim();
|
| 514 |
+
if (!fr_clean) { notify('add-word-msg','โ fr_clean requis','err'); return; }
|
| 515 |
+
const r = await api('POST', '/api/admin/words', {fr_clean, fr_original, nnh_original});
|
| 516 |
+
if (r && r.ok) {
|
| 517 |
+
notify('add-word-msg', `โ
Mot "${fr_clean}" ajoutรฉ`, 'ok');
|
| 518 |
+
$('add-fr-clean').value = $('add-fr-orig').value = $('add-nnh-orig').value = '';
|
| 519 |
+
loadAdminWords();
|
| 520 |
+
} else {
|
| 521 |
+
const e = r ? await r.json() : {};
|
| 522 |
+
notify('add-word-msg', `โ ${e.detail || 'Erreur'}`, 'err');
|
| 523 |
+
}
|
| 524 |
+
}
|
| 525 |
+
|
| 526 |
+
// ================================================================
|
| 527 |
+
// ๐ ADMIN โ STATS
|
| 528 |
+
// ================================================================
|
| 529 |
+
|
| 530 |
+
async function loadAdminStats() {
|
| 531 |
+
const r = await api('GET', '/api/admin/stats');
|
| 532 |
+
if (!r) return;
|
| 533 |
+
const d = await r.json();
|
| 534 |
+
|
| 535 |
+
$('admin-stats-global').innerHTML = `
|
| 536 |
+
<div class="stat-box">
|
| 537 |
+
<div class="stat-num">${d.total}</div>
|
| 538 |
+
<div class="stat-lbl">Total mots</div>
|
| 539 |
+
</div>
|
| 540 |
+
<div class="stat-box">
|
| 541 |
+
<div class="stat-num">${d.translated}</div>
|
| 542 |
+
<div class="stat-lbl">Traduits</div>
|
| 543 |
+
</div>
|
| 544 |
+
<div class="stat-box">
|
| 545 |
+
<div class="stat-num">${d.with_audio}</div>
|
| 546 |
+
<div class="stat-lbl">Avec audio</div>
|
| 547 |
+
</div>`;
|
| 548 |
+
|
| 549 |
+
$('admin-stats-users').innerHTML = `
|
| 550 |
+
<table>
|
| 551 |
+
<thead><tr>
|
| 552 |
+
<th>Utilisateur</th><th>Mode</th><th>Assignรฉs</th>
|
| 553 |
+
<th>Traduits</th><th>Audios</th><th>Progression</th>
|
| 554 |
+
</tr></thead>
|
| 555 |
+
<tbody>
|
| 556 |
+
${d.per_user.map(u => {
|
| 557 |
+
const pct = u.assigned ? Math.round(u.translated/u.assigned*100) : 0;
|
| 558 |
+
return `<tr>
|
| 559 |
+
<td>${escHtml(u.username)}</td>
|
| 560 |
+
<td>${{edit:'โ
',read:'๐๏ธ',blocked:'๐ซ'}[u.mode]||'?'} ${u.mode}</td>
|
| 561 |
+
<td>${u.assigned}</td>
|
| 562 |
+
<td style="color:var(--green)">${u.translated}</td>
|
| 563 |
+
<td style="color:var(--yellow)">${u.audio}</td>
|
| 564 |
+
<td style="min-width:160px;">${progressBar(u.translated, u.assigned)}</td>
|
| 565 |
+
</tr>`;
|
| 566 |
+
}).join('')}
|
| 567 |
+
</tbody>
|
| 568 |
+
</table>`;
|
| 569 |
+
}
|
| 570 |
+
|
| 571 |
+
// ================================================================
|
| 572 |
+
// ๐๏ธ ONGLETS ADMIN
|
| 573 |
+
// ================================================================
|
| 574 |
+
|
| 575 |
+
function showAdminTab(name) {
|
| 576 |
+
document.querySelectorAll('.tab').forEach((t,i) => {
|
| 577 |
+
const names = ['users','words','progress','export'];
|
| 578 |
+
t.classList.toggle('active', names[i] === name);
|
| 579 |
+
});
|
| 580 |
+
document.querySelectorAll('.tab-content').forEach(c => c.classList.remove('active'));
|
| 581 |
+
$(`tab-${name}`).classList.add('active');
|
| 582 |
+
if (name === 'progress') loadAdminStats();
|
| 583 |
+
}
|
| 584 |
+
|
| 585 |
+
// โโ Init โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 586 |
+
window.addEventListener('DOMContentLoaded', () => {
|
| 587 |
+
// Activer le filtre "all" par dรฉfaut
|
| 588 |
+
$('f-all').classList.add('btn-primary');
|
| 589 |
+
$('f-all').classList.remove('btn-secondary');
|
| 590 |
+
init();
|
| 591 |
+
});
|
static/index.html
ADDED
|
@@ -0,0 +1,536 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="fr">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Mimba โ Collecte NNH</title>
|
| 7 |
+
<style>
|
| 8 |
+
:root {
|
| 9 |
+
--bg: #0d0a1a;
|
| 10 |
+
--bg2: #1a1030;
|
| 11 |
+
--bg3: #110d22;
|
| 12 |
+
--border: #2d1b69;
|
| 13 |
+
--purple: #6d28d9;
|
| 14 |
+
--purple-l: #c4b5fd;
|
| 15 |
+
--purple-m: #a78bfa;
|
| 16 |
+
--text: #e2d9f3;
|
| 17 |
+
--text-dim: #7c6fa0;
|
| 18 |
+
--green: #10b981;
|
| 19 |
+
--yellow: #f59e0b;
|
| 20 |
+
--red: #ef4444;
|
| 21 |
+
--blue: #6366f1;
|
| 22 |
+
}
|
| 23 |
+
* { box-sizing: border-box; margin: 0; padding: 0; }
|
| 24 |
+
|
| 25 |
+
body {
|
| 26 |
+
font-family: 'Segoe UI', system-ui, sans-serif;
|
| 27 |
+
background: var(--bg);
|
| 28 |
+
color: var(--text);
|
| 29 |
+
height: 100vh;
|
| 30 |
+
display: flex;
|
| 31 |
+
flex-direction: column;
|
| 32 |
+
overflow: hidden;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
/* โโ Topbar fixe โโ */
|
| 36 |
+
#topbar {
|
| 37 |
+
background: var(--bg3);
|
| 38 |
+
border-bottom: 1px solid var(--border);
|
| 39 |
+
padding: 10px 20px;
|
| 40 |
+
display: flex;
|
| 41 |
+
align-items: center;
|
| 42 |
+
justify-content: space-between;
|
| 43 |
+
flex-shrink: 0;
|
| 44 |
+
z-index: 100;
|
| 45 |
+
}
|
| 46 |
+
#topbar h1 { font-size: 1.1rem; color: var(--purple-l); }
|
| 47 |
+
#topbar-right { display: flex; align-items: center; gap: 12px; }
|
| 48 |
+
#topbar-user { font-size: 13px; color: var(--text-dim); }
|
| 49 |
+
|
| 50 |
+
/* โโ Contenu scrollable โโ */
|
| 51 |
+
#content {
|
| 52 |
+
flex: 1;
|
| 53 |
+
overflow-y: auto;
|
| 54 |
+
padding: 20px;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
/* โโ Pages โโ */
|
| 58 |
+
.page { display: none; }
|
| 59 |
+
.page.active { display: block; }
|
| 60 |
+
|
| 61 |
+
/* โโ Connexion โโ */
|
| 62 |
+
#page-login {
|
| 63 |
+
display: flex;
|
| 64 |
+
align-items: center;
|
| 65 |
+
justify-content: center;
|
| 66 |
+
height: 100%;
|
| 67 |
+
}
|
| 68 |
+
.login-box {
|
| 69 |
+
background: var(--bg2);
|
| 70 |
+
border: 1px solid var(--border);
|
| 71 |
+
border-radius: 16px;
|
| 72 |
+
padding: 40px;
|
| 73 |
+
width: 100%;
|
| 74 |
+
max-width: 380px;
|
| 75 |
+
}
|
| 76 |
+
.login-box h2 { color: var(--purple-l); margin-bottom: 24px; text-align: center; }
|
| 77 |
+
|
| 78 |
+
/* โโ Layout 2 colonnes โโ */
|
| 79 |
+
.layout-split {
|
| 80 |
+
display: grid;
|
| 81 |
+
grid-template-columns: 380px 1fr;
|
| 82 |
+
gap: 20px;
|
| 83 |
+
height: calc(100vh - 120px);
|
| 84 |
+
}
|
| 85 |
+
.panel-left {
|
| 86 |
+
background: var(--bg2);
|
| 87 |
+
border: 1px solid var(--border);
|
| 88 |
+
border-radius: 12px;
|
| 89 |
+
display: flex;
|
| 90 |
+
flex-direction: column;
|
| 91 |
+
overflow: hidden;
|
| 92 |
+
}
|
| 93 |
+
.panel-right {
|
| 94 |
+
background: var(--bg2);
|
| 95 |
+
border: 1px solid var(--border);
|
| 96 |
+
border-radius: 12px;
|
| 97 |
+
overflow-y: auto;
|
| 98 |
+
padding: 20px;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
/* โโ Barre filtres โโ */
|
| 102 |
+
.filter-bar {
|
| 103 |
+
padding: 12px;
|
| 104 |
+
border-bottom: 1px solid var(--border);
|
| 105 |
+
display: flex;
|
| 106 |
+
flex-wrap: wrap;
|
| 107 |
+
gap: 6px;
|
| 108 |
+
flex-shrink: 0;
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
/* โโ Liste des mots (scrollable) โโ */
|
| 112 |
+
#word-list {
|
| 113 |
+
flex: 1;
|
| 114 |
+
overflow-y: auto;
|
| 115 |
+
padding: 12px;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
/* โโ Pagination โโ */
|
| 119 |
+
.pagination {
|
| 120 |
+
padding: 10px 12px;
|
| 121 |
+
border-top: 1px solid var(--border);
|
| 122 |
+
display: flex;
|
| 123 |
+
align-items: center;
|
| 124 |
+
justify-content: space-between;
|
| 125 |
+
flex-shrink: 0;
|
| 126 |
+
font-size: 13px;
|
| 127 |
+
color: var(--text-dim);
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
/* โโ Carte mot โโ */
|
| 131 |
+
.word-card {
|
| 132 |
+
background: var(--bg3);
|
| 133 |
+
border: 1px solid var(--border);
|
| 134 |
+
border-left: 4px solid var(--blue);
|
| 135 |
+
border-radius: 10px;
|
| 136 |
+
padding: 12px;
|
| 137 |
+
margin-bottom: 10px;
|
| 138 |
+
cursor: pointer;
|
| 139 |
+
transition: border-color 0.15s, background 0.15s;
|
| 140 |
+
}
|
| 141 |
+
.word-card:hover { background: #1e1540; }
|
| 142 |
+
.word-card.selected { border-color: var(--purple); background: #1e1540; }
|
| 143 |
+
.word-card.translated { border-left-color: var(--green); }
|
| 144 |
+
.word-card.assigned { border-left-color: var(--yellow); }
|
| 145 |
+
.word-card.pending { border-left-color: var(--blue); }
|
| 146 |
+
|
| 147 |
+
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
|
| 148 |
+
.card-id { font-size: 11px; color: var(--text-dim); }
|
| 149 |
+
.card-fr { font-size: 15px; font-weight: 600; color: #f0e6ff; margin: 4px 0; }
|
| 150 |
+
.card-nnh { font-size: 13px; color: var(--purple-m); font-family: 'Noto Sans', serif; }
|
| 151 |
+
.card-meta { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
|
| 152 |
+
|
| 153 |
+
/* โโ Badge โโ */
|
| 154 |
+
.badge {
|
| 155 |
+
font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 500;
|
| 156 |
+
}
|
| 157 |
+
.badge-done { background: #065f46; color: #6ee7b7; }
|
| 158 |
+
.badge-assigned{ background: #78350f; color: #fcd34d; }
|
| 159 |
+
.badge-pending { background: #1e1b4b; color: #a5b4fc; }
|
| 160 |
+
|
| 161 |
+
/* โโ Formulaires โโ */
|
| 162 |
+
.form-group { margin-bottom: 14px; }
|
| 163 |
+
.form-group label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 5px; }
|
| 164 |
+
input[type=text], input[type=password], textarea, select {
|
| 165 |
+
width: 100%;
|
| 166 |
+
background: var(--bg);
|
| 167 |
+
border: 1px solid var(--border);
|
| 168 |
+
border-radius: 8px;
|
| 169 |
+
color: var(--text);
|
| 170 |
+
padding: 9px 12px;
|
| 171 |
+
font-size: 14px;
|
| 172 |
+
outline: none;
|
| 173 |
+
transition: border-color 0.15s;
|
| 174 |
+
}
|
| 175 |
+
input:focus, textarea:focus, select:focus { border-color: var(--purple); }
|
| 176 |
+
textarea { resize: vertical; min-height: 70px; font-family: 'Noto Sans', serif; font-size: 15px; }
|
| 177 |
+
input[type=text][readonly], textarea[readonly] { opacity: 0.6; cursor: default; }
|
| 178 |
+
|
| 179 |
+
/* โโ Boutons โโ */
|
| 180 |
+
.btn {
|
| 181 |
+
padding: 8px 16px; border-radius: 8px; border: none;
|
| 182 |
+
cursor: pointer; font-size: 13px; font-weight: 500;
|
| 183 |
+
transition: opacity 0.15s, background 0.15s;
|
| 184 |
+
}
|
| 185 |
+
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
|
| 186 |
+
.btn-primary { background: var(--purple); color: #fff; }
|
| 187 |
+
.btn-secondary { background: var(--bg3); color: var(--purple-l); border: 1px solid var(--border); }
|
| 188 |
+
.btn-danger { background: #7f1d1d; color: #fca5a5; }
|
| 189 |
+
.btn-small { padding: 5px 10px; font-size: 12px; }
|
| 190 |
+
.btn-primary:not(:disabled):hover { background: #5b21b6; }
|
| 191 |
+
.btn-secondary:not(:disabled):hover { background: #2d1b69; }
|
| 192 |
+
|
| 193 |
+
/* โโ Clavier NNH โโ */
|
| 194 |
+
.keyboard {
|
| 195 |
+
background: var(--bg3);
|
| 196 |
+
border: 1px solid var(--border);
|
| 197 |
+
border-radius: 10px;
|
| 198 |
+
padding: 10px;
|
| 199 |
+
margin: 10px 0;
|
| 200 |
+
}
|
| 201 |
+
.keyboard-row { margin: 5px 0; }
|
| 202 |
+
.keyboard-label { font-size: 11px; color: var(--text-dim); display: block; margin-bottom: 3px; }
|
| 203 |
+
.key {
|
| 204 |
+
display: inline-block; padding: 5px 9px; margin: 2px;
|
| 205 |
+
background: #2d1b69; color: #fff; border: 1px solid #4a3080;
|
| 206 |
+
border-radius: 6px; cursor: pointer; font-size: 15px;
|
| 207 |
+
font-family: 'Noto Sans', serif;
|
| 208 |
+
transition: background 0.1s;
|
| 209 |
+
}
|
| 210 |
+
.key:hover { background: var(--purple); }
|
| 211 |
+
|
| 212 |
+
/* โโ Stats โโ */
|
| 213 |
+
.stats-grid {
|
| 214 |
+
display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 12px 0;
|
| 215 |
+
}
|
| 216 |
+
.stat-box {
|
| 217 |
+
background: var(--bg3); border-radius: 10px; padding: 14px; text-align: center;
|
| 218 |
+
}
|
| 219 |
+
.stat-num { font-size: 26px; font-weight: 700; color: var(--purple-m); }
|
| 220 |
+
.stat-lbl { font-size: 12px; color: var(--text-dim); }
|
| 221 |
+
|
| 222 |
+
/* โโ Progress bar โโ */
|
| 223 |
+
.progress-wrap { background: var(--bg3); border-radius: 8px; overflow: hidden; height: 8px; margin: 6px 0; }
|
| 224 |
+
.progress-fill { height: 100%; background: var(--purple); border-radius: 8px; transition: width 0.4s; }
|
| 225 |
+
|
| 226 |
+
/* โโ Table admin โโ */
|
| 227 |
+
table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
| 228 |
+
th { padding: 10px 12px; background: #2d1b69; color: var(--purple-l); text-align: left; }
|
| 229 |
+
td { padding: 9px 12px; border-bottom: 1px solid var(--border); }
|
| 230 |
+
tr:hover td { background: var(--bg3); }
|
| 231 |
+
|
| 232 |
+
/* โโ Onglets โโ */
|
| 233 |
+
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
|
| 234 |
+
.tab {
|
| 235 |
+
padding: 10px 20px; cursor: pointer; font-size: 14px;
|
| 236 |
+
color: var(--text-dim); border-bottom: 2px solid transparent;
|
| 237 |
+
transition: color 0.15s;
|
| 238 |
+
}
|
| 239 |
+
.tab.active { color: var(--purple-l); border-bottom-color: var(--purple); }
|
| 240 |
+
.tab-content { display: none; }
|
| 241 |
+
.tab-content.active { display: block; }
|
| 242 |
+
|
| 243 |
+
/* โโ Notifications โโ */
|
| 244 |
+
.notif {
|
| 245 |
+
padding: 10px 14px; border-radius: 8px; margin: 8px 0;
|
| 246 |
+
font-size: 13px; display: none;
|
| 247 |
+
}
|
| 248 |
+
.notif.show { display: block; }
|
| 249 |
+
.notif-ok { background: #064e3b; color: #6ee7b7; }
|
| 250 |
+
.notif-err { background: #7f1d1d; color: #fca5a5; }
|
| 251 |
+
.notif-info{ background: #1e1b4b; color: #a5b4fc; }
|
| 252 |
+
|
| 253 |
+
/* โโ Audio player โโ */
|
| 254 |
+
audio { width: 100%; margin: 6px 0; }
|
| 255 |
+
.audio-entry { background: var(--bg3); border-radius: 8px; padding: 8px 12px; margin: 6px 0; }
|
| 256 |
+
.audio-entry-user { font-size: 12px; color: var(--purple-m); margin-bottom: 4px; }
|
| 257 |
+
|
| 258 |
+
/* โโ Section header โโ */
|
| 259 |
+
.section-title {
|
| 260 |
+
font-size: 14px; font-weight: 600; color: var(--purple-l);
|
| 261 |
+
margin: 16px 0 8px; padding-bottom: 6px;
|
| 262 |
+
border-bottom: 1px solid var(--border);
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
/* โโ Responsive โโ */
|
| 266 |
+
@media (max-width: 768px) {
|
| 267 |
+
.layout-split { grid-template-columns: 1fr; height: auto; }
|
| 268 |
+
.panel-left { height: 50vh; }
|
| 269 |
+
}
|
| 270 |
+
</style>
|
| 271 |
+
</head>
|
| 272 |
+
<body>
|
| 273 |
+
|
| 274 |
+
<!-- TOPBAR -->
|
| 275 |
+
<div id="topbar">
|
| 276 |
+
<h1>๐ Mimba โ Collecte NNH</h1>
|
| 277 |
+
<div id="topbar-right" style="display:none;">
|
| 278 |
+
<span id="topbar-user"></span>
|
| 279 |
+
<button class="btn btn-secondary btn-small" onclick="doLogout()">Dรฉconnexion</button>
|
| 280 |
+
</div>
|
| 281 |
+
</div>
|
| 282 |
+
|
| 283 |
+
<!-- CONTENU -->
|
| 284 |
+
<div id="content">
|
| 285 |
+
|
| 286 |
+
<!-- PAGE LOGIN -->
|
| 287 |
+
<div id="page-login" class="page active">
|
| 288 |
+
<div class="login-box">
|
| 289 |
+
<h2>๐ Connexion</h2>
|
| 290 |
+
<div class="form-group">
|
| 291 |
+
<label>Nom d'utilisateur</label>
|
| 292 |
+
<input type="text" id="login-user" placeholder="ex: alice" autocomplete="username">
|
| 293 |
+
</div>
|
| 294 |
+
<div class="form-group">
|
| 295 |
+
<label>Mot de passe</label>
|
| 296 |
+
<input type="password" id="login-pass" autocomplete="current-password"
|
| 297 |
+
onkeydown="if(event.key==='Enter')doLogin()">
|
| 298 |
+
</div>
|
| 299 |
+
<button class="btn btn-primary" style="width:100%" onclick="doLogin()">Se connecter</button>
|
| 300 |
+
<div id="login-msg" class="notif"></div>
|
| 301 |
+
</div>
|
| 302 |
+
</div>
|
| 303 |
+
|
| 304 |
+
<!-- PAGE UTILISATEUR -->
|
| 305 |
+
<div id="page-user" class="page">
|
| 306 |
+
<!-- Stats rapides -->
|
| 307 |
+
<div class="stats-grid" id="user-stats" style="margin-bottom:16px;"></div>
|
| 308 |
+
|
| 309 |
+
<div class="layout-split">
|
| 310 |
+
<!-- Panneau gauche : liste -->
|
| 311 |
+
<div class="panel-left">
|
| 312 |
+
<div class="filter-bar">
|
| 313 |
+
<button class="btn btn-secondary btn-small" onclick="setFilter('all')" id="f-all">Tous</button>
|
| 314 |
+
<button class="btn btn-secondary btn-small" onclick="setFilter('mine')" id="f-mine">Mes mots</button>
|
| 315 |
+
<button class="btn btn-secondary btn-small" onclick="setFilter('free')" id="f-free">Libres</button>
|
| 316 |
+
<button class="btn btn-secondary btn-small" onclick="setFilter('done')" id="f-done">Traduits โ
</button>
|
| 317 |
+
<button class="btn btn-secondary btn-small" onclick="setFilter('audio')" id="f-audio">Audio โ</button>
|
| 318 |
+
</div>
|
| 319 |
+
<div id="word-list">
|
| 320 |
+
<p style="color:var(--text-dim);text-align:center;padding:20px;">Chargement...</p>
|
| 321 |
+
</div>
|
| 322 |
+
<div class="pagination">
|
| 323 |
+
<button class="btn btn-secondary btn-small" onclick="changePage(-1)">โ</button>
|
| 324 |
+
<span id="page-info">โ</span>
|
| 325 |
+
<button class="btn btn-secondary btn-small" onclick="changePage(1)">โถ</button>
|
| 326 |
+
</div>
|
| 327 |
+
</div>
|
| 328 |
+
|
| 329 |
+
<!-- Panneau droit : รฉditeur -->
|
| 330 |
+
<div class="panel-right">
|
| 331 |
+
<div id="editor-placeholder" style="text-align:center;padding:40px;color:var(--text-dim);">
|
| 332 |
+
โ Sรฉlectionnez un mot dans la liste
|
| 333 |
+
</div>
|
| 334 |
+
<div id="editor" style="display:none;">
|
| 335 |
+
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:16px;">
|
| 336 |
+
<span id="ed-id" style="color:var(--text-dim);font-size:13px;"></span>
|
| 337 |
+
<span id="ed-badge" class="badge"></span>
|
| 338 |
+
</div>
|
| 339 |
+
|
| 340 |
+
<div class="form-group">
|
| 341 |
+
<label>๐ซ๐ท Mot / Phrase</label>
|
| 342 |
+
<input type="text" id="ed-fr" readonly>
|
| 343 |
+
</div>
|
| 344 |
+
<div class="form-group">
|
| 345 |
+
<label>Contexte original</label>
|
| 346 |
+
<input type="text" id="ed-fr-orig" readonly style="font-size:12px;">
|
| 347 |
+
</div>
|
| 348 |
+
<div class="form-group">
|
| 349 |
+
<label>Indice NNH (dataset)</label>
|
| 350 |
+
<input type="text" id="ed-nnh-orig" readonly style="font-size:12px;color:var(--purple-m);">
|
| 351 |
+
</div>
|
| 352 |
+
|
| 353 |
+
<!-- Clavier NNH -->
|
| 354 |
+
<div class="keyboard">
|
| 355 |
+
<p style="font-size:11px;color:var(--text-dim);margin-bottom:6px;">โจ๏ธ Clavier NNH โ cliquer pour insรฉrer</p>
|
| 356 |
+
<div class="keyboard-row">
|
| 357 |
+
<span class="keyboard-label">Voyelles</span>
|
| 358 |
+
<span class="key" onclick="kbInsert('ษ')">ษ</span>
|
| 359 |
+
<span class="key" onclick="kbInsert('ษ')">ษ</span>
|
| 360 |
+
<span class="key" onclick="kbInsert('ษ')">ษ</span>
|
| 361 |
+
<span class="key" onclick="kbInsert('ษฉ')">ษฉ</span>
|
| 362 |
+
<span class="key" onclick="kbInsert('ส')">ส</span>
|
| 363 |
+
<span class="key" onclick="kbInsert('ฦ')">ฦ</span>
|
| 364 |
+
<span class="key" onclick="kbInsert('ฦ')">ฦ</span>
|
| 365 |
+
</div>
|
| 366 |
+
<div class="keyboard-row">
|
| 367 |
+
<span class="keyboard-label">Consonnes</span>
|
| 368 |
+
<span class="key" onclick="kbInsert('ล')">ล</span>
|
| 369 |
+
<span class="key" onclick="kbInsert('ษฒ')">ษฒ</span>
|
| 370 |
+
<span class="key" onclick="kbInsert('สผ')">สผ</span>
|
| 371 |
+
<span class="key" onclick="kbInsert('ล')">ล</span>
|
| 372 |
+
</div>
|
| 373 |
+
<div class="keyboard-row">
|
| 374 |
+
<span class="keyboard-label">Tons (combiner avec voyelle)</span>
|
| 375 |
+
<span class="key" onclick="kbInsert('\u0301')" title="ton aigu">โฬ</span>
|
| 376 |
+
<span class="key" onclick="kbInsert('\u0300')" title="ton grave">โฬ</span>
|
| 377 |
+
<span class="key" onclick="kbInsert('\u0302')" title="ton circonflexe">โฬ</span>
|
| 378 |
+
<span class="key" onclick="kbInsert('\u030c')" title="ton caron">โฬ</span>
|
| 379 |
+
</div>
|
| 380 |
+
</div>
|
| 381 |
+
|
| 382 |
+
<div class="form-group">
|
| 383 |
+
<label>๐ Traduction NNH</label>
|
| 384 |
+
<textarea id="ed-nnh" placeholder="รcrire la traduction..."></textarea>
|
| 385 |
+
</div>
|
| 386 |
+
<button class="btn btn-primary" onclick="saveText()" style="width:100%">
|
| 387 |
+
๐พ Sauvegarder le texte NNH
|
| 388 |
+
</button>
|
| 389 |
+
<div id="save-text-msg" class="notif"></div>
|
| 390 |
+
|
| 391 |
+
<div class="section-title" style="margin-top:20px;">๐ค Enregistrement audio</div>
|
| 392 |
+
<div id="audio-info" class="notif notif-info show" style="margin-bottom:10px;">
|
| 393 |
+
โ ๏ธ Sauvegardez d'abord le texte NNH pour enregistrer l'audio.
|
| 394 |
+
</div>
|
| 395 |
+
<div id="audio-section" style="display:none;">
|
| 396 |
+
<input type="file" id="audio-file" accept="audio/*" style="display:none"
|
| 397 |
+
onchange="previewAudio(this)">
|
| 398 |
+
<div style="display:flex;gap:8px;margin-bottom:8px;">
|
| 399 |
+
<button class="btn btn-secondary" onclick="startRecord()" id="btn-record">
|
| 400 |
+
๐ด Enregistrer
|
| 401 |
+
</button>
|
| 402 |
+
<button class="btn btn-secondary" onclick="stopRecord()" id="btn-stop"
|
| 403 |
+
style="display:none;">โน Stop</button>
|
| 404 |
+
<button class="btn btn-secondary" onclick="document.getElementById('audio-file').click()">
|
| 405 |
+
๐ Fichier
|
| 406 |
+
</button>
|
| 407 |
+
</div>
|
| 408 |
+
<audio id="audio-preview" controls style="display:none;width:100%;margin:8px 0;"></audio>
|
| 409 |
+
<button class="btn btn-primary" id="btn-save-audio" onclick="saveAudio()"
|
| 410 |
+
style="width:100%;display:none;">
|
| 411 |
+
๐พ Sauvegarder l'audio
|
| 412 |
+
</button>
|
| 413 |
+
<div id="save-audio-msg" class="notif"></div>
|
| 414 |
+
</div>
|
| 415 |
+
|
| 416 |
+
<div class="section-title">๐ Voix existantes</div>
|
| 417 |
+
<div id="existing-audio"></div>
|
| 418 |
+
</div>
|
| 419 |
+
</div>
|
| 420 |
+
</div>
|
| 421 |
+
</div>
|
| 422 |
+
|
| 423 |
+
<!-- PAGE ADMIN -->
|
| 424 |
+
<div id="page-admin" class="page">
|
| 425 |
+
<div class="tabs">
|
| 426 |
+
<div class="tab active" onclick="showAdminTab('users')">๐ฅ Utilisateurs</div>
|
| 427 |
+
<div class="tab" onclick="showAdminTab('words')">๐ Mots FR</div>
|
| 428 |
+
<div class="tab" onclick="showAdminTab('progress')">๐ Progression</div>
|
| 429 |
+
<div class="tab" onclick="showAdminTab('export')">๐ฆ Export</div>
|
| 430 |
+
</div>
|
| 431 |
+
|
| 432 |
+
<!-- USERS -->
|
| 433 |
+
<div class="tab-content active" id="tab-users">
|
| 434 |
+
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px;">
|
| 435 |
+
<span class="section-title" style="margin:0;">Liste des utilisateurs</span>
|
| 436 |
+
<button class="btn btn-secondary btn-small" onclick="loadAdminUsers()">๐ Actualiser</button>
|
| 437 |
+
</div>
|
| 438 |
+
<div id="admin-users-table"></div>
|
| 439 |
+
|
| 440 |
+
<div class="section-title">โ Crรฉer / Modifier un utilisateur</div>
|
| 441 |
+
<div style="display:grid;grid-template-columns:1fr 1fr 160px;gap:10px;margin-bottom:10px;">
|
| 442 |
+
<div class="form-group" style="margin:0;">
|
| 443 |
+
<label>Nom d'utilisateur</label>
|
| 444 |
+
<input type="text" id="new-uname">
|
| 445 |
+
</div>
|
| 446 |
+
<div class="form-group" style="margin:0;">
|
| 447 |
+
<label>Mot de passe</label>
|
| 448 |
+
<input type="password" id="new-upass" placeholder="Laisser vide pour ne pas changer">
|
| 449 |
+
</div>
|
| 450 |
+
<div class="form-group" style="margin:0;">
|
| 451 |
+
<label>Mode</label>
|
| 452 |
+
<select id="new-umode">
|
| 453 |
+
<option value="edit">โ
edit</option>
|
| 454 |
+
<option value="read">๐๏ธ read</option>
|
| 455 |
+
<option value="blocked">๐ซ blocked</option>
|
| 456 |
+
</select>
|
| 457 |
+
</div>
|
| 458 |
+
</div>
|
| 459 |
+
<button class="btn btn-primary" onclick="createUser()">๐พ Sauvegarder</button>
|
| 460 |
+
<div id="create-user-msg" class="notif"></div>
|
| 461 |
+
</div>
|
| 462 |
+
|
| 463 |
+
<!-- WORDS -->
|
| 464 |
+
<div class="tab-content" id="tab-words">
|
| 465 |
+
<div class="section-title">๐ฅ Importer un CSV</div>
|
| 466 |
+
<p style="font-size:12px;color:var(--text-dim);margin-bottom:8px;">
|
| 467 |
+
Colonnes attendues : <code>id, fr_clean, fr_original, nnh_original</code>
|
| 468 |
+
</p>
|
| 469 |
+
<div style="display:flex;gap:10px;align-items:center;margin-bottom:8px;">
|
| 470 |
+
<input type="file" id="csv-file" accept=".csv">
|
| 471 |
+
<button class="btn btn-primary" onclick="importCSV()">๐ฅ Importer</button>
|
| 472 |
+
</div>
|
| 473 |
+
<div id="import-msg" class="notif"></div>
|
| 474 |
+
|
| 475 |
+
<div class="section-title">โ Ajouter manuellement</div>
|
| 476 |
+
<div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:10px;margin-bottom:10px;">
|
| 477 |
+
<div class="form-group" style="margin:0;">
|
| 478 |
+
<label>fr_clean</label>
|
| 479 |
+
<input type="text" id="add-fr-clean">
|
| 480 |
+
</div>
|
| 481 |
+
<div class="form-group" style="margin:0;">
|
| 482 |
+
<label>fr_original</label>
|
| 483 |
+
<input type="text" id="add-fr-orig">
|
| 484 |
+
</div>
|
| 485 |
+
<div class="form-group" style="margin:0;">
|
| 486 |
+
<label>nnh_original (indice)</label>
|
| 487 |
+
<input type="text" id="add-nnh-orig">
|
| 488 |
+
</div>
|
| 489 |
+
</div>
|
| 490 |
+
<button class="btn btn-secondary" onclick="addWord()">โ Ajouter</button>
|
| 491 |
+
<div id="add-word-msg" class="notif"></div>
|
| 492 |
+
|
| 493 |
+
<div style="display:flex;justify-content:space-between;align-items:center;margin-top:20px;">
|
| 494 |
+
<span class="section-title" style="margin:0;">๐ Mots actuels</span>
|
| 495 |
+
<div style="display:flex;gap:6px;align-items:center;">
|
| 496 |
+
<button class="btn btn-secondary btn-small" onclick="loadAdminWords()">๐</button>
|
| 497 |
+
<button class="btn btn-secondary btn-small" onclick="changeAdminPage(-1)">โ</button>
|
| 498 |
+
<span id="admin-page-info" style="font-size:12px;color:var(--text-dim);">โ</span>
|
| 499 |
+
<button class="btn btn-secondary btn-small" onclick="changeAdminPage(1)">โถ</button>
|
| 500 |
+
</div>
|
| 501 |
+
</div>
|
| 502 |
+
<div id="admin-words-table" style="margin-top:10px;"></div>
|
| 503 |
+
</div>
|
| 504 |
+
|
| 505 |
+
<!-- PROGRESS -->
|
| 506 |
+
<div class="tab-content" id="tab-progress">
|
| 507 |
+
<div style="display:flex;justify-content:space-between;margin-bottom:12px;">
|
| 508 |
+
<span class="section-title" style="margin:0;">Progression globale</span>
|
| 509 |
+
<button class="btn btn-secondary btn-small" onclick="loadAdminStats()">๐ Actualiser</button>
|
| 510 |
+
</div>
|
| 511 |
+
<div id="admin-stats-global" class="stats-grid" style="margin-bottom:20px;"></div>
|
| 512 |
+
<div id="admin-stats-users"></div>
|
| 513 |
+
</div>
|
| 514 |
+
|
| 515 |
+
<!-- EXPORT -->
|
| 516 |
+
<div class="tab-content" id="tab-export">
|
| 517 |
+
<div class="section-title">๐ฅ Exporter les donnรฉes</div>
|
| 518 |
+
<p style="color:var(--text-dim);font-size:13px;margin-bottom:20px;">
|
| 519 |
+
Le CSV contient toutes les traductions. Le ZIP inclut le CSV + tous les fichiers audio MP3.
|
| 520 |
+
</p>
|
| 521 |
+
<div style="display:flex;gap:12px;">
|
| 522 |
+
<a id="dl-csv" href="/api/admin/export/csv">
|
| 523 |
+
<button class="btn btn-primary">๐ Exporter CSV</button>
|
| 524 |
+
</a>
|
| 525 |
+
<a id="dl-zip" href="/api/admin/export/zip">
|
| 526 |
+
<button class="btn btn-secondary">๐ฆ Exporter ZIP (CSV + Audio)</button>
|
| 527 |
+
</a>
|
| 528 |
+
</div>
|
| 529 |
+
</div>
|
| 530 |
+
</div>
|
| 531 |
+
|
| 532 |
+
</div><!-- /content -->
|
| 533 |
+
|
| 534 |
+
<script src="app.js"></script>
|
| 535 |
+
</body>
|
| 536 |
+
</html>
|