fix: sécurisation extraction API, affichage permanent du solde dans le menu latéral et maj financière post-requête
Build and Push Docker Image / build-and-push (push) Successful in 45s
Build and Push Docker Image / build-and-push (push) Successful in 45s
This commit is contained in:
1 parent
36f205a56e
commit
95125df3b2
3 files changed
+128
-55
No files matched your search
+79
-26
@@ -15,14 +15,36 @@
|
||||
.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 PARAMÈTRES (Sécurité) -->
|
||||
<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', isSidebarOpen ? 'w-72' : 'w-0']">
|
||||
<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">
|
||||
@@ -68,16 +90,26 @@
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- NOUVEAU : ENCART FINANCIER SOUS LE MENU RÉCENTS -->
|
||||
<div class="px-4 pb-2 border-b border-gray-700">
|
||||
<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 border-t border-gray-700 flex justify-between items-center cursor-pointer hover:bg-gray-800 transition-colors" @click="activeView = 'settings'">
|
||||
<div class="p-4 flex justify-between items-center cursor-pointer hover:bg-gray-800 transition-colors" @click="activeView = 'settings'">
|
||||
<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>
|
||||
<span class="text-sm font-medium">
|
||||
{{ user.username }}
|
||||
<span v-if="user.is_superadmin" class="text-[10px] bg-purple-900 text-purple-200 px-1.5 py-0.5 rounded ml-1">Super-Admin</span>
|
||||
<span v-else-if="user.is_admin" class="text-[10px] bg-red-900 text-red-200 px-1.5 py-0.5 rounded ml-1">Admin</span>
|
||||
</span>
|
||||
<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>
|
||||
@@ -178,9 +210,12 @@
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
<div v-for="fin in modelInfo.finances" :key="fin.provider" class="bg-gray-800 border border-gray-700 rounded-xl p-4 flex flex-col justify-between">
|
||||
<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 text-aethas-cyan">${{ fin.balance.toFixed(4) }}</div><div class="text-xs text-gray-400 mt-1">Conso. Totale : ${{ fin.total_usage.toFixed(4) }}</div></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>
|
||||
|
||||
@@ -200,15 +235,15 @@
|
||||
<option value="paid">Payants</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="overflow-x-auto">
|
||||
<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"><tr><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>
|
||||
<thead class="text-xs uppercase bg-gray-800 text-gray-400 sticky top-0"><tr><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">
|
||||
<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 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>
|
||||
@@ -225,7 +260,7 @@
|
||||
<h2 class="text-2xl font-bold text-gray-200 mb-2">Comment puis-je vous aider aujourd'hui ?</h2>
|
||||
</div>
|
||||
|
||||
<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 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']">
|
||||
@@ -242,7 +277,7 @@
|
||||
<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"><code>{{ part.content }}</code></pre>
|
||||
<pre class="p-4 text-xs font-mono text-gray-300 overflow-x-auto custom-scrollbar"><code>{{ part.content }}</code></pre>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
@@ -293,7 +328,7 @@
|
||||
</div>
|
||||
|
||||
<div class="relative flex items-end bg-gray-800 border border-gray-600 rounded-2xl p-2 shadow-lg focus-within:border-aethas-cyan">
|
||||
<textarea v-model="prompt" @input="autoResize" @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" placeholder="Sélectionnez vos modèles ci-dessus, puis posez votre question..."></textarea>
|
||||
<textarea v-model="prompt" @input="autoResize" @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="Sélectionnez vos modèles ci-dessus, puis posez votre question..."></textarea>
|
||||
<button @click="sendMessage" :disabled="!prompt.trim() || 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>
|
||||
@@ -325,7 +360,8 @@
|
||||
const settingsMessage = ref("");
|
||||
const passForm = reactive({ old: '', new: '', confirm: '' });
|
||||
|
||||
const modelInfo = reactive({ last_sync_date: null, last_sync_type: null, models: [], finances: [] });
|
||||
const modelInfo = reactive({ last_sync_date: null, last_sync_type: null, models: [] });
|
||||
const financesList = ref([]);
|
||||
const filterSearch = ref("");
|
||||
const filterDomain = ref("");
|
||||
const filterPricing = ref("");
|
||||
@@ -359,8 +395,24 @@
|
||||
const scrollToBottom = () => { nextTick(() => { const c = document.getElementById('chat-container'); if (c) c.scrollTop = c.scrollHeight; }); };
|
||||
|
||||
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; modelInfo.finances = data.finances; } } catch(e){} };
|
||||
const syncModels = async () => { isSyncing.value = true; try { const res = await fetch('/api/models/sync', { method: 'POST' }); if(res.ok) { await fetchModelsInfo(); alert("Synchronisation terminée"); } } catch(e) {} isSyncing.value = false; };
|
||||
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;
|
||||
try {
|
||||
const res = await fetch('/api/models/sync', { method: 'POST' });
|
||||
if(res.ok) {
|
||||
await fetchModelsInfo();
|
||||
await fetchFinances();
|
||||
alert("Synchronisation terminée !");
|
||||
} else {
|
||||
const err = await res.json();
|
||||
alert("Erreur: " + err.detail);
|
||||
}
|
||||
} catch(e) { alert("Erreur réseau de synchronisation."); }
|
||||
isSyncing.value = false;
|
||||
};
|
||||
|
||||
const uploadAvatar = async (event) => {
|
||||
const file = event.target.files[0];
|
||||
@@ -393,8 +445,13 @@
|
||||
const payload = { role: 'user', content: userText, config: { workers: selectedWorkers.value, prompter: selectedPrompter.value, concatenator: selectedConcatenator.value } };
|
||||
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; }
|
||||
else { const err = await response.json(); alert("Erreur: " + err.detail); }
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
if (Array.isArray(data)) messages.value = data;
|
||||
await fetchFinances(); // MAJ du budget sous le nom
|
||||
} else {
|
||||
const err = await response.json(); alert("Erreur API IA : " + err.detail);
|
||||
}
|
||||
} catch (error) {} finally { isAiThinking.value = false; scrollToBottom(); nextTick(()=>lucide.createIcons()); }
|
||||
};
|
||||
|
||||
@@ -411,23 +468,19 @@
|
||||
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) {} };
|
||||
const limitWorkers = () => { if(selectedWorkers.value.length > 5) { selectedWorkers.value.pop(); alert("Max 5 travailleurs."); } };
|
||||
|
||||
onMounted(() => { lucide.createIcons(); fetchUser(); fetchProjects(); fetchModelsInfo(); });
|
||||
onMounted(() => { lucide.createIcons(); fetchUser(); fetchProjects(); fetchModelsInfo(); fetchFinances(); });
|
||||
|
||||
return {
|
||||
user, activeView, settingsTab, isSidebarOpen, toggleSidebar, prompt, autoResize, promptTextarea,
|
||||
projects, pinnedProjects, recentProjects, activeProject, messages, isAiThinking,
|
||||
createNewProject, selectProject, renameProject, sendMessage, isLoading, togglePin, deleteProject,
|
||||
passForm, settingsMessage, isSavingSettings, changePassword, uploadAvatar,
|
||||
modelInfo, filterSearch, filterDomain, filterPricing, filteredModels, formatDate, syncModels, isSyncing,
|
||||
modelInfo, financesList, filterSearch, filterDomain, filterPricing, filteredModels, formatDate, syncModels, isSyncing,
|
||||
selectedWorkers, selectedPrompter, selectedConcatenator, limitWorkers,
|
||||
exportProject, copyToClipboard, downloadFile, downloadMessage, parseMessage
|
||||
};
|
||||
}
|
||||
}).mount('#app');
|
||||
</script>
|
||||
<style>
|
||||
.custom-scrollbar::-webkit-scrollbar { width: 4px; }
|
||||
.custom-scrollbar::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }
|
||||
</style>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user