293 lines
15 KiB
PHP
293 lines
15 KiB
PHP
<?php
|
|
require_once('/opt/wevads/config/credentials.php');
|
|
/**
|
|
* WEVAL MIND - Dashboard Administration
|
|
* Gestion centralisée des widgets et stats
|
|
*/
|
|
$pdo = get_pdo('adx_system');
|
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
|
|
// Récupérer stats
|
|
$stats = [];
|
|
try {
|
|
$stats['mta_servers'] = $pdo->query("SELECT COUNT(*) FROM admin.mta_servers")->fetchColumn();
|
|
$stats['mta_active'] = $pdo->query("SELECT COUNT(*) FROM admin.mta_servers WHERE status='Activated'")->fetchColumn();
|
|
$stats['office_accounts'] = $pdo->query("SELECT COUNT(*) FROM admin.office_accounts")->fetchColumn();
|
|
$stats['office_domains'] = $pdo->query("SELECT COUNT(*) FROM admin.office_domains")->fetchColumn();
|
|
$stats['kb_entries'] = $pdo->query("SELECT COUNT(*) FROM admin.commonia_knowledge")->fetchColumn();
|
|
$stats['kb_articles'] = $pdo->query("SELECT COUNT(*) FROM admin.commonia_articles")->fetchColumn();
|
|
} catch (Exception $e) {}
|
|
|
|
// Config WEVAL MIND
|
|
$config = [];
|
|
try {
|
|
$stmt = $pdo->query("SELECT config_key, config_value FROM admin.commonia_config");
|
|
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
$config[$row['config_key']] = $row['config_value'];
|
|
}
|
|
} catch (Exception $e) {}
|
|
|
|
// Sauvegarder config
|
|
$msg = '';
|
|
if ($_POST && isset($_POST['save_hamid'])) {
|
|
$keys = ['default_provider', 'bot_name', 'welcome_message'];
|
|
foreach ($keys as $key) {
|
|
if (isset($_POST[$key])) {
|
|
$stmt = $pdo->prepare("INSERT INTO admin.commonia_config (config_key, config_value)
|
|
VALUES (?, ?) ON CONFLICT (config_key) DO UPDATE SET config_value = EXCLUDED.config_value");
|
|
$stmt->execute([$key, $_POST[$key]]);
|
|
}
|
|
}
|
|
$msg = '✅ Configuration sauvegardée!';
|
|
header("Location: ?saved=1");
|
|
exit;
|
|
}
|
|
if (isset($_GET['saved'])) $msg = '✅ Configuration sauvegardée!';
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>WEVAL MIND - Dashboard</title>
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
<style>
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%); min-height: 100vh; color: #e2e8f0; }
|
|
.container { max-width: 1400px; margin: 0 auto; padding: 20px; }
|
|
.header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 30px; padding: 20px; background: rgba(255,255,255,0.05); border-radius: 16px; border: 1px solid rgba(255,255,255,0.1); }
|
|
.header h1 { font-size: 28px; display: flex; align-items: center; gap: 12px; }
|
|
.header h1 .icon { font-size: 36px; }
|
|
.nav-links { display: flex; gap: 10px; }
|
|
.nav-links a { padding: 10px 20px; background: rgba(99, 102, 241, 0.2); color: #a5b4fc; text-decoration: none; border-radius: 8px; font-size: 14px; transition: all 0.3s; }
|
|
.nav-links a:hover { background: rgba(99, 102, 241, 0.4); }
|
|
|
|
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin-bottom: 30px; }
|
|
.card { background: rgba(255,255,255,0.05); border-radius: 16px; padding: 24px; border: 1px solid rgba(255,255,255,0.1); }
|
|
.card h3 { font-size: 14px; color: #94a3b8; margin-bottom: 16px; text-transform: uppercase; letter-spacing: 1px; }
|
|
|
|
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
|
|
.stat { text-align: center; padding: 16px; background: rgba(255,255,255,0.03); border-radius: 12px; }
|
|
.stat .value { font-size: 32px; font-weight: 700; color: #a78bfa; }
|
|
.stat .label { font-size: 12px; color: #64748b; margin-top: 4px; }
|
|
|
|
.widget-list { display: flex; flex-direction: column; gap: 12px; }
|
|
.widget-item { display: flex; align-items: center; justify-content: space-between; padding: 16px; background: rgba(255,255,255,0.03); border-radius: 12px; }
|
|
.widget-item .info { display: flex; align-items: center; gap: 12px; }
|
|
.widget-item .icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; }
|
|
.widget-item .icon.purple { background: linear-gradient(135deg, #8b5cf6, #6366f1); }
|
|
.widget-item .icon.cyan { background: linear-gradient(135deg, #06b6d4, #0891b2); }
|
|
.widget-item .icon.green { background: linear-gradient(135deg, #10b981, #059669); }
|
|
.widget-item .name { font-weight: 600; }
|
|
.widget-item .url { font-size: 11px; color: #64748b; font-family: monospace; }
|
|
.widget-item .actions a { padding: 8px 16px; background: rgba(99, 102, 241, 0.2); color: #a5b4fc; text-decoration: none; border-radius: 6px; font-size: 12px; margin-left: 8px; }
|
|
.widget-item .actions a:hover { background: rgba(99, 102, 241, 0.4); }
|
|
|
|
.form-group { margin-bottom: 16px; }
|
|
.form-group label { display: block; font-size: 13px; color: #94a3b8; margin-bottom: 6px; }
|
|
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 12px; background: rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; color: #e2e8f0; font-size: 14px; }
|
|
.form-group input:focus, .form-group select:focus { outline: none; border-color: #8b5cf6; }
|
|
.btn { padding: 12px 24px; background: linear-gradient(135deg, #8b5cf6, #6366f1); color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; }
|
|
.btn:hover { opacity: 0.9; }
|
|
|
|
.msg { padding: 12px 20px; background: rgba(16, 185, 129, 0.2); border: 1px solid rgba(16, 185, 129, 0.3); border-radius: 8px; color: #6ee7b7; margin-bottom: 20px; }
|
|
|
|
.providers-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
|
|
.provider { padding: 12px; background: rgba(255,255,255,0.03); border-radius: 8px; text-align: center; font-size: 12px; cursor: pointer; transition: all 0.3s; border: 2px solid transparent; }
|
|
.provider:hover { background: rgba(255,255,255,0.08); }
|
|
.provider.active { border-color: #8b5cf6; background: rgba(139, 92, 246, 0.1); }
|
|
.provider .icon { font-size: 24px; margin-bottom: 6px; }
|
|
|
|
.kb-stats { display: flex; gap: 20px; }
|
|
.kb-stat { flex: 1; padding: 20px; background: rgba(255,255,255,0.03); border-radius: 12px; text-align: center; }
|
|
.kb-stat .value { font-size: 36px; font-weight: 700; color: #22d3ee; }
|
|
.kb-stat .label { font-size: 12px; color: #64748b; }
|
|
</style>
|
|
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div class="header">
|
|
<h1><span class="icon">🧠</span> WEVAL MIND Dashboard</h1>
|
|
<div class="nav-links">
|
|
<a href="hamid-fullscreen.php"><i class="fas fa-expand"></i> Fullscreen</a>
|
|
<a href="hamid-widget.php"><i class="fas fa-comment"></i> Widget</a>
|
|
<a href="widget-admin.php"><i class="fas fa-cog"></i> Config Widget</a>
|
|
<a href="hamid-admin.php"><i class="fas fa-sliders-h"></i> Admin IA</a>
|
|
<a href="standalone-index.php"><i class="fas fa-home"></i> Index</a>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if ($msg): ?><div class="msg"><?= $msg ?></div><?php endif; ?>
|
|
|
|
<div class="grid">
|
|
<!-- Stats WEVAL -->
|
|
<div class="card">
|
|
<h3><i class="fas fa-chart-bar"></i> Statistiques WEVAL</h3>
|
|
<div class="stat-grid">
|
|
<div class="stat">
|
|
<div class="value"><?= $stats['mta_servers'] ?? 0 ?></div>
|
|
<div class="label">Serveurs MTA</div>
|
|
</div>
|
|
<div class="stat">
|
|
<div class="value"><?= $stats['mta_active'] ?? 0 ?></div>
|
|
<div class="label">MTA Actifs</div>
|
|
</div>
|
|
<div class="stat">
|
|
<div class="value"><?= number_format($stats['office_accounts'] ?? 0) ?></div>
|
|
<div class="label">Comptes Office</div>
|
|
</div>
|
|
<div class="stat">
|
|
<div class="value"><?= $stats['office_domains'] ?? 0 ?></div>
|
|
<div class="label">Domaines Office</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Knowledge Base -->
|
|
<div class="card">
|
|
<h3><i class="fas fa-brain"></i> Knowledge Base</h3>
|
|
<div class="kb-stats">
|
|
<div class="kb-stat">
|
|
<div class="value"><?= $stats['kb_entries'] ?? 0 ?></div>
|
|
<div class="label">Entrées KB</div>
|
|
</div>
|
|
<div class="kb-stat">
|
|
<div class="value"><?= $stats['kb_articles'] ?? 0 ?></div>
|
|
<div class="label">Articles</div>
|
|
</div>
|
|
</div>
|
|
<div style="margin-top:16px;text-align:center">
|
|
<a href="kb-admin.php" class="btn" style="display:inline-block;text-decoration:none"><i class="fas fa-edit"></i> Gérer KB</a>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Widgets WEVAL MIND -->
|
|
<div class="card">
|
|
<h3><i class="fas fa-puzzle-piece"></i> Widgets WEVAL MIND</h3>
|
|
<div class="widget-list">
|
|
<div class="widget-item">
|
|
<div class="info">
|
|
<div class="icon purple"><i class="fas fa-expand"></i></div>
|
|
<div>
|
|
<div class="name">WEVAL MIND Fullscreen</div>
|
|
<div class="url">/hamid-fullscreen.php</div>
|
|
</div>
|
|
</div>
|
|
<div class="actions">
|
|
<a href="hamid-fullscreen.php" target="_blank"><i class="fas fa-external-link-alt"></i></a>
|
|
</div>
|
|
</div>
|
|
<div class="widget-item">
|
|
<div class="info">
|
|
<div class="icon cyan"><i class="fas fa-comment-dots"></i></div>
|
|
<div>
|
|
<div class="name">Widget Standalone</div>
|
|
<div class="url">/hamid-widget.php</div>
|
|
</div>
|
|
</div>
|
|
<div class="actions">
|
|
<a href="hamid-widget.php" target="_blank"><i class="fas fa-external-link-alt"></i></a>
|
|
</div>
|
|
</div>
|
|
<div class="widget-item">
|
|
<div class="info">
|
|
<div class="icon green"><i class="fas fa-robot"></i></div>
|
|
<div>
|
|
<div class="name">Widget Flottant</div>
|
|
<div class="url">/includes/chatbot-widget.php</div>
|
|
</div>
|
|
</div>
|
|
<div class="actions">
|
|
<a href="widget-admin.php"><i class="fas fa-cog"></i> Config</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Config WEVAL MIND -->
|
|
<div class="card">
|
|
<h3><i class="fas fa-sliders-h"></i> Configuration WEVAL MIND</h3>
|
|
<form method="POST">
|
|
<div class="form-group">
|
|
<label>Nom du Bot</label>
|
|
<input type="text" name="bot_name" value="<?= htmlspecialchars($config['bot_name'] ?? 'WEVAL MIND') ?>">
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Message de Bienvenue</label>
|
|
<textarea name="welcome_message" rows="2"><?= htmlspecialchars($config['welcome_message'] ?? '') ?></textarea>
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Provider par Défaut</label>
|
|
<select name="default_provider">
|
|
<?php
|
|
$providers = ['cerebras','groq','sambanova','cloudflare','mistral','cohere','deepseek','claude','openai','gemini','ollama'];
|
|
foreach ($providers as $p):
|
|
$sel = ($config['default_provider'] ?? 'cerebras') === $p ? 'selected' : '';
|
|
?>
|
|
<option value="<?= $p ?>" <?= $sel ?>><?= ucfirst($p) ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</div>
|
|
<button type="submit" name="save_hamid" class="btn"><i class="fas fa-save"></i> Sauvegarder</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Test API -->
|
|
<div class="card">
|
|
<h3><i class="fas fa-vial"></i> Test API WEVAL MIND</h3>
|
|
<div style="display:flex;gap:16px;align-items:flex-end">
|
|
<div class="form-group" style="flex:1;margin:0">
|
|
<label>Message Test</label>
|
|
<input type="text" id="testMsg" value="Combien de serveurs MTA avons-nous?" placeholder="Entrez un message...">
|
|
</div>
|
|
<button class="btn" onclick="testWEVAL Mind()"><i class="fas fa-paper-plane"></i> Tester</button>
|
|
</div>
|
|
<div id="testResult" style="margin-top:16px;padding:16px;background:rgba(0,0,0,0.2);border-radius:8px;display:none">
|
|
<div id="testThinking" style="color:#a78bfa;font-size:13px;margin-bottom:12px"></div>
|
|
<div id="testResponse" style="color:#e2e8f0"></div>
|
|
<div id="testMeta" style="color:#64748b;font-size:12px;margin-top:8px"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
async function testWEVAL Mind() {
|
|
const msg = document.getElementById('testMsg').value;
|
|
const result = document.getElementById('testResult');
|
|
const thinking = document.getElementById('testThinking');
|
|
const response = document.getElementById('testResponse');
|
|
const meta = document.getElementById('testMeta');
|
|
|
|
result.style.display = 'block';
|
|
thinking.innerHTML = '⏳ Réflexion en cours...';
|
|
response.innerHTML = '';
|
|
meta.innerHTML = '';
|
|
|
|
try {
|
|
const r = await fetch('/hamid-api.php', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({message: msg, provider: 'cerebras', session_id: 'dashboard_test'})
|
|
});
|
|
const d = await r.json();
|
|
|
|
if (d.thinking) {
|
|
thinking.innerHTML = '✨ <b>Réflexion:</b><br>' + d.thinking.replace(/\n/g, '<br>');
|
|
} else {
|
|
thinking.innerHTML = '';
|
|
}
|
|
response.innerHTML = '<b>Réponse:</b><br>' + (d.response || d.error).replace(/\n/g, '<br>');
|
|
meta.innerHTML = '📊 Provider: ' + (d.provider || 'N/A') + ' | ⏱️ ' + (d.duration || 'N/A') + 'ms | 📚 KB: ' + (d.kb_count || 0) + ' sources';
|
|
} catch(e) {
|
|
response.innerHTML = '❌ Erreur: ' + e.message;
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<?php include("includes/chatbot-widget.php"); ?>
|
|
|
|
</body>
|
|
</html>
|