Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48f929a8f3 | ||
|
|
fd82d77709 |
No files matched your search
+10
-3
@@ -143,14 +143,21 @@ def get_messages(project_id: int, db: Session = Depends(get_db), current_user: U
|
||||
|
||||
@app.post("/api/projects/{project_id}/messages", response_model=List[MessageResponse])
|
||||
async def create_message(project_id: int, message: MessageCreate, db: Session = Depends(get_db), current_user: User = Depends(get_current_user)):
|
||||
db.add(Message(role=message.role, content=message.content, project_id=project_id)); db.commit()
|
||||
final_content = message.content
|
||||
if message.file_content and message.file_name:
|
||||
final_content = f"[Fichier attaché : {message.file_name}]\n```\n{message.file_content}\n```\n\n{message.content}"
|
||||
|
||||
db.add(Message(role=message.role, content=final_content, project_id=project_id))
|
||||
db.commit()
|
||||
|
||||
history = db.query(Message).filter(Message.project_id == project_id).order_by(Message.created_at.asc()).all()
|
||||
settings = db.query(SystemSettings).first()
|
||||
conf = message.config.dict() if message.config else {"workers": ["gemini-3.5-flash-lite"]}
|
||||
|
||||
ai_resp = await run_orchestrator(db, history, settings, conf) # Transmission de DB
|
||||
ai_resp = await run_orchestrator(db, history, settings, conf)
|
||||
|
||||
db.add(Message(role="assistant", content=ai_resp, project_id=project_id)); db.commit()
|
||||
db.add(Message(role="assistant", content=ai_resp, project_id=project_id))
|
||||
db.commit()
|
||||
return db.query(Message).filter(Message.project_id == project_id).order_by(Message.created_at.asc()).all()
|
||||
|
||||
# --- ROUTES MODÈLES & FINANCES ---
|
||||
|
||||
@@ -50,6 +50,8 @@ class MessageBase(BaseModel):
|
||||
|
||||
class MessageCreate(MessageBase):
|
||||
config: Optional[OrchestratorConfig] = None
|
||||
file_content: Optional[str] = None
|
||||
file_name: Optional[str] = None
|
||||
|
||||
class MessageResponse(MessageBase):
|
||||
id: int
|
||||
|
||||
+292
-7
@@ -101,7 +101,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="p-4 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="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>
|
||||
@@ -236,7 +236,7 @@
|
||||
<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>
|
||||
@@ -299,7 +299,7 @@
|
||||
<!-- 1. PAYANT / GRATUIT -->
|
||||
<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="filterPricing" class="w-full bg-aethas-dark border border-gray-700 rounded text-gray-200 text-[10px] p-1 outline-none">
|
||||
<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>
|
||||
@@ -309,7 +309,7 @@
|
||||
<!-- 2. TYPE (DOMAINE) -->
|
||||
<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="filterDomain" class="w-full bg-aethas-dark border border-gray-700 rounded text-gray-200 text-[10px] p-1 outline-none">
|
||||
<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>
|
||||
@@ -323,7 +323,7 @@
|
||||
<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 filteredBarModels" :key="m.model_id" :value="m.model_id">{{ m.name || m.model_id }}</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>
|
||||
|
||||
@@ -332,9 +332,294 @@
|
||||
<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 filteredBarModels" :key="m.model_id" :value="m.model_id">{{ m.name || m.model_id }}</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>
|
||||
|
||||
<!-- 5. TRAVAILLEUR 3 -->
|
||||
<div class="
|
||||
<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>
|
||||
|
||||
<!-- 6. TRAVAILLEUR 4 -->
|
||||
<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>
|
||||
|
||||
<!-- 7. TRAVAILLEUR 5 -->
|
||||
<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>
|
||||
|
||||
<!-- 8. PROMPTEUR -->
|
||||
<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="gemini-3.5-flash-lite">Gemini Flash</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>
|
||||
|
||||
<!-- 9. CONCATENEUR -->
|
||||
<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="gemini-3.5-flash-lite">Gemini Flash</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>
|
||||
|
||||
<!-- Champ de texte et boutons d'envoi / fichiers -->
|
||||
<div class="relative flex items-end bg-gray-800 border border-gray-600 rounded-2xl p-2 shadow-lg focus-within:border-aethas-cyan">
|
||||
<!-- Bouton d'import de fichiers -->
|
||||
<label class="p-3 text-gray-400 hover:text-aethas-cyan cursor-pointer transition-colors" title="Joindre un fichier (code, texte, script, etc.)">
|
||||
<i data-lucide="paperclip" class="w-5 h-5"></i>
|
||||
<input type="file" @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="attachedFile ? 'Fichier attaché : ' + attachedFile.name : 'Posez votre question ou glissez un fichier ici...'"></textarea>
|
||||
|
||||
<button v-if="attachedFile" @click="removeFile" class="p-2 text-red-400 hover:text-red-300 text-xs flex items-center gap-1 mr-2" title="Retirer le fichier"><i data-lucide="x-circle" class="w-4 h-4"></i></button>
|
||||
|
||||
<button @click="sendMessage" :disabled="(!prompt.trim() && !attachedFile) || 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>
|
||||
</template>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const { createApp, ref, reactive, onMounted, nextTick, computed } = 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 isSettingsModalOpen = ref(false);
|
||||
const settingsMessage = ref("");
|
||||
const passForm = reactive({ old: '', new: '', confirm: '' });
|
||||
|
||||
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 colPricing = ref("");
|
||||
const colDomain = ref("");
|
||||
|
||||
const workers = ref(["gemini-3.5-flash-lite", "", "", "", ""]);
|
||||
const selectedPrompter = ref("gemini-3.5-flash-lite");
|
||||
const selectedConcatenator = ref("gemini-3.5-flash-lite");
|
||||
|
||||
const attachedFile = ref(null);
|
||||
|
||||
const pinnedProjects = computed(() => projects.value.filter(p => p.is_pinned));
|
||||
const recentProjects = computed(() => projects.value.filter(p => !p.is_pinned));
|
||||
|
||||
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;
|
||||
let matchPrice = true;
|
||||
if (filterPricing.value === 'free') matchPrice = m.is_free;
|
||||
if (filterPricing.value === 'paid') matchPrice = !m.is_free;
|
||||
return matchSearch && matchDomain && matchPrice;
|
||||
});
|
||||
});
|
||||
|
||||
const getFilteredModelsForCol = (pricingFilter, domainFilter, currentSelectedId) => {
|
||||
return modelInfo.models.filter(m => {
|
||||
if (m.model_id === currentSelectedId) return true;
|
||||
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;
|
||||
});
|
||||
};
|
||||
|
||||
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 = () => { isSettingsModalOpen.value = true; nextTick(() => lucide.createIcons()); };
|
||||
const closeSettings = () => { isSettingsModalOpen.value = false; };
|
||||
|
||||
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;
|
||||
try {
|
||||
const res = await fetch('/api/models/sync', { method: 'POST' });
|
||||
if(res.ok) {
|
||||
await fetchModelsInfo();
|
||||
await fetchFinances();
|
||||
alert("Synchronisation réussie !");
|
||||
} 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 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 file = event.target.files[0];
|
||||
if (!file) return;
|
||||
processFile(file);
|
||||
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) processFile(file);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const processFile = (file) => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = (e) => {
|
||||
attachedFile.value = { name: file.name, content: e.target.result };
|
||||
};
|
||||
reader.readAsText(file);
|
||||
};
|
||||
|
||||
const removeFile = () => { attachedFile.value = null; };
|
||||
|
||||
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) => { let fname = hint ? hint.trim() : 'code.txt'; if (!fname.includes('.')) fname += '.txt'; const blob = new Blob([content], { type: 'text/plain;charset=utf-8' }); 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 = []; try { const res = await fetch(`/api/projects/${project.id}/messages`); if(res.ok) { messages.value = await res.json(); scrollToBottom(); nextTick(()=>lucide.createIcons()); } } catch(e){} };
|
||||
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); } } catch(e){} finally{isLoading.value = false;} };
|
||||
|
||||
const sendMessage = async () => {
|
||||
const activeWorkers = workers.value.filter(w => w && w.trim() !== "");
|
||||
if ((!prompt.value.trim() && !attachedFile.value) || !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();
|
||||
|
||||
messages.value.push({ id: Date.now(), role: 'user', content: userText + (attachedFile.value ? `\n[Fichier joint: ${attachedFile.value.name}]` : "") });
|
||||
isAiThinking.value = true;
|
||||
scrollToBottom();
|
||||
|
||||
const payload = {
|
||||
role: 'user',
|
||||
content: userText || "Analyse ce fichier joint.",
|
||||
config: {
|
||||
workers: activeWorkers,
|
||||
prompter: selectedPrompter.value,
|
||||
concatenator: selectedConcatenator.value
|
||||
},
|
||||
file_content: attachedFile.value ? attachedFile.value.content : null,
|
||||
file_name: attachedFile.value ? attachedFile.value.name : null
|
||||
};
|
||||
|
||||
// DESTRUCTION IMMÉDIATE DU FICHIER CÔTÉ FRONTEND APRÈS ENVOI
|
||||
attachedFile.value = null;
|
||||
|
||||
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 {
|
||||
const err = await response.json(); alert("Erreur API IA : " + err.detail);
|
||||
}
|
||||
} catch (error) {} finally { isAiThinking.value = false; scrollToBottom(); nextTick(()=>lucide.createIcons()); }
|
||||
};
|
||||
|
||||
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(); fetchFinances(); });
|
||||
|
||||
return {
|
||||
user, activeView, settingsTab, isSidebarOpen, toggleSidebar, prompt, autoResize, promptTextarea,
|
||||
projects, pinnedProjects, recentProjects, activeProject, messages, isAiThinking,
|
||||
createNewProject, selectProject, renameProject, sendMessage, isLoading, togglePin, deleteProject,
|
||||
isSettingsModalOpen, openSettings, closeSettings, passForm, settingsMessage, isSavingSettings, changePassword, uploadAvatar,
|
||||
modelInfo, financesList, filterSearch, filterDomain, filterPricing, filteredModels, getFilteredModelsForCol, formatDate, syncModels, isSyncing,
|
||||
workers, selectedPrompter, selectedConcatenator, colPricing, colDomain,
|
||||
attachedFile, handleFileUpload, handlePaste, removeFile,
|
||||
exportProject, copyToClipboard, downloadFile, downloadMessage, parseMessage
|
||||
};
|
||||
}
|
||||
}).mount('#app');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user