Initial commit

This commit is contained in:
Orionis312050 committed 2026-04-16 14:18:56 +02:00
commit e6e07dc5c2
30 files changed
+5948

No files matched your search

+104
View File
@@ -0,0 +1,104 @@
import React, { useState, useEffect } from 'react';
import { createPortal } from 'react-dom';
export default function SettingsModal({ onClose }: { onClose: () => void }) {
const [formData, setFormData] = useState({
notionToken: '',
notionDbId: '',
ollamaUrl: '',
ollamaModel: '',
searxngUrl: ''
});
const [saved, setSaved] = useState(false);
useEffect(() => {
fetch('http://localhost:3001/api/settings', {
credentials: 'include'
})
.then(res => res.json())
.then(data => {
if (data) {
setFormData({
notionToken: data.notionToken || '',
notionDbId: data.notionDbId || '',
ollamaUrl: data.ollamaUrl || '',
ollamaModel: data.ollamaModel || '',
searxngUrl: data.searxngUrl || ''
});
}
})
.catch(console.error);
}, []);
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
try {
await fetch('http://localhost:3001/api/settings', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
credentials: 'include',
body: JSON.stringify(formData)
});
setSaved(true);
setTimeout(() => setSaved(false), 3000);
} catch (err) {
console.error(err);
}
};
return createPortal(
<div className="modal-overlay" onClick={onClose}>
<div className="glass-panel modal-content" onClick={e => e.stopPropagation()}>
<form onSubmit={handleSubmit} style={{ maxHeight: '90vh', overflowY: 'auto' }}>
<h2 style={{ marginBottom: '1.5rem', color: 'var(--text-main)' }}>Paramètres Globaux</h2>
<div style={{ padding: '1.5rem', background: 'rgba(59, 130, 246, 0.05)', borderRadius: '8px', border: '1px solid rgba(59, 130, 246, 0.2)', marginBottom: '1.5rem' }}>
<h4 style={{ fontSize: '1rem', marginBottom: '1rem', color: 'var(--text-main)' }}>Intégration Notion</h4>
<div className="form-group">
<label>Token d'intégration Notion (Internal App)</label>
<input type="password" className="form-control" value={formData.notionToken} onChange={e => setFormData({...formData, notionToken: e.target.value})} placeholder="secret_..." />
</div>
<div className="form-group" style={{ marginBottom: 0 }}>
<label>ID de la base de données (Database ID)</label>
<input type="text" className="form-control" value={formData.notionDbId} onChange={e => setFormData({...formData, notionDbId: e.target.value})} placeholder="ex: a1b2c3d4e5f6..." />
</div>
</div>
<div style={{ padding: '1.5rem', background: 'rgba(16, 185, 129, 0.05)', borderRadius: '8px', border: '1px solid rgba(16, 185, 129, 0.2)', marginBottom: '1.5rem' }}>
<h4 style={{ fontSize: '1rem', marginBottom: '1rem', color: 'var(--text-main)' }}>Intégration IA (Ollama Local)</h4>
<div className="form-group">
<label>URL de l'API Ollama</label>
<input type="text" className="form-control" value={formData.ollamaUrl} onChange={e => setFormData({...formData, ollamaUrl: e.target.value})} placeholder="ex: http://localhost:11434" />
</div>
<div className="form-group" style={{ marginBottom: 0 }}>
<label>Nom du modèle (ex: qwen:7b, llama3)</label>
<input type="text" className="form-control" value={formData.ollamaModel} onChange={e => setFormData({...formData, ollamaModel: e.target.value})} placeholder="ex: qwen:7b" />
</div>
</div>
<div style={{ padding: '1.5rem', background: 'rgba(234, 179, 8, 0.05)', borderRadius: '8px', border: '1px solid rgba(234, 179, 8, 0.2)', marginBottom: '1.5rem' }}>
<h4 style={{ fontSize: '1rem', marginBottom: '1rem', color: 'var(--text-main)' }}>Recherche Web (SearXNG)</h4>
<div className="form-group" style={{ marginBottom: 0 }}>
<label>URL de SearXNG (pour enrichir l'IA)</label>
<input type="text" className="form-control" value={formData.searxngUrl} onChange={e => setFormData({...formData, searxngUrl: e.target.value})} placeholder="ex: http://localhost:8080" />
</div>
</div>
<div style={{ display: 'flex', justifyContent: 'flex-end', gap: '1rem', alignItems: 'center' }}>
{saved && <span style={{ color: 'var(--success-color)', fontSize: '0.875rem' }}>Sauvegardé !</span>}
<button type="button" className="btn" onClick={onClose}>Fermer</button>
<button type="submit" className="btn btn-primary">Enregistrer</button>
</div>
</form>
</div>
</div>,
document.body
);
}