diff --git a/react_frontend/src/api/maintenance.ts b/react_frontend/src/api/maintenance.ts new file mode 100644 index 0000000..a269925 --- /dev/null +++ b/react_frontend/src/api/maintenance.ts @@ -0,0 +1,22 @@ +import { api } from '@/lib/api'; + +export interface OrphanResult { + posters: number; + logos: number; + backdrops: number; + stills: number; +} + +export const maintenanceApi = { + scanOrphanFiles: () => + api.get('/maintenance/orphan-files').then((r) => r.data), + + deleteOrphanFiles: () => + api.delete('/maintenance/orphan-files').then((r) => r.data), + + scanOrphanMediaRecords: () => + api.get('/maintenance/orphan-media-records').then((r) => r.data), + + deleteOrphanMediaRecords: () => + api.delete('/maintenance/orphan-media-records').then((r) => r.data), +}; diff --git a/react_frontend/src/components/dashboard/LibraryGrowthChart.tsx b/react_frontend/src/components/dashboard/LibraryGrowthChart.tsx index 567c23b..099f122 100644 --- a/react_frontend/src/components/dashboard/LibraryGrowthChart.tsx +++ b/react_frontend/src/components/dashboard/LibraryGrowthChart.tsx @@ -43,8 +43,8 @@ export function LibraryGrowthChart() { const allEntries = useLibraryEntries(); const currentYear = new Date().getFullYear(); - const getEntryDate = (e: { createdAt?: string; date_first_seen?: string | null }) => - e.date_first_seen || e.createdAt || null; + const getEntryDate = (e: { createdAt?: string }) => + e.createdAt || null; const years = useMemo(() => { const set = new Set(); @@ -62,11 +62,12 @@ export function LibraryGrowthChart() { const effectiveYear = year === 'all' ? 'all' : (years.includes(year) ? year : years[0]); const chartData = useMemo(() => { - const library = allEntries.filter((e) => !e.watchlist); + // Include all entries (library + watchlist) + const entries = allEntries; if (effectiveYear === 'all') { // Build monthly data across all years - const dateEntries = library + const dateEntries = entries .map((e) => { const d = getEntryDate(e); return d ? new Date(d) : null; @@ -100,13 +101,13 @@ export function LibraryGrowthChart() { return data; } - const beforeYear = library.filter((e) => { + const beforeYear = entries.filter((e) => { const d = getEntryDate(e); return d && new Date(d).getFullYear() < effectiveYear; }).length; const monthlyCounts = new Array(12).fill(0); - library.forEach((e) => { + entries.forEach((e) => { const d = getEntryDate(e); if (!d) return; const date = new Date(d); diff --git a/react_frontend/src/components/dialogs/EntrySeenDialog.tsx b/react_frontend/src/components/dialogs/EntrySeenDialog.tsx index c85e3cf..bc07f55 100644 --- a/react_frontend/src/components/dialogs/EntrySeenDialog.tsx +++ b/react_frontend/src/components/dialogs/EntrySeenDialog.tsx @@ -3,7 +3,7 @@ import { useForm } from 'react-hook-form'; import { zodResolver } from '@hookform/resolvers/zod'; import { z } from 'zod'; import { format } from 'date-fns'; -import { CalendarIcon, Loader2 } from 'lucide-react'; +import { Loader2 } from 'lucide-react'; import { Dialog, DialogContent, @@ -14,12 +14,6 @@ import { import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; -import { - Popover, - PopoverContent, - PopoverTrigger, -} from '@/components/ui/popover'; -import { Calendar } from '@/components/ui/calendar'; import { Select, SelectContent, @@ -27,7 +21,6 @@ import { SelectTrigger, SelectValue, } from '@/components/ui/select'; -import { cn } from '@/lib/utils'; import { useCreateEntrySeen, useUpdateEntrySeen } from '@/hooks/useEntrySeen'; import { useCreateEpisodeSeen } from '@/hooks/useEpisodeSeen'; import type { Entry, Season, EntrySeen, SeenAccuracy } from '@/types'; @@ -57,9 +50,6 @@ export function EntrySeenDialog({ mode, editRecord, }: EntrySeenDialogProps) { - const [date, setDate] = useState( - editRecord?.date_seen ? new Date(editRecord.date_seen) : new Date() - ); const [selectedSeasonId, setSelectedSeasonId] = useState(''); const isTV = entry.is_tvseries; @@ -196,34 +186,33 @@ export function EntrySeenDialog({ )} - {/* Date picker */} + {/* Date + Accuracy */}
- - - - - - { - setDate(d); - if (d) setValue('date_seen', format(d, 'yyyy-MM-dd')); - }} - initialFocus - /> - - +
+ { + setValue('date_seen', e.target.value); + setDate(e.target.value ? new Date(e.target.value) : undefined); + }} + className="flex-1" + /> + +
{errors.date_seen && (

{errors.date_seen.message} @@ -237,24 +226,6 @@ export function EntrySeenDialog({

- {/* Accuracy */} -
- - -
- diff --git a/react_frontend/src/pages/EpisodePage.tsx b/react_frontend/src/pages/EpisodePage.tsx index a789bc0..2991e3c 100644 --- a/react_frontend/src/pages/EpisodePage.tsx +++ b/react_frontend/src/pages/EpisodePage.tsx @@ -2,6 +2,8 @@ import { useState } from 'react'; import { useParams, useNavigate, Link } from 'react-router-dom'; import { useQuery } from '@tanstack/react-query'; import { seasonsApi } from '@/api/seasons'; +import { useSeason } from '@/hooks/useSeasons'; +import { useLibraryStore } from '@/stores/useLibraryStore'; import { useEpisodeSeenByEpisode, useDeleteEpisodeSeen, @@ -29,6 +31,10 @@ export function EpisodePage() { queryFn: () => seasonsApi.getEpisodes(parseInt(seasonId!, 10)), }); + const { data: season } = useSeason(parseInt(seasonId!, 10)); + const entryTitle = useLibraryStore((s) => s.entries.get(parseInt(entryId!, 10))?.title); + const seasonNumber = season?.season_number; + const epId = parseInt(episodeId!, 10); const entryIdNum = parseInt(entryId!, 10); const episode: Episode | undefined = episodes.find((ep: Episode) => ep.id === epId); @@ -56,29 +62,31 @@ export function EpisodePage() { } return ( -
- {/* Back navigation */} -
+
+ {/* Breadcrumb: Title / Season x / Episode x */} +
- Entry + {entryTitle || 'Entry'} / - Season + Season {seasonNumber ?? '?'} + / + Episode {episode.episode_number}
{/* Top bar: nav breadcrumb + Mark Watched */}
- S{String(parseInt(seasonId!, 10)).padStart(2, '0')} E{String(episode.episode_number).padStart(2, '0')} + S{String(seasonNumber ?? 0).padStart(2, '0')} E{String(episode.episode_number).padStart(2, '0')}
+ {hasOrphans(orphanFilesResult) && ( + + )} +
+ {orphanFilesResult && ( +

+ {formatOrphanResult(orphanFilesResult)} +

+ )} +
+ + {/* Orphan Media Records */} +
+ +

+ Database records that have no matching file on disk. +

+
+ + {hasOrphans(orphanRecordsResult) && ( + + )} +
+ {orphanRecordsResult && ( +

+ {formatOrphanResult(orphanRecordsResult)} +

+ )} +
+ +
); }