SPB Git

Repository Public

Journal.tsx 3.5 KB 70 lines tsx

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : KA Maps Engine8 * File             : studio/web/src/Journal.tsx9 * Module           : studio10 * Repository       : https://git.spboucher.ai/ka-maps-engine11 * Created          : 2026-12-0112 * Last Modified    : 2026-12-0113 *14 * Author           : Simon-Pierre Boucher15 * Position         : Professor of Finance16 * Institution      : Université du Québec en Outaouais (UQO)17 * Organization     : SP Boucher18 * Website          : https://spboucher.ai19 * Git              : https://git.spboucher.ai20 *21 * Preferred Contact: support@spboucher.ai22 * Development      : dev@spboucher.ai23 * Support          : support@spboucher.ai24 * Security/Admin   : admin@spboucher.ai25 *26 * Copyright (c) 202627 * Simon-Pierre Boucher28 * All rights reserved where applicable. This file is governed by the29 * applicable project license, copyright notices and relevant law.30 * Existing third-party rights and notices remain unaffected.31 *32 * License          : None specified (no license file in this repository)33 *34 * Do not embed credentials, private keys, access tokens,35 * certificates or confidential personal information.36 *37 * =============================================================================38 * END OF SP BOUCHER SOURCE HEADER39 * =============================================================================40 */4142import { api, fmtDate } from './api.ts';43import { Notice, useAsync } from './ui.tsx';4445export function Journal() {46  const audit = useAsync(() => api.get('/api/audit?limit=300'), []);47  const admins = useAsync(() => api.get('/api/admins'), []);48  return (49    <>50      <div className="head"><div><h1>Journal</h1><p className="muted">Chaque modification est consignée : qui, quoi, quand. Les administrateurs sont créés sur le serveur (<code>studio admin-invite "Nom" courriel</code>).</p></div><button className="btn" onClick={audit.reload}>Actualiser</button></div>51      {audit.error ? <Notice kind="bad">{audit.error}</Notice> : null}52      <h2 style={{ marginTop: 0 }}>Administrateurs</h2>53      <div className="table-wrap"><table>54        <thead><tr><th>Nom</th><th>Courriel</th><th>Clés d'accès</th><th>Dernière connexion</th><th>État</th></tr></thead>55        <tbody>{admins.data?.admins.map((a: any) => (56          <tr key={a.id}><td>{a.name}</td><td>{a.email}</td><td className="num">{a.credentials}</td><td>{fmtDate(a.last_login)}</td>57            <td>{a.disabled_at ? <span className="tag bad">désactivé</span> : a.credentials ? <span className="tag ok">actif</span> : <span className="tag warn">{a.pending_invites ? 'invitation en attente' : 'sans clé'}</span>}</td></tr>58        ))}</tbody>59      </table></div>60      <h2>Journal d'audit</h2>61      <div className="table-wrap"><table data-testid="audit">62        <thead><tr><th>Date</th><th>Auteur</th><th>Action</th><th>Objet</th><th>Détail</th></tr></thead>63        <tbody>{audit.data?.entries.map((e: any) => (64          <tr key={e.id}><td style={{ whiteSpace: 'nowrap' }}>{fmtDate(e.at)}</td><td>{e.admin_name}</td><td className="mono small">{e.action}</td><td>{e.target ?? '—'}</td><td className="mono small" style={{ overflowWrap: 'anywhere' }}>{JSON.stringify(e.detail).slice(0, 220)}</td></tr>65        ))}</tbody>66      </table></div>67    </>68  );69}70
Files main
Menu

Theme