Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | INFRASTRUCTURE & AUTOMATION4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : MacLustr Vision8 * File : web/src/components/StatusRail.tsx9 * Module : components10 * Repository : https://git.spboucher.ai/maclustr-vision11 * Project Website : https://camera.spboucher.ai12 * Created : 2026-11-3013 * Last Modified : 2026-11-3014 *15 * Author : Simon-Pierre Boucher16 * Position : Professor of Finance17 * Institution : Université du Québec en Outaouais (UQO)18 * Organization : SP Boucher19 * Website : https://spboucher.ai20 * Git : https://git.spboucher.ai21 *22 * Preferred Contact: admin@spboucher.ai23 * Technical Contact: dev@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 } from '../api';43import { useApp, useNow, usePoll } from '../ctx';44import { fmtBytes, fmtDate, fmtTime } from '../fmt';45import { IconHelp, IconSearch } from '../icons';4647/** Bandeau d'état permanent : horloge du serveur, caméras, enregistrement, archive. Uniquement des mesures réelles. */48export function StatusRail({ onPalette, onHelp }: { onPalette: () => void; onHelp: () => void }) {49 const { cameras, clockOffset } = useApp();50 const now = useNow(1000) + clockOffset;51 const { data: st } = usePoll(() => api<any>('/api/storage/status'), 60000);52 const online = cameras.filter((c) => c.status.reachable).length;53 const rec = cameras.filter((c) => c.status.recConfirmed).length;54 const pct = st ? Math.min(100, st.archive.usedPct) : 0;55 const cls = st && (st.archive.level === 'critical' || st.archive.level === 'high') ? 'bad' : st?.archive.level === 'warning' ? 'warn' : '';56 const mac = /Mac|iPhone|iPad/.test(navigator.platform);57 return (58 <div className="rail" role="status" aria-label="État du système">59 <span className="clock" title="Heure du serveur">60 {fmtTime(now)}61 </span>62 <span className="item hide-s">{fmtDate(now)}</span>63 <span className="item">64 <span className={`dot ${cameras.length && online === cameras.length ? 'ok' : online ? 'warn' : 'bad'}`} />65 <b>66 {online}/{cameras.length}67 </b>68 <span className="hide-s">en ligne</span>69 </span>70 <span className="item">71 <span className={`dot ${rec ? 'bad' : ''}`} />72 <b>{rec}</b> REC73 </span>74 {st && (75 <span className="item hide-s" title={`Archive : ${fmtBytes(st.archive.usedBytes)} sur ${fmtBytes(st.archive.quotaBytes)}`}>76 <span className="gauge">77 <i className={cls} style={{ width: `${Math.max(pct, 2)}%` }} />78 </span>79 <b>{fmtBytes(st.archive.usedBytes)}</b>80 </span>81 )}82 {st && !st.archive.ok && <span className="item" style={{ color: 'var(--rec)' }}>ARCHIVE INDISPONIBLE</span>}83 {st?.suspended && <span className="item" style={{ color: 'var(--rec)' }}>ENREGISTREMENT SUSPENDU</span>}84 <span className="grow" />85 <button onClick={onPalette} aria-label="Ouvrir la palette de commandes">86 <IconSearch />87 <span className="hide-s">Commandes</span>88 <kbd className="hide-s">{mac ? '⌘K' : 'Ctrl K'}</kbd>89 </button>90 <button onClick={onHelp} aria-label="Raccourcis clavier" className="hide-s">91 <IconHelp />92 </button>93 </div>94 );95}96