refactor(ui): retire article feed and legacy jobs surfaces

Remove obsolete article and scrape-job screens and APIs, preserve reports, and clear legacy API caches from the service worker.

Refs #8

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 21:20:51 +01:00
parent 768c0fd7f5
commit 0ebc531124
21 changed files with 315 additions and 357 deletions

View File

@ -11,12 +11,6 @@ export interface OllamaModelInfo {
details: { parameter_size: string; quantization_level: string; family: string }
}
export interface Source { id: string; name: string; type: string; enabled: boolean; article_limit: number }
export interface ScrapeJob {
id: string; source_id: string; source_name: string; status: string
started_at: { Time: string; Valid: boolean } | null
finished_at: { Time: string; Valid: boolean } | null
articles_found: number; error_msg: string; created_at: string
}
export interface Setting { key: string; value: string }
export interface ScheduleSlot { id?: string; day_of_week: number; hour: number; minute: number }
export interface AdminUser { id: string; email: string; role: string; created_at: string }
@ -54,10 +48,6 @@ export const adminApi = {
updateSource: (id: string, enabled: boolean, article_limit?: number) =>
api.put<void>(`/admin/sources/${id}`, { enabled, ...(article_limit === undefined ? {} : { article_limit }) }),
// Jobs
listJobs: () => api.get<ScrapeJob[]>('/admin/scrape-jobs'),
triggerJob: (source_id: string) => api.post<void>('/admin/scrape-jobs/trigger', { source_id }),
// Settings
listSettings: () => api.get<Setting[]>('/admin/settings'),
updateSettings: (settings: Setting[]) => api.put<void>('/admin/settings', { settings }),

View File

@ -1,25 +0,0 @@
import { api } from './client'
export interface Article {
id: string
source_id: string
source_name: string
title: string
content: string
url: string
published_at: { Time: string; Valid: boolean } | null
created_at: string
symbols?: string[]
}
export const articlesApi = {
list: (params?: { symbol?: string; limit?: number; offset?: number }) => {
const q = new URLSearchParams()
if (params?.symbol) q.set('symbol', params.symbol)
if (params?.limit) q.set('limit', String(params.limit))
if (params?.offset) q.set('offset', String(params.offset))
const qs = q.toString()
return api.get<Article[]>(`/articles${qs ? `?${qs}` : ''}`)
},
get: (id: string) => api.get<Article>(`/articles/${id}`),
}

View File

@ -1,10 +1,12 @@
import { Outlet, Navigate } from 'react-router-dom'
import { Outlet, Navigate, useLocation } from 'react-router-dom'
import { useAuth } from '@/lib/auth'
import { Sidebar } from './Sidebar'
import { MobileNav } from './MobileNav'
export function AppLayout() {
const { token } = useAuth()
const location = useLocation()
const notice = typeof location.state?.notice === 'string' ? location.state.notice : null
if (!token) return <Navigate to="/login" replace />
return (
@ -15,7 +17,8 @@ export function AppLayout() {
</div>
{/* Main content */}
<main className="flex-1 overflow-y-auto pb-16 md:pb-0">
<main className="min-w-0 flex-1 overflow-y-auto pb-16 md:pb-0">
{notice && <p role="status" className="m-4 rounded-md border bg-muted p-3 text-sm">{notice}</p>}
<Outlet />
</main>

View File

@ -1,12 +1,11 @@
import { NavLink } from 'react-router-dom'
import { LayoutDashboard, Newspaper, Star, Settings, FileText } from 'lucide-react'
import { LayoutDashboard, Star, Settings, FileText } from 'lucide-react'
import { useAuth } from '@/lib/auth'
import { cn } from '@/lib/cn'
const items = [
{ to: '/', icon: LayoutDashboard, label: 'Dashboard' },
{ to: '/feed', icon: Newspaper, label: 'Actus' },
{ to: '/watchlist', icon: Star, label: 'Watchlist' },
{ to: '/', icon: LayoutDashboard, label: 'Synthèses' },
{ to: '/assets', icon: Star, label: 'Indices suivis' },
{ to: '/reports', icon: FileText, label: 'Rapports' },
{ to: '/preferences', icon: Settings, label: 'Mes préférences' },
]

View File

@ -1,21 +1,19 @@
import { NavLink } from 'react-router-dom'
import { LayoutDashboard, Newspaper, Star, Settings, Key, Cpu, Database, ClipboardList, Users, LogOut, CalendarDays, FileText } from 'lucide-react'
import { LayoutDashboard, Star, Settings, Key, Cpu, Database, Users, LogOut, CalendarDays, FileText } from 'lucide-react'
import { useAuth } from '@/lib/auth'
import { cn } from '@/lib/cn'
const navItems = [
{ to: '/', icon: LayoutDashboard, label: 'Dashboard' },
{ to: '/feed', icon: Newspaper, label: 'Actualités' },
{ to: '/watchlist', icon: Star, label: 'Watchlist' },
{ to: '/', icon: LayoutDashboard, label: 'Synthèses' },
{ to: '/assets', icon: Star, label: 'Indices suivis' },
{ to: '/preferences', icon: Settings, label: 'Mes préférences' },
{ to: '/reports', icon: FileText, label: 'Rapports' },
]
const adminItems = [
{ to: '/admin/ai', icon: Cpu, label: 'Fournisseurs IA' },
{ to: '/admin/credentials', icon: Key, label: 'Identifiants' },
{ to: '/admin/credentials', icon: Key, label: 'Accès aux sources' },
{ to: '/admin/sources', icon: Database, label: 'Sources et plafonds' },
{ to: '/admin/jobs', icon: ClipboardList, label: 'Jobs' },
{ to: '/admin/users', icon: Users, label: 'Utilisateurs' },
{ to: '/admin/schedule', icon: CalendarDays, label: 'Planning' },
{ to: '/admin/settings', icon: Settings, label: 'Paramètres' },

View File

@ -1,14 +1,12 @@
import { createBrowserRouter } from 'react-router-dom'
import { createBrowserRouter, Navigate } from 'react-router-dom'
import { AppLayout } from '@/components/layout/AppLayout'
import { Login } from '@/pages/Login'
import { Dashboard } from '@/pages/Dashboard'
import { Feed } from '@/pages/Feed'
import { Watchlist } from '@/pages/Watchlist'
import { AdminLayout } from '@/pages/admin/AdminLayout'
import { AIProviders } from '@/pages/admin/AIProviders'
import { Credentials } from '@/pages/admin/Credentials'
import { Sources } from '@/pages/admin/Sources'
import { Jobs } from '@/pages/admin/Jobs'
import { AdminUsers } from '@/pages/admin/AdminUsers'
import { AdminSettings } from '@/pages/admin/AdminSettings'
import { Schedule } from '@/pages/admin/Schedule'
@ -21,7 +19,8 @@ export const router = createBrowserRouter([
element: <AppLayout />,
children: [
{ path: '/', element: <Dashboard /> },
{ path: '/feed', element: <Feed /> },
{ path: '/feed', element: <Navigate to="/" replace state={{ notice: 'Le fil d’articles a été retiré. Retrouvez vos synthèses et leurs bilans ici.' }} /> },
{ path: '/assets', element: <Watchlist /> },
{ path: '/watchlist', element: <Watchlist /> },
{ path: '/preferences', element: <Preferences /> },
{ path: '/reports', element: <Reports /> },
@ -33,7 +32,7 @@ export const router = createBrowserRouter([
{ path: 'ai', element: <AIProviders /> },
{ path: 'credentials', element: <Credentials /> },
{ path: 'sources', element: <Sources /> },
{ path: 'jobs', element: <Jobs /> },
{ path: 'jobs', element: <Navigate to="/admin/sources" replace /> },
{ path: 'users', element: <AdminUsers /> },
{ path: 'settings', element: <AdminSettings /> },
{ path: 'schedule', element: <Schedule /> },

View File

@ -1,115 +0,0 @@
import { useState, useEffect, useCallback } from 'react'
import { ExternalLink, RefreshCw, Search } from 'lucide-react'
import { articlesApi, type Article } from '@/api/articles'
import { assetsApi, type Asset } from '@/api/assets'
import { Card, CardContent } from '@/components/ui/card'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { Select } from '@/components/ui/select'
import { Badge } from '@/components/ui/badge'
import { Spinner } from '@/components/ui/spinner'
function fmtDate(a: Article) {
const d = a.published_at?.Valid ? new Date(a.published_at.Time) : new Date(a.created_at)
const now = Date.now()
const diff = now - d.getTime()
if (diff < 3600000) return `Il y a ${Math.floor(diff / 60000)} min`
if (diff < 86400000) return `Il y a ${Math.floor(diff / 3600000)} h`
return d.toLocaleDateString('fr-FR')
}
export function Feed() {
const [articles, setArticles] = useState<Article[]>([])
const [assets, setAssets] = useState<Asset[]>([])
const [loading, setLoading] = useState(true)
const [search, setSearch] = useState('')
const [filterSymbol, setFilterSymbol] = useState('')
const [offset, setOffset] = useState(0)
const limit = 30
useEffect(() => {
assetsApi.list().then(a => setAssets(a ?? []))
}, [])
const load = useCallback(async (newOffset = 0) => {
try {
const data = await articlesApi.list({ symbol: filterSymbol || undefined, limit, offset: newOffset })
if (newOffset === 0) setArticles(data ?? [])
else setArticles(prev => [...prev, ...(data ?? [])])
setOffset(newOffset + limit)
} finally { setLoading(false) }
}, [filterSymbol])
useEffect(() => { void load(0) }, [load])
const filtered = search
? articles.filter(a => a.title.toLowerCase().includes(search.toLowerCase()) || a.source_name?.toLowerCase().includes(search.toLowerCase()))
: articles
return (
<div className="p-4 md:p-6 space-y-4">
<div className="flex flex-wrap items-center gap-4">
<h1 className="text-2xl font-bold flex-1">Actualités</h1>
<Button variant="outline" size="icon" onClick={() => { setLoading(true); void load(0) }}><RefreshCw className="h-4 w-4" /></Button>
</div>
{/* Filtres */}
<div className="flex flex-wrap gap-3">
<div className="relative flex-1 min-w-48">
<Search className="absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
<Input className="pl-8" placeholder="Rechercher…" value={search} onChange={e => setSearch(e.target.value)} />
</div>
<Select value={filterSymbol} onChange={e => { setLoading(true); setFilterSymbol(e.target.value) }} className="w-40">
<option value="">Tous les symboles</option>
{assets.map(a => <option key={a.id} value={a.symbol}>{a.symbol}</option>)}
</Select>
</div>
{loading && articles.length === 0 ? (
<div className="flex justify-center py-20"><Spinner /></div>
) : (
<>
<div className="space-y-3">
{filtered.map(a => (
<Card key={a.id} className="hover:border-border/80 transition-colors">
<CardContent className="py-4">
<div className="flex items-start justify-between gap-4">
<div className="flex-1 min-w-0">
<div className="flex items-center gap-2 flex-wrap mb-1">
<Badge variant="outline" className="text-xs">{a.source_name}</Badge>
<span className="text-xs text-muted-foreground">{fmtDate(a)}</span>
</div>
<h3 className="font-medium leading-snug mb-2">{a.title}</h3>
{a.content && (
<p className="text-sm text-muted-foreground line-clamp-2">{a.content}</p>
)}
</div>
<a
href={a.url}
target="_blank"
rel="noopener noreferrer"
className="shrink-0 text-muted-foreground hover:text-foreground transition-colors"
>
<ExternalLink className="h-4 w-4" />
</a>
</div>
</CardContent>
</Card>
))}
{filtered.length === 0 && (
<Card><CardContent className="py-12 text-center text-muted-foreground">Aucun article</CardContent></Card>
)}
</div>
{filtered.length >= limit && (
<div className="flex justify-center pt-2">
<Button variant="outline" onClick={() => { setLoading(true); void load(offset) }} disabled={loading}>
{loading ? <Spinner className="h-4 w-4" /> : 'Charger plus'}
</Button>
</div>
)}
</>
)}
</div>
)
}

View File

@ -1,13 +1,12 @@
import { NavLink, Outlet, Navigate } from 'react-router-dom'
import { Cpu, Key, Database, ClipboardList, Users, CalendarDays, Settings } from 'lucide-react'
import { Cpu, Key, Database, Users, CalendarDays, Settings } from 'lucide-react'
import { useAuth } from '@/lib/auth'
import { cn } from '@/lib/cn'
const adminItems = [
{ to: '/admin/ai', icon: Cpu, label: 'Fournisseurs IA' },
{ to: '/admin/credentials', icon: Key, label: 'Identifiants' },
{ to: '/admin/credentials', icon: Key, label: 'Accès aux sources' },
{ to: '/admin/sources', icon: Database, label: 'Sources et plafonds' },
{ to: '/admin/jobs', icon: ClipboardList,label: 'Jobs' },
{ to: '/admin/users', icon: Users, label: 'Utilisateurs' },
{ to: '/admin/schedule', icon: CalendarDays, label: 'Planning' },
{ to: '/admin/settings', icon: Settings, label: 'Paramètres' },

View File

@ -98,7 +98,7 @@ export function AdminSettings() {
<div className="space-y-1">
<Label>Timezone (IANA)</Label>
<p className="text-xs text-muted-foreground">
Utilisé pour le planning de scraping et l&apos;horodatage des résumés
Utilisé pour le planning de génération et l’horodatage des synthèses
</p>
<div className="flex gap-2 max-w-sm">
<Input

View File

@ -52,8 +52,8 @@ export function Credentials() {
return (
<div className="space-y-6">
<div>
<h1 className="text-2xl font-bold">Identifiants de scraping</h1>
<p className="text-muted-foreground text-sm">Les mots de passe sont chiffrés en AES-256-GCM côté serveur</p>
<h1 className="text-2xl font-bold">Accès aux sources</h1>
<p className="text-muted-foreground text-sm">Ces accès sont utilisés par le mécanisme de récupération existant. Les enregistrer ne lance aucune récupération. Les mots de passe sont chiffrés côté serveur.</p>
</div>
{creds.length === 0 && (

View File

@ -1,109 +0,0 @@
import { useState, useEffect } from 'react'
import { Play, RefreshCw } from 'lucide-react'
import { adminApi, type ScrapeJob, type Source } from '@/api/admin'
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
import { Button } from '@/components/ui/button'
import { Badge } from '@/components/ui/badge'
import { Select } from '@/components/ui/select'
import { Spinner } from '@/components/ui/spinner'
function jobStatusVariant(status: string) {
if (status === 'done') return 'bullish'
if (status === 'error') return 'bearish'
if (status === 'running') return 'default'
return 'outline'
}
function fmtDate(t: { Time: string; Valid: boolean } | null) {
if (!t?.Valid) return '—'
return new Date(t.Time).toLocaleString('fr-FR')
}
export function Jobs() {
const [jobs, setJobs] = useState<ScrapeJob[]>([])
const [sources, setSources] = useState<Source[]>([])
const [loading, setLoading] = useState(true)
const [triggering, setTriggering] = useState(false)
const [selectedSource, setSelectedSource] = useState('')
useEffect(() => { load() }, [])
async function load() {
setLoading(true)
try {
const [j, s] = await Promise.all([adminApi.listJobs(), adminApi.listSources()])
setJobs(j ?? [])
setSources(s ?? [])
if (s?.[0]) setSelectedSource(s[0].id)
} finally { setLoading(false) }
}
async function trigger() {
if (!selectedSource) return
setTriggering(true)
await adminApi.triggerJob(selectedSource)
setTimeout(() => { load(); setTriggering(false) }, 1000)
}
return (
<div className="space-y-6">
<div className="flex flex-wrap items-center justify-between gap-4">
<div>
<h1 className="text-2xl font-bold">Jobs de scraping</h1>
<p className="text-muted-foreground text-sm">Historique et déclenchement manuel</p>
</div>
<div className="flex items-center gap-2">
<Select value={selectedSource} onChange={e => setSelectedSource(e.target.value)} className="w-40">
{sources.map(s => <option key={s.id} value={s.id}>{s.name}</option>)}
</Select>
<Button onClick={trigger} disabled={triggering || !selectedSource}>
{triggering ? <Spinner className="h-4 w-4" /> : <Play className="h-4 w-4" />}
Lancer
</Button>
<Button variant="outline" size="icon" onClick={load}><RefreshCw className="h-4 w-4" /></Button>
</div>
</div>
{loading ? (
<div className="flex justify-center py-12"><Spinner /></div>
) : (
<Card>
<CardHeader><CardTitle>Historique</CardTitle></CardHeader>
<CardContent className="p-0">
<div className="overflow-x-auto">
<table className="w-full text-sm">
<thead className="border-b">
<tr className="text-left text-muted-foreground">
<th className="px-4 py-3">Source</th>
<th className="px-4 py-3">Statut</th>
<th className="px-4 py-3">Début</th>
<th className="px-4 py-3">Fin</th>
<th className="px-4 py-3">Articles</th>
<th className="px-4 py-3">Erreur</th>
</tr>
</thead>
<tbody>
{jobs.map(j => (
<tr key={j.id} className="border-b last:border-0 hover:bg-muted/30">
<td className="px-4 py-3 font-medium">{j.source_name}</td>
<td className="px-4 py-3">
<Badge variant={jobStatusVariant(j.status) as 'bullish' | 'bearish' | 'default' | 'outline'}>{j.status}</Badge>
</td>
<td className="px-4 py-3 text-muted-foreground">{fmtDate(j.started_at)}</td>
<td className="px-4 py-3 text-muted-foreground">{fmtDate(j.finished_at)}</td>
<td className="px-4 py-3">{j.articles_found}</td>
<td className="px-4 py-3 text-destructive max-w-xs truncate">{j.error_msg || '—'}</td>
</tr>
))}
{jobs.length === 0 && (
<tr><td colSpan={6} className="px-4 py-8 text-center text-muted-foreground">Aucun job</td></tr>
)}
</tbody>
</table>
</div>
</CardContent>
</Card>
)}
</div>
)
}

View File

@ -68,11 +68,11 @@ export function Schedule() {
return (
<div className="space-y-6">
<div className="flex items-center justify-between">
<div className="flex flex-wrap items-center justify-between gap-3">
<div>
<h1 className="text-2xl font-bold">Planning hebdomadaire</h1>
<p className="text-muted-foreground text-sm">
Définissez les créneaux de scraping + résumé IA pour chaque jour
Définissez les créneaux de génération des synthèses pour chaque jour.
</p>
</div>
<Button onClick={save} disabled={saving}>
@ -137,7 +137,7 @@ export function Schedule() {
</div>
<p className="text-xs text-muted-foreground">
À chaque créneau, le service lance le scraping de toutes les sources actives puis génère les résumés IA.
Le planning est utilisé par le service de génération existant. Enregistrer ces créneaux ne lance aucune récupération ni génération immédiate.
</p>
</div>
)

View File

@ -95,6 +95,7 @@ export function Sources() {
return (
<div className="space-y-6">
<h1 className="text-2xl font-bold">Sources et plafonds</h1>
<p className="text-sm text-muted-foreground">Choisissez les sources utilisées pour les synthèses et leurs plafonds. Modifier ces réglages ne lance aucune récupération d’articles.</p>
{loading ? <p role="status">Chargement des sources et plafonds…</p> : loadError ? (
<div className="space-y-3"><p role="alert">{loadError}</p><Button onClick={() => void load()}>Réessayer</Button></div>
) : <>