476 lines
18 KiB
HTML
476 lines
18 KiB
HTML
<!doctype html>
|
|
<html lang="fr" data-theme="dark">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title data-i18n="admin.page_title">ObsiGate — Administration</title>
|
|
<meta name="robots" content="noindex" />
|
|
|
|
<link rel="icon" type="image/svg+xml" href="/static/icons/icon-72x72.svg" />
|
|
|
|
<!-- Lucide : requis par safeCreateIcons() (icônes des modales, ex. bouton fermer) -->
|
|
<script defer src="https://unpkg.com/[email protected]/dist/umd/lucide.min.js"></script>
|
|
|
|
<!-- Anti-FOUC : applique vite le mode du thème sauvegardé avant le CSS -->
|
|
<script>
|
|
(function () {
|
|
var root = document.documentElement;
|
|
try {
|
|
var mode = localStorage.getItem("obsigate-theme-mode") || "dark";
|
|
root.setAttribute("data-theme", mode);
|
|
var light = mode === "light" || mode === "sepia";
|
|
root.style.setProperty("--bg-primary", light ? "#ffffff" : "#0f1117");
|
|
root.style.setProperty("--text-primary", light ? "#1a1a1a" : "#e6edf3");
|
|
} catch (e) { root.setAttribute("data-theme", "dark"); }
|
|
})();
|
|
</script>
|
|
|
|
<link rel="stylesheet" href="/static/style.css" />
|
|
|
|
<style>
|
|
/* ── Admin page — local styles (kept inline to limit impact on /static/style.css) ── */
|
|
:root {
|
|
--admin-card-bg: var(--bg-secondary, #161b22);
|
|
--admin-card-border: var(--border, #21262d);
|
|
--admin-success: var(--success, #3fb950);
|
|
--admin-warning: var(--warning, #f59e0b);
|
|
--admin-danger: var(--danger, #ff7b72);
|
|
}
|
|
body.admin-page {
|
|
margin: 0;
|
|
min-height: 100vh;
|
|
overflow: auto; /* override SPA style.css: body{overflow:hidden} */
|
|
height: auto; /* override SPA style.css: body{height:100vh} */
|
|
background: var(--bg-primary, #0f1117);
|
|
color: var(--text-primary, #e6edf3);
|
|
font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
|
|
}
|
|
|
|
/* ── Sticky section nav ── */
|
|
.admin-subnav {
|
|
position: sticky;
|
|
top: 0;
|
|
z-index: 50;
|
|
display: flex;
|
|
gap: 6px;
|
|
flex-wrap: nowrap;
|
|
overflow-x: auto;
|
|
padding: 8px 24px;
|
|
background: var(--bg-secondary, #161b22);
|
|
border-bottom: 1px solid var(--border, #21262d);
|
|
backdrop-filter: blur(4px);
|
|
scrollbar-width: thin;
|
|
}
|
|
.admin-subnav::-webkit-scrollbar { height: 6px; }
|
|
.admin-subnav a {
|
|
flex: 0 0 auto;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
padding: 6px 14px;
|
|
border-radius: 8px;
|
|
font-size: 0.85rem;
|
|
font-weight: 500;
|
|
color: var(--text-secondary, #8b949e);
|
|
text-decoration: none;
|
|
border: 1px solid transparent;
|
|
transition: background 0.15s, color 0.15s, border-color 0.15s;
|
|
}
|
|
.admin-subnav a:hover {
|
|
background: var(--bg-hover, #1f2430);
|
|
color: var(--text-primary, #e6edf3);
|
|
}
|
|
.admin-subnav a.active {
|
|
background: var(--accent-bg, #1f2a3a);
|
|
color: var(--accent-text, #79c0ff);
|
|
border-color: var(--accent, #58a6ff);
|
|
}
|
|
.admin-section { scroll-margin-top: 64px; }
|
|
@media (max-width: 600px) {
|
|
.admin-subnav { padding: 8px 12px; }
|
|
.admin-subnav a { font-size: 0.8rem; padding: 6px 10px; }
|
|
}
|
|
.admin-header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 14px 24px;
|
|
background: var(--bg-secondary, #161b22);
|
|
border-bottom: 1px solid var(--admin-card-border);
|
|
}
|
|
.admin-header-left { display: flex; align-items: center; gap: 14px; }
|
|
.admin-header h1 {
|
|
font-size: 1.25rem;
|
|
font-weight: 600;
|
|
margin: 0;
|
|
color: var(--text-primary, #e6edf3);
|
|
}
|
|
.admin-header .admin-subtitle {
|
|
font-size: 0.85rem;
|
|
color: var(--text-secondary, #8b949e);
|
|
}
|
|
.admin-header-right { display: flex; align-items: center; gap: 12px; }
|
|
#admin-role-badge {
|
|
padding: 4px 10px;
|
|
border-radius: 12px;
|
|
font-size: 0.75rem;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
background: var(--accent-bg, #1f2a3a);
|
|
color: var(--accent-text, #79c0ff);
|
|
border: 1px solid var(--accent, #58a6ff);
|
|
}
|
|
#admin-role-badge[data-role="admin"] {
|
|
background: var(--success-bg, #1a3d1f);
|
|
color: var(--success, #3fb950);
|
|
border-color: var(--success, #3fb950);
|
|
}
|
|
.admin-back-btn {
|
|
padding: 6px 14px;
|
|
background: var(--bg-hover, #1f2430);
|
|
color: var(--text-primary, #e6edf3);
|
|
border: 1px solid var(--admin-card-border);
|
|
border-radius: 6px;
|
|
font-size: 0.85rem;
|
|
cursor: pointer;
|
|
text-decoration: none;
|
|
transition: background 0.15s;
|
|
}
|
|
.admin-back-btn:hover { background: var(--bg-sidebar, #13161d); }
|
|
|
|
.admin-main {
|
|
max-width: 1400px;
|
|
margin: 0 auto;
|
|
padding: 24px;
|
|
display: grid;
|
|
gap: 24px;
|
|
}
|
|
.admin-section {
|
|
background: var(--admin-card-bg);
|
|
border: 1px solid var(--admin-card-border);
|
|
border-radius: 10px;
|
|
padding: 20px;
|
|
}
|
|
.admin-section h2 {
|
|
font-size: 1.05rem;
|
|
font-weight: 600;
|
|
margin: 0 0 16px 0;
|
|
color: var(--text-primary, #e6edf3);
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
.admin-section h2::before {
|
|
content: "";
|
|
display: inline-block;
|
|
width: 4px;
|
|
height: 18px;
|
|
background: var(--accent, #58a6ff);
|
|
border-radius: 2px;
|
|
}
|
|
|
|
/* ── Stats grid ── */
|
|
#admin-stats-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
|
gap: 14px;
|
|
}
|
|
.admin-stat-card {
|
|
background: var(--bg-hover, #1f2430);
|
|
border: 1px solid var(--admin-card-border);
|
|
border-radius: 8px;
|
|
padding: 14px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 8px;
|
|
}
|
|
.admin-stat-label {
|
|
font-size: 0.75rem;
|
|
color: var(--text-secondary, #8b949e);
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
font-weight: 600;
|
|
}
|
|
.admin-stat-value {
|
|
font-size: 1.6rem;
|
|
font-weight: 700;
|
|
color: var(--text-primary, #e6edf3);
|
|
}
|
|
.admin-stat-unit {
|
|
font-size: 0.85rem;
|
|
font-weight: 400;
|
|
color: var(--text-secondary, #8b949e);
|
|
}
|
|
.admin-stat-bar {
|
|
height: 6px;
|
|
background: var(--bg-primary, #0f1117);
|
|
border-radius: 3px;
|
|
overflow: hidden;
|
|
}
|
|
.admin-stat-bar-fill {
|
|
height: 100%;
|
|
border-radius: 3px;
|
|
transition: width 0.4s ease, background 0.4s ease;
|
|
}
|
|
|
|
/* ── Tables ── */
|
|
.admin-table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
font-size: 0.85rem;
|
|
}
|
|
.admin-table th, .admin-table td {
|
|
padding: 8px 12px;
|
|
text-align: left;
|
|
border-bottom: 1px solid var(--admin-card-border);
|
|
}
|
|
.admin-table th {
|
|
background: var(--bg-primary, #0f1117);
|
|
color: var(--text-secondary, #8b949e);
|
|
font-weight: 600;
|
|
font-size: 0.75rem;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
}
|
|
.admin-table tbody tr:hover {
|
|
background: var(--bg-hover, #1f2430);
|
|
}
|
|
.admin-table code {
|
|
background: var(--bg-primary, #0f1117);
|
|
padding: 2px 6px;
|
|
border-radius: 4px;
|
|
font-size: 0.8rem;
|
|
color: var(--accent-text, #79c0ff);
|
|
}
|
|
|
|
/* ── Filters ── */
|
|
.admin-filters {
|
|
display: flex;
|
|
gap: 10px;
|
|
margin-bottom: 14px;
|
|
flex-wrap: wrap;
|
|
}
|
|
.admin-filters input, .admin-filters select {
|
|
padding: 6px 12px;
|
|
background: var(--bg-primary, #0f1117);
|
|
color: var(--text-primary, #e6edf3);
|
|
border: 1px solid var(--admin-card-border);
|
|
border-radius: 6px;
|
|
font-size: 0.85rem;
|
|
}
|
|
.admin-filters input:focus, .admin-filters select:focus {
|
|
outline: none;
|
|
border-color: var(--accent, #58a6ff);
|
|
}
|
|
.admin-btn {
|
|
padding: 6px 14px;
|
|
background: var(--accent, #58a6ff);
|
|
color: #fff;
|
|
border: none;
|
|
border-radius: 6px;
|
|
font-size: 0.85rem;
|
|
cursor: pointer;
|
|
font-weight: 600;
|
|
transition: opacity 0.15s;
|
|
}
|
|
.admin-btn:hover { opacity: 0.85; }
|
|
.admin-btn-secondary {
|
|
background: var(--bg-hover, #1f2430);
|
|
color: var(--text-primary, #e6edf3);
|
|
border: 1px solid var(--admin-card-border);
|
|
}
|
|
|
|
/* ── Backups ── */
|
|
#admin-backups-summary {
|
|
display: flex;
|
|
gap: 20px;
|
|
margin-bottom: 14px;
|
|
flex-wrap: wrap;
|
|
font-size: 0.85rem;
|
|
color: var(--text-secondary, #8b949e);
|
|
}
|
|
#admin-backups-summary > div {
|
|
padding: 8px 14px;
|
|
background: var(--bg-primary, #0f1117);
|
|
border-radius: 6px;
|
|
border: 1px solid var(--admin-card-border);
|
|
}
|
|
.admin-backup-bar {
|
|
height: 8px;
|
|
background: var(--bg-primary, #0f1117);
|
|
border-radius: 4px;
|
|
overflow: hidden;
|
|
min-width: 120px;
|
|
}
|
|
.admin-backup-bar-fill {
|
|
height: 100%;
|
|
background: linear-gradient(90deg, var(--accent, #58a6ff), var(--accent-text, #79c0ff));
|
|
transition: width 0.4s ease;
|
|
}
|
|
|
|
/* ── Users management ── */
|
|
#section-users .admin-users-hint {
|
|
color: var(--text-secondary, #8b949e);
|
|
font-size: 0.85rem;
|
|
margin-bottom: 14px;
|
|
}
|
|
|
|
/* ── Footer ── */
|
|
.admin-footer {
|
|
max-width: 1400px;
|
|
margin: 0 auto;
|
|
padding: 16px 24px;
|
|
font-size: 0.75rem;
|
|
color: var(--text-muted, #484f58);
|
|
display: flex;
|
|
justify-content: space-between;
|
|
border-top: 1px solid var(--admin-card-border);
|
|
}
|
|
#admin-stats-timestamp { color: var(--text-secondary, #8b949e); }
|
|
|
|
/* ── Forbidden screen ── */
|
|
#admin-forbidden {
|
|
display: none;
|
|
max-width: 500px;
|
|
margin: 100px auto;
|
|
padding: 40px;
|
|
text-align: center;
|
|
background: var(--admin-card-bg);
|
|
border: 1px solid var(--admin-danger);
|
|
border-radius: 10px;
|
|
}
|
|
#admin-forbidden h2 { color: var(--admin-danger); margin-top: 0; }
|
|
|
|
/* ── Loading state ── */
|
|
.admin-loading {
|
|
padding: 40px;
|
|
text-align: center;
|
|
color: var(--text-secondary, #8b949e);
|
|
font-size: 0.9rem;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body class="admin-page">
|
|
<header class="admin-header">
|
|
<div class="admin-header-left">
|
|
<h1>ObsiGate — Admin</h1>
|
|
<span class="admin-subtitle" data-i18n="admin.header_subtitle">Tableau de bord administrateur</span>
|
|
</div>
|
|
<div class="admin-header-right">
|
|
<span id="admin-role-badge">…</span>
|
|
<a href="/" class="admin-back-btn" data-i18n="admin.back_btn">← Retour</a>
|
|
</div>
|
|
</header>
|
|
|
|
<nav class="admin-subnav" id="admin-subnav" aria-label="Sections admin">
|
|
<a href="#section-stats" class="active" data-section="stats">📊 <span data-i18n="admin.stats_title">Statistiques</span></a>
|
|
<a href="#section-audit" data-section="audit">🕒 <span data-i18n="admin.audit_title">Logs d'audit</span></a>
|
|
<a href="#section-backups" data-section="backups">💾 <span data-i18n="admin.backups_title">Backups</span></a>
|
|
<a href="#section-users" data-section="users">👥 <span data-i18n="admin.users_title">Utilisateurs</span></a>
|
|
</nav>
|
|
|
|
<main id="admin-main" class="admin-main">
|
|
<!-- Loading state shown until init() resolves -->
|
|
<div id="admin-loading" class="admin-loading" data-i18n="common.loading">Chargement…</div>
|
|
|
|
<!-- Section 1 — Stats temps réel -->
|
|
<section class="admin-section" id="section-stats">
|
|
<h2 data-i18n="admin.stats_title">Statistiques temps réel</h2>
|
|
<div id="admin-stats-grid" class="admin-loading">…</div>
|
|
</section>
|
|
|
|
<!-- Section 2 — Logs d'audit -->
|
|
<section class="admin-section" id="section-audit">
|
|
<h2 data-i18n="admin.audit_title">Logs d'audit</h2>
|
|
<div class="admin-filters">
|
|
<input type="text" id="admin-audit-user" data-i18n-placeholder="admin.audit_filter_user" placeholder="Filtrer par utilisateur" />
|
|
<select id="admin-audit-action">
|
|
<option value="" data-i18n="admin.audit_all_actions">Toutes les actions</option>
|
|
</select>
|
|
<button id="admin-audit-refresh" class="admin-btn admin-btn-secondary" data-i18n="admin.audit_refresh">Rafraîchir</button>
|
|
</div>
|
|
<div id="admin-audit-empty" class="admin-loading" style="display:none;" data-i18n="admin.audit_empty">Aucun log disponible</div>
|
|
<table class="admin-table">
|
|
<thead>
|
|
<tr>
|
|
<th>Date</th>
|
|
<th>Action</th>
|
|
<th>User</th>
|
|
<th>Vault</th>
|
|
<th>IP</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="admin-audit-tbody"></tbody>
|
|
</table>
|
|
</section>
|
|
|
|
<!-- Section 3 — Statistiques backups -->
|
|
<section class="admin-section" id="section-backups">
|
|
<h2 data-i18n="admin.backups_title">Statistiques backups</h2>
|
|
<div id="admin-backups-summary"></div>
|
|
<div id="admin-backups-empty" class="admin-loading" style="display:none;" data-i18n="admin.backups_vault_empty">Aucun backup</div>
|
|
<table class="admin-table">
|
|
<thead>
|
|
<tr>
|
|
<th data-i18n="admin.backups_per_vault">Par vault</th>
|
|
<th>Count</th>
|
|
<th>Size</th>
|
|
<th>Distribution</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="admin-backups-tbody"></tbody>
|
|
</table>
|
|
</section>
|
|
|
|
<!-- Section 4 — Gestion utilisateurs -->
|
|
<section class="admin-section" id="section-users">
|
|
<h2 data-i18n="admin.users_title">Gestion utilisateurs</h2>
|
|
<p class="admin-users-hint" data-i18n="admin.users_manage_hint">Ouvrir la modale de gestion des utilisateurs (CRUD complet)</p>
|
|
<button id="admin-users-manage-btn" class="admin-btn" data-i18n="admin.users_manage_btn">Gérer les utilisateurs</button>
|
|
</section>
|
|
</main>
|
|
|
|
<div id="admin-forbidden">
|
|
<h2 data-i18n="admin.forbidden_title">Accès refusé</h2>
|
|
<p data-i18n="admin.forbidden_msg">Vous devez être administrateur pour accéder à cette page.</p>
|
|
<a href="/" class="admin-back-btn" data-i18n="admin.back_btn">← Retour</a>
|
|
</div>
|
|
|
|
<footer class="admin-footer">
|
|
<span>ObsiGate Admin — ROADMAP #71</span>
|
|
<span id="admin-stats-timestamp">—</span>
|
|
</footer>
|
|
|
|
<script type="module">
|
|
// Theme: applique le thème/mode sauvegardé dans l'app principale
|
|
// (même origine => localStorage partagé). Fait AVANT le rendu pour
|
|
// éviter que la page admin n'utilise les vars CSS par défaut.
|
|
import { initThemes } from "/static/js/themes.js";
|
|
// We import admin.js which provides init() — but the i18n module
|
|
// is global (window.t), so we can use t() right away to translate
|
|
// static DOM. admin.js will then call init() after DOMContentLoaded.
|
|
import { initI18n } from "/static/js/i18n.js";
|
|
import * as Admin from "/static/js/admin.js";
|
|
|
|
initThemes();
|
|
await initI18n();
|
|
// Re-apply DOM translations now that locale strings are loaded
|
|
document.querySelectorAll("[data-i18n]").forEach((el) => {
|
|
el.textContent = window.t(el.getAttribute("data-i18n"));
|
|
});
|
|
document.querySelectorAll("[data-i18n-placeholder]").forEach((el) => {
|
|
el.setAttribute("placeholder", window.t(el.getAttribute("data-i18n-placeholder")));
|
|
});
|
|
// Remove loading hint now that i18n is ready
|
|
const loading = document.getElementById("admin-loading");
|
|
if (loading) loading.style.display = "none";
|
|
|
|
if (typeof Admin.init === "function") {
|
|
Admin.init();
|
|
} else {
|
|
console.error("admin.js did not export init()");
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|