feat(admin): frontend dashboard complet pour #71
CI / lint (push) Successful in 36s
CI / security (push) Successful in 23s
CI / test (push) Successful in 46s
CI / build (push) Successful in 22s
CI / e2e (push) Successful in 5m43s
Desktop Build / build-windows (push) Canceled after 0s
Desktop Build / build-linux (push) Canceled after 0s
CI / lint (push) Successful in 36s
CI / security (push) Successful in 23s
CI / test (push) Successful in 46s
CI / build (push) Successful in 22s
CI / e2e (push) Successful in 5m43s
Desktop Build / build-windows (push) Canceled after 0s
Desktop Build / build-linux (push) Canceled after 0s
Page admin standalone + widgets temps réel + CRUD users via AdminPanel existant.
- frontend/admin.html : page admin (header + 4 sections : stats temps réel,
audit logs, backups, gestion utilisateurs + footer)
- frontend/js/admin.js : module ES avec init(), connectSSE(), loadStatsOnce(),
loadAuditLogs(), loadBackupStats(), renderStatsWidget(), renderAuditTable(),
renderBackups() + helpers (formatBytes, formatUptime, severityColor)
- frontend/locales/{fr,en}.json : 36 clés admin.* identiques (diff vérifié)
- frontend/js/auth.js : adminRow.onclick redirige vers /admin.html (au lieu de
AdminPanel.show() qui reste fonctionnel)
- tests/frontend/unit.test.mjs : 3 nouveaux tests (admin.js existe + exports + parse)
- tests/test_auth_api.py : 2 nouveaux tests smoke (PATCH + DELETE /api/auth/admin/users)
Vérifié :
- pytest : 494 passed, 5 skipped (492 baseline + 2 nouveaux)
- frontend unit : 7 passed (4 baseline + 3 admin)
- validate-imports : 30 modules validated (29 + admin.js)
- pane-manager JSDOM : 9/9 passed
- ruff check backend/ : All checks passed
This commit is contained in:
@@ -0,0 +1,398 @@
|
||||
<!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" />
|
||||
<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;
|
||||
background: var(--bg-primary, #0f1117);
|
||||
color: var(--text-primary, #e6edf3);
|
||||
font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
|
||||
}
|
||||
.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 ── */
|
||||
#admin-users-section .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>
|
||||
|
||||
<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">
|
||||
<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">
|
||||
<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">
|
||||
<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="admin-users-section">
|
||||
<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">
|
||||
// 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 "/frontend/js/i18n.js";
|
||||
import * as Admin from "/frontend/js/admin.js";
|
||||
|
||||
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>
|
||||
Reference in New Issue
Block a user