Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec37ac06fe | ||
|
|
6f7e3efd6e | ||
|
|
f794937fd8 | ||
|
|
4b80ff404f | ||
|
|
9288e849af | ||
|
|
00a92de1c4 | ||
|
|
43be6b5be6 | ||
|
|
22c640837c |
No files matched your search
@@ -0,0 +1,20 @@
|
|||||||
|
# 📚 WIKI AETHAS38 - Configuration des Fournisseurs IA
|
||||||
|
|
||||||
|
Ce document détaille la procédure pour obtenir les clés API avec les droits complets (Inférence + Accès financier) nécessaires au fonctionnement de l'Orchestrateur AETHAS38.
|
||||||
|
|
||||||
|
## 1. OpenRouter (Prioritaire)
|
||||||
|
OpenRouter agit comme un agrégateur. C'est le fournisseur recommandé car il permet d'accéder à presque tous les modèles (y compris Gemini, Claude, Llama) avec un seul portefeuille prépayé.
|
||||||
|
* **Obtenir la clé API :** Allez sur [OpenRouter Keys](https://openrouter.ai/keys). Créez une clé standard sans limite de crédit pour permettre à AETHAS38 de requêter les modèles.
|
||||||
|
* **Accès Financier (Management Key) :** Pour que AETHAS38 lise votre solde en temps réel, vous devez générer une clé spécifique d'administration (Management Key) sur la même page, ou accorder les droits `read_balance` à votre clé API principale selon les dernières mises à jour de leur interface.
|
||||||
|
|
||||||
|
## 2. Google Gemini Studio
|
||||||
|
* **Obtenir la clé API :** Rendez-vous sur [Google AI Studio](https://aistudio.google.com/app/apikey).
|
||||||
|
* **Levée des quotas :** Par défaut, la clé est gratuite mais soumise à des limites strictes (ex: 15 requêtes/minute) qui bloqueront le travail en parallèle d'AETHAS38. Pour un accès total, liez votre projet AI Studio à un compte de facturation Google Cloud Platform (GCP).
|
||||||
|
|
||||||
|
## 3. DeepSeek & Groq
|
||||||
|
* **DeepSeek :** [DeepSeek Platform](https://platform.deepseek.com/api_keys). Facturation à l'usage (Token). Il faut provisionner le compte par carte bancaire (Top-up).
|
||||||
|
* **Groq :** [Groq Console](https://console.groq.com/keys). Actuellement en phase gratuite avec quotas de requêtes très élevés, idéal pour les travailleurs de base de l'orchestrateur.
|
||||||
|
|
||||||
|
## 4. Cloudflare Workers AI & HuggingFace
|
||||||
|
* **Cloudflare :** [Cloudflare Dash](https://dash.cloudflare.com/profile/api-tokens). Créez un token personnalisé avec la permission `Workers AI : Read/Write`. L'ID de compte (Account ID) est visible dans la barre latérale droite de l'aperçu de la zone.
|
||||||
|
* **HuggingFace :** [HF Settings](https://huggingface.co/settings/tokens). Générez un token *Fine-Grained* et cochez les permissions liées à l'`Inference API` pour permettre l'exécution des modèles serverless.
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
from openai import OpenAI
|
||||||
|
from fastapi import HTTPException
|
||||||
|
from .models import SystemSettings
|
||||||
|
|
||||||
|
def get_ai_response(messages: list, settings: SystemSettings) -> str:
|
||||||
|
"""Route la conversation vers le premier fournisseur IA disponible, priorité à Gemini Direct."""
|
||||||
|
if not settings:
|
||||||
|
raise HTTPException(status_code=500, detail="Configuration système introuvable.")
|
||||||
|
|
||||||
|
formatted_messages = [{"role": msg.role, "content": msg.content} for msg in messages]
|
||||||
|
|
||||||
|
try:
|
||||||
|
# 1. Priorité absolue : Test Gemini direct (Rapide, sans intermédiaire)
|
||||||
|
if settings.gemini_api_key:
|
||||||
|
client = OpenAI(
|
||||||
|
base_url="https://generativelanguage.googleapis.com/v1beta/openai/",
|
||||||
|
api_key=settings.gemini_api_key
|
||||||
|
)
|
||||||
|
# Utilisation de l'identifiant standard API pour la version Flash
|
||||||
|
model = "gemini-1.5-flash"
|
||||||
|
response = client.chat.completions.create(model=model, messages=formatted_messages)
|
||||||
|
|
||||||
|
# 2. Test OpenRouter (Fallback)
|
||||||
|
elif settings.openrouter_api_key:
|
||||||
|
client = OpenAI(base_url="https://openrouter.ai/api/v1", api_key=settings.openrouter_api_key)
|
||||||
|
model = "google/gemini-1.5-pro" # Identifiant mis à jour et valide
|
||||||
|
response = client.chat.completions.create(
|
||||||
|
model=model,
|
||||||
|
messages=formatted_messages,
|
||||||
|
extra_headers={"HTTP-Referer": "https://aethas38.duckdns.org", "X-Title": "AETHAS38"}
|
||||||
|
)
|
||||||
|
|
||||||
|
# 3. Test DeepSeek
|
||||||
|
elif settings.deepseek_api_key:
|
||||||
|
client = OpenAI(base_url="https://api.deepseek.com/v1", api_key=settings.deepseek_api_key)
|
||||||
|
model = "deepseek-chat"
|
||||||
|
response = client.chat.completions.create(model=model, messages=formatted_messages)
|
||||||
|
|
||||||
|
# 4. Test Groq
|
||||||
|
elif settings.groq_api_key:
|
||||||
|
client = OpenAI(base_url="https://api.groq.com/openai/v1", api_key=settings.groq_api_key)
|
||||||
|
model = "llama3-8b-8192"
|
||||||
|
response = client.chat.completions.create(model=model, messages=formatted_messages)
|
||||||
|
|
||||||
|
else:
|
||||||
|
raise HTTPException(status_code=400, detail="Aucune clé API IA n'est configurée.")
|
||||||
|
|
||||||
|
return response.choices[0].message.content
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Erreur API IA : {str(e)}")
|
||||||
|
raise HTTPException(status_code=502, detail=f"Détail du fournisseur : {str(e)}")
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import logging
|
||||||
|
from logging.handlers import TimedRotatingFileHandler
|
||||||
|
import os
|
||||||
|
|
||||||
|
# Création du dossier logs à la racine du projet
|
||||||
|
log_dir = os.path.join(os.getcwd(), "logs")
|
||||||
|
os.makedirs(log_dir, exist_ok=True)
|
||||||
|
|
||||||
|
# Configuration du logger
|
||||||
|
system_logger = logging.getLogger("AETHAS38_Logger")
|
||||||
|
system_logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
|
# Rotation tous les jours à minuit, conservation sur 7 jours
|
||||||
|
handler = TimedRotatingFileHandler(
|
||||||
|
filename=os.path.join(log_dir, "aethas38_system.log"),
|
||||||
|
when="midnight",
|
||||||
|
interval=1,
|
||||||
|
backupCount=7,
|
||||||
|
encoding="utf-8"
|
||||||
|
)
|
||||||
|
|
||||||
|
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s', datefmt='%d/%m/%Y %H:%M:%S')
|
||||||
|
handler.setFormatter(formatter)
|
||||||
|
system_logger.addHandler(handler)
|
||||||
+43
-102
@@ -7,22 +7,22 @@ import os
|
|||||||
|
|
||||||
# Importation de nos modules locaux
|
# Importation de nos modules locaux
|
||||||
from .database import engine, Base, get_db
|
from .database import engine, Base, get_db
|
||||||
from .models import User, Project, Message
|
|
||||||
from .auth import get_password_hash, generate_totp_secret, get_totp_uri, verify_password, verify_totp, create_access_token, verify_token
|
from .auth import get_password_hash, generate_totp_secret, get_totp_uri, verify_password, verify_totp, create_access_token, verify_token
|
||||||
from .schemas import AdminCreate, LoginRequest, ProjectCreate, ProjectResponse, ProjectRename, MessageCreate, MessageResponse
|
from .schemas import AdminCreate, LoginRequest, ProjectCreate, ProjectResponse, ProjectRename, MessageCreate, MessageResponse
|
||||||
|
from .models import User, Project, Message, SystemSettings
|
||||||
|
from .ai import get_ai_response
|
||||||
|
|
||||||
# Création des tables dans la base de données
|
# Création des tables dans la base de données
|
||||||
Base.metadata.create_all(bind=engine)
|
Base.metadata.create_all(bind=engine)
|
||||||
|
|
||||||
app = FastAPI(title="AETHAS38 - Orchestrateur Multi-IA")
|
app = FastAPI(title="AETHAS38 - Orchestrateur Multi-IA")
|
||||||
|
|
||||||
# Configuration des fichiers statiques (images, css locaux, etc.)
|
# Configuration des fichiers statiques
|
||||||
assets_path = os.path.join(os.getcwd(), "frontend", "assets")
|
assets_path = os.path.join(os.getcwd(), "frontend", "assets")
|
||||||
os.makedirs(assets_path, exist_ok=True) # Crée le dossier s'il n'existe pas
|
os.makedirs(assets_path, exist_ok=True)
|
||||||
app.mount("/static", StaticFiles(directory=assets_path), name="static")
|
app.mount("/assets", StaticFiles(directory=assets_path), name="assets")
|
||||||
|
|
||||||
def is_setup_required(db: Session) -> bool:
|
def is_setup_required(db: Session) -> bool:
|
||||||
"""Vérifie si la base de données contient au moins un administrateur."""
|
|
||||||
admin = db.query(User).filter(User.is_admin == True).first()
|
admin = db.query(User).filter(User.is_admin == True).first()
|
||||||
return admin is None
|
return admin is None
|
||||||
|
|
||||||
@@ -34,137 +34,82 @@ def read_root(db: Session = Depends(get_db)):
|
|||||||
|
|
||||||
@app.get("/setup")
|
@app.get("/setup")
|
||||||
def setup_page(db: Session = Depends(get_db)):
|
def setup_page(db: Session = Depends(get_db)):
|
||||||
"""Affiche l'interface d'installation Vue.js."""
|
|
||||||
if not is_setup_required(db):
|
if not is_setup_required(db):
|
||||||
return RedirectResponse(url="/login")
|
return RedirectResponse(url="/login")
|
||||||
|
|
||||||
frontend_path = os.path.join(os.getcwd(), "frontend", "index.html")
|
frontend_path = os.path.join(os.getcwd(), "frontend", "index.html")
|
||||||
if not os.path.exists(frontend_path):
|
if not os.path.exists(frontend_path):
|
||||||
raise HTTPException(status_code=404, detail="Interface introuvable.")
|
raise HTTPException(status_code=404, detail="Interface introuvable.")
|
||||||
|
|
||||||
return FileResponse(frontend_path)
|
return FileResponse(frontend_path)
|
||||||
|
|
||||||
@app.get("/login")
|
@app.get("/login")
|
||||||
def login_page(db: Session = Depends(get_db)):
|
def login_page(db: Session = Depends(get_db)):
|
||||||
"""Affiche la page de connexion sécurisée."""
|
|
||||||
if is_setup_required(db):
|
if is_setup_required(db):
|
||||||
return RedirectResponse(url="/setup")
|
return RedirectResponse(url="/setup")
|
||||||
|
|
||||||
frontend_path = os.path.join(os.getcwd(), "frontend", "login.html")
|
frontend_path = os.path.join(os.getcwd(), "frontend", "login.html")
|
||||||
if not os.path.exists(frontend_path):
|
if not os.path.exists(frontend_path):
|
||||||
raise HTTPException(status_code=404, detail="Interface de connexion introuvable.")
|
raise HTTPException(status_code=404, detail="Interface de connexion introuvable.")
|
||||||
|
|
||||||
return FileResponse(frontend_path)
|
return FileResponse(frontend_path)
|
||||||
|
|
||||||
@app.post("/api/setup")
|
@app.post("/api/setup")
|
||||||
def create_admin(admin_data: AdminCreate, db: Session = Depends(get_db)):
|
def create_admin(admin_data: AdminCreate, db: Session = Depends(get_db)):
|
||||||
"""Reçoit les données du frontend, crée l'admin et retourne le QR Code 2FA."""
|
|
||||||
if not is_setup_required(db):
|
if not is_setup_required(db):
|
||||||
raise HTTPException(
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="L'installation a déjà été effectuée.")
|
||||||
status_code=status.HTTP_403_FORBIDDEN,
|
|
||||||
detail="L'installation a déjà été effectuée."
|
|
||||||
)
|
|
||||||
|
|
||||||
# Sécurisation des accès
|
|
||||||
hashed_pw = get_password_hash(admin_data.password)
|
hashed_pw = get_password_hash(admin_data.password)
|
||||||
totp_secret = generate_totp_secret()
|
totp_secret = generate_totp_secret()
|
||||||
|
new_admin = User(email=admin_data.email, username=admin_data.username, hashed_password=hashed_pw, totp_secret=totp_secret, is_admin=True)
|
||||||
new_admin = User(
|
|
||||||
email=admin_data.email,
|
|
||||||
username=admin_data.username,
|
|
||||||
hashed_password=hashed_pw,
|
|
||||||
totp_secret=totp_secret,
|
|
||||||
is_admin=True
|
|
||||||
)
|
|
||||||
|
|
||||||
db.add(new_admin)
|
db.add(new_admin)
|
||||||
|
|
||||||
|
new_settings = SystemSettings(
|
||||||
|
smtp_host=admin_data.smtp_host, smtp_port=admin_data.smtp_port, smtp_user=admin_data.smtp_user, smtp_password=admin_data.smtp_password,
|
||||||
|
openrouter_api_key=admin_data.openrouter_api_key, openrouter_management_key=admin_data.openrouter_management_key,
|
||||||
|
groq_api_key=admin_data.groq_api_key, gemini_api_key=admin_data.gemini_api_key, deepseek_api_key=admin_data.deepseek_api_key,
|
||||||
|
mistral_api_key=admin_data.mistral_api_key, cloudflare_account_id=admin_data.cloudflare_account_id, cloudflare_api_token=admin_data.cloudflare_api_token,
|
||||||
|
huggingface_api_key=admin_data.huggingface_api_key
|
||||||
|
)
|
||||||
|
db.add(new_settings)
|
||||||
db.commit()
|
db.commit()
|
||||||
db.refresh(new_admin)
|
db.refresh(new_admin)
|
||||||
|
|
||||||
# Génération de l'URI pour l'affichage du QR Code côté frontend
|
return {"message": "Configuration terminée avec succès.", "totp_secret": totp_secret, "totp_uri": get_totp_uri(totp_secret, new_admin.username)}
|
||||||
totp_uri = get_totp_uri(totp_secret, new_admin.username)
|
|
||||||
|
|
||||||
return {
|
|
||||||
"message": "Administrateur créé avec succès.",
|
|
||||||
"totp_secret": totp_secret,
|
|
||||||
"totp_uri": totp_uri
|
|
||||||
}
|
|
||||||
|
|
||||||
@app.post("/api/login")
|
@app.post("/api/login")
|
||||||
def login(login_data: LoginRequest, response: Response, db: Session = Depends(get_db)):
|
def login(login_data: LoginRequest, response: Response, db: Session = Depends(get_db)):
|
||||||
"""Vérifie les identifiants et crée une session de 60 minutes."""
|
|
||||||
user = db.query(User).filter(User.username == login_data.username).first()
|
user = db.query(User).filter(User.username == login_data.username).first()
|
||||||
|
|
||||||
# Vérification de l'utilisateur et du mot de passe
|
|
||||||
if not user or not verify_password(login_data.password, user.hashed_password):
|
if not user or not verify_password(login_data.password, user.hashed_password):
|
||||||
raise HTTPException(
|
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Identifiants incorrects.")
|
||||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
||||||
detail="Nom d'utilisateur ou mot de passe incorrect."
|
|
||||||
)
|
|
||||||
|
|
||||||
# Vérification du code 2FA
|
|
||||||
if not verify_totp(user.totp_secret, login_data.totp_code):
|
if not verify_totp(user.totp_secret, login_data.totp_code):
|
||||||
raise HTTPException(
|
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Code 2FA invalide.")
|
||||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
||||||
detail="Code 2FA invalide."
|
|
||||||
)
|
|
||||||
|
|
||||||
# Création du jeton de session
|
|
||||||
access_token = create_access_token(data={"sub": user.username})
|
access_token = create_access_token(data={"sub": user.username})
|
||||||
|
response.set_cookie(key="session_token", value=access_token, httponly=True, max_age=3600, samesite="lax")
|
||||||
# Injection du jeton dans un cookie sécurisé (invisible pour le JavaScript côté client)
|
|
||||||
response.set_cookie(
|
|
||||||
key="session_token",
|
|
||||||
value=access_token,
|
|
||||||
httponly=True,
|
|
||||||
max_age=3600, # 3600 secondes = 60 minutes
|
|
||||||
samesite="lax"
|
|
||||||
)
|
|
||||||
|
|
||||||
return {"message": "Connexion réussie"}
|
return {"message": "Connexion réussie"}
|
||||||
|
|
||||||
@app.get("/dashboard")
|
@app.get("/dashboard")
|
||||||
def dashboard(request: Request):
|
def dashboard(request: Request):
|
||||||
"""Route protégée : affiche l'interface principale si le cookie est valide."""
|
|
||||||
token = request.cookies.get("session_token")
|
token = request.cookies.get("session_token")
|
||||||
if not token:
|
if not token or not verify_token(token):
|
||||||
return RedirectResponse(url="/login")
|
return RedirectResponse(url="/login")
|
||||||
|
|
||||||
payload = verify_token(token)
|
|
||||||
if not payload:
|
|
||||||
return RedirectResponse(url="/login")
|
|
||||||
|
|
||||||
frontend_path = os.path.join(os.getcwd(), "frontend", "dashboard.html")
|
frontend_path = os.path.join(os.getcwd(), "frontend", "dashboard.html")
|
||||||
if not os.path.exists(frontend_path):
|
|
||||||
raise HTTPException(status_code=404, detail="Interface du tableau de bord introuvable.")
|
|
||||||
|
|
||||||
return FileResponse(frontend_path)
|
return FileResponse(frontend_path)
|
||||||
|
|
||||||
# --- GESTION DES PROJETS ---
|
# --- GESTION DES PROJETS ---
|
||||||
|
|
||||||
def get_current_user(request: Request, db: Session = Depends(get_db)):
|
def get_current_user(request: Request, db: Session = Depends(get_db)):
|
||||||
"""Extrait l'utilisateur actuel à partir du cookie de session JWT."""
|
|
||||||
token = request.cookies.get("session_token")
|
token = request.cookies.get("session_token")
|
||||||
if not token:
|
if not token: raise HTTPException(status_code=401, detail="Non authentifié")
|
||||||
raise HTTPException(status_code=401, detail="Non authentifié")
|
|
||||||
|
|
||||||
payload = verify_token(token)
|
payload = verify_token(token)
|
||||||
if not payload:
|
if not payload: raise HTTPException(status_code=401, detail="Session expirée")
|
||||||
raise HTTPException(status_code=401, detail="Session expirée")
|
|
||||||
|
|
||||||
user = db.query(User).filter(User.username == payload.get("sub")).first()
|
user = db.query(User).filter(User.username == payload.get("sub")).first()
|
||||||
if not user:
|
if not user: raise HTTPException(status_code=401, detail="Utilisateur introuvable")
|
||||||
raise HTTPException(status_code=401, detail="Utilisateur introuvable")
|
|
||||||
return user
|
return user
|
||||||
|
|
||||||
@app.get("/api/projects", response_model=List[ProjectResponse])
|
@app.get("/api/projects", response_model=List[ProjectResponse])
|
||||||
def get_projects(db: Session = Depends(get_db), current_user: User = Depends(get_current_user)):
|
def get_projects(db: Session = Depends(get_db), current_user: User = Depends(get_current_user)):
|
||||||
"""Récupère tous les projets de l'utilisateur connecté."""
|
|
||||||
return db.query(Project).filter(Project.user_id == current_user.id).order_by(Project.created_at.desc()).all()
|
return db.query(Project).filter(Project.user_id == current_user.id).order_by(Project.created_at.desc()).all()
|
||||||
|
|
||||||
@app.post("/api/projects", response_model=ProjectResponse)
|
@app.post("/api/projects", response_model=ProjectResponse)
|
||||||
def create_project(project: ProjectCreate, db: Session = Depends(get_db), current_user: User = Depends(get_current_user)):
|
def create_project(project: ProjectCreate, db: Session = Depends(get_db), current_user: User = Depends(get_current_user)):
|
||||||
"""Crée un nouveau projet pour l'utilisateur connecté."""
|
|
||||||
new_project = Project(title=project.title, user_id=current_user.id)
|
new_project = Project(title=project.title, user_id=current_user.id)
|
||||||
db.add(new_project)
|
db.add(new_project)
|
||||||
db.commit()
|
db.commit()
|
||||||
@@ -173,11 +118,8 @@ def create_project(project: ProjectCreate, db: Session = Depends(get_db), curren
|
|||||||
|
|
||||||
@app.put("/api/projects/{project_id}/rename", response_model=ProjectResponse)
|
@app.put("/api/projects/{project_id}/rename", response_model=ProjectResponse)
|
||||||
def rename_project(project_id: int, project_data: ProjectRename, db: Session = Depends(get_db), current_user: User = Depends(get_current_user)):
|
def rename_project(project_id: int, project_data: ProjectRename, db: Session = Depends(get_db), current_user: User = Depends(get_current_user)):
|
||||||
"""Renomme un projet existant."""
|
|
||||||
project = db.query(Project).filter(Project.id == project_id, Project.user_id == current_user.id).first()
|
project = db.query(Project).filter(Project.id == project_id, Project.user_id == current_user.id).first()
|
||||||
if not project:
|
if not project: raise HTTPException(status_code=404, detail="Projet introuvable")
|
||||||
raise HTTPException(status_code=404, detail="Projet introuvable")
|
|
||||||
|
|
||||||
project.title = project_data.title
|
project.title = project_data.title
|
||||||
db.commit()
|
db.commit()
|
||||||
db.refresh(project)
|
db.refresh(project)
|
||||||
@@ -185,11 +127,8 @@ def rename_project(project_id: int, project_data: ProjectRename, db: Session = D
|
|||||||
|
|
||||||
@app.put("/api/projects/{project_id}/pin", response_model=ProjectResponse)
|
@app.put("/api/projects/{project_id}/pin", response_model=ProjectResponse)
|
||||||
def toggle_pin_project(project_id: int, db: Session = Depends(get_db), current_user: User = Depends(get_current_user)):
|
def toggle_pin_project(project_id: int, db: Session = Depends(get_db), current_user: User = Depends(get_current_user)):
|
||||||
"""Bascule le statut épinglé (is_pinned) d'un projet."""
|
|
||||||
project = db.query(Project).filter(Project.id == project_id, Project.user_id == current_user.id).first()
|
project = db.query(Project).filter(Project.id == project_id, Project.user_id == current_user.id).first()
|
||||||
if not project:
|
if not project: raise HTTPException(status_code=404, detail="Projet introuvable")
|
||||||
raise HTTPException(status_code=404, detail="Projet introuvable")
|
|
||||||
|
|
||||||
project.is_pinned = not project.is_pinned
|
project.is_pinned = not project.is_pinned
|
||||||
db.commit()
|
db.commit()
|
||||||
db.refresh(project)
|
db.refresh(project)
|
||||||
@@ -197,11 +136,8 @@ def toggle_pin_project(project_id: int, db: Session = Depends(get_db), current_u
|
|||||||
|
|
||||||
@app.delete("/api/projects/{project_id}")
|
@app.delete("/api/projects/{project_id}")
|
||||||
def delete_project(project_id: int, db: Session = Depends(get_db), current_user: User = Depends(get_current_user)):
|
def delete_project(project_id: int, db: Session = Depends(get_db), current_user: User = Depends(get_current_user)):
|
||||||
"""Supprime définitivement un projet et tous ses messages associés."""
|
|
||||||
project = db.query(Project).filter(Project.id == project_id, Project.user_id == current_user.id).first()
|
project = db.query(Project).filter(Project.id == project_id, Project.user_id == current_user.id).first()
|
||||||
if not project:
|
if not project: raise HTTPException(status_code=404, detail="Projet introuvable")
|
||||||
raise HTTPException(status_code=404, detail="Projet introuvable")
|
|
||||||
|
|
||||||
db.delete(project)
|
db.delete(project)
|
||||||
db.commit()
|
db.commit()
|
||||||
return {"message": "Projet supprimé"}
|
return {"message": "Projet supprimé"}
|
||||||
@@ -210,21 +146,26 @@ def delete_project(project_id: int, db: Session = Depends(get_db), current_user:
|
|||||||
|
|
||||||
@app.get("/api/projects/{project_id}/messages", response_model=List[MessageResponse])
|
@app.get("/api/projects/{project_id}/messages", response_model=List[MessageResponse])
|
||||||
def get_messages(project_id: int, db: Session = Depends(get_db), current_user: User = Depends(get_current_user)):
|
def get_messages(project_id: int, db: Session = Depends(get_db), current_user: User = Depends(get_current_user)):
|
||||||
"""Récupère tous les messages d'un projet spécifique."""
|
|
||||||
project = db.query(Project).filter(Project.id == project_id, Project.user_id == current_user.id).first()
|
project = db.query(Project).filter(Project.id == project_id, Project.user_id == current_user.id).first()
|
||||||
if not project:
|
if not project: raise HTTPException(status_code=404, detail="Projet introuvable")
|
||||||
raise HTTPException(status_code=404, detail="Projet introuvable")
|
|
||||||
return db.query(Message).filter(Message.project_id == project_id).order_by(Message.created_at.asc()).all()
|
return db.query(Message).filter(Message.project_id == project_id).order_by(Message.created_at.asc()).all()
|
||||||
|
|
||||||
@app.post("/api/projects/{project_id}/messages", response_model=MessageResponse)
|
@app.post("/api/projects/{project_id}/messages", response_model=List[MessageResponse])
|
||||||
def create_message(project_id: int, message: MessageCreate, db: Session = Depends(get_db), current_user: User = Depends(get_current_user)):
|
def create_message(project_id: int, message: MessageCreate, db: Session = Depends(get_db), current_user: User = Depends(get_current_user)):
|
||||||
"""Ajoute un message à un projet."""
|
|
||||||
project = db.query(Project).filter(Project.id == project_id, Project.user_id == current_user.id).first()
|
project = db.query(Project).filter(Project.id == project_id, Project.user_id == current_user.id).first()
|
||||||
if not project:
|
if not project: raise HTTPException(status_code=404, detail="Projet introuvable")
|
||||||
raise HTTPException(status_code=404, detail="Projet introuvable")
|
|
||||||
|
|
||||||
new_message = Message(role=message.role, content=message.content, project_id=project_id)
|
user_message = Message(role=message.role, content=message.content, project_id=project_id)
|
||||||
db.add(new_message)
|
db.add(user_message)
|
||||||
db.commit()
|
db.commit()
|
||||||
db.refresh(new_message)
|
|
||||||
return new_message
|
history = db.query(Message).filter(Message.project_id == project_id).order_by(Message.created_at.asc()).all()
|
||||||
|
settings = db.query(SystemSettings).first()
|
||||||
|
|
||||||
|
ai_response_text = get_ai_response(history, settings)
|
||||||
|
|
||||||
|
ai_message = Message(role="assistant", content=ai_response_text, project_id=project_id)
|
||||||
|
db.add(ai_message)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
return db.query(Message).filter(Message.project_id == project_id).order_by(Message.created_at.asc()).all()
|
||||||
@@ -2,6 +2,8 @@ from sqlalchemy import Column, Integer, String, Boolean, DateTime, ForeignKey, T
|
|||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
from .database import Base
|
from .database import Base
|
||||||
|
from sqlalchemy import Float, DateTime
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
class User(Base):
|
class User(Base):
|
||||||
__tablename__ = "users"
|
__tablename__ = "users"
|
||||||
@@ -42,3 +44,46 @@ class Message(Base):
|
|||||||
|
|
||||||
# Relation
|
# Relation
|
||||||
project = relationship("Project", back_populates="messages")
|
project = relationship("Project", back_populates="messages")
|
||||||
|
|
||||||
|
class SystemSettings(Base):
|
||||||
|
__tablename__ = "system_settings"
|
||||||
|
|
||||||
|
id = Column(Integer, primary_key=True, index=True)
|
||||||
|
# Serveur Mail (Obligatoire)
|
||||||
|
smtp_host = Column(String, nullable=False)
|
||||||
|
smtp_port = Column(Integer, nullable=False)
|
||||||
|
smtp_user = Column(String, nullable=False)
|
||||||
|
smtp_password = Column(String, nullable=False)
|
||||||
|
# Clés API (Optionnelles)
|
||||||
|
openrouter_api_key = Column(String, nullable=True)
|
||||||
|
openrouter_management_key = Column(String, nullable=True)
|
||||||
|
groq_api_key = Column(String, nullable=True)
|
||||||
|
gemini_api_key = Column(String, nullable=True)
|
||||||
|
deepseek_api_key = Column(String, nullable=True)
|
||||||
|
mistral_api_key = Column(String, nullable=True)
|
||||||
|
cloudflare_account_id = Column(String, nullable=True)
|
||||||
|
cloudflare_api_token = Column(String, nullable=True)
|
||||||
|
huggingface_api_key = Column(String, nullable=True)
|
||||||
|
|
||||||
|
class AIModel(Base):
|
||||||
|
"""Stocke la liste des modèles extraits depuis les fournisseurs."""
|
||||||
|
__tablename__ = "ai_models"
|
||||||
|
|
||||||
|
id = Column(Integer, primary_key=True, index=True)
|
||||||
|
provider = Column(String, index=True) # ex: openrouter, groq
|
||||||
|
model_id = Column(String, unique=True, index=True) # ex: google/gemini-1.5-pro
|
||||||
|
name = Column(String)
|
||||||
|
context_length = Column(Integer)
|
||||||
|
pricing_prompt = Column(Float) # Coût pour 1M tokens
|
||||||
|
pricing_completion = Column(Float)
|
||||||
|
last_updated = Column(DateTime, default=lambda: datetime.now(timezone.utc))
|
||||||
|
|
||||||
|
class FinancialLog(Base):
|
||||||
|
"""Suivi financier par fournisseur."""
|
||||||
|
__tablename__ = "financial_logs"
|
||||||
|
|
||||||
|
id = Column(Integer, primary_key=True, index=True)
|
||||||
|
provider = Column(String, index=True)
|
||||||
|
balance = Column(Float) # Crédit restant
|
||||||
|
total_usage = Column(Float) # Consommation totale
|
||||||
|
checked_at = Column(DateTime, default=lambda: datetime.now(timezone.utc))
|
||||||
+17
-5
@@ -6,6 +6,21 @@ class AdminCreate(BaseModel):
|
|||||||
email: EmailStr
|
email: EmailStr
|
||||||
username: str
|
username: str
|
||||||
password: str
|
password: str
|
||||||
|
# Serveur Mail (Obligatoire)
|
||||||
|
smtp_host: str
|
||||||
|
smtp_port: int
|
||||||
|
smtp_user: str
|
||||||
|
smtp_password: str
|
||||||
|
# Clés API (Optionnelles)
|
||||||
|
openrouter_api_key: Optional[str] = None
|
||||||
|
openrouter_management_key: Optional[str] = None
|
||||||
|
groq_api_key: Optional[str] = None
|
||||||
|
gemini_api_key: Optional[str] = None
|
||||||
|
deepseek_api_key: Optional[str] = None
|
||||||
|
mistral_api_key: Optional[str] = None
|
||||||
|
cloudflare_account_id: Optional[str] = None
|
||||||
|
cloudflare_api_token: Optional[str] = None
|
||||||
|
huggingface_api_key: Optional[str] = None
|
||||||
|
|
||||||
class LoginRequest(BaseModel):
|
class LoginRequest(BaseModel):
|
||||||
username: str
|
username: str
|
||||||
@@ -24,10 +39,10 @@ class ProjectResponse(ProjectBase):
|
|||||||
created_at: datetime
|
created_at: datetime
|
||||||
is_pinned: bool
|
is_pinned: bool
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
from_attributes = True
|
from_attributes = True
|
||||||
|
|
||||||
# --- NOUVEAU : Schémas pour les Messages ---
|
# --- NOUVEAU : Schémas pour les Messages ---
|
||||||
class MessageBase(BaseModel):
|
class MessageBase(BaseModel):
|
||||||
role: str
|
role: str
|
||||||
content: str
|
content: str
|
||||||
@@ -40,8 +55,5 @@ class MessageResponse(MessageBase):
|
|||||||
created_at: datetime
|
created_at: datetime
|
||||||
project_id: int
|
project_id: int
|
||||||
|
|
||||||
class Config:
|
|
||||||
from_attributes = True
|
|
||||||
|
|
||||||
class ProjectRename(BaseModel):
|
class ProjectRename(BaseModel):
|
||||||
title: str
|
title: str
|
||||||
+28
-24
@@ -26,12 +26,11 @@
|
|||||||
<div id="app" class="flex w-full h-full relative bg-aethas-dark">
|
<div id="app" class="flex w-full h-full relative bg-aethas-dark">
|
||||||
<div v-if="isSidebarOpen" @click="toggleSidebar" class="md:hidden fixed inset-0 bg-black/60 z-40 transition-opacity"></div>
|
<div v-if="isSidebarOpen" @click="toggleSidebar" class="md:hidden fixed inset-0 bg-black/60 z-40 transition-opacity"></div>
|
||||||
|
|
||||||
<!-- BARRE LATÉRALE -->
|
|
||||||
<div :class="['transition-all duration-300 flex-shrink-0 relative z-50', isSidebarOpen ? 'w-72' : 'w-0']">
|
<div :class="['transition-all duration-300 flex-shrink-0 relative z-50', isSidebarOpen ? 'w-72' : 'w-0']">
|
||||||
<aside :class="['absolute top-0 left-0 h-full w-72 bg-aethas-panel border-r border-gray-700 flex flex-col transition-transform duration-300', isSidebarOpen ? 'translate-x-0' : '-translate-x-full']">
|
<aside :class="['absolute top-0 left-0 h-full w-72 bg-aethas-panel border-r border-gray-700 flex flex-col transition-transform duration-300', isSidebarOpen ? 'translate-x-0' : '-translate-x-full']">
|
||||||
<div class="p-4 border-b border-gray-700 flex items-center justify-between">
|
<div class="p-4 border-b border-gray-700 flex items-center justify-between">
|
||||||
<div class="flex items-center gap-3">
|
<div class="flex items-center gap-3">
|
||||||
<img src="/static/logo.png" alt="Logo" class="w-10 h-10 rounded-full border border-aethas-cyan object-cover bg-gray-800 flex-shrink-0">
|
<img src="/assets/logo.png" alt="Logo" class="w-10 h-10 rounded-full border border-aethas-cyan object-cover bg-gray-800 flex-shrink-0">
|
||||||
<span class="font-bold text-lg tracking-wider neon-text">AETHAS38</span>
|
<span class="font-bold text-lg tracking-wider neon-text">AETHAS38</span>
|
||||||
</div>
|
</div>
|
||||||
<button @click="toggleSidebar" class="md:hidden text-gray-400 hover:text-white"><i data-lucide="x" class="w-5 h-5"></i></button>
|
<button @click="toggleSidebar" class="md:hidden text-gray-400 hover:text-white"><i data-lucide="x" class="w-5 h-5"></i></button>
|
||||||
@@ -44,7 +43,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex-1 overflow-y-auto p-4 space-y-6">
|
<div class="flex-1 overflow-y-auto p-4 space-y-6">
|
||||||
<!-- Projets Épinglés -->
|
|
||||||
<div v-if="pinnedProjects.length > 0">
|
<div v-if="pinnedProjects.length > 0">
|
||||||
<h3 class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-3">Épinglés</h3>
|
<h3 class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-3">Épinglés</h3>
|
||||||
<ul class="space-y-1">
|
<ul class="space-y-1">
|
||||||
@@ -62,7 +60,6 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Projets Récents -->
|
|
||||||
<div>
|
<div>
|
||||||
<h3 class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-3">Récents</h3>
|
<h3 class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-3">Récents</h3>
|
||||||
<ul class="space-y-1">
|
<ul class="space-y-1">
|
||||||
@@ -82,20 +79,24 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="p-4 border-t border-gray-700 flex items-center gap-2">
|
<div class="p-4 border-t border-gray-700 flex justify-between items-center">
|
||||||
<div class="w-8 h-8 rounded-full bg-gradient-to-tr from-aethas-cyan to-aethas-purple flex items-center justify-center text-sm font-bold shadow-md">{{ username.charAt(0).toUpperCase() }}</div>
|
<div class="flex items-center gap-2">
|
||||||
<span class="text-sm font-medium">{{ username }}</span>
|
<div class="w-8 h-8 rounded-full bg-gradient-to-tr from-aethas-cyan to-aethas-purple flex items-center justify-center text-sm font-bold shadow-md">{{ username.charAt(0).toUpperCase() }}</div>
|
||||||
|
<span class="text-sm font-medium">{{ username }}</span>
|
||||||
|
</div>
|
||||||
|
<button class="text-gray-400 hover:text-white transition-colors" title="Paramètres">
|
||||||
|
<i data-lucide="settings" class="w-5 h-5"></i>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- ZONE PRINCIPALE -->
|
|
||||||
<main class="flex-1 flex flex-col min-w-0 z-10 transition-all duration-300">
|
<main class="flex-1 flex flex-col min-w-0 z-10 transition-all duration-300">
|
||||||
<header class="flex items-center justify-between p-4 border-b border-gray-700 bg-aethas-panel h-[73px]">
|
<header class="flex items-center justify-between p-4 border-b border-gray-700 bg-aethas-panel h-[73px]">
|
||||||
<div class="flex items-center gap-3">
|
<div class="flex items-center gap-3">
|
||||||
<button @click="toggleSidebar" class="text-gray-400 hover:text-white transition-colors p-1.5 rounded hover:bg-gray-700"><i data-lucide="menu" class="w-6 h-6"></i></button>
|
<button @click="toggleSidebar" class="text-gray-400 hover:text-white transition-colors p-1.5 rounded hover:bg-gray-700"><i data-lucide="menu" class="w-6 h-6"></i></button>
|
||||||
<div v-show="!isSidebarOpen" class="flex items-center gap-2 transition-opacity duration-300">
|
<div v-show="!isSidebarOpen" class="flex items-center gap-2 transition-opacity duration-300">
|
||||||
<img src="/static/logo.png" alt="Logo" class="w-8 h-8 rounded-full border border-aethas-cyan object-cover bg-gray-800 flex-shrink-0">
|
<img src="/assets/logo.png" alt="Logo" class="w-8 h-8 rounded-full border border-aethas-cyan object-cover bg-gray-800 flex-shrink-0">
|
||||||
<span class="font-bold text-lg neon-text">AETHAS38</span>
|
<span class="font-bold text-lg neon-text">AETHAS38</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -105,14 +106,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<!-- Affichage par défaut -->
|
|
||||||
<div v-if="!activeProject" class="flex-1 overflow-y-auto p-4 md:p-8 flex flex-col items-center justify-center">
|
<div v-if="!activeProject" class="flex-1 overflow-y-auto p-4 md:p-8 flex flex-col items-center justify-center">
|
||||||
<img src="/static/logo.png" alt="AETHAS38 Logo" class="w-24 h-24 mb-6 rounded-full border-2 border-aethas-cyan shadow-[0_0_15px_rgba(6,182,212,0.5)] object-cover bg-gray-800 flex-shrink-0">
|
<img src="/assets/logo.png" alt="AETHAS38 Logo" class="w-24 h-24 mb-6 rounded-full border-2 border-aethas-cyan shadow-[0_0_15px_rgba(6,182,212,0.5)] object-cover bg-gray-800 flex-shrink-0">
|
||||||
<h2 class="text-2xl font-bold text-gray-200 mb-2 text-center">Comment puis-je vous aider aujourd'hui ?</h2>
|
<h2 class="text-2xl font-bold text-gray-200 mb-2 text-center">Comment puis-je vous aider aujourd'hui ?</h2>
|
||||||
<p class="text-gray-500 text-sm text-center">Sélectionnez ou créez un projet pour commencer.</p>
|
<p class="text-gray-500 text-sm text-center">Sélectionnez ou créez un projet pour commencer.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Zone de Chat -->
|
|
||||||
<div v-else class="flex-1 overflow-y-auto p-4 md:p-8 space-y-6 flex flex-col" id="chat-container">
|
<div v-else class="flex-1 overflow-y-auto p-4 md:p-8 space-y-6 flex flex-col" id="chat-container">
|
||||||
<div v-if="messages.length === 0" class="flex-1 flex items-center justify-center text-gray-500 italic">Démarrez la conversation ci-dessous.</div>
|
<div v-if="messages.length === 0" class="flex-1 flex items-center justify-center text-gray-500 italic">Démarrez la conversation ci-dessous.</div>
|
||||||
|
|
||||||
@@ -125,7 +124,6 @@
|
|||||||
<div class="text-gray-200 whitespace-pre-wrap text-sm leading-relaxed">{{ msg.content }}</div>
|
<div class="text-gray-200 whitespace-pre-wrap text-sm leading-relaxed">{{ msg.content }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Indicateur de chargement IA -->
|
|
||||||
<div v-if="isAiThinking" class="max-w-3xl rounded-2xl p-4 bg-aethas-panel mr-auto border border-aethas-cyan/30 w-24">
|
<div v-if="isAiThinking" class="max-w-3xl rounded-2xl p-4 bg-aethas-panel mr-auto border border-aethas-cyan/30 w-24">
|
||||||
<div class="flex items-center gap-2 mb-2">
|
<div class="flex items-center gap-2 mb-2">
|
||||||
<i data-lucide="bot" class="w-4 h-4 text-aethas-cyan"></i>
|
<i data-lucide="bot" class="w-4 h-4 text-aethas-cyan"></i>
|
||||||
@@ -139,7 +137,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Saisie du Prompt -->
|
|
||||||
<div class="p-4 md:p-6 w-full max-w-4xl mx-auto">
|
<div class="p-4 md:p-6 w-full max-w-4xl mx-auto">
|
||||||
<div class="relative flex items-end bg-gray-800 border border-gray-600 rounded-2xl p-2 shadow-lg focus-within:border-aethas-cyan focus-within:ring-1 focus-within:ring-aethas-cyan transition-all">
|
<div class="relative flex items-end bg-gray-800 border border-gray-600 rounded-2xl p-2 shadow-lg focus-within:border-aethas-cyan focus-within:ring-1 focus-within:ring-aethas-cyan transition-all">
|
||||||
<button class="p-3 text-gray-400 hover:text-aethas-cyan transition-colors flex-shrink-0" :disabled="!activeProject || isAiThinking"><i data-lucide="paperclip" class="w-5 h-5"></i></button>
|
<button class="p-3 text-gray-400 hover:text-aethas-cyan transition-colors flex-shrink-0" :disabled="!activeProject || isAiThinking"><i data-lucide="paperclip" class="w-5 h-5"></i></button>
|
||||||
@@ -264,26 +261,33 @@
|
|||||||
nextTick(() => lucide.createIcons());
|
nextTick(() => lucide.createIcons());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await fetch(`/api/projects/${activeProject.value.id}/messages`, {
|
const response = await fetch(`/api/projects/${activeProject.value.id}/messages`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ role: 'user', content: userText })
|
body: JSON.stringify({ role: 'user', content: userText })
|
||||||
});
|
});
|
||||||
|
|
||||||
// SIMULATION TEMPORAIRE : Attente de l'IA (2 secondes)
|
if (response.ok) {
|
||||||
setTimeout(() => {
|
const data = await response.json();
|
||||||
isAiThinking.value = false;
|
if (Array.isArray(data)) {
|
||||||
scrollToBottom();
|
messages.value = data;
|
||||||
// La prochaine étape remplacera ce setTimeout par le véritable appel au moteur IA !
|
} else {
|
||||||
}, 2000);
|
selectProject(activeProject.value);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const err = await response.json();
|
||||||
|
alert("Erreur de l'IA: " + err.detail);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Erreur envoi message", error);
|
console.error("Erreur envoi message", error);
|
||||||
|
} finally {
|
||||||
isAiThinking.value = false;
|
isAiThinking.value = false;
|
||||||
|
scrollToBottom();
|
||||||
|
nextTick(() => lucide.createIcons());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const togglePin = async (projectId) => { /* ... code existant identique ... */
|
const togglePin = async (projectId) => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`/api/projects/${projectId}/pin`, { method: 'PUT' });
|
const response = await fetch(`/api/projects/${projectId}/pin`, { method: 'PUT' });
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
@@ -294,7 +298,7 @@
|
|||||||
} catch (error) { console.error(error); }
|
} catch (error) { console.error(error); }
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteProject = async (projectId) => { /* ... code existant identique ... */
|
const deleteProject = async (projectId) => {
|
||||||
if (!confirm("Voulez-vous vraiment supprimer ce projet ?")) return;
|
if (!confirm("Voulez-vous vraiment supprimer ce projet ?")) return;
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`/api/projects/${projectId}`, { method: 'DELETE' });
|
const response = await fetch(`/api/projects/${projectId}`, { method: 'DELETE' });
|
||||||
|
|||||||
+146
-37
@@ -3,60 +3,166 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>AETHAS38 - Installation</title>
|
<title>AETHAS38 - Installation Complète</title>
|
||||||
<script src="https://cdn.tailwindcss.com"></script>
|
<script src="https://cdn.tailwindcss.com"></script>
|
||||||
<script>
|
<script>
|
||||||
tailwind.config = {
|
tailwind.config = { darkMode: 'class', theme: { extend: { colors: { aethas: { dark: '#0f172a', panel: '#1e293b', cyan: '#06b6d4', purple: '#a855f7' } } } } }
|
||||||
darkMode: 'class',
|
|
||||||
theme: {
|
|
||||||
extend: { colors: { aethas: { dark: '#0f172a', panel: '#1e293b', cyan: '#06b6d4', purple: '#a855f7' } } }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
|
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
|
||||||
|
<script src="https://unpkg.com/lucide@latest"></script>
|
||||||
<style>
|
<style>
|
||||||
body { background-color: #0f172a; color: #f8fafc; font-family: 'Inter', sans-serif; }
|
body { background-color: #0f172a; color: #f8fafc; font-family: 'Inter', sans-serif; }
|
||||||
.glass-panel { background: rgba(30, 41, 59, 0.7); backdrop-filter: blur(10px); border: 1px solid rgba(6, 182, 212, 0.2); box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5); }
|
.glass-panel { background: rgba(30, 41, 59, 0.7); backdrop-filter: blur(10px); border: 1px solid rgba(6, 182, 212, 0.2); box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5); }
|
||||||
.neon-text { background: linear-gradient(to right, #06b6d4, #a855f7); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
|
.neon-text { background: linear-gradient(to right, #06b6d4, #a855f7); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
|
||||||
|
::-webkit-scrollbar { width: 6px; }
|
||||||
|
::-webkit-scrollbar-thumb { background: #334155; border-radius: 10px; }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body class="flex items-center justify-center min-h-screen p-4 sm:p-8">
|
<body class="flex items-center justify-center min-h-screen p-4 sm:p-8 overflow-y-auto">
|
||||||
|
|
||||||
<div id="app" class="w-full max-w-md transition-all duration-500">
|
<div id="app" class="w-full max-w-3xl transition-all duration-500 my-8">
|
||||||
<div class="text-center mb-8">
|
<div class="text-center mb-8">
|
||||||
<!-- Chemin du logo corrigé -->
|
<img src="/assets/logo.png" alt="AETHAS38 Logo" class="w-24 h-24 mx-auto mb-4 rounded-full border-2 border-aethas-cyan shadow-[0_0_15px_rgba(6,182,212,0.5)] object-cover bg-gray-800">
|
||||||
<img src="/static/logo.png" alt="AETHAS38 Logo" class="w-24 h-24 mx-auto mb-4 rounded-full border-2 border-aethas-cyan shadow-[0_0_15px_rgba(6,182,212,0.5)] object-cover bg-gray-800">
|
|
||||||
<h1 class="text-3xl font-bold tracking-wider neon-text">AETHAS38</h1>
|
<h1 class="text-3xl font-bold tracking-wider neon-text">AETHAS38</h1>
|
||||||
<p class="text-gray-400 text-sm mt-2">Configuration de l'Orchestrateur Multi-IA</p>
|
<p class="text-gray-400 text-sm mt-2">Configuration Initiale (Super Admin)</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="glass-panel rounded-2xl p-6 sm:p-8">
|
<div class="glass-panel rounded-2xl p-6 sm:p-8">
|
||||||
|
<form v-if="!setupComplete" @submit.prevent="submitSetup" class="space-y-8">
|
||||||
<form v-if="!setupComplete" @submit.prevent="submitSetup" class="space-y-5">
|
|
||||||
<div v-if="errorMessage" class="p-3 bg-red-900/50 border border-red-500 rounded text-red-200 text-sm text-center">{{ errorMessage }}</div>
|
<div v-if="errorMessage" class="p-3 bg-red-900/50 border border-red-500 rounded text-red-200 text-sm text-center">{{ errorMessage }}</div>
|
||||||
|
|
||||||
|
<!-- Section 1 : Compte Admin -->
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium text-gray-300 mb-1">Email Administrateur</label>
|
<h2 class="text-lg font-semibold text-white border-b border-gray-700 pb-2 mb-4 flex items-center gap-2">
|
||||||
<input v-model="form.email" type="email" required class="w-full bg-aethas-dark border border-gray-600 rounded-lg px-4 py-2.5 focus:outline-none focus:border-aethas-cyan focus:ring-1 focus:ring-aethas-cyan transition-colors" placeholder="admin@domaine.com">
|
<i data-lucide="user-plus" class="w-5 h-5 text-aethas-cyan"></i> Compte Administrateur
|
||||||
|
</h2>
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm text-gray-300 mb-1">Nom d'utilisateur</label>
|
||||||
|
<input v-model="form.username" type="text" required class="w-full bg-aethas-dark border border-gray-600 rounded-lg px-4 py-2 focus:border-aethas-cyan focus:ring-1 focus:ring-aethas-cyan outline-none" placeholder="Admin">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm text-gray-300 mb-1">Mot de passe</label>
|
||||||
|
<input v-model="form.password" type="password" required class="w-full bg-aethas-dark border border-gray-600 rounded-lg px-4 py-2 focus:border-aethas-cyan focus:ring-1 focus:ring-aethas-cyan outline-none" placeholder="••••••••">
|
||||||
|
</div>
|
||||||
|
<div class="md:col-span-2">
|
||||||
|
<label class="block text-sm text-gray-300 mb-1">Email de récupération</label>
|
||||||
|
<input v-model="form.email" type="email" required class="w-full bg-aethas-dark border border-gray-600 rounded-lg px-4 py-2 focus:border-aethas-cyan focus:ring-1 focus:ring-aethas-cyan outline-none" placeholder="admin@domaine.com">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Section 2 : Serveur Mail -->
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium text-gray-300 mb-1">Nom d'utilisateur</label>
|
<div class="flex items-center justify-between border-b border-gray-700 pb-2 mb-4">
|
||||||
<input v-model="form.username" type="text" required class="w-full bg-aethas-dark border border-gray-600 rounded-lg px-4 py-2.5 focus:outline-none focus:border-aethas-cyan focus:ring-1 focus:ring-aethas-cyan transition-colors" placeholder="Admin">
|
<h2 class="text-lg font-semibold text-white flex items-center gap-2">
|
||||||
|
<i data-lucide="mail" class="w-5 h-5 text-aethas-cyan"></i> Serveur Mail (Obligatoire)
|
||||||
|
</h2>
|
||||||
|
<button type="button" @click="showWiki = !showWiki" class="text-xs text-aethas-cyan hover:text-white underline">Aide FAI Français</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="showWiki" class="mb-4 p-4 bg-gray-800 rounded-lg border border-gray-600 text-sm text-gray-300 space-y-2">
|
||||||
|
<p><strong>Freebox :</strong> Hôte: smtp.free.fr | Port: 465 (SSL) ou 587 (TLS)</p>
|
||||||
|
<p><strong>Orange :</strong> Hôte: smtp.orange.fr | Port: 465 (SSL)</p>
|
||||||
|
<p><strong>SFR :</strong> Hôte: smtp.sfr.fr | Port: 465 (SSL)</p>
|
||||||
|
<p><strong>Bouygues :</strong> Hôte: smtp.bbox.fr | Port: 587 (TLS)</p>
|
||||||
|
<p><strong>Gmail :</strong> Hôte: smtp.gmail.com | Port: 465 (Nécessite un "Mot de passe d'application" Google)</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-4 gap-4">
|
||||||
|
<div class="md:col-span-3">
|
||||||
|
<label class="block text-sm text-gray-300 mb-1">Hôte SMTP</label>
|
||||||
|
<input v-model="form.smtp_host" type="text" required class="w-full bg-aethas-dark border border-gray-600 rounded-lg px-4 py-2 focus:border-aethas-cyan outline-none" placeholder="ex: smtp.free.fr">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm text-gray-300 mb-1">Port</label>
|
||||||
|
<input v-model="form.smtp_port" type="number" required class="w-full bg-aethas-dark border border-gray-600 rounded-lg px-4 py-2 focus:border-aethas-cyan outline-none" placeholder="465">
|
||||||
|
</div>
|
||||||
|
<div class="md:col-span-2">
|
||||||
|
<label class="block text-sm text-gray-300 mb-1">Utilisateur SMTP</label>
|
||||||
|
<input v-model="form.smtp_user" type="text" required class="w-full bg-aethas-dark border border-gray-600 rounded-lg px-4 py-2 focus:border-aethas-cyan outline-none">
|
||||||
|
</div>
|
||||||
|
<div class="md:col-span-2">
|
||||||
|
<label class="block text-sm text-gray-300 mb-1">Mot de passe SMTP</label>
|
||||||
|
<input v-model="form.smtp_password" type="password" required class="w-full bg-aethas-dark border border-gray-600 rounded-lg px-4 py-2 focus:border-aethas-cyan outline-none">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Section 3 : Clés API IA -->
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium text-gray-300 mb-1">Mot de passe</label>
|
<h2 class="text-lg font-semibold text-white border-b border-gray-700 pb-2 mb-4 flex items-center gap-2">
|
||||||
<input v-model="form.password" type="password" required class="w-full bg-aethas-dark border border-gray-600 rounded-lg px-4 py-2.5 focus:outline-none focus:border-aethas-cyan focus:ring-1 focus:ring-aethas-cyan transition-colors" placeholder="••••••••">
|
<i data-lucide="cpu" class="w-5 h-5 text-aethas-cyan"></i> Moteurs IA (Optionnel - modifiable plus tard)
|
||||||
|
</h2>
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||||
|
|
||||||
|
<!-- OpenRouter -->
|
||||||
|
<div class="space-y-2 bg-gray-800/50 p-3 rounded-lg border border-gray-700">
|
||||||
|
<h3 class="text-sm font-bold text-white flex items-center justify-between">OpenRouter <a href="https://openrouter.ai/keys" target="_blank" class="text-aethas-cyan hover:underline text-xs"><i data-lucide="external-link" class="w-3 h-3 inline"></i> Récupérer</a></h3>
|
||||||
|
<p class="text-xs text-gray-400">Générez une clé standard pour les requêtes, et une "Management Key" pour la récupération des crédits.</p>
|
||||||
|
<input v-model="form.openrouter_api_key" type="password" class="w-full bg-aethas-dark border border-gray-600 rounded-lg px-3 py-1.5 text-sm focus:border-aethas-cyan outline-none" placeholder="API Key (sk-or-v1-...)">
|
||||||
|
<input v-model="form.openrouter_management_key" type="password" class="w-full bg-aethas-dark border border-gray-600 rounded-lg px-3 py-1.5 text-sm focus:border-aethas-cyan outline-none" placeholder="Management Key">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Gemini -->
|
||||||
|
<div class="space-y-2 bg-gray-800/50 p-3 rounded-lg border border-gray-700">
|
||||||
|
<h3 class="text-sm font-bold text-white flex items-center justify-between">Google Gemini <a href="https://aistudio.google.com/app/apikey" target="_blank" class="text-aethas-cyan hover:underline text-xs"><i data-lucide="external-link" class="w-3 h-3 inline"></i> Récupérer</a></h3>
|
||||||
|
<p class="text-xs text-gray-400">Créez une API Key depuis Google AI Studio (Associez un projet Google Cloud pour lever les quotas gratuits limités).</p>
|
||||||
|
<input v-model="form.gemini_api_key" type="password" class="w-full bg-aethas-dark border border-gray-600 rounded-lg px-3 py-1.5 text-sm focus:border-aethas-cyan outline-none" placeholder="AIzaSy...">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Groq -->
|
||||||
|
<div class="space-y-2 bg-gray-800/50 p-3 rounded-lg border border-gray-700">
|
||||||
|
<h3 class="text-sm font-bold text-white flex items-center justify-between">Groq <a href="https://console.groq.com/keys" target="_blank" class="text-aethas-cyan hover:underline text-xs"><i data-lucide="external-link" class="w-3 h-3 inline"></i> Récupérer</a></h3>
|
||||||
|
<p class="text-xs text-gray-400">Créez une clé d'API. L'accès aux modèles Llama est gratuit avec quotas.</p>
|
||||||
|
<input v-model="form.groq_api_key" type="password" class="w-full bg-aethas-dark border border-gray-600 rounded-lg px-3 py-1.5 text-sm focus:border-aethas-cyan outline-none" placeholder="gsk_...">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- DeepSeek -->
|
||||||
|
<div class="space-y-2 bg-gray-800/50 p-3 rounded-lg border border-gray-700">
|
||||||
|
<h3 class="text-sm font-bold text-white flex items-center justify-between">DeepSeek <a href="https://platform.deepseek.com/api_keys" target="_blank" class="text-aethas-cyan hover:underline text-xs"><i data-lucide="external-link" class="w-3 h-3 inline"></i> Récupérer</a></h3>
|
||||||
|
<p class="text-xs text-gray-400">Créez une clé d'API. Parfait pour le traitement du code de AETHAS38.</p>
|
||||||
|
<input v-model="form.deepseek_api_key" type="password" class="w-full bg-aethas-dark border border-gray-600 rounded-lg px-3 py-1.5 text-sm focus:border-aethas-cyan outline-none" placeholder="sk-...">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Mistral -->
|
||||||
|
<div class="space-y-2 bg-gray-800/50 p-3 rounded-lg border border-gray-700">
|
||||||
|
<h3 class="text-sm font-bold text-white flex items-center justify-between">Mistral AI <a href="https://console.mistral.ai/api-keys/" target="_blank" class="text-aethas-cyan hover:underline text-xs"><i data-lucide="external-link" class="w-3 h-3 inline"></i> Récupérer</a></h3>
|
||||||
|
<p class="text-xs text-gray-400">Assurez-vous d'avoir enregistré une méthode de facturation pour lever la période d'essai.</p>
|
||||||
|
<input v-model="form.mistral_api_key" type="password" class="w-full bg-aethas-dark border border-gray-600 rounded-lg px-3 py-1.5 text-sm focus:border-aethas-cyan outline-none" placeholder="Clé API Mistral">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- HuggingFace -->
|
||||||
|
<div class="space-y-2 bg-gray-800/50 p-3 rounded-lg border border-gray-700">
|
||||||
|
<h3 class="text-sm font-bold text-white flex items-center justify-between">HuggingFace <a href="https://huggingface.co/settings/tokens" target="_blank" class="text-aethas-cyan hover:underline text-xs"><i data-lucide="external-link" class="w-3 h-3 inline"></i> Récupérer</a></h3>
|
||||||
|
<p class="text-xs text-gray-400">Générez un Access Token (Fine-grained) avec les droits de lecture et génération (Inference).</p>
|
||||||
|
<input v-model="form.huggingface_api_key" type="password" class="w-full bg-aethas-dark border border-gray-600 rounded-lg px-3 py-1.5 text-sm focus:border-aethas-cyan outline-none" placeholder="hf_...">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Cloudflare -->
|
||||||
|
<div class="space-y-2 bg-gray-800/50 p-3 rounded-lg border border-gray-700 md:col-span-2">
|
||||||
|
<h3 class="text-sm font-bold text-white flex items-center justify-between">Cloudflare Workers AI <a href="https://dash.cloudflare.com/profile/api-tokens" target="_blank" class="text-aethas-cyan hover:underline text-xs"><i data-lucide="external-link" class="w-3 h-3 inline"></i> Récupérer</a></h3>
|
||||||
|
<p class="text-xs text-gray-400">Créez un "Custom Token" avec l'autorisation "Workers AI : Read/Write". Votre ID de compte se trouve sur la page d'accueil Workers.</p>
|
||||||
|
<div class="flex gap-2">
|
||||||
|
<input v-model="form.cloudflare_account_id" type="text" class="w-1/3 bg-aethas-dark border border-gray-600 rounded-lg px-3 py-1.5 text-sm focus:border-aethas-cyan outline-none" placeholder="Account ID">
|
||||||
|
<input v-model="form.cloudflare_api_token" type="password" class="w-2/3 bg-aethas-dark border border-gray-600 rounded-lg px-3 py-1.5 text-sm focus:border-aethas-cyan outline-none" placeholder="API Token">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" :disabled="isSubmitting" class="w-full bg-gradient-to-r from-aethas-cyan to-aethas-purple hover:opacity-90 text-white font-semibold py-3 px-4 rounded-lg transition-all shadow-[0_0_10px_rgba(168,85,247,0.4)] flex justify-center items-center mt-6">
|
|
||||||
<span v-if="isSubmitting">Création en cours...</span>
|
<button type="submit" :disabled="isSubmitting" class="w-full bg-gradient-to-r from-aethas-cyan to-aethas-purple hover:opacity-90 text-white font-semibold py-3 px-4 rounded-lg transition-all shadow-[0_0_10px_rgba(168,85,247,0.4)] flex justify-center items-center mt-8">
|
||||||
<span v-else>Initialiser le système</span>
|
<span v-if="isSubmitting">Initialisation et Chiffrement...</span>
|
||||||
|
<span v-else>Terminer l'installation</span>
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div v-else class="text-center space-y-6 animate-fade-in">
|
<div v-else class="text-center space-y-6 animate-fade-in">
|
||||||
<div class="inline-flex items-center justify-center w-12 h-12 rounded-full bg-green-900/50 text-green-400 mb-2">
|
<div class="inline-flex items-center justify-center w-12 h-12 rounded-full bg-green-900/50 text-green-400 mb-2">
|
||||||
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path></svg>
|
<i data-lucide="check" class="w-6 h-6"></i>
|
||||||
</div>
|
</div>
|
||||||
<h2 class="text-xl font-bold text-white">Compte créé avec succès</h2>
|
<h2 class="text-xl font-bold text-white">Plateforme Opérationnelle</h2>
|
||||||
|
|
||||||
<div class="bg-white p-4 rounded-xl inline-block mx-auto min-w-[200px] min-h-[200px] flex items-center justify-center">
|
<div class="bg-white p-4 rounded-xl inline-block mx-auto min-w-[200px] min-h-[200px] flex items-center justify-center">
|
||||||
<img v-if="qrCodeUrl" :src="qrCodeUrl" alt="QR Code 2FA" class="w-full h-full object-contain">
|
<img v-if="qrCodeUrl" :src="qrCodeUrl" alt="QR Code 2FA" class="w-full h-full object-contain">
|
||||||
@@ -65,7 +171,7 @@
|
|||||||
|
|
||||||
<div class="text-sm text-gray-300 space-y-2">
|
<div class="text-sm text-gray-300 space-y-2">
|
||||||
<p>Scannez ce QR Code avec votre application 2FA (Keepassium, Google Authenticator...).</p>
|
<p>Scannez ce QR Code avec votre application 2FA (Keepassium, Google Authenticator...).</p>
|
||||||
<p class="text-xs text-gray-500 break-all bg-aethas-dark p-2 rounded">Secret manuel : {{ totpSecret }}</p>
|
<p class="text-xs text-gray-500 break-all bg-aethas-dark p-2 rounded border border-gray-600">Secret manuel : {{ totpSecret }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a href="/login" class="block w-full border border-aethas-cyan text-aethas-cyan hover:bg-aethas-cyan hover:text-aethas-dark font-semibold py-3 px-4 rounded-lg transition-colors mt-6">
|
<a href="/login" class="block w-full border border-aethas-cyan text-aethas-cyan hover:bg-aethas-cyan hover:text-aethas-dark font-semibold py-3 px-4 rounded-lg transition-colors mt-6">
|
||||||
@@ -76,16 +182,25 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const { createApp, ref, reactive } = Vue;
|
const { createApp, ref, reactive, onMounted } = Vue;
|
||||||
|
|
||||||
createApp({
|
createApp({
|
||||||
setup() {
|
setup() {
|
||||||
const form = reactive({ email: '', username: '', password: '' });
|
const form = reactive({
|
||||||
|
email: '', username: '', password: '',
|
||||||
|
smtp_host: '', smtp_port: 465, smtp_user: '', smtp_password: '',
|
||||||
|
openrouter_api_key: '', openrouter_management_key: '',
|
||||||
|
groq_api_key: '', gemini_api_key: '', deepseek_api_key: '', mistral_api_key: '',
|
||||||
|
cloudflare_account_id: '', cloudflare_api_token: '', huggingface_api_key: ''
|
||||||
|
});
|
||||||
const isSubmitting = ref(false);
|
const isSubmitting = ref(false);
|
||||||
const setupComplete = ref(false);
|
const setupComplete = ref(false);
|
||||||
const errorMessage = ref('');
|
const errorMessage = ref('');
|
||||||
const totpSecret = ref('');
|
const totpSecret = ref('');
|
||||||
const qrCodeUrl = ref('');
|
const qrCodeUrl = ref('');
|
||||||
|
const showWiki = ref(false);
|
||||||
|
|
||||||
|
onMounted(() => { lucide.createIcons(); });
|
||||||
|
|
||||||
const submitSetup = async () => {
|
const submitSetup = async () => {
|
||||||
isSubmitting.value = true;
|
isSubmitting.value = true;
|
||||||
@@ -97,27 +212,21 @@
|
|||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify(form)
|
body: JSON.stringify(form)
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
if (!response.ok) throw new Error(data.detail || "Erreur lors de l'installation");
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(data.detail || "Erreur lors de l'installation");
|
|
||||||
}
|
|
||||||
|
|
||||||
totpSecret.value = data.totp_secret;
|
totpSecret.value = data.totp_secret;
|
||||||
setupComplete.value = true;
|
setupComplete.value = true;
|
||||||
|
|
||||||
// CORRECTION ICI : Génération par API externe ultra fiable (plus besoin de librairie)
|
|
||||||
qrCodeUrl.value = `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(data.totp_uri)}&color=0f172a&bgcolor=ffffff`;
|
qrCodeUrl.value = `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(data.totp_uri)}&color=0f172a&bgcolor=ffffff`;
|
||||||
|
|
||||||
|
setTimeout(() => lucide.createIcons(), 100);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
errorMessage.value = error.message;
|
errorMessage.value = error.message;
|
||||||
} finally {
|
} finally {
|
||||||
isSubmitting.value = false;
|
isSubmitting.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
return { form, isSubmitting, setupComplete, errorMessage, totpSecret, qrCodeUrl, showWiki, submitSetup };
|
||||||
return { form, isSubmitting, setupComplete, errorMessage, totpSecret, qrCodeUrl, submitSetup };
|
|
||||||
}
|
}
|
||||||
}).mount('#app');
|
}).mount('#app');
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
+23
-33
@@ -6,26 +6,12 @@
|
|||||||
<title>AETHAS38 - Connexion</title>
|
<title>AETHAS38 - Connexion</title>
|
||||||
<script src="https://cdn.tailwindcss.com"></script>
|
<script src="https://cdn.tailwindcss.com"></script>
|
||||||
<script>
|
<script>
|
||||||
tailwind.config = {
|
tailwind.config = { darkMode: 'class', theme: { extend: { colors: { aethas: { dark: '#0f172a', panel: '#1e293b', cyan: '#06b6d4', purple: '#a855f7' } } } } }
|
||||||
darkMode: 'class',
|
|
||||||
theme: {
|
|
||||||
extend: {
|
|
||||||
colors: {
|
|
||||||
aethas: {
|
|
||||||
dark: '#0f172a', panel: '#1e293b', cyan: '#06b6d4', purple: '#a855f7'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
|
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
|
||||||
<style>
|
<style>
|
||||||
body { background-color: #0f172a; color: #f8fafc; font-family: 'Inter', sans-serif; }
|
body { background-color: #0f172a; color: #f8fafc; font-family: 'Inter', sans-serif; }
|
||||||
.glass-panel {
|
.glass-panel { background: rgba(30, 41, 59, 0.7); backdrop-filter: blur(10px); border: 1px solid rgba(6, 182, 212, 0.2); box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5); }
|
||||||
background: rgba(30, 41, 59, 0.7); backdrop-filter: blur(10px);
|
|
||||||
border: 1px solid rgba(6, 182, 212, 0.2); box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
|
|
||||||
}
|
|
||||||
.neon-text { background: linear-gradient(to right, #06b6d4, #a855f7); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
|
.neon-text { background: linear-gradient(to right, #06b6d4, #a855f7); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
@@ -33,16 +19,14 @@
|
|||||||
|
|
||||||
<div id="app" class="w-full max-w-md transition-all duration-500">
|
<div id="app" class="w-full max-w-md transition-all duration-500">
|
||||||
<div class="text-center mb-8">
|
<div class="text-center mb-8">
|
||||||
<img src="https://via.placeholder.com/150x150/0f172a/06b6d4?text=Logo+A38" alt="AETHAS38 Logo" class="w-24 h-24 mx-auto mb-4 rounded-full border-2 border-aethas-cyan shadow-[0_0_15px_rgba(6,182,212,0.5)]">
|
<img src="/assets/logo.png" alt="AETHAS38 Logo" class="w-24 h-24 mx-auto mb-4 rounded-full border-2 border-aethas-cyan shadow-[0_0_15px_rgba(6,182,212,0.5)] object-cover bg-gray-800">
|
||||||
<h1 class="text-3xl font-bold tracking-wider neon-text">AETHAS38</h1>
|
<h1 class="text-3xl font-bold tracking-wider neon-text">AETHAS38</h1>
|
||||||
<p class="text-gray-400 text-sm mt-2">Authentification Sécurisée</p>
|
<p class="text-gray-400 text-sm mt-2">Authentification Sécurisée</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="glass-panel rounded-2xl p-6 sm:p-8">
|
<div class="glass-panel rounded-2xl p-6 sm:p-8">
|
||||||
<form @submit.prevent="submitLogin" class="space-y-5">
|
<form @submit.prevent="submitLogin" class="space-y-5">
|
||||||
<div v-if="errorMessage" class="p-3 bg-red-900/50 border border-red-500 rounded text-red-200 text-sm text-center">
|
<div v-if="errorMessage" class="p-3 bg-red-900/50 border border-red-500 rounded text-red-200 text-sm text-center">{{ errorMessage }}</div>
|
||||||
{{ errorMessage }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium text-gray-300 mb-1">Nom d'utilisateur</label>
|
<label class="block text-sm font-medium text-gray-300 mb-1">Nom d'utilisateur</label>
|
||||||
@@ -56,11 +40,11 @@
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium text-gray-300 mb-1">Code 2FA (6 chiffres)</label>
|
<label class="block text-sm font-medium text-gray-300 mb-1">Code 2FA (6 chiffres)</label>
|
||||||
<input v-model="form.totp_code" type="text" inputmode="numeric" pattern="[0-9]{6}" required maxlength="6" class="w-full bg-aethas-dark border border-gray-600 rounded-lg px-4 py-2.5 focus:outline-none focus:border-aethas-cyan focus:ring-1 focus:ring-aethas-cyan transition-colors text-center tracking-widest text-lg" placeholder="123456">
|
<input v-model="form.totp_code" type="text" required pattern="[0-9]{6}" class="w-full bg-aethas-dark border border-gray-600 rounded-lg px-4 py-2.5 focus:outline-none focus:border-aethas-cyan focus:ring-1 focus:ring-aethas-cyan transition-colors text-center tracking-widest text-lg" placeholder="123456">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="submit" :disabled="isSubmitting" class="w-full bg-gradient-to-r from-aethas-cyan to-aethas-purple hover:opacity-90 text-white font-semibold py-3 px-4 rounded-lg transition-all shadow-[0_0_10px_rgba(168,85,247,0.4)] flex justify-center items-center mt-6">
|
<button type="submit" :disabled="isLoading" class="w-full bg-gradient-to-r from-aethas-cyan to-aethas-purple hover:opacity-90 text-white font-semibold py-3 px-4 rounded-lg transition-all shadow-[0_0_10px_rgba(168,85,247,0.4)] flex justify-center items-center mt-6">
|
||||||
<span v-if="isSubmitting">Vérification...</span>
|
<span v-if="isLoading">Connexion...</span>
|
||||||
<span v-else>Se connecter</span>
|
<span v-else>Se connecter</span>
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
@@ -68,37 +52,43 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const { createApp, reactive, ref } = Vue;
|
const { createApp, ref, reactive } = Vue;
|
||||||
|
|
||||||
createApp({
|
createApp({
|
||||||
setup() {
|
setup() {
|
||||||
const form = reactive({ username: '', password: '', totp_code: '' });
|
const form = reactive({ username: '', password: '', totp_code: '' });
|
||||||
const isSubmitting = ref(false);
|
const isLoading = ref(false);
|
||||||
const errorMessage = ref('');
|
const errorMessage = ref('');
|
||||||
|
|
||||||
const submitLogin = async () => {
|
const submitLogin = async () => {
|
||||||
isSubmitting.value = true;
|
isLoading.value = true;
|
||||||
errorMessage.value = '';
|
errorMessage.value = '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/login', {
|
const response = await fetch('/api/login', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify(form)
|
body: JSON.stringify(form)
|
||||||
});
|
});
|
||||||
const data = await response.json();
|
|
||||||
if (!response.ok) throw new Error(data.detail || "Erreur de connexion");
|
|
||||||
|
|
||||||
// Redirection vers le tableau de bord une fois connecté
|
const data = await response.json();
|
||||||
window.location.href = "/dashboard";
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(data.detail || "Erreur de connexion");
|
||||||
|
}
|
||||||
|
|
||||||
|
window.location.href = '/dashboard';
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
errorMessage.value = error.message;
|
errorMessage.value = error.message;
|
||||||
} finally {
|
} finally {
|
||||||
isSubmitting.value = false;
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return { form, isSubmitting, errorMessage, submitLogin };
|
|
||||||
|
return { form, isLoading, errorMessage, submitLogin };
|
||||||
}
|
}
|
||||||
}).mount('#app');
|
}).mount('#app');
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -11,3 +11,4 @@ python-multipart
|
|||||||
bcrypt
|
bcrypt
|
||||||
email-validator
|
email-validator
|
||||||
PyJWT
|
PyJWT
|
||||||
|
openai
|
||||||
Reference in new issue
Block a user