Add JWT authentication with user/password login, role-based access control, and Bearer token support while maintaining legacy API key compatibility for transition; update README with comprehensive JWT security guidelines, installation instructions for Python/SSH, development startup scripts (.env, run_dev.sh/ps1), and migrate all API examples to JWT authentication; update Ansible inventory SSH key paths from Docker container paths to local user paths

This commit is contained in:
2025-12-14 17:33:34 -05:00
parent 5a512d39b5
commit 0030fcc101
177 changed files with 22810 additions and 289 deletions
+602 -50
View File
@@ -2548,6 +2548,197 @@
</style>
</head>
<body>
<!-- Login Screen - shown when not authenticated -->
<div id="login-screen" class="fixed inset-0 bg-black z-[100] flex items-center justify-center hidden">
<div class="max-w-md w-full mx-4">
<!-- Login Form -->
<div id="login-form-container" class="glass-card p-8">
<div class="text-center mb-8">
<div class="w-16 h-16 bg-gradient-to-br from-purple-600 to-blue-600 rounded-2xl flex items-center justify-center mx-auto mb-4">
<i class="fas fa-server text-white text-2xl"></i>
</div>
<h1 class="text-2xl font-bold gradient-text mb-2">Homelab Dashboard</h1>
<p class="text-gray-400">Connectez-vous pour continuer</p>
</div>
<form id="login-form" onsubmit="handleLogin(event)" class="space-y-6">
<div>
<label for="login-username" class="block text-sm font-medium text-gray-300 mb-2">
<i class="fas fa-user mr-2"></i>Nom d'utilisateur
</label>
<input
type="text"
id="login-username"
name="username"
required
autocomplete="username"
class="w-full px-4 py-3 bg-gray-800 border border-gray-700 rounded-lg text-white placeholder-gray-500 focus:border-purple-500 focus:ring-1 focus:ring-purple-500 transition-colors"
placeholder="Entrez votre nom d'utilisateur"
>
</div>
<div>
<label for="login-password" class="block text-sm font-medium text-gray-300 mb-2">
<i class="fas fa-lock mr-2"></i>Mot de passe
</label>
<div class="relative">
<input
type="password"
id="login-password"
name="password"
required
autocomplete="current-password"
class="w-full px-4 py-3 bg-gray-800 border border-gray-700 rounded-lg text-white placeholder-gray-500 focus:border-purple-500 focus:ring-1 focus:ring-purple-500 transition-colors pr-12"
placeholder="Entrez votre mot de passe"
>
<button
type="button"
onclick="togglePasswordVisibility('login-password', this)"
class="absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-300"
>
<i class="fas fa-eye"></i>
</button>
</div>
</div>
<div id="login-error" class="hidden text-red-400 text-sm bg-red-900/20 border border-red-800 rounded-lg p-3">
<i class="fas fa-exclamation-circle mr-2"></i>
<span id="login-error-text"></span>
</div>
<button
type="submit"
id="login-submit-btn"
class="w-full btn-primary py-3 flex items-center justify-center gap-2"
>
<i class="fas fa-sign-in-alt"></i>
<span>Se connecter</span>
</button>
</form>
</div>
<!-- Setup Form (first user creation) -->
<div id="setup-form-container" class="glass-card p-8 hidden">
<div class="text-center mb-8">
<div class="w-16 h-16 bg-gradient-to-br from-green-600 to-emerald-600 rounded-2xl flex items-center justify-center mx-auto mb-4">
<i class="fas fa-user-plus text-white text-2xl"></i>
</div>
<h1 class="text-2xl font-bold gradient-text mb-2">Configuration Initiale</h1>
<p class="text-gray-400">Créez votre compte administrateur</p>
</div>
<form id="setup-form" onsubmit="handleSetup(event)" class="space-y-5">
<div>
<label for="setup-username" class="block text-sm font-medium text-gray-300 mb-2">
<i class="fas fa-user mr-2"></i>Nom d'utilisateur *
</label>
<input
type="text"
id="setup-username"
name="username"
required
minlength="3"
maxlength="50"
autocomplete="username"
class="w-full px-4 py-3 bg-gray-800 border border-gray-700 rounded-lg text-white placeholder-gray-500 focus:border-purple-500 focus:ring-1 focus:ring-purple-500 transition-colors"
placeholder="admin"
>
</div>
<div>
<label for="setup-password" class="block text-sm font-medium text-gray-300 mb-2">
<i class="fas fa-lock mr-2"></i>Mot de passe *
</label>
<div class="relative">
<input
type="password"
id="setup-password"
name="password"
required
minlength="6"
autocomplete="new-password"
class="w-full px-4 py-3 bg-gray-800 border border-gray-700 rounded-lg text-white placeholder-gray-500 focus:border-purple-500 focus:ring-1 focus:ring-purple-500 transition-colors pr-12"
placeholder="Minimum 6 caractères"
>
<button
type="button"
onclick="togglePasswordVisibility('setup-password', this)"
class="absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-300"
>
<i class="fas fa-eye"></i>
</button>
</div>
</div>
<div>
<label for="setup-password-confirm" class="block text-sm font-medium text-gray-300 mb-2">
<i class="fas fa-lock mr-2"></i>Confirmer le mot de passe *
</label>
<input
type="password"
id="setup-password-confirm"
name="password_confirm"
required
minlength="6"
autocomplete="new-password"
class="w-full px-4 py-3 bg-gray-800 border border-gray-700 rounded-lg text-white placeholder-gray-500 focus:border-purple-500 focus:ring-1 focus:ring-purple-500 transition-colors"
placeholder="Confirmez votre mot de passe"
>
</div>
<div>
<label for="setup-email" class="block text-sm font-medium text-gray-300 mb-2">
<i class="fas fa-envelope mr-2"></i>Email (optionnel)
</label>
<input
type="email"
id="setup-email"
name="email"
autocomplete="email"
class="w-full px-4 py-3 bg-gray-800 border border-gray-700 rounded-lg text-white placeholder-gray-500 focus:border-purple-500 focus:ring-1 focus:ring-purple-500 transition-colors"
placeholder="[email protected]"
>
</div>
<div>
<label for="setup-display-name" class="block text-sm font-medium text-gray-300 mb-2">
<i class="fas fa-id-card mr-2"></i>Nom d'affichage (optionnel)
</label>
<input
type="text"
id="setup-display-name"
name="display_name"
maxlength="100"
class="w-full px-4 py-3 bg-gray-800 border border-gray-700 rounded-lg text-white placeholder-gray-500 focus:border-purple-500 focus:ring-1 focus:ring-purple-500 transition-colors"
placeholder="Administrateur"
>
</div>
<div id="setup-error" class="hidden text-red-400 text-sm bg-red-900/20 border border-red-800 rounded-lg p-3">
<i class="fas fa-exclamation-circle mr-2"></i>
<span id="setup-error-text"></span>
</div>
<button
type="submit"
id="setup-submit-btn"
class="w-full btn-primary py-3 flex items-center justify-center gap-2"
>
<i class="fas fa-user-plus"></i>
<span>Créer le compte</span>
</button>
</form>
</div>
<p class="text-center text-gray-500 text-sm mt-6">
Homelab Automation Dashboard v1.0
</p>
</div>
</div>
<!-- Main Content Wrapper -->
<div id="main-content">
<!-- Loading indicator - will be hidden when JS loads -->
<div id="page-loading" style="position:fixed;inset:0;background:#0a0a0a;display:flex;flex-direction:column;align-items:center;justify-content:center;z-index:9999;">
<div style="width:50px;height:50px;border:3px solid #333;border-top-color:#7c3aed;border-radius:50%;animation:spin 1s linear infinite;"></div>
@@ -2610,16 +2801,28 @@
<i class="fas fa-file-alt"></i>
<span>Logs</span>
</button>
<button type="button" data-page="alerts" class="mobile-nav-link" onclick="mobileNavigateTo('alerts'); return false;">
<i class="fas fa-bell"></i>
<span>Alertes</span>
</button>
<button type="button" data-page="configuration" class="mobile-nav-link" onclick="mobileNavigateTo('configuration'); return false;">
<i class="fas fa-sliders-h"></i>
<span>Configuration</span>
</button>
<button type="button" data-page="help" class="mobile-nav-link" onclick="mobileNavigateTo('help'); return false;">
<i class="fas fa-question-circle"></i>
<span>Aide</span>
</button>
</nav>
<div class="p-4 border-t border-gray-700">
<div class="p-4 border-t border-gray-700 space-y-3">
<button type="button" id="mobile-theme-toggle" onclick="toggleTheme()" class="w-full flex items-center justify-center gap-2 p-3 bg-gray-800 rounded-lg hover:bg-gray-700 transition-colors">
<i class="fas fa-moon text-gray-300" id="mobile-theme-icon"></i>
<span class="text-sm text-gray-300" id="mobile-theme-label">Thème sombre</span>
</button>
<button type="button" onclick="handleLogout(); closeMobileNav();" class="w-full flex items-center justify-center gap-2 p-3 bg-red-900/30 border border-red-800 rounded-lg hover:bg-red-900/50 transition-colors">
<i class="fas fa-sign-out-alt text-red-400"></i>
<span class="text-sm text-red-400">Déconnexion</span>
</button>
</div>
</aside>
@@ -2644,10 +2847,40 @@
<a href="#" data-page="tasks" class="nav-link text-gray-300 hover:text-white transition-colors">Tasks</a>
<a href="#" data-page="schedules" class="nav-link text-gray-300 hover:text-white transition-colors">Schedules</a>
<a href="#" data-page="logs" class="nav-link text-gray-300 hover:text-white transition-colors">Logs</a>
<a href="#" data-page="alerts" class="nav-link text-gray-300 hover:text-white transition-colors">Alertes</a>
<a href="#" data-page="configuration" class="nav-link text-gray-300 hover:text-white transition-colors">Configuration</a>
<a href="#" data-page="help" class="nav-link text-gray-300 hover:text-white transition-colors">Aide</a>
<button id="theme-toggle" class="p-2 rounded-lg bg-gray-800 hover:bg-gray-700 transition-colors touch-target">
<i class="fas fa-moon text-gray-300"></i>
</button>
<button id="alerts-button" class="relative p-2 rounded-lg bg-gray-800 hover:bg-gray-700 transition-colors touch-target" onclick="navigateTo('alerts')" title="Alertes">
<i class="fas fa-bell text-gray-300"></i>
<span id="alerts-badge" class="hidden absolute -top-1 -right-1 min-w-[18px] h-[18px] px-1 bg-red-600 text-white text-[10px] leading-[18px] rounded-full text-center"></span>
</button>
<!-- User Menu -->
<div class="relative group">
<button class="flex items-center gap-2 p-2 rounded-lg bg-gray-800 hover:bg-gray-700 transition-colors">
<i class="fas fa-user-circle text-gray-300"></i>
<span id="current-user-name" class="text-sm text-gray-300 hidden lg:inline"></span>
<i class="fas fa-chevron-down text-xs text-gray-500"></i>
</button>
<div class="absolute right-0 mt-2 w-48 bg-gray-800 border border-gray-700 rounded-lg shadow-xl opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all z-50">
<div class="p-3 border-b border-gray-700">
<p class="text-sm font-medium text-white" id="user-menu-name">Utilisateur</p>
<p class="text-xs text-gray-400" id="current-user-role">Admin</p>
</div>
<div class="p-2">
<button type="button" onclick="navigateTo('configuration')" class="w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-200 hover:bg-gray-700 rounded-lg transition-colors">
<i class="fas fa-sliders-h text-gray-300"></i>
<span>Configuration</span>
</button>
<button onclick="handleLogout()" class="w-full flex items-center gap-2 px-3 py-2 text-sm text-red-400 hover:bg-gray-700 rounded-lg transition-colors">
<i class="fas fa-sign-out-alt"></i>
<span>Déconnexion</span>
</button>
</div>
</div>
</div>
</div>
<!-- Mobile Menu Button -->
@@ -2721,27 +2954,85 @@
<!-- Mobile: Quick Actions first, then schedules -->
<div class="grid grid-cols-1 lg:grid-cols-3 gap-4 sm:gap-8">
<!-- Quick Actions - Show first on mobile -->
<div class="glass-card p-4 sm:p-6 fade-in order-1 lg:order-2">
<h3 class="text-lg sm:text-xl font-semibold mb-4 sm:mb-6">Actions Rapides</h3>
<!-- Mobile: 2x2 grid, Desktop: vertical stack -->
<div class="grid grid-cols-2 lg:grid-cols-1 gap-2 sm:gap-4">
<button type="button" class="w-full p-3 sm:p-4 bg-gradient-to-r from-green-600 to-green-700 rounded-lg text-left hover:from-green-500 hover:to-green-600 transition-all flex items-center" onclick="executeTask('upgrade-all')">
<i class="fas fa-arrow-up mr-2 sm:mr-3 text-sm sm:text-base"></i>
<span class="text-xs sm:text-sm lg:text-base">Mise à jour</span>
</button>
<button type="button" class="w-full p-3 sm:p-4 bg-gradient-to-r from-blue-600 to-blue-700 rounded-lg text-left hover:from-blue-500 hover:to-blue-600 transition-all flex items-center" onclick="executeTask('reboot-all')">
<i class="fas fa-redo mr-2 sm:mr-3 text-sm sm:text-base"></i>
<span class="text-xs sm:text-sm lg:text-base">Redémarrer</span>
</button>
<button type="button" class="w-full p-3 sm:p-4 bg-gradient-to-r from-purple-600 to-purple-700 rounded-lg text-left hover:from-purple-500 hover:to-purple-600 transition-all flex items-center" onclick="executeTask('health-check')">
<i class="fas fa-heartbeat mr-2 sm:mr-3 text-sm sm:text-base"></i>
<span class="text-xs sm:text-sm lg:text-base">Santé</span>
</button>
<button type="button" class="w-full p-3 sm:p-4 bg-gradient-to-r from-orange-600 to-orange-700 rounded-lg text-left hover:from-orange-500 hover:to-orange-600 transition-all flex items-center" onclick="executeTask('backup')">
<i class="fas fa-save mr-2 sm:mr-3 text-sm sm:text-base"></i>
<span class="text-xs sm:text-sm lg:text-base">Backup</span>
<!-- Console Ad-Hoc Widget + Quick Actions - Stacked on right column -->
<div class="flex flex-col gap-4 sm:gap-6 order-1 lg:order-2">
<!-- Console Ad-Hoc Ansible Widget -->
<div class="glass-card p-4 sm:p-6 fade-in">
<div class="flex items-center justify-between mb-4">
<h3 class="text-base sm:text-lg font-semibold flex items-center">
<i class="fas fa-terminal text-purple-400 mr-2"></i>
Console Ad-Hoc
</h3>
<div class="flex items-center gap-2">
<span id="adhoc-widget-count" class="text-xs text-gray-500 hidden sm:inline"></span>
</div>
</div>
<!-- Bouton principal Console -->
<button type="button" onclick="dashboard.showAdHocConsole()"
class="w-full p-3 sm:p-4 bg-gradient-to-r from-purple-600 to-purple-700 rounded-lg hover:from-purple-500 hover:to-purple-600 transition-all flex items-center justify-center mb-4 group">
<i class="fas fa-terminal mr-2 sm:mr-3 text-sm sm:text-base group-hover:animate-pulse"></i>
<span class="text-sm sm:text-base font-medium">Console Ad-Hoc</span>
</button>
<!-- Mini stats -->
<div class="grid grid-cols-3 gap-2 mb-4">
<div class="text-center p-2 bg-gray-800/50 rounded">
<div class="text-sm sm:text-base font-bold text-green-400" id="adhoc-widget-success">0</div>
<div class="text-[9px] sm:text-xs text-gray-500">Succès</div>
</div>
<div class="text-center p-2 bg-gray-800/50 rounded">
<div class="text-sm sm:text-base font-bold text-red-400" id="adhoc-widget-failed">0</div>
<div class="text-[9px] sm:text-xs text-gray-500">Échecs</div>
</div>
<div class="text-center p-2 bg-gray-800/50 rounded">
<div class="text-sm sm:text-base font-bold text-purple-400" id="adhoc-widget-total">0</div>
<div class="text-[9px] sm:text-xs text-gray-500">Total</div>
</div>
</div>
<!-- Historique récent -->
<div class="border-t border-gray-700/50 pt-3">
<div class="flex items-center justify-between mb-2">
<span class="text-xs text-gray-400 uppercase tracking-wide">
<i class="fas fa-history mr-1"></i>Dernières exécutions
</span>
</div>
<div id="adhoc-widget-history" class="space-y-2 max-h-48 overflow-y-auto">
<p class="text-xs text-gray-500 text-center py-3">
<i class="fas fa-spinner fa-spin mr-1"></i>Chargement...
</p>
</div>
<button type="button" onclick="dashboard.loadMoreAdhocHistory()"
id="adhoc-widget-load-more"
class="w-full mt-3 p-2 text-xs text-purple-400 hover:text-purple-300 hover:bg-purple-900/20 rounded transition-colors hidden">
<i class="fas fa-chevron-down mr-1"></i>Charger plus
</button>
</div>
</div>
<!-- Quick Actions - Now below Ad-Hoc widget -->
<div class="glass-card p-4 sm:p-6 fade-in">
<h3 class="text-lg sm:text-xl font-semibold mb-4 sm:mb-6">Actions Rapides</h3>
<!-- Mobile: 2x2 grid, Desktop: vertical stack -->
<div class="grid grid-cols-2 lg:grid-cols-1 gap-2 sm:gap-4">
<button type="button" class="w-full p-3 sm:p-4 bg-gradient-to-r from-green-600 to-green-700 rounded-lg text-left hover:from-green-500 hover:to-green-600 transition-all flex items-center" onclick="executeTask('upgrade-all')">
<i class="fas fa-arrow-up mr-2 sm:mr-3 text-sm sm:text-base"></i>
<span class="text-xs sm:text-sm lg:text-base">Mise à jour</span>
</button>
<button type="button" class="w-full p-3 sm:p-4 bg-gradient-to-r from-blue-600 to-blue-700 rounded-lg text-left hover:from-blue-500 hover:to-blue-600 transition-all flex items-center" onclick="executeTask('reboot-all')">
<i class="fas fa-redo mr-2 sm:mr-3 text-sm sm:text-base"></i>
<span class="text-xs sm:text-sm lg:text-base">Redémarrer</span>
</button>
<button type="button" class="w-full p-3 sm:p-4 bg-gradient-to-r from-purple-600 to-purple-700 rounded-lg text-left hover:from-purple-500 hover:to-purple-600 transition-all flex items-center" onclick="executeTask('health-check')">
<i class="fas fa-heartbeat mr-2 sm:mr-3 text-sm sm:text-base"></i>
<span class="text-xs sm:text-sm lg:text-base">Santé</span>
</button>
<button type="button" class="w-full p-3 sm:p-4 bg-gradient-to-r from-orange-600 to-orange-700 rounded-lg text-left hover:from-orange-500 hover:to-orange-600 transition-all flex items-center" onclick="executeTask('backup')">
<i class="fas fa-save mr-2 sm:mr-3 text-sm sm:text-base"></i>
<span class="text-xs sm:text-sm lg:text-base">Backup</span>
</button>
</div>
</div>
</div>
@@ -3266,6 +3557,104 @@
</section>
<!-- END PAGE: SCHEDULES -->
<section id="page-alerts" class="page-section">
<div class="pt-20 sm:pt-24 pb-8 sm:pb-16 min-h-screen bg-gradient-to-b from-gray-900 to-black">
<div class="max-w-7xl mx-auto px-4 sm:px-6">
<div class="text-center mb-6 sm:mb-12">
<h1 class="text-2xl sm:text-3xl md:text-4xl font-bold mb-2 sm:mb-4 gradient-text">
<i class="fas fa-bell mr-2 sm:mr-3"></i>Centre d'Alertes
</h1>
<p class="text-sm sm:text-base text-gray-400 px-4">Tous les messages reçus (toasts) avec statut lu/non-lu, date et catégorie</p>
</div>
<div class="glass-card p-4 sm:p-6 fade-in">
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-4 sm:mb-6">
<h3 class="text-lg sm:text-xl font-semibold">Messages</h3>
<div class="flex gap-2 sm:gap-3">
<button type="button" class="flex-1 sm:flex-none px-3 sm:px-4 py-2 bg-gray-700 rounded-lg hover:bg-gray-600 transition-colors text-sm touch-target" onclick="dashboard.refreshAlerts()">
<i class="fas fa-sync-alt mr-1 sm:mr-2"></i>
<span class="hidden sm:inline">Rafraîchir</span>
</button>
<button type="button" class="flex-1 sm:flex-none px-3 sm:px-4 py-2 bg-purple-600 rounded-lg hover:bg-purple-500 transition-colors text-sm touch-target" onclick="dashboard.markAllAlertsRead()">
<i class="fas fa-check-double mr-1 sm:mr-2"></i>
<span class="hidden sm:inline">Tout marquer lu</span>
</button>
</div>
</div>
<div id="alerts-container" class="space-y-2 max-h-[600px] overflow-y-auto">
</div>
</div>
</div>
</div>
</section>
<section id="page-configuration" class="page-section">
<div class="pt-20 sm:pt-24 pb-8 sm:pb-16 min-h-screen bg-gradient-to-b from-gray-900 to-black">
<div class="max-w-7xl mx-auto px-4 sm:px-6">
<div class="text-center mb-6 sm:mb-12">
<h1 class="text-2xl sm:text-3xl md:text-4xl font-bold mb-2 sm:mb-4 gradient-text">
<i class="fas fa-sliders-h mr-2 sm:mr-3"></i>Configuration
</h1>
<p class="text-sm sm:text-base text-gray-400 px-4">Paramètres et outils d'administration</p>
</div>
<div class="glass-card p-4 sm:p-6 fade-in">
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-4 sm:mb-6">
<h3 class="text-lg sm:text-xl font-semibold">Outils de base</h3>
<div class="flex gap-2 sm:gap-3">
<button type="button" class="flex-1 sm:flex-none px-3 sm:px-4 py-2 bg-purple-600 rounded-lg hover:bg-purple-500 transition-colors text-sm touch-target" onclick="dashboard.installBaseToolsAllHosts()">
<i class="fas fa-tools mr-1 sm:mr-2"></i>
<span class="hidden sm:inline">Installer sur tous les hôtes</span>
<span class="sm:hidden">Installer</span>
</button>
</div>
</div>
<div class="p-3 bg-gray-800/40 border border-gray-700 rounded-lg text-sm text-gray-300">
<div class="flex gap-2">
<i class="fas fa-info-circle text-blue-400 mt-0.5"></i>
<div>
<p class="font-medium">Ce bouton exécute un builtin playbook d'installation</p>
<p class="text-gray-400">Installe notamment: coreutils, util-linux (lsblk), gawk/grep, python3, iproute2/procps, et optionnels: lvm2, lm-sensors, zfsutils-linux.</p>
</div>
</div>
</div>
</div>
<div class="glass-card p-4 sm:p-6 mt-6 fade-in">
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-4 sm:mb-6">
<h3 class="text-lg sm:text-xl font-semibold">Collecte des métriques</h3>
<div class="flex gap-2 sm:gap-3">
<button type="button" id="metrics-collection-save" class="flex-1 sm:flex-none px-3 sm:px-4 py-2 bg-purple-600 rounded-lg hover:bg-purple-500 transition-colors text-sm touch-target">
<i class="fas fa-save mr-1 sm:mr-2"></i>
<span class="hidden sm:inline">Sauvegarder</span>
<span class="sm:hidden">OK</span>
</button>
</div>
</div>
<div class="space-y-3">
<div>
<label class="block text-sm text-gray-400 mb-1">Période de collecte</label>
<select id="metrics-collection-interval" class="w-full px-4 py-2 bg-gray-800 border border-gray-700 rounded-lg">
<option value="off">off</option>
<option value="5min">5 min</option>
<option value="15min">15 min</option>
<option value="30min">30 min</option>
<option value="1h">1 h</option>
<option value="6h">6 h</option>
<option value="12h">12 h</option>
<option value="24h">24 h</option>
</select>
<p class="text-xs text-gray-500 mt-1" id="metrics-collection-current">Chargement…</p>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- ==================== PAGE: LOGS ==================== -->
<section id="page-logs" class="page-section">
<div id="logs" class="pt-20 sm:pt-24 pb-8 sm:pb-16 min-h-screen bg-gradient-to-b from-black to-gray-900">
@@ -3280,7 +3669,18 @@
<div class="glass-card p-4 sm:p-6 fade-in">
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-4 sm:mb-6">
<h3 class="text-lg sm:text-xl font-semibold">Logs Récentes</h3>
<div class="flex gap-2 sm:gap-3">
<div class="flex flex-col sm:flex-row gap-2 sm:gap-3">
<div class="flex gap-2">
<button type="button" class="flex-1 sm:flex-none px-3 sm:px-4 py-2 bg-gray-800 border border-gray-700 rounded-lg hover:bg-gray-700 transition-colors text-sm touch-target" onclick="dashboard.setLogsView('server')">
<i class="fas fa-terminal mr-1 sm:mr-2"></i>
<span class="hidden sm:inline">Console</span>
</button>
<button type="button" class="flex-1 sm:flex-none px-3 sm:px-4 py-2 bg-gray-800 border border-gray-700 rounded-lg hover:bg-gray-700 transition-colors text-sm touch-target" onclick="dashboard.setLogsView('db')">
<i class="fas fa-database mr-1 sm:mr-2"></i>
<span class="hidden sm:inline">BD</span>
</button>
</div>
<div class="flex gap-2 sm:gap-3">
<button type="button" class="flex-1 sm:flex-none px-3 sm:px-4 py-2 bg-gray-700 rounded-lg hover:bg-gray-600 transition-colors text-sm touch-target" onclick="dashboard.clearLogs()">
<i class="fas fa-trash mr-1 sm:mr-2"></i>
<span class="hidden sm:inline">Effacer</span>
@@ -3289,6 +3689,7 @@
<i class="fas fa-download mr-1 sm:mr-2"></i>
<span class="hidden sm:inline">Exporter</span>
</button>
</div>
</div>
</div>
@@ -3308,12 +3709,20 @@
<!-- Header -->
<div class="text-center mb-6 sm:mb-12">
<h1 class="text-2xl sm:text-3xl md:text-4xl font-bold mb-2 sm:mb-4 gradient-text">
<i class="fas fa-question-circle mr-2 sm:mr-3"></i>Centre d'Aide
🚀 Guide d'Utilisation
</h1>
<p class="text-sm sm:text-base text-gray-400 max-w-2xl mx-auto px-4">
Bienvenue dans le guide d'utilisation du Homelab Automation Dashboard.
Découvrez comment gérer efficacement votre infrastructure.
Bienvenue dans le guide officiel de votre <strong class="text-purple-400">Homelab Automation Dashboard</strong> !
Découvrez comment gérer et automatiser efficacement votre infrastructure grâce à cette solution puissante et centralisée.
</p>
<div class="mt-4 flex flex-col sm:flex-row gap-2 sm:gap-3 justify-center px-4">
<button type="button" class="px-4 py-2 bg-gray-800 border border-gray-700 rounded-lg hover:bg-gray-700 transition-colors text-sm touch-target" onclick="dashboard.downloadHelpDocumentation('md')">
<i class="fas fa-file-alt mr-2"></i>Télécharger (.md)
</button>
<button type="button" class="px-4 py-2 bg-gray-800 border border-gray-700 rounded-lg hover:bg-gray-700 transition-colors text-sm touch-target" onclick="dashboard.downloadHelpDocumentation('pdf')">
<i class="fas fa-file-pdf mr-2"></i>Télécharger (.pdf)
</button>
</div>
</div>
<!-- Layout avec Table des Matières -->
@@ -3324,31 +3733,31 @@
<div class="help-toc-title">Table des Matières</div>
<nav>
<a href="#help-quickstart" class="help-toc-item" onclick="scrollToHelpSection(event, 'help-quickstart')">
<i class="fas fa-rocket mr-2 text-purple-400"></i>Démarrage Rapide
<span class="mr-2">⚡️</span>Démarrage Rapide
</a>
<a href="#help-indicators" class="help-toc-item" onclick="scrollToHelpSection(event, 'help-indicators')">
<i class="fas fa-heartbeat mr-2 text-red-400"></i>Indicateurs de Santé
<span class="mr-2">❤️‍🩹</span>Indicateurs de Santé
</a>
<a href="#help-architecture" class="help-toc-item" onclick="scrollToHelpSection(event, 'help-architecture')">
<i class="fas fa-sitemap mr-2 text-blue-400"></i>Architecture
<span class="mr-2">🏗️</span>Architecture
</a>
<a href="#help-features" class="help-toc-item" onclick="scrollToHelpSection(event, 'help-features')">
<i class="fas fa-th-large mr-2 text-green-400"></i>Fonctionnalités
<span class="mr-2">⚙️</span>Fonctionnalités
</a>
<a href="#help-notifications" class="help-toc-item" onclick="scrollToHelpSection(event, 'help-notifications')">
<i class="fas fa-bell mr-2 text-yellow-400"></i>Notifications
<span class="mr-2">🔔</span>Notifications
</a>
<a href="#help-playbooks" class="help-toc-item" onclick="scrollToHelpSection(event, 'help-playbooks')">
<i class="fas fa-book mr-2 text-orange-400"></i>Playbooks Ansible
<span class="mr-2">📖</span>Playbooks Ansible
</a>
<a href="#help-api" class="help-toc-item" onclick="scrollToHelpSection(event, 'help-api')">
<i class="fas fa-code mr-2 text-cyan-400"></i>Référence API
<span class="mr-2">🔗</span>Référence API
</a>
<a href="#help-troubleshooting" class="help-toc-item" onclick="scrollToHelpSection(event, 'help-troubleshooting')">
<i class="fas fa-wrench mr-2 text-red-400"></i>Dépannage
<span class="mr-2">🛠️</span>Dépannage
</a>
<a href="#help-shortcuts" class="help-toc-item" onclick="scrollToHelpSection(event, 'help-shortcuts')">
<i class="fas fa-keyboard mr-2 text-yellow-400"></i>Raccourcis
<span class="mr-2">✨</span>Raccourcis & Astuces
</a>
</nav>
</div>
@@ -3360,7 +3769,7 @@
<!-- Quick Start -->
<div id="help-quickstart" class="glass-card p-8 mb-8 fade-in help-section-anchor">
<h2 class="help-section-title">
<i class="fas fa-rocket text-purple-500"></i>
<span class="text-2xl mr-2">⚡️</span>
Démarrage Rapide
</h2>
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
@@ -3394,7 +3803,7 @@
<!-- Indicateurs de Santé -->
<div id="help-indicators" class="glass-card p-8 mb-8 fade-in help-section-anchor">
<h2 class="help-section-title">
<i class="fas fa-heartbeat text-red-500"></i>
<span class="text-2xl mr-2">❤️‍🩹</span>
Indicateurs de Santé des Hosts
</h2>
<p class="text-gray-400 mb-6">
@@ -3571,7 +3980,7 @@
<!-- Architecture -->
<div id="help-architecture" class="glass-card p-8 mb-8 fade-in help-section-anchor">
<h2 class="help-section-title">
<i class="fas fa-sitemap text-blue-500"></i>
<span class="text-2xl mr-2">🏗️</span>
Architecture de la Solution
</h2>
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
@@ -3625,8 +4034,8 @@ homelab-automation/
<!-- Fonctionnalités -->
<div id="help-features" class="glass-card p-8 mb-8 fade-in help-section-anchor">
<h2 class="help-section-title">
<i class="fas fa-th-large text-green-500"></i>
Fonctionnalités par Section
<span class="text-2xl mr-2">⚙️</span>
Fonctionnalités Détaillées par Section
</h2>
<!-- Accordéon -->
@@ -3763,14 +4172,56 @@ homelab-automation/
</div>
</div>
</div>
<!-- Alertes -->
<div class="accordion-item" onclick="toggleAccordion(this)">
<div class="accordion-header">
<span class="flex items-center gap-3">
<i class="fas fa-bell text-red-400"></i>
<strong>Alertes</strong>
</span>
<i class="fas fa-chevron-down accordion-icon text-gray-400"></i>
</div>
<div class="accordion-content">
<div class="p-4">
<p class="text-gray-400 mb-4">Centre de messages pour les événements importants.</p>
<ul class="help-list text-sm">
<li><strong>Suivi:</strong> Consultez les alertes récentes (succès/échec, changements d'état).</li>
<li><strong>Lecture:</strong> Les alertes peuvent être marquées comme lues pour garder une boîte de réception propre.</li>
<li><strong>Notifications:</strong> Certaines alertes peuvent déclencher des notifications ntfy (si activé).</li>
</ul>
</div>
</div>
</div>
<!-- Configuration -->
<div class="accordion-item" onclick="toggleAccordion(this)">
<div class="accordion-header">
<span class="flex items-center gap-3">
<i class="fas fa-cog text-cyan-400"></i>
<strong>Configuration</strong>
</span>
<i class="fas fa-chevron-down accordion-icon text-gray-400"></i>
</div>
<div class="accordion-content">
<div class="p-4">
<p class="text-gray-400 mb-4">Paramètres de l'application et intégrations.</p>
<ul class="help-list text-sm">
<li><strong>Paramètres applicatifs:</strong> Options persistées (ex: collecte des métriques).</li>
<li><strong>Notifications:</strong> Configuration et test du service ntfy.</li>
<li><strong>Sécurité:</strong> Gestion du compte utilisateur (mot de passe) via l'écran utilisateur.</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<!-- Notifications -->
<div id="help-notifications" class="glass-card p-8 mb-8 fade-in help-section-anchor">
<h2 class="help-section-title">
<i class="fas fa-bell text-yellow-500"></i>
Système de Notifications
<span class="text-2xl mr-2">🔔</span>
Système de Notifications (ntfy)
</h2>
<p class="text-gray-400 mb-6">
Restez informé de l'état de votre infrastructure grâce au système de notifications intégré basé sur <strong>ntfy</strong>.
@@ -3795,10 +4246,10 @@ homelab-automation/
Vous recevez des notifications pour les événements critiques :
</p>
<ul class="help-list text-sm">
<li><i class="fas fa-check-circle text-green-400 mr-2"></i>Succès des Backups</li>
<li><i class="fas fa-exclamation-circle text-red-400 mr-2"></i>Échecs de Tâches</li>
<li><i class="fas fa-heartbeat text-purple-400 mr-2"></i>Changements de Santé Host</li>
<li><i class="fas fa-rocket text-blue-400 mr-2"></i>Fin de Bootstrap</li>
<li><span class="mr-2">✅</span>Succès des Backups</li>
<li><span class="mr-2">❌</span>Échecs de Tâches</li>
<li><span class="mr-2">⚠️</span>Changements de Santé Host</li>
<li><span class="mr-2">🛠️</span>Fin de Bootstrap</li>
</ul>
</div>
</div>
@@ -3807,7 +4258,7 @@ homelab-automation/
<!-- Playbooks Ansible -->
<div id="help-playbooks" class="glass-card p-8 mb-8 fade-in help-section-anchor">
<h2 class="help-section-title">
<i class="fas fa-book text-orange-500"></i>
<span class="text-2xl mr-2">📖</span>
Playbooks Ansible Disponibles
</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
@@ -3857,11 +4308,11 @@ homelab-automation/
<!-- API Reference -->
<div id="help-api" class="glass-card p-8 mb-8 fade-in help-section-anchor">
<h2 class="help-section-title">
<i class="fas fa-code text-cyan-500"></i>
<span class="text-2xl mr-2">🔗</span>
Référence API
</h2>
<p class="text-gray-400 mb-6">
L'API REST est accessible sur le port configuré. Authentification via header <span class="help-code">X-API-Key</span>.
L'API REST est accessible sur le port configuré. Authentification via header <span class="help-code">Authorization: Bearer &lt;token&gt;</span>.
</p>
<div class="overflow-x-auto">
<table class="w-full text-sm">
@@ -3911,7 +4362,7 @@ homelab-automation/
<!-- Troubleshooting -->
<div id="help-troubleshooting" class="glass-card p-8 mb-8 fade-in help-section-anchor">
<h2 class="help-section-title">
<i class="fas fa-wrench text-red-500"></i>
<span class="text-2xl mr-2">🛠️</span>
Dépannage
</h2>
<div class="space-y-4">
@@ -3969,7 +4420,7 @@ homelab-automation/
<!-- Keyboard Shortcuts -->
<div id="help-shortcuts" class="glass-card p-8 fade-in help-section-anchor">
<h2 class="help-section-title">
<i class="fas fa-keyboard text-yellow-500"></i>
<span class="text-2xl mr-2">✨</span>
Raccourcis & Astuces
</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
@@ -4549,5 +5000,106 @@ homelab-automation/
})();
</script>
</div><!-- End main-content -->
<!-- Authentication handlers -->
<script>
// Toggle password visibility
function togglePasswordVisibility(inputId, btn) {
const input = document.getElementById(inputId);
const icon = btn.querySelector('i');
if (input.type === 'password') {
input.type = 'text';
icon.classList.remove('fa-eye');
icon.classList.add('fa-eye-slash');
} else {
input.type = 'password';
icon.classList.remove('fa-eye-slash');
icon.classList.add('fa-eye');
}
}
// Handle login form submission
async function handleLogin(event) {
event.preventDefault();
const username = document.getElementById('login-username').value;
const password = document.getElementById('login-password').value;
const errorEl = document.getElementById('login-error');
const errorText = document.getElementById('login-error-text');
const submitBtn = document.getElementById('login-submit-btn');
// Reset error state
errorEl.classList.add('hidden');
// Show loading state
submitBtn.disabled = true;
submitBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i><span>Connexion...</span>';
try {
const success = await dashboard.login(username, password);
if (!success) {
errorText.textContent = 'Nom d\'utilisateur ou mot de passe incorrect';
errorEl.classList.remove('hidden');
}
} catch (error) {
errorText.textContent = error.message || 'Erreur de connexion';
errorEl.classList.remove('hidden');
} finally {
submitBtn.disabled = false;
submitBtn.innerHTML = '<i class="fas fa-sign-in-alt"></i><span>Se connecter</span>';
}
}
// Handle setup form submission
async function handleSetup(event) {
event.preventDefault();
const username = document.getElementById('setup-username').value;
const password = document.getElementById('setup-password').value;
const passwordConfirm = document.getElementById('setup-password-confirm').value;
const email = document.getElementById('setup-email').value || null;
const displayName = document.getElementById('setup-display-name').value || null;
const errorEl = document.getElementById('setup-error');
const errorText = document.getElementById('setup-error-text');
const submitBtn = document.getElementById('setup-submit-btn');
// Reset error state
errorEl.classList.add('hidden');
// Validate password confirmation
if (password !== passwordConfirm) {
errorText.textContent = 'Les mots de passe ne correspondent pas';
errorEl.classList.remove('hidden');
return;
}
// Show loading state
submitBtn.disabled = true;
submitBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i><span>Création...</span>';
try {
const success = await dashboard.setupAdmin(username, password, email, displayName);
if (!success) {
errorText.textContent = 'Erreur lors de la création du compte';
errorEl.classList.remove('hidden');
}
} catch (error) {
errorText.textContent = error.message || 'Erreur de configuration';
errorEl.classList.remove('hidden');
} finally {
submitBtn.disabled = false;
submitBtn.innerHTML = '<i class="fas fa-user-plus"></i><span>Créer le compte</span>';
}
}
// Logout function (exposed globally)
function handleLogout() {
if (dashboard) {
dashboard.logout();
}
}
</script>
</body>
</html>