Bouton ⚙ sur « Mois par mois » : aperçu de la courbe et une case par mois pour l'afficher ou non (ex. le mois d'un ajout en lot). Les mois masqués n'apparaissent plus dans la courbe ni dans « mois le plus chargé » mais les titres restent comptés partout ailleurs. Réglage synchronisé (statsHiddenMonths), inclus dans la sauvegarde, 18 langues. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
25 files changed
+239
-14
No files matched your search
+38
-5
@@ -1,7 +1,9 @@
|
||||
import { Settings2 } from 'lucide-react'
|
||||
import { useMemo, useState } from 'react'
|
||||
import { t } from '../i18n'
|
||||
import { BarList, Columns, Panel, StatTile } from '../components/stats/Charts'
|
||||
import Poster from '../components/Poster'
|
||||
import StatsSettings from '../components/stats/StatsSettings'
|
||||
import { EmptyState, PageHeader } from '../components/ui'
|
||||
import { STATUSES, TYPE_BY_VALUE } from '../lib/constants'
|
||||
import { genreLabel } from '../lib/genres'
|
||||
@@ -26,6 +28,7 @@ export default function StatsPage({ onOpen }: { onOpen: (item: MediaItem) => voi
|
||||
const { items, settings } = useMedia()
|
||||
const [scope, setScope] = useState<Scope>('all')
|
||||
const [year, setYear] = useState('')
|
||||
const [settingsOpen, setSettingsOpen] = useState(false)
|
||||
|
||||
const scoped = useMemo(() => (scope === 'all' ? items : items.filter((i) => SCOPE_TYPES[scope].includes(i.type))), [items, scope])
|
||||
const years = useMemo(() => availableYears(scoped), [scoped])
|
||||
@@ -66,13 +69,32 @@ export default function StatsPage({ onOpen }: { onOpen: (item: MediaItem) => voi
|
||||
{list.length === 0 ? (
|
||||
<EmptyState title={t('stats.emptyTitle')} text={t('stats.emptyText')} />
|
||||
) : (
|
||||
<StatsBody key={scope + period} scope={scope} items={list} year={period} scale={settings.ratingScale} onOpen={onOpen} />
|
||||
<StatsBody key={scope + period} scope={scope} items={list} year={period} scale={settings.ratingScale} hiddenMonths={settings.statsHiddenMonths} onOpen={onOpen} onSettings={() => setSettingsOpen(true)} />
|
||||
)}
|
||||
{settingsOpen && <StatsSettings initialYear={period} onClose={() => setSettingsOpen(false)} />}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
function StatsBody({ scope, items, year, scale, onOpen }: { scope: Scope; items: MediaItem[]; year: string; scale: '5' | '10'; onOpen: (item: MediaItem) => void }) {
|
||||
function StatsBody({
|
||||
scope,
|
||||
items,
|
||||
year,
|
||||
scale,
|
||||
hiddenMonths,
|
||||
onOpen,
|
||||
onSettings,
|
||||
}: {
|
||||
scope: Scope
|
||||
items: MediaItem[]
|
||||
year: string
|
||||
scale: '5' | '10'
|
||||
/** Mois masqués dans la courbe (paramètres des stats) */
|
||||
hiddenMonths?: string[]
|
||||
onOpen: (item: MediaItem) => void
|
||||
onSettings: () => void
|
||||
}) {
|
||||
const hidden = useMemo(() => new Set(hiddenMonths ?? []), [hiddenMonths])
|
||||
const s = useMemo(() => computeStats(items), [items])
|
||||
const months = useMemo(() => monthly(items, year), [items, year])
|
||||
const rec = useMemo(() => records(items), [items])
|
||||
@@ -94,7 +116,7 @@ function StatsBody({ scope, items, year, scale, onOpen }: { scope: Scope; items:
|
||||
const days = Math.floor(s.totalMinutes / 1440)
|
||||
const timeHint = days > 0 ? `${t('stats.nonStopPre')}${t('stats.days', { count: days })}${t('stats.nonStopPost')}` : undefined
|
||||
// Mois le plus chargé : seulement s'il sort vraiment du lot (pas d'égalité en tête)
|
||||
const ranked = [...months].sort((a, b) => b.count - a.count)
|
||||
const ranked = months.filter((m) => !hidden.has(m.key)).sort((a, b) => b.count - a.count)
|
||||
const busiest = ranked[0] && ranked[0].count > (ranked[1]?.count ?? 0) ? ranked[0] : undefined
|
||||
|
||||
// Répartition des notes : 10 tranches sur /10 (½ étoile par tranche en échelle /5)
|
||||
@@ -125,7 +147,15 @@ function StatsBody({ scope, items, year, scale, onOpen }: { scope: Scope; items:
|
||||
|
||||
<div className="grid gap-4 lg:grid-cols-2">
|
||||
{/* Activité mois par mois */}
|
||||
<Panel title={year ? t('stats.monthByMonth', { year }) : t('stats.last12')} className="lg:col-span-2">
|
||||
<Panel
|
||||
title={year ? t('stats.monthByMonth', { year }) : t('stats.last12')}
|
||||
className="lg:col-span-2"
|
||||
action={
|
||||
<button onClick={onSettings} className="-me-2 grid size-9 place-items-center rounded-full text-ink-3 transition-colors hover:text-ink" aria-label={t('stats.settings')}>
|
||||
<Settings2 size={18} />
|
||||
</button>
|
||||
}
|
||||
>
|
||||
<Columns
|
||||
label={year ? t('stats.monthByMonth', { year }) : t('stats.last12')}
|
||||
height={150}
|
||||
@@ -134,7 +164,10 @@ function StatsBody({ scope, items, year, scale, onOpen }: { scope: Scope; items:
|
||||
axis: m.initial,
|
||||
value: m.count,
|
||||
highlight: m === busiest,
|
||||
tip: `${m.label} : ${t('stats.monthFinished', { count: m.count })}${m.minutes ? ` · ${formatDuration(m.minutes)}` : ''}`,
|
||||
hidden: hidden.has(m.key),
|
||||
tip: hidden.has(m.key)
|
||||
? `${m.label} : ${t('stats.monthHidden')}`
|
||||
: `${m.label} : ${t('stats.monthFinished', { count: m.count })}${m.minutes ? ` · ${formatDuration(m.minutes)}` : ''}`,
|
||||
}))}
|
||||
/>
|
||||
{busiest && busiest.count > 0 && (
|
||||
|
||||
Reference in new issue
Block a user