1029 lines
71 KiB
HTML
1029 lines
71 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="fr" class="dark">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>AETHAS38 - Dashboard</title>
|
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
<script>
|
|
tailwind.config = { darkMode: 'class', theme: { extend: { colors: { aethas: { dark: '#0f172a', panel: '#1e293b', cyan: '#06b6d4', purple: '#a855f7' } } } } }
|
|
</script>
|
|
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
|
|
<script src="https://unpkg.com/lucide@latest"></script>
|
|
<style>
|
|
body { background-color: #0f172a; color: #f8fafc; font-family: 'Inter', sans-serif; }
|
|
.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; }
|
|
.custom-scrollbar::-webkit-scrollbar { width: 4px; }
|
|
.custom-scrollbar::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }
|
|
</style>
|
|
</head>
|
|
<body class="h-screen flex overflow-hidden">
|
|
|
|
<div id="app" class="flex w-full h-full relative bg-aethas-dark">
|
|
|
|
<!-- MODAL ASSIGNATION MODÈLE -->
|
|
<div v-if="isAssignModalOpen" class="fixed inset-0 bg-black/80 z-[100] flex items-center justify-center p-4">
|
|
<div class="bg-aethas-panel border border-gray-600 rounded-2xl w-full max-w-md overflow-hidden shadow-[0_0_30px_rgba(0,0,0,0.7)]">
|
|
<div class="p-4 border-b border-gray-700 flex justify-between items-center bg-gray-800/50">
|
|
<h2 class="text-lg font-bold text-white flex items-center gap-2"><i data-lucide="link" class="w-5 h-5 text-aethas-cyan"></i> Assigner un modèle</h2>
|
|
<button @click="closeAssignModal" class="text-gray-400 hover:text-white"><i data-lucide="x" class="w-5 h-5"></i></button>
|
|
</div>
|
|
<div class="p-6 space-y-4">
|
|
<div v-if="assignMessage" class="p-3 rounded text-sm text-center bg-green-900/50 text-green-200 border border-green-500">{{ assignMessage }}</div>
|
|
|
|
<div>
|
|
<label class="block text-sm text-gray-300 mb-1">Modèle sélectionné</label>
|
|
<input type="text" :value="assignForm.modelId" disabled class="w-full bg-gray-800 border border-gray-600 rounded-lg px-4 py-2 text-aethas-cyan font-mono text-xs">
|
|
</div>
|
|
|
|
<div>
|
|
<label class="block text-sm text-gray-300 mb-1">Associer à la discussion :</label>
|
|
<select v-model="assignForm.projectId" class="w-full bg-aethas-dark border border-gray-600 rounded-lg px-4 py-2 focus:border-aethas-cyan focus:outline-none text-gray-200">
|
|
<option v-for="p in projects" :key="p.id" :value="p.id">{{ p.title }}</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="block text-sm text-gray-300 mb-1">Définir le rôle :</label>
|
|
<select v-model="assignForm.role" class="w-full bg-aethas-dark border border-gray-600 rounded-lg px-4 py-2 focus:border-aethas-cyan focus:outline-none text-gray-200">
|
|
<option value="prompter">Prompteur</option>
|
|
<option value="worker1">Travailleur 1</option>
|
|
<option value="worker2">Travailleur 2</option>
|
|
<option value="worker3">Travailleur 3</option>
|
|
<option value="worker4">Travailleur 4</option>
|
|
<option value="worker5">Travailleur 5</option>
|
|
<option value="concatenator">Concaténeur</option>
|
|
</select>
|
|
</div>
|
|
|
|
<button @click="confirmAssignModel" class="w-full mt-4 bg-aethas-cyan hover:bg-cyan-600 text-black font-bold py-2.5 px-4 rounded-lg transition-colors">
|
|
Valider l'assignation
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- MODAL PARAMÈTRES -->
|
|
<div v-if="isSettingsModalOpen" class="fixed inset-0 bg-black/80 z-[100] flex items-center justify-center p-4">
|
|
<div class="bg-aethas-panel border border-gray-600 rounded-2xl w-full max-w-md overflow-hidden shadow-[0_0_30px_rgba(0,0,0,0.7)]">
|
|
<div class="p-4 border-b border-gray-700 flex justify-between items-center bg-gray-800/50">
|
|
<h2 class="text-lg font-bold text-white flex items-center gap-2"><i data-lucide="settings" class="w-5 h-5 text-aethas-cyan"></i> Paramètres</h2>
|
|
<button @click="closeSettings" class="text-gray-400 hover:text-white"><i data-lucide="x" class="w-5 h-5"></i></button>
|
|
</div>
|
|
<div class="p-6 space-y-4">
|
|
<h3 class="text-sm font-semibold text-aethas-cyan uppercase tracking-wider mb-2">Sécurité du compte</h3>
|
|
<div v-if="settingsMessage" :class="['p-3 rounded text-sm text-center', settingsMessage.includes('succès') ? 'bg-green-900/50 text-green-200 border border-green-500' : 'bg-red-900/50 text-red-200 border border-red-500']">{{ settingsMessage }}</div>
|
|
<div><label class="block text-sm text-gray-300 mb-1">Ancien mot de passe</label><input v-model="passForm.old" type="password" class="w-full bg-aethas-dark border border-gray-600 rounded-lg px-4 py-2 focus:border-aethas-cyan focus:outline-none"></div>
|
|
<div><label class="block text-sm text-gray-300 mb-1">Nouveau mot de passe</label><input v-model="passForm.new" type="password" class="w-full bg-aethas-dark border border-gray-600 rounded-lg px-4 py-2 focus:border-aethas-cyan focus:outline-none"></div>
|
|
<div><label class="block text-sm text-gray-300 mb-1">Confirmer</label><input v-model="passForm.confirm" type="password" class="w-full bg-aethas-dark border border-gray-600 rounded-lg px-4 py-2 focus:border-aethas-cyan focus:outline-none"></div>
|
|
<button @click="changePassword" :disabled="isSavingSettings" class="w-full mt-4 bg-gray-700 hover:bg-gray-600 text-white font-semibold py-2.5 px-4 rounded-lg transition-colors border border-gray-500 disabled:opacity-50">
|
|
<span v-if="isSavingSettings">Mise à jour...</span><span v-else>Modifier</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- BARRE LATÉRALE -->
|
|
<div :class="['transition-all duration-300 flex-shrink-0 relative z-50 flex flex-col', 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']">
|
|
<div class="p-4 border-b border-gray-700 flex items-center justify-between">
|
|
<div class="flex items-center gap-3">
|
|
<img src="/assets/logo.png" class="w-10 h-10 rounded-full border border-aethas-cyan object-cover bg-gray-800">
|
|
<span class="font-bold text-lg tracking-wider neon-text">AETHAS38</span>
|
|
</div>
|
|
<button @click="toggleSidebar" class="md:hidden text-gray-400 hover:text-white"><i data-lucide="x" class="w-5 h-5"></i></button>
|
|
</div>
|
|
|
|
<div class="p-4 space-y-2">
|
|
<button @click="createNewProject" :disabled="isLoading" class="w-full bg-gray-800 hover:bg-gray-700 text-white border border-gray-600 rounded-lg py-2 px-4 flex items-center justify-center gap-2 shadow-md">
|
|
<i data-lucide="plus" class="w-4 h-4 text-aethas-cyan"></i> Nouveau Projet
|
|
</button>
|
|
<button v-if="user.is_admin" @click="activeView = 'models'" :class="['w-full border rounded-lg py-2 px-4 flex items-center justify-center gap-2 transition-colors', activeView === 'models' ? 'bg-aethas-cyan/10 border-aethas-cyan text-aethas-cyan' : 'bg-aethas-dark hover:bg-gray-800 text-gray-300 border-gray-700']">
|
|
<i data-lucide="database" class="w-4 h-4"></i> Modèles & Finances
|
|
</button>
|
|
</div>
|
|
|
|
<div class="flex-1 overflow-y-auto p-4 space-y-6 custom-scrollbar">
|
|
<div v-if="pinnedProjects.length > 0">
|
|
<h3 class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2">Épinglés</h3>
|
|
<ul class="space-y-1">
|
|
<li v-for="project in pinnedProjects" :key="project.id" @click="selectProject(project)" :class="['group flex items-center justify-between p-2 rounded cursor-pointer text-sm', activeView === 'chat' && activeProject && activeProject.id === project.id ? 'bg-gray-700 text-white' : 'hover:bg-gray-800 text-gray-300']">
|
|
<div class="flex items-center gap-2 truncate"><i data-lucide="pin" class="w-3 h-3 text-aethas-cyan"></i><span class="truncate">{{ project.title }}</span></div>
|
|
<div class="hidden group-hover:flex items-center gap-1 bg-gray-800 pl-2 rounded">
|
|
<button @click.stop="togglePin(project.id)" class="text-gray-400 hover:text-white"><i data-lucide="pin-off" class="w-3.5 h-3.5"></i></button>
|
|
<button @click.stop="deleteProject(project.id)" class="text-red-500 hover:text-red-400"><i data-lucide="trash-2" class="w-3.5 h-3.5"></i></button>
|
|
</div>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div>
|
|
<div class="flex items-center justify-between mb-2">
|
|
<h3 class="text-xs font-semibold text-gray-400 uppercase tracking-wider">Récents</h3>
|
|
<span class="text-[9px] text-red-400/80" title="Les discussions non épinglées de plus de 7 jours sont supprimées automatiquement.">Auto-suppression > 7j</span>
|
|
</div>
|
|
<ul class="space-y-1">
|
|
<li v-for="project in recentProjects" :key="project.id" @click="selectProject(project)" :class="['group flex items-center justify-between p-2 rounded cursor-pointer text-sm', activeView === 'chat' && activeProject && activeProject.id === project.id ? 'bg-gray-700 text-white' : 'hover:bg-gray-800 text-gray-300']">
|
|
<div class="flex items-center gap-2 truncate"><i data-lucide="message-square" class="w-3 h-3 text-gray-500"></i><span class="truncate">{{ project.title }}</span></div>
|
|
<div class="hidden group-hover:flex items-center gap-1 bg-gray-800 pl-2 rounded">
|
|
<button @click.stop="renameProject(project)" class="text-gray-400 hover:text-aethas-cyan"><i data-lucide="edit-2" class="w-3.5 h-3.5"></i></button>
|
|
<button @click.stop="togglePin(project.id)" class="text-gray-400 hover:text-white"><i data-lucide="pin" class="w-3.5 h-3.5"></i></button>
|
|
<button @click.stop="deleteProject(project.id)" class="text-gray-400 hover:text-red-400"><i data-lucide="trash-2" class="w-3.5 h-3.5"></i></button>
|
|
</div>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- TERMINAL SYSTEME -->
|
|
<div class="h-40 border-t border-gray-700 bg-black flex flex-col font-mono text-[9px] flex-shrink-0 shadow-inner">
|
|
<div class="p-1.5 bg-gray-900 border-b border-gray-700 text-aethas-cyan font-bold flex items-center justify-between">
|
|
<div class="flex items-center gap-1"><i data-lucide="terminal" class="w-3 h-3"></i> SYSTEM LOGS</div>
|
|
<div class="w-2 h-2 rounded-full bg-green-500 animate-pulse"></div>
|
|
</div>
|
|
<div class="flex-1 overflow-y-auto p-2 custom-scrollbar text-green-400 space-y-1" id="terminal-logs">
|
|
<div v-for="(log, i) in systemLogs" :key="i" class="break-words">{{ log }}</div>
|
|
<div v-if="systemLogs.length === 0" class="text-gray-600">En attente d'activité serveur...</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ENCART FINANCIER -->
|
|
<div class="px-4 pb-2 pt-2 border-t border-gray-700 bg-aethas-panel flex-shrink-0">
|
|
<div v-if="financesList.length > 0" class="flex flex-col gap-1.5 mb-2">
|
|
<div v-for="fin in financesList" :key="fin.provider" class="text-[10px] bg-gray-800/80 border border-gray-600/50 px-2 py-1.5 rounded flex justify-between items-center shadow-inner">
|
|
<span class="text-gray-400 capitalize">{{ fin.provider }}</span>
|
|
<span :class="fin.balance > 0 ? 'text-green-400 font-bold' : 'text-aethas-cyan'">${{ fin.balance > 0 ? fin.balance.toFixed(4) : Math.abs(fin.total_usage).toFixed(4) }}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="p-4 flex justify-between items-center cursor-pointer hover:bg-gray-800 transition-colors border-t border-gray-700 flex-shrink-0" @click="openSettings">
|
|
<div class="flex items-center gap-2">
|
|
<img v-if="user.avatar_path" :src="user.avatar_path" class="w-8 h-8 rounded-full object-cover border border-gray-600 bg-gray-900">
|
|
<div v-else 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">{{ user.username.charAt(0).toUpperCase() }}</div>
|
|
<div class="flex flex-col leading-tight">
|
|
<span class="text-sm font-medium">{{ user.username }}</span>
|
|
<span v-if="user.is_superadmin" class="text-[9px] text-purple-300">SUPER-ADMIN</span>
|
|
<span v-else-if="user.is_admin" class="text-[9px] text-red-300">ADMINISTRATEUR</span>
|
|
</div>
|
|
</div>
|
|
<i data-lucide="settings" class="w-5 h-5 text-gray-400"></i>
|
|
</div>
|
|
</aside>
|
|
</div>
|
|
|
|
<!-- ZONE PRINCIPALE -->
|
|
<main class="flex-1 flex flex-col min-w-0 z-10 transition-all duration-300 bg-aethas-dark relative">
|
|
|
|
<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">
|
|
<button @click="toggleSidebar" class="text-gray-400 hover:text-white 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">
|
|
<img src="/assets/logo.png" class="w-8 h-8 rounded-full border border-aethas-cyan">
|
|
<span class="font-bold text-lg neon-text">AETHAS38</span>
|
|
</div>
|
|
</div>
|
|
<div v-if="activeView === 'chat' && activeProject" class="text-sm font-medium text-gray-300 flex items-center gap-4">
|
|
<span class="truncate max-w-[200px] md:max-w-md">{{ activeProject.title }}</span>
|
|
<div class="flex items-center gap-2 border-l border-gray-600 pl-4">
|
|
<button @click="exportProject('txt')" class="text-xs bg-gray-800 hover:bg-gray-700 text-gray-300 border border-gray-600 px-2 py-1 rounded flex items-center gap-1"><i data-lucide="download" class="w-3 h-3"></i> TXT</button>
|
|
<button @click="exportProject('json')" class="text-xs bg-gray-800 hover:bg-gray-700 text-gray-300 border border-gray-600 px-2 py-1 rounded flex items-center gap-1"><i data-lucide="file-json" class="w-3 h-3"></i> JSON</button>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<!-- VUE : CONFIGURATION -->
|
|
<div v-if="activeView === 'settings'" class="flex-1 overflow-y-auto p-4 md:p-8 custom-scrollbar">
|
|
<div class="max-w-4xl mx-auto space-y-6">
|
|
<h2 class="text-2xl font-bold text-white flex items-center gap-2 border-b border-gray-700 pb-4"><i data-lucide="settings-2" class="w-6 h-6 text-aethas-cyan"></i> Configuration Système</h2>
|
|
|
|
<div class="flex border-b border-gray-700">
|
|
<button @click="settingsTab = 'user'" :class="['py-2 px-4 text-sm font-semibold border-b-2 transition-colors', settingsTab === 'user' ? 'border-aethas-cyan text-aethas-cyan' : 'border-transparent text-gray-400 hover:text-white']">Mon Profil (Utilisateur)</button>
|
|
<button v-if="user.is_admin" @click="settingsTab = 'admin'" :class="['py-2 px-4 text-sm font-semibold border-b-2 transition-colors', settingsTab === 'admin' ? 'border-red-500 text-red-400' : 'border-transparent text-gray-400 hover:text-white']">Administration</button>
|
|
<button v-if="user.is_superadmin" @click="settingsTab = 'super'" :class="['py-2 px-4 text-sm font-semibold border-b-2 transition-colors', settingsTab === 'super' ? 'border-aethas-purple text-purple-400' : 'border-transparent text-gray-400 hover:text-white']">Super-Admin</button>
|
|
</div>
|
|
|
|
<div v-if="settingsTab === 'user'" class="space-y-6">
|
|
<div class="bg-gray-800 p-6 rounded-xl border border-gray-700">
|
|
<h3 class="text-lg font-semibold text-white mb-4">Personnalisation du Profil</h3>
|
|
<div class="flex items-center gap-6">
|
|
<img v-if="user.avatar_path" :src="user.avatar_path" class="w-20 h-20 rounded-full object-cover border-2 border-aethas-cyan bg-gray-900 shadow-lg">
|
|
<div v-else class="w-20 h-20 rounded-full bg-gradient-to-tr from-aethas-cyan to-aethas-purple flex items-center justify-center text-2xl font-bold shadow-lg">{{ user.username.charAt(0).toUpperCase() }}</div>
|
|
<div class="flex-1">
|
|
<label class="bg-aethas-panel hover:bg-gray-700 text-white border border-gray-600 px-4 py-2 rounded-lg cursor-pointer transition-colors text-sm inline-block">
|
|
<i data-lucide="upload" class="w-4 h-4 inline mr-1"></i> Uploader un nouvel Avatar
|
|
<input type="file" accept="image/*" @change="uploadAvatar" class="hidden">
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="bg-gray-800 p-6 rounded-xl border border-gray-700">
|
|
<h3 class="text-lg font-semibold text-white mb-4">Sécurité</h3>
|
|
<div v-if="settingsMessage" class="p-3 rounded text-sm mb-4 bg-gray-900 border border-aethas-cyan text-aethas-cyan">{{ settingsMessage }}</div>
|
|
<div class="grid gap-4 max-w-md">
|
|
<input v-model="passForm.old" type="password" placeholder="Ancien mot de passe" class="bg-aethas-dark border border-gray-600 rounded-lg px-4 py-2 focus:border-aethas-cyan focus:outline-none">
|
|
<input v-model="passForm.new" type="password" placeholder="Nouveau mot de passe" class="bg-aethas-dark border border-gray-600 rounded-lg px-4 py-2 focus:border-aethas-cyan focus:outline-none">
|
|
<input v-model="passForm.confirm" type="password" placeholder="Confirmer" class="bg-aethas-dark border border-gray-600 rounded-lg px-4 py-2 focus:border-aethas-cyan focus:outline-none">
|
|
<button @click="changePassword" :disabled="isSavingSettings" class="bg-gray-700 hover:bg-gray-600 text-white font-semibold py-2 px-4 rounded-lg disabled:opacity-50">Modifier le mot de passe</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div v-if="settingsTab === 'admin' && user.is_admin" class="space-y-6">
|
|
<div class="bg-gray-800 p-6 rounded-xl border border-gray-700">
|
|
<h3 class="text-lg font-semibold text-red-400 mb-4">Outils Administrateur</h3>
|
|
<div class="flex gap-4">
|
|
<button @click="activeView = 'models'" class="bg-gray-700 hover:bg-gray-600 text-white px-4 py-2 rounded-lg text-sm border border-gray-600">Ouvrir le panneau Modèles IA</button>
|
|
<a href="/api/models/export" target="_blank" class="bg-gray-700 hover:bg-gray-600 text-white px-4 py-2 rounded-lg text-sm border border-gray-600">Exporter DB Modèles (ZIP CSV/MD)</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div v-if="settingsTab === 'super' && user.is_superadmin" class="space-y-6">
|
|
<div class="bg-gray-800 p-6 rounded-xl border border-gray-700 border-l-4 border-l-aethas-purple">
|
|
<h3 class="text-lg font-semibold text-purple-400 mb-4">Espace Réservé Super-Admin</h3>
|
|
<p class="text-sm text-gray-400">Gestion globale du système.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- VUE : MODÈLES ET FINANCES -->
|
|
<div v-if="activeView === 'models' && user.is_admin" class="flex-1 overflow-y-auto p-4 md:p-8 space-y-6 custom-scrollbar">
|
|
<div class="flex justify-between items-end border-b border-gray-700 pb-4">
|
|
<div>
|
|
<h2 class="text-2xl font-bold text-white flex items-center gap-2"><i data-lucide="cpu" class="w-6 h-6 text-aethas-cyan"></i> Modèles & Finances API</h2>
|
|
<p class="text-sm text-gray-400 mt-1">Dernière extraction : <span class="text-gray-200 font-mono">{{ formatDate(modelInfo.last_sync_date) }}</span> <span class="text-xs bg-gray-800 px-2 py-0.5 rounded border border-gray-600 ml-2 uppercase">{{ modelInfo.last_sync_type || 'Aucune' }}</span></p>
|
|
</div>
|
|
<button @click="syncModels" :disabled="isSyncing" class="bg-aethas-cyan hover:bg-cyan-600 text-aethas-dark font-semibold py-2 px-4 rounded flex items-center gap-2 text-sm disabled:opacity-50"><i data-lucide="refresh-cw" :class="{'animate-spin': isSyncing}" class="w-4 h-4"></i> Forcer Extraction</button>
|
|
</div>
|
|
|
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
|
<div v-for="fin in financesList" :key="fin.provider" class="bg-gray-800 border border-gray-700 rounded-xl p-4 flex flex-col justify-between">
|
|
<div class="flex justify-between items-start mb-2"><span class="font-bold text-gray-200 capitalize">{{ fin.provider }}</span><i data-lucide="wallet" class="w-5 h-5 text-gray-500"></i></div>
|
|
<div>
|
|
<div class="text-2xl font-mono" :class="fin.balance > 0 ? 'text-green-400' : 'text-aethas-cyan'">${{ fin.balance > 0 ? fin.balance.toFixed(4) : Math.abs(fin.total_usage).toFixed(4) }}</div>
|
|
<div class="text-xs text-gray-400 mt-1">Conso. API : ${{ fin.total_usage.toFixed(4) }}</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="bg-aethas-panel border border-gray-700 rounded-xl overflow-hidden flex flex-col">
|
|
<div class="p-4 bg-gray-800/50 border-b border-gray-700 flex flex-wrap gap-4 items-center">
|
|
<input v-model="filterSearch" type="text" placeholder="Rechercher..." class="bg-gray-900 border border-gray-600 rounded px-3 py-1.5 text-sm text-gray-200 w-full md:w-64 focus:border-aethas-cyan focus:outline-none">
|
|
<select v-model="filterProvider" class="bg-gray-900 border border-gray-600 rounded px-3 py-1.5 text-sm text-gray-200 focus:outline-none">
|
|
<option value="">Tous les fournisseurs</option>
|
|
<option v-for="p in uniqueProviders" :key="p" :value="p">{{ p.toUpperCase() }}</option>
|
|
</select>
|
|
<select v-model="filterDomain" class="bg-gray-900 border border-gray-600 rounded px-3 py-1.5 text-sm text-gray-200 focus:outline-none">
|
|
<option value="">Tous les domaines</option>
|
|
<option value="Texte Polyvalent">Texte Polyvalent</option>
|
|
<option value="Code & Logique">Code & Logique</option>
|
|
<option value="Vision & Texte">Vision & Texte</option>
|
|
<option value="Audio">Audio</option>
|
|
</select>
|
|
<select v-model="filterPricing" class="bg-gray-900 border border-gray-600 rounded px-3 py-1.5 text-sm text-gray-200 focus:outline-none">
|
|
<option value="">Tous les prix</option>
|
|
<option value="free">Gratuits uniquement</option>
|
|
<option value="paid">Payants</option>
|
|
</select>
|
|
|
|
<button @click="exportCSV" class="bg-aethas-panel border border-gray-600 hover:border-aethas-cyan text-gray-300 hover:text-white px-3 py-1.5 rounded flex items-center gap-2 text-sm transition-colors md:ml-auto">
|
|
<i data-lucide="download" class="w-4 h-4 text-green-500"></i> Export CSV
|
|
</button>
|
|
</div>
|
|
<div class="overflow-x-auto max-h-[500px] custom-scrollbar">
|
|
<table class="w-full text-left text-sm text-gray-300">
|
|
<thead class="text-xs uppercase bg-gray-800 text-gray-400 sticky top-0">
|
|
<tr>
|
|
<th class="px-4 py-3 text-center">Assigner</th>
|
|
<th class="px-4 py-3">Modèle</th>
|
|
<th class="px-4 py-3">Fournisseur</th>
|
|
<th class="px-4 py-3">Domaine</th>
|
|
<th class="px-4 py-3">Coût (1M Tokens)</th>
|
|
<th class="px-4 py-3">Contexte</th>
|
|
<th class="px-4 py-3 w-1/3">Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr v-for="model in filteredModels" :key="model.model_id" class="border-b border-gray-700 hover:bg-gray-800/50 transition-colors">
|
|
<!-- PUCE DE SELECTION -->
|
|
<td class="px-4 py-3 text-center">
|
|
<input type="radio" name="modelSelect" @click.prevent="openAssignModal(model.model_id)" class="w-4 h-4 text-aethas-cyan bg-gray-900 border-gray-600 focus:ring-aethas-cyan cursor-pointer">
|
|
</td>
|
|
<td class="px-4 py-3 font-mono text-xs text-aethas-cyan break-all">{{ model.model_id }}</td>
|
|
<td class="px-4 py-3 capitalize">{{ model.provider }}</td>
|
|
<td class="px-4 py-3"><span class="bg-gray-700 text-gray-200 px-2 py-1 rounded text-xs">{{ model.domain }}</span></td>
|
|
<td class="px-4 py-3 font-mono text-xs"><span v-if="model.is_free" class="text-green-400 font-bold">GRATUIT</span><span v-else>In: ${{ model.pricing_prompt.toFixed(2) }}<br>Out: ${{ model.pricing_completion.toFixed(2) }}</span></td>
|
|
<td class="px-4 py-3">{{ (model.context_length / 1000).toFixed(0) }}k</td>
|
|
<td class="px-4 py-3 text-xs text-gray-400 truncate max-w-[250px]" :title="model.description_fr">{{ model.description_fr }}</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- VUE : CHAT -->
|
|
<div v-show="activeView === 'chat'" class="flex-1 flex flex-col min-h-0">
|
|
<div v-if="!activeProject" class="flex-1 overflow-y-auto p-4 flex flex-col items-center justify-center">
|
|
<img src="/assets/logo.png" class="w-24 h-24 mb-6 rounded-full border-2 border-aethas-cyan shadow-[0_0_15px_rgba(6,182,212,0.5)]">
|
|
<h2 class="text-2xl font-bold text-gray-200 mb-2">Comment puis-je vous aider aujourd'hui ?</h2>
|
|
<p class="text-gray-500 text-sm">Sélectionnez ou créez un projet dans la barre latérale.</p>
|
|
</div>
|
|
|
|
<template v-else>
|
|
<div class="flex-1 overflow-y-auto p-4 md:p-8 space-y-6 flex flex-col custom-scrollbar" 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-for="msg in messages" :key="msg.id" :class="['max-w-4xl rounded-2xl p-4', msg.role === 'user' ? 'bg-gray-800 ml-auto border border-gray-700' : 'bg-aethas-panel mr-auto border border-aethas-cyan/30 flex flex-col']">
|
|
<div class="flex items-center gap-2 mb-2">
|
|
<img v-if="msg.role === 'user' && user.avatar_path" :src="user.avatar_path" class="w-5 h-5 rounded-full object-cover">
|
|
<span class="text-xs font-semibold uppercase tracking-wider text-gray-400">{{ msg.role === 'user' ? 'Vous' : 'AETHAS38' }}</span>
|
|
</div>
|
|
|
|
<div class="text-gray-200 text-sm leading-relaxed w-full">
|
|
<template v-for="(part, index) in parseMessage(msg.content)" :key="index">
|
|
<div v-if="part.type === 'text'" class="whitespace-pre-wrap font-sans">{{ part.content }}</div>
|
|
<div v-if="part.type === 'code'" class="my-4 bg-gray-900 rounded-lg border border-gray-700 overflow-hidden shadow-inner">
|
|
<div class="flex justify-between items-center px-4 py-2 bg-gray-800 border-b border-gray-700">
|
|
<span class="text-xs text-gray-400 font-mono flex items-center gap-2"><i data-lucide="file-code-2" class="w-4 h-4"></i> {{ part.language || 'code' }}</span>
|
|
<button @click="downloadFile(part.content, part.language)" class="text-aethas-cyan hover:text-white flex items-center gap-1 text-xs transition-colors bg-gray-700 hover:bg-gray-600 px-2 py-1 rounded"><i data-lucide="download" class="w-3 h-3"></i> Fichier</button>
|
|
</div>
|
|
<pre class="p-4 text-xs font-mono text-gray-300 overflow-x-auto custom-scrollbar"><code>{{ part.content }}</code></pre>
|
|
</div>
|
|
</template>
|
|
</div>
|
|
|
|
<!-- Boutons de copie et téléchargement individuel -->
|
|
<div class="mt-3 flex items-center gap-3 border-t border-gray-700/50 pt-2 opacity-50 hover:opacity-100 transition-opacity">
|
|
<button @click="copyToClipboard(msg.content)" class="text-xs text-gray-400 hover:text-aethas-cyan flex items-center gap-1"><i data-lucide="copy" class="w-3 h-3"></i> Copier</button>
|
|
<button @click="downloadMessage(msg.content, msg.created_at || new Date().toISOString())" class="text-xs text-gray-400 hover:text-aethas-cyan flex items-center gap-1"><i data-lucide="file-down" class="w-3 h-3"></i> Extraire</button>
|
|
</div>
|
|
</div>
|
|
|
|
<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 space-x-1.5 h-4 items-center">
|
|
<div class="w-2 h-2 bg-aethas-cyan rounded-full animate-bounce"></div>
|
|
<div class="w-2 h-2 bg-aethas-cyan rounded-full animate-bounce" style="animation-delay: 0.15s"></div>
|
|
<div class="w-2 h-2 bg-aethas-cyan rounded-full animate-bounce" style="animation-delay: 0.3s"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="p-4 md:px-6 md:pt-6 pb-2 w-full max-w-7xl mx-auto flex-shrink-0">
|
|
<div class="flex justify-between items-center mb-2">
|
|
<span class="text-xs font-semibold text-gray-400 uppercase tracking-wider">Configuration des IA</span>
|
|
<div class="flex gap-2">
|
|
<button @click="downloadTemplate" class="text-xs bg-gray-800 hover:bg-gray-700 text-aethas-cyan border border-gray-600 px-2 py-1 rounded flex items-center gap-1 transition-colors" title="Télécharger le modèle .md"><i data-lucide="download" class="w-3 h-3"></i> Template MD</button>
|
|
<label class="text-xs bg-gray-800 hover:bg-gray-700 text-aethas-cyan border border-gray-600 px-2 py-1 rounded flex items-center gap-1 transition-colors cursor-pointer" title="Importer une configuration .md">
|
|
<i data-lucide="upload" class="w-3 h-3"></i> Importer
|
|
<input type="file" accept=".md" @change="handleConfigImport" class="hidden">
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- BARRE DE SÉLECTION -->
|
|
<div class="grid grid-cols-9 border border-black bg-gray-900 rounded-lg overflow-hidden text-center text-xs font-bold shadow-lg mb-4">
|
|
<div class="border-r border-black p-1.5 bg-gray-800 flex flex-col justify-center">
|
|
<label class="block text-[9px] text-gray-400 mb-1">PRIX</label>
|
|
<select v-model="colPricing" class="w-full bg-aethas-dark border border-gray-700 rounded text-gray-200 text-[10px] p-1 outline-none">
|
|
<option value="">TOUS</option>
|
|
<option value="free">GRATUIT</option>
|
|
<option value="paid">PAYANT</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="border-r border-black p-1.5 bg-gray-800 flex flex-col justify-center">
|
|
<label class="block text-[9px] text-gray-400 mb-1">TYPE</label>
|
|
<select v-model="colDomain" class="w-full bg-aethas-dark border border-gray-700 rounded text-gray-200 text-[10px] p-1 outline-none">
|
|
<option value="">TOUS</option>
|
|
<option value="Texte Polyvalent">Texte</option>
|
|
<option value="Code & Logique">Codage</option>
|
|
<option value="Vision & Texte">Vision</option>
|
|
<option value="Audio">Audio</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="border-r border-black p-1.5 bg-gray-800 flex flex-col justify-center">
|
|
<label class="block text-[9px] text-aethas-cyan mb-1">TRAVAILLEUR 1</label>
|
|
<select v-model="workers[0]" class="w-full bg-aethas-dark border border-gray-700 rounded text-gray-200 text-[10px] p-1 outline-none truncate">
|
|
<option value="">(Aucun)</option>
|
|
<option v-for="m in getFilteredModelsForCol(colPricing, colDomain, workers[0])" :key="m.model_id" :value="m.model_id">{{ m.name || m.model_id }}</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="border-r border-black p-1.5 bg-gray-800 flex flex-col justify-center">
|
|
<label class="block text-[9px] text-aethas-cyan mb-1">TRAVAILLEUR 2</label>
|
|
<select v-model="workers[1]" class="w-full bg-aethas-dark border border-gray-700 rounded text-gray-200 text-[10px] p-1 outline-none truncate">
|
|
<option value="">(Aucun)</option>
|
|
<option v-for="m in getFilteredModelsForCol(colPricing, colDomain, workers[1])" :key="m.model_id" :value="m.model_id">{{ m.name || m.model_id }}</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="border-r border-black p-1.5 bg-gray-800 flex flex-col justify-center">
|
|
<label class="block text-[9px] text-aethas-cyan mb-1">TRAVAILLEUR 3</label>
|
|
<select v-model="workers[2]" class="w-full bg-aethas-dark border border-gray-700 rounded text-gray-200 text-[10px] p-1 outline-none truncate">
|
|
<option value="">(Aucun)</option>
|
|
<option v-for="m in getFilteredModelsForCol(colPricing, colDomain, workers[2])" :key="m.model_id" :value="m.model_id">{{ m.name || m.model_id }}</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="border-r border-black p-1.5 bg-gray-800 flex flex-col justify-center">
|
|
<label class="block text-[9px] text-aethas-cyan mb-1">TRAVAILLEUR 4</label>
|
|
<select v-model="workers[3]" class="w-full bg-aethas-dark border border-gray-700 rounded text-gray-200 text-[10px] p-1 outline-none truncate">
|
|
<option value="">(Aucun)</option>
|
|
<option v-for="m in getFilteredModelsForCol(colPricing, colDomain, workers[3])" :key="m.model_id" :value="m.model_id">{{ m.name || m.model_id }}</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="border-r border-black p-1.5 bg-gray-800 flex flex-col justify-center">
|
|
<label class="block text-[9px] text-aethas-cyan mb-1">TRAVAILLEUR 5</label>
|
|
<select v-model="workers[4]" class="w-full bg-aethas-dark border border-gray-700 rounded text-gray-200 text-[10px] p-1 outline-none truncate">
|
|
<option value="">(Aucun)</option>
|
|
<option v-for="m in getFilteredModelsForCol(colPricing, colDomain, workers[4])" :key="m.model_id" :value="m.model_id">{{ m.name || m.model_id }}</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="border-r border-black p-1.5 bg-gray-800 flex flex-col justify-center">
|
|
<label class="block text-[9px] text-gray-400 mb-1">PROMPTEUR</label>
|
|
<select v-model="selectedPrompter" class="w-full bg-aethas-dark border border-gray-700 rounded text-gray-200 text-[10px] p-1 outline-none truncate">
|
|
<option value="">(Par défaut)</option>
|
|
<option v-for="m in getFilteredModelsForCol(colPricing, colDomain, selectedPrompter)" :key="m.model_id" :value="m.model_id">{{ m.name || m.model_id }}</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="p-1.5 bg-gray-800 flex flex-col justify-center">
|
|
<label class="block text-[9px] text-aethas-purple mb-1">CONCATENEUR</label>
|
|
<select v-model="selectedConcatenator" class="w-full bg-aethas-dark border border-gray-700 rounded text-gray-200 text-[10px] p-1 outline-none truncate">
|
|
<option value="">(Par défaut)</option>
|
|
<option v-for="m in getFilteredModelsForCol(colPricing, colDomain, selectedConcatenator)" :key="m.model_id" :value="m.model_id">{{ m.name || m.model_id }}</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- CHAT INPUT -->
|
|
<div class="relative flex items-end bg-gray-800 border border-gray-600 rounded-2xl p-2 shadow-lg focus-within:border-aethas-cyan flex-col gap-2">
|
|
<div v-if="attachedFiles.length > 0" class="w-full flex flex-wrap gap-2 px-2 pt-2">
|
|
<div v-for="(file, index) in attachedFiles" :key="index" class="bg-gray-900 border border-gray-700 rounded px-2 py-1 text-xs text-gray-300 flex items-center gap-2">
|
|
<i data-lucide="file" class="w-3.5 h-3.5 text-aethas-cyan"></i>
|
|
<span class="truncate max-w-[150px]">{{ file.name }}</span>
|
|
<button @click="removeFile(index)" class="text-red-400 hover:text-red-300"><i data-lucide="x" class="w-3 h-3"></i></button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="w-full flex items-end">
|
|
<label class="p-3 text-gray-400 hover:text-aethas-cyan cursor-pointer transition-colors" title="Joindre des fichiers (max 10)">
|
|
<i data-lucide="paperclip" class="w-5 h-5"></i>
|
|
<input type="file" multiple @change="handleFileUpload" class="hidden">
|
|
</label>
|
|
|
|
<textarea v-model="prompt" @input="autoResize" @paste="handlePaste" @keydown.enter.exact.prevent="sendMessage" ref="promptTextarea" :disabled="isAiThinking" rows="1" class="w-full bg-transparent text-gray-200 p-3 max-h-[200px] overflow-y-auto focus:outline-none resize-none disabled:opacity-50 custom-scrollbar" :placeholder="attachedFiles.length > 0 ? attachedFiles.length + ' fichier(s) attaché(s)' : 'Posez votre question ou glissez jusqu\'à 10 fichiers ici...'"></textarea>
|
|
|
|
<button @click="sendMessage" :disabled="(!prompt.trim() && attachedFiles.length === 0) || isAiThinking" class="p-3 text-aethas-cyan hover:text-white disabled:opacity-50"><i data-lucide="send" class="w-5 h-5"></i></button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</div>
|
|
</main>
|
|
</div>
|
|
|
|
<script>
|
|
const { createApp, ref, reactive, onMounted, nextTick, computed, watch } = Vue;
|
|
|
|
createApp({
|
|
setup() {
|
|
const user = ref({ username: "Guest", is_admin: false, is_superadmin: false, avatar_path: null });
|
|
const activeView = ref('chat');
|
|
const settingsTab = ref('user');
|
|
const isSidebarOpen = ref(true);
|
|
const prompt = ref("");
|
|
const promptTextarea = ref(null);
|
|
|
|
const projects = ref([]);
|
|
const activeProject = ref(null);
|
|
const messages = ref([]);
|
|
|
|
const isLoading = ref(false);
|
|
const isAiThinking = ref(false);
|
|
const isSyncing = ref(false);
|
|
const isSavingSettings = ref(false);
|
|
|
|
const isAssignModalOpen = ref(false);
|
|
const assignForm = reactive({ modelId: '', projectId: '', role: 'worker1' });
|
|
const assignMessage = ref("");
|
|
|
|
const isSettingsModalOpen = ref(false); // Ajout crucial : initialisation de la variable du modal paramètres
|
|
|
|
const passForm = reactive({ old: '', new: '', confirm: '' });
|
|
const settingsMessage = ref("");
|
|
|
|
const modelInfo = reactive({ last_sync_date: null, last_sync_type: null, models: [] });
|
|
const financesList = ref([]);
|
|
const filterSearch = ref("");
|
|
const filterDomain = ref("");
|
|
const filterPricing = ref("");
|
|
const filterProvider = ref("");
|
|
|
|
const colPricing = ref("");
|
|
const colDomain = ref("");
|
|
|
|
const workers = ref(["", "", "", "", ""]);
|
|
const selectedPrompter = ref("");
|
|
const selectedConcatenator = ref("");
|
|
|
|
const attachedFiles = ref([]);
|
|
|
|
const systemLogs = ref([]);
|
|
let logInterval = null;
|
|
|
|
const pinnedProjects = computed(() => projects.value.filter(p => p.is_pinned));
|
|
const recentProjects = computed(() => projects.value.filter(p => !p.is_pinned));
|
|
|
|
const uniqueProviders = computed(() => {
|
|
return [...new Set(modelInfo.models.map(m => m.provider))].sort();
|
|
});
|
|
|
|
const filteredModels = computed(() => {
|
|
return modelInfo.models.filter(m => {
|
|
const matchSearch = (m.model_id.toLowerCase().includes(filterSearch.value.toLowerCase()) || m.provider.toLowerCase().includes(filterSearch.value.toLowerCase()));
|
|
const matchDomain = filterDomain.value === "" || m.domain === filterDomain.value;
|
|
const matchProvider = filterProvider.value === "" || m.provider === filterProvider.value;
|
|
let matchPrice = true;
|
|
if (filterPricing.value === 'free') matchPrice = m.is_free;
|
|
if (filterPricing.value === 'paid') matchPrice = !m.is_free;
|
|
return matchSearch && matchDomain && matchProvider && matchPrice;
|
|
});
|
|
});
|
|
|
|
const getFilteredModelsForCol = (pricingFilter, domainFilter, currentSelectedId) => {
|
|
let filtered = modelInfo.models.filter(m => {
|
|
const matchDomain = domainFilter === "" || m.domain === domainFilter;
|
|
let matchPrice = true;
|
|
if (pricingFilter === 'free') matchPrice = m.is_free;
|
|
if (pricingFilter === 'paid') matchPrice = !m.is_free;
|
|
return matchDomain && matchPrice;
|
|
});
|
|
|
|
if (currentSelectedId && currentSelectedId.trim() !== "") {
|
|
const exists = filtered.find(m => m.model_id === currentSelectedId);
|
|
if (!exists) {
|
|
const original = modelInfo.models.find(m => m.model_id === currentSelectedId);
|
|
if (original) {
|
|
filtered.unshift(original);
|
|
} else {
|
|
filtered.unshift({ model_id: currentSelectedId, name: currentSelectedId, domain: "Importé", pricing_prompt: 0, pricing_completion: 0 });
|
|
}
|
|
}
|
|
}
|
|
return filtered;
|
|
};
|
|
|
|
const formatDate = (isoString) => {
|
|
if (!isoString) return "Jamais";
|
|
const d = new Date(isoString);
|
|
return d.toLocaleDateString('fr-FR', { day: '2-digit', month: '2-digit', year: 'numeric' }) + " à " + d.toLocaleTimeString('fr-FR', { hour: '2-digit', minute: '2-digit' });
|
|
};
|
|
|
|
const toggleSidebar = () => { isSidebarOpen.value = !isSidebarOpen.value; };
|
|
const autoResize = () => { const el = promptTextarea.value; if(el){ el.style.height = 'auto'; el.style.height = el.scrollHeight + 'px'; }};
|
|
const scrollToBottom = () => { nextTick(() => { const c = document.getElementById('chat-container'); if (c) c.scrollTop = c.scrollHeight; }); };
|
|
|
|
const openSettings = () => {
|
|
activeView.value = 'settings';
|
|
if(window.innerWidth < 768) isSidebarOpen.value = false;
|
|
nextTick(() => lucide.createIcons());
|
|
};
|
|
|
|
const closeSettings = () => {
|
|
isSettingsModalOpen.value = false;
|
|
};
|
|
|
|
const openAssignModal = (modelId) => {
|
|
assignForm.modelId = modelId;
|
|
assignForm.projectId = activeProject.value ? activeProject.value.id : (projects.value.length > 0 ? projects.value[0].id : '');
|
|
assignForm.role = 'worker1';
|
|
assignMessage.value = "";
|
|
isAssignModalOpen.value = true;
|
|
nextTick(() => lucide.createIcons());
|
|
};
|
|
|
|
const closeAssignModal = () => {
|
|
isAssignModalOpen.value = false;
|
|
};
|
|
|
|
const confirmAssignModel = () => {
|
|
if(!assignForm.projectId || !assignForm.role) {
|
|
assignMessage.value = "Veuillez sélectionner une discussion et un rôle.";
|
|
return;
|
|
}
|
|
const storageKey = 'aethas_config_' + assignForm.projectId;
|
|
let config = { workers: ["", "", "", "", ""], prompter: "", concatenator: "" };
|
|
const saved = localStorage.getItem(storageKey);
|
|
if (saved) {
|
|
try { config = JSON.parse(saved); } catch(e){}
|
|
}
|
|
|
|
if(assignForm.role === 'prompter') config.prompter = assignForm.modelId;
|
|
else if(assignForm.role === 'concatenator') config.concatenator = assignForm.modelId;
|
|
else {
|
|
const idx = parseInt(assignForm.role.replace('worker', '')) - 1;
|
|
config.workers[idx] = assignForm.modelId;
|
|
}
|
|
|
|
localStorage.setItem(storageKey, JSON.stringify(config));
|
|
|
|
if (activeProject.value && activeProject.value.id == assignForm.projectId) {
|
|
workers.value = config.workers;
|
|
selectedPrompter.value = config.prompter;
|
|
selectedConcatenator.value = config.concatenator;
|
|
}
|
|
|
|
assignMessage.value = `Modèle assigné avec succès !`;
|
|
setTimeout(() => { closeAssignModal(); }, 1200);
|
|
};
|
|
|
|
const logToTerminal = async (msg) => {
|
|
try { await fetch('/api/logs', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ message: msg }) }); } catch(e){}
|
|
};
|
|
|
|
const fetchLogs = async () => {
|
|
try {
|
|
const res = await fetch('/api/logs');
|
|
if (res.ok) {
|
|
const data = await res.json();
|
|
if (systemLogs.value.length !== data.logs.length || data.logs[data.logs.length-1] !== systemLogs.value[systemLogs.value.length-1]) {
|
|
systemLogs.value = data.logs;
|
|
nextTick(() => {
|
|
const el = document.getElementById('terminal-logs');
|
|
if (el) el.scrollTop = el.scrollHeight;
|
|
});
|
|
}
|
|
}
|
|
} catch(e){}
|
|
};
|
|
|
|
const validateConfigAndReplace = async () => {
|
|
if (!modelInfo.models || modelInfo.models.length === 0) return;
|
|
const availableModels = modelInfo.models.map(m => m.model_id);
|
|
const replacements = [];
|
|
|
|
const checkAndReplace = async (val, setterCallback, roleName) => {
|
|
if (val && val.trim() !== "" && !availableModels.includes(val)) {
|
|
logToTerminal(`Le modèle ${val} n'est plus reconnu. Recherche Gemini...`);
|
|
try {
|
|
const res = await fetch('/api/models/suggest_replacement', {
|
|
method: 'POST', headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({ missing_model: val })
|
|
});
|
|
if (res.ok) {
|
|
const data = await res.json();
|
|
setterCallback(data.suggestion);
|
|
replacements.push(`- ${roleName} : ${val} a été remplacé par ${data.suggestion}\n Raison: ${data.reason}`);
|
|
} else {
|
|
setterCallback("gemini-3.5-flash-lite");
|
|
replacements.push(`- ${roleName} : ${val} remplacé par gemini-3.5-flash-lite (Erreur API)`);
|
|
}
|
|
} catch(e) {
|
|
setterCallback("gemini-3.5-flash-lite");
|
|
}
|
|
}
|
|
};
|
|
|
|
await checkAndReplace(selectedPrompter.value, (n) => selectedPrompter.value = n, "Prompteur");
|
|
await checkAndReplace(selectedConcatenator.value, (n) => selectedConcatenator.value = n, "Concaténeur");
|
|
for(let i=0; i<5; i++) {
|
|
await checkAndReplace(workers.value[i], (n) => workers.value[i] = n, `Travailleur ${i+1}`);
|
|
}
|
|
|
|
if (replacements.length > 0) {
|
|
alert("⚠️ Mise à jour de la conversation\n\nCertains modèles ne sont plus disponibles. L'IA a trouvé des alternatives :\n\n" + replacements.join("\n\n"));
|
|
}
|
|
};
|
|
|
|
watch([workers, selectedPrompter, selectedConcatenator], () => {
|
|
if (activeProject.value) {
|
|
const config = {
|
|
workers: workers.value,
|
|
prompter: selectedPrompter.value,
|
|
concatenator: selectedConcatenator.value
|
|
};
|
|
localStorage.setItem('aethas_config_' + activeProject.value.id, JSON.stringify(config));
|
|
}
|
|
}, { deep: true });
|
|
|
|
const fetchUser = async () => { try { const res = await fetch('/api/users/me'); if(res.ok) user.value = await res.json(); } catch(e){} };
|
|
const fetchModelsInfo = async () => { try { const res = await fetch('/api/models/info'); if(res.ok) { const data = await res.json(); modelInfo.last_sync_date = data.last_sync_date; modelInfo.last_sync_type = data.last_sync_type; modelInfo.models = data.models; } } catch(e){} };
|
|
const fetchFinances = async () => { try { const res = await fetch('/api/finances'); if(res.ok) financesList.value = await res.json(); } catch(e){} };
|
|
|
|
const syncModels = async () => {
|
|
isSyncing.value = true;
|
|
logToTerminal("Déclenchement manuel de l'extraction des modèles...");
|
|
try {
|
|
const res = await fetch('/api/models/sync', { method: 'POST' });
|
|
if(res.ok) {
|
|
await fetchModelsInfo();
|
|
await fetchFinances();
|
|
alert("Synchronisation réussie !");
|
|
} else if (res.status === 401) {
|
|
alert("Votre session a expiré."); window.location.href = '/login';
|
|
} else {
|
|
let errText = await res.text();
|
|
try { const errObj = JSON.parse(errText); errText = errObj.detail || errText; } catch(e){}
|
|
alert("Erreur retournée par le serveur : " + errText);
|
|
}
|
|
} catch(e) { alert("Erreur réseau: impossible de contacter le serveur."); }
|
|
isSyncing.value = false;
|
|
};
|
|
|
|
const downloadTemplate = () => {
|
|
logToTerminal("Téléchargement du template MD généré.");
|
|
const templateContent = `# AETHAS38 - Configuration Multi-Agents\n\n**Rappel important :**\n- **Prompteur :** Le système de l'orchestrateur utilisera ce modèle pour traduire et optimiser votre requête initiale en ANGLAIS (langue native des IA).\n- **Concaténeur :** Le système utilisera ce modèle pour regrouper les réponses des travailleurs et traduire la synthèse finale en FRANÇAIS (en préservant le code brut).\n\n## Sélection des Modèles\nRenseignez l'ID exact du modèle (ex: gemini-3.5-flash-lite, mistralai/mistral-large-4-0). Laissez vide si inutilisé.\n\n- Prompteur : \n- Travailleur 1 : \n- Travailleur 2 : \n- Travailleur 3 : \n- Travailleur 4 : \n- Travailleur 5 : \n- Concaténeur : \n`;
|
|
downloadFile(templateContent, 'aethas38-config-agents.md');
|
|
};
|
|
|
|
const exportCSV = () => {
|
|
logToTerminal("Génération de l'extraction CSV (vue filtrée)...");
|
|
let csvContent = "\uFEFF";
|
|
csvContent += "Fournisseur,Modèle,Nom,Domaine,Gratuit,Contexte,Prix_In,Prix_Out,Description\n";
|
|
|
|
filteredModels.value.forEach(m => {
|
|
const escapeCSV = (str) => {
|
|
if (str === null || str === undefined) return '""';
|
|
return `"${String(str).replace(/"/g, '""')}"`;
|
|
};
|
|
const row = [
|
|
escapeCSV(m.provider),
|
|
escapeCSV(m.model_id),
|
|
escapeCSV(m.name),
|
|
escapeCSV(m.domain),
|
|
m.is_free ? "Oui" : "Non",
|
|
m.context_length,
|
|
m.pricing_prompt,
|
|
m.pricing_completion,
|
|
escapeCSV(m.description_fr)
|
|
];
|
|
csvContent += row.join(",") + "\n";
|
|
});
|
|
|
|
const d = new Date();
|
|
const dateStr = d.getFullYear() + String(d.getMonth()+1).padStart(2, '0') + String(d.getDate()).padStart(2, '0');
|
|
downloadFile(csvContent, `${dateStr}-extraction-modeles.csv`, 'text/csv;charset=utf-8');
|
|
};
|
|
|
|
const handleConfigImport = (event) => {
|
|
const file = event.target.files[0];
|
|
if (!file) return;
|
|
logToTerminal(`Importation de configuration depuis ${file.name}`);
|
|
const reader = new FileReader();
|
|
reader.onload = async (e) => {
|
|
const content = e.target.result;
|
|
|
|
const extractModel = (key) => {
|
|
const safeKey = key.replace(/[éèe]/gi, '[éèe]');
|
|
const regex = new RegExp(`-\\s*${safeKey}\\s*:\\s*([^\\r\\n]*)`, 'i');
|
|
const match = content.match(regex);
|
|
return match && match[1] ? match[1].trim() : "";
|
|
};
|
|
|
|
const w1 = extractModel('Travailleur 1');
|
|
const w2 = extractModel('Travailleur 2');
|
|
const w3 = extractModel('Travailleur 3');
|
|
const w4 = extractModel('Travailleur 4');
|
|
const w5 = extractModel('Travailleur 5');
|
|
|
|
workers.value = [w1, w2, w3, w4, w5];
|
|
selectedPrompter.value = extractModel('Prompteur');
|
|
selectedConcatenator.value = extractModel('Concateneur');
|
|
|
|
await validateConfigAndReplace();
|
|
alert("Configuration IA importée et appliquée avec succès !");
|
|
};
|
|
reader.readAsText(file);
|
|
event.target.value = null;
|
|
};
|
|
|
|
const uploadAvatar = async (event) => {
|
|
const file = event.target.files[0];
|
|
if (!file) return;
|
|
const formData = new FormData(); formData.append("file", file);
|
|
try {
|
|
const res = await fetch('/api/users/me/avatar', { method: 'POST', body: formData });
|
|
const data = await res.json();
|
|
if(res.ok) user.value.avatar_path = data.avatar_path;
|
|
else alert(data.detail);
|
|
} catch(e) { alert("Erreur d'upload"); }
|
|
event.target.value = null;
|
|
};
|
|
|
|
const handleFileUpload = (event) => {
|
|
const files = event.target.files;
|
|
if (!files) return;
|
|
for (let i = 0; i < files.length; i++) {
|
|
if (attachedFiles.value.length >= 10) {
|
|
alert("Maximum 10 fichiers autorisés par message.");
|
|
break;
|
|
}
|
|
processFile(files[i]);
|
|
}
|
|
event.target.value = null;
|
|
};
|
|
|
|
const handlePaste = (event) => {
|
|
const items = (event.clipboardData || event.originalEvent.clipboardData).items;
|
|
for (let index in items) {
|
|
let item = items[index];
|
|
if (item.kind === 'file') {
|
|
let file = item.getAsFile();
|
|
if (file) {
|
|
if (attachedFiles.value.length >= 10) {
|
|
alert("Maximum 10 fichiers autorisés par message.");
|
|
break;
|
|
}
|
|
processFile(file);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
const processFile = (file) => {
|
|
logToTerminal(`Fichier ${file.name} ajouté en pièce jointe.`);
|
|
const reader = new FileReader();
|
|
const textExts = ['.txt', '.md', '.csv', '.json', '.py', '.js', '.html', '.css', '.xml', '.yml', '.yaml', '.sh', '.bat', '.ps1', '.ini', '.cfg', '.conf', '.log'];
|
|
const isText = textExts.some(ext => file.name.toLowerCase().endsWith(ext)) || file.type.startsWith('text/');
|
|
|
|
reader.onload = (e) => {
|
|
attachedFiles.value.push({ name: file.name, content: e.target.result });
|
|
};
|
|
|
|
if (isText) {
|
|
reader.readAsText(file);
|
|
} else {
|
|
reader.readAsDataURL(file);
|
|
}
|
|
};
|
|
|
|
const removeFile = (index) => { attachedFiles.value.splice(index, 1); };
|
|
|
|
const exportProject = (format) => { if(activeProject.value) window.open(`/api/projects/${activeProject.value.id}/export?format=${format}`, '_blank'); };
|
|
const copyToClipboard = async (text) => { try { await navigator.clipboard.writeText(text); alert("Copié !"); } catch (e) {} };
|
|
|
|
const downloadFile = (content, hint, mimeType = 'text/plain;charset=utf-8') => {
|
|
let fname = hint ? hint.trim() : 'code.txt';
|
|
if (!fname.includes('.')) fname += '.txt';
|
|
const blob = new Blob([content], { type: mimeType });
|
|
const url = URL.createObjectURL(blob);
|
|
const a = document.createElement('a');
|
|
a.href = url;
|
|
a.download = fname;
|
|
a.click();
|
|
URL.revokeObjectURL(url);
|
|
};
|
|
|
|
const downloadMessage = (content, dateString) => { downloadFile(content, `message_${dateString.replace(/[:T.Z]/g, '-')}.txt`); };
|
|
const parseMessage = (content) => { const regex = /```([\w.-]*)\n([\s\S]*?)```/g; let parts = [], last = 0, m; while ((m = regex.exec(content)) !== null) { if (m.index > last) parts.push({ type: 'text', content: content.slice(last, m.index) }); parts.push({ type: 'code', language: m[1], content: m[2] }); last = m.index + m[0].length; } if (last < content.length) parts.push({ type: 'text', content: content.slice(last) }); return parts.length > 0 ? parts : [{ type: 'text', content: content }]; };
|
|
|
|
const fetchProjects = async () => { try { const res = await fetch('/api/projects'); if(res.ok) projects.value = await res.json(); nextTick(()=>lucide.createIcons()); } catch(e){} };
|
|
const selectProject = async (project) => {
|
|
activeView.value = 'chat';
|
|
activeProject.value = project;
|
|
messages.value = [];
|
|
logToTerminal(`Chargement du projet: ${project.title}`);
|
|
|
|
const saved = localStorage.getItem('aethas_config_' + project.id);
|
|
if (saved) {
|
|
try {
|
|
const config = JSON.parse(saved);
|
|
workers.value = config.workers || ["", "", "", "", ""];
|
|
selectedPrompter.value = config.prompter || "";
|
|
selectedConcatenator.value = config.concatenator || "";
|
|
} catch(e) {
|
|
workers.value = ["", "", "", "", ""];
|
|
selectedPrompter.value = "";
|
|
selectedConcatenator.value = "";
|
|
}
|
|
} else {
|
|
workers.value = ["", "", "", "", ""];
|
|
selectedPrompter.value = "";
|
|
selectedConcatenator.value = "";
|
|
}
|
|
|
|
try {
|
|
const res = await fetch(`/api/projects/${project.id}/messages`);
|
|
if(res.ok) {
|
|
messages.value = await res.json();
|
|
scrollToBottom();
|
|
nextTick(()=>lucide.createIcons());
|
|
} else if (res.status === 401) {
|
|
alert("Votre session a expiré."); window.location.href = '/login';
|
|
}
|
|
} catch(e){}
|
|
|
|
await validateConfigAndReplace();
|
|
};
|
|
|
|
const createNewProject = async () => {
|
|
activeView.value = 'chat'; isLoading.value = true;
|
|
try {
|
|
const res = await fetch('/api/projects', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({title: "Nouvelle discussion"})});
|
|
if(res.ok){ const np = await res.json(); projects.value.unshift(np); selectProject(np); } else if (res.status === 401) { alert("Session expirée."); window.location.href='/login'; }
|
|
} catch(e){} finally{isLoading.value = false;}
|
|
};
|
|
|
|
const sendMessage = async () => {
|
|
const activeWorkers = workers.value.filter(w => w && w.trim() !== "");
|
|
if ((!prompt.value.trim() && attachedFiles.value.length === 0) || !activeProject.value || activeWorkers.length === 0) {
|
|
alert("Veuillez sélectionner au moins un travailleur et rédiger ou joindre un contenu.");
|
|
return;
|
|
}
|
|
const userText = prompt.value.trim();
|
|
prompt.value = "";
|
|
autoResize();
|
|
|
|
const fileNames = attachedFiles.value.map(f => f.name).join(", ");
|
|
messages.value.push({ id: Date.now(), role: 'user', content: userText + (attachedFiles.value.length > 0 ? `\n[Fichiers joints: ${fileNames}]` : "") });
|
|
isAiThinking.value = true;
|
|
scrollToBottom();
|
|
|
|
const payloadFiles = [...attachedFiles.value];
|
|
const payload = {
|
|
role: 'user',
|
|
content: userText || "Analyse ces fichiers joints.",
|
|
config: { workers: activeWorkers, prompter: selectedPrompter.value, concatenator: selectedConcatenator.value },
|
|
files: payloadFiles
|
|
};
|
|
|
|
attachedFiles.value = [];
|
|
logToTerminal("Envoi de la requête à l'orchestrateur...");
|
|
|
|
try {
|
|
const response = await fetch(`/api/projects/${activeProject.value.id}/messages`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) });
|
|
if (response.ok) {
|
|
const data = await response.json();
|
|
if (Array.isArray(data)) messages.value = data;
|
|
await fetchFinances();
|
|
} else if (response.status === 401) {
|
|
alert("Votre session a expiré. Veuillez vous reconnecter.");
|
|
window.location.href = '/login';
|
|
return;
|
|
} else {
|
|
const err = await response.json(); alert("Erreur API IA : " + err.detail);
|
|
}
|
|
} catch (error) {
|
|
alert("Erreur locale lors de l'envoi : " + error.message);
|
|
} finally {
|
|
isAiThinking.value = false;
|
|
scrollToBottom();
|
|
nextTick(()=>lucide.createIcons());
|
|
|
|
fetchProjects().then(() => {
|
|
if(activeProject.value) {
|
|
const updated = projects.value.find(p => p.id === activeProject.value.id);
|
|
if(updated) activeProject.value.title = updated.title;
|
|
}
|
|
});
|
|
}
|
|
};
|
|
|
|
const changePassword = async () => {
|
|
settingsMessage.value = "";
|
|
if (passForm.new !== passForm.confirm) { settingsMessage.value = "Mots de passe différents."; return; }
|
|
if (passForm.new.length < 8) { settingsMessage.value = "8 caractères minimum."; return; }
|
|
isSavingSettings.value = true;
|
|
try { const res = await fetch('/api/users/me/password', { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ old_password: passForm.old, new_password: passForm.new }) }); const data = await res.json(); if (res.ok) { settingsMessage.value = data.message; passForm.old=''; passForm.new=''; passForm.confirm=''; } else { settingsMessage.value = data.detail; } } catch (e) {} finally { isSavingSettings.value = false; }
|
|
};
|
|
|
|
const renameProject = async (project) => { const nt = window.prompt("Nom :", project.title); if (!nt || nt.trim() === "" || nt === project.title) return; try { const res = await fetch(`/api/projects/${project.id}/rename`, { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ title: nt.trim() }) }); if (res.ok) { const up = await res.json(); const i = projects.value.findIndex(p => p.id === project.id); if (i !== -1) projects.value[i] = up; if (activeProject.value && activeProject.value.id === project.id) activeProject.value.title = up.title; } } catch (e) {} };
|
|
const togglePin = async (pid) => { try { const res = await fetch(`/api/projects/${pid}/pin`, { method: 'PUT' }); if (res.ok) { const up = await res.json(); const i = projects.value.findIndex(p => p.id === pid); if (i !== -1) projects.value[i] = up; } } catch (e) {} };
|
|
const deleteProject = async (pid) => { if (!confirm("Supprimer ce projet ?")) return; try { const res = await fetch(`/api/projects/${pid}`, { method: 'DELETE' }); if (res.ok) { projects.value = projects.value.filter(p => p.id !== pid); if (activeProject.value && activeProject.value.id === pid) activeProject.value = null; } } catch (e) {} };
|
|
|
|
onMounted(() => {
|
|
lucide.createIcons();
|
|
fetchUser();
|
|
fetchProjects();
|
|
fetchModelsInfo().then(() => {
|
|
if(activeProject.value) validateConfigAndReplace();
|
|
});
|
|
fetchFinances();
|
|
logInterval = setInterval(fetchLogs, 2000);
|
|
});
|
|
|
|
return {
|
|
user, activeView, settingsTab, isSidebarOpen, toggleSidebar, prompt, autoResize, promptTextarea,
|
|
projects, pinnedProjects, recentProjects, activeProject, messages, isAiThinking,
|
|
createNewProject, selectProject, renameProject, sendMessage, isLoading, togglePin, deleteProject,
|
|
openSettings, closeSettings, passForm, settingsMessage, isSavingSettings, changePassword, uploadAvatar,
|
|
modelInfo, financesList, filterSearch, filterDomain, filterPricing, filterProvider, uniqueProviders, filteredModels, getFilteredModelsForCol, formatDate, syncModels, isSyncing,
|
|
workers, selectedPrompter, selectedConcatenator, colPricing, colDomain, downloadTemplate, exportCSV, handleConfigImport,
|
|
isAssignModalOpen, openAssignModal, closeAssignModal, assignForm, assignMessage, confirmAssignModel,
|
|
isSettingsModalOpen, // EXPORTATION OBLIGATOIRE DE LA VARIABLE ICI
|
|
attachedFiles, handleFileUpload, handlePaste, removeFile,
|
|
exportProject, copyToClipboard, downloadFile, downloadMessage, parseMessage, systemLogs
|
|
};
|
|
}
|
|
}).mount('#app');
|
|
</script>
|
|
</body>
|
|
</html> |