diff --git a/frontend/src/api/articleHistory.ts b/frontend/src/api/articleHistory.ts index 23fbcda..967fabf 100644 --- a/frontend/src/api/articleHistory.ts +++ b/frontend/src/api/articleHistory.ts @@ -14,4 +14,7 @@ export const articleHistoryApi = { getProvenance: (synthesisId: string): Promise => api.get(`/syntheses/${synthesisId}/provenance`), + + clearAll: (): Promise<{ deleted: number }> => + api.delete<{ deleted: number }>('/article-history'), }; diff --git a/frontend/src/i18n/fr.ts b/frontend/src/i18n/fr.ts index 7fa9f0b..56fff29 100644 --- a/frontend/src/i18n/fr.ts +++ b/frontend/src/i18n/fr.ts @@ -348,6 +348,9 @@ const fr = { 'articleHistory.provenance': 'Provenance', 'articleHistory.provenanceEmpty': 'Aucune donnee de provenance disponible pour cette synthese.', 'articleHistory.provenanceDescription': 'Articles candidats traites lors de la generation de cette synthese.', + 'articleHistory.clearAll': 'Effacer l\'historique', + 'articleHistory.clearConfirm': 'Etes-vous sur de vouloir effacer tout l\'historique des articles ? Cette action est irreversible.', + 'articleHistory.cleared': 'Historique efface', // LLM Logs 'llmLogs.title': 'Logs des appels IA', diff --git a/frontend/src/pages/ArticleHistory.tsx b/frontend/src/pages/ArticleHistory.tsx index 5a24e54..47588a8 100644 --- a/frontend/src/pages/ArticleHistory.tsx +++ b/frontend/src/pages/ArticleHistory.tsx @@ -55,6 +55,7 @@ const ArticleHistory: Component = () => { const [filterStatus, setFilterStatus] = createSignal(''); const [filterSourceType, setFilterSourceType] = createSignal(''); const [page, setPage] = createSignal(0); + const [confirming, setConfirming] = createSignal(false); const totalPages = () => Math.max(1, Math.ceil(total() / PAGE_SIZE)); @@ -88,6 +89,22 @@ const ArticleHistory: Component = () => { // Skip the initial run which is handled by onMount }); + const handleClear = async () => { + if (!confirming()) { + setConfirming(true); + setTimeout(() => setConfirming(false), 3000); + return; + } + try { + await articleHistoryApi.clearAll(); + setConfirming(false); + setPage(0); + fetchHistory(); + } catch (err) { + console.error('Failed to clear history', err); + } + }; + const handleFilterChange = () => { setPage(0); fetchHistory(); @@ -101,10 +118,20 @@ const ArticleHistory: Component = () => { return (
{/* Page header */} -
+

{t('articleHistory.title')}

+
{/* Filters */}