From 63fdc00ac2600061c2ea2cf73c6b071b5e4ffc7e Mon Sep 17 00:00:00 2001 From: Mohammed Abad Date: Mon, 20 Apr 2026 01:24:55 +0100 Subject: [PATCH] feat: entry details overhaul, navigation, rating half-stars, library growth "all", accuracy field - SeasonPage: add back navigation link to entry details page - EpisodePage: add breadcrumb navigation back to entry and season pages - EntryCard: non-library entries now open a details dialog on click with overview, rating, and add-to-library button - EntryDetailsPage: move favorite and mark-watched buttons into grouped dropdown menu with separators - EntryDetailsPage: add favorite badge (heart icon) on top-left of poster - EntryDetailsPage: add "mark as watched" clickable text next to runtime for unwatched movies - EntryDetailsPage: genre pills are now clickable links that navigate to library page with genre filter - EntryDetailsPage: hide status pill for movies; show status as text next to release date for TV series - EntryDetailsPage: add delete entry option in dropdown menu with confirmation dialog and redirect to library - EntryDetailsPage: add TMDB and IMDb external links under poster using entry.entryIds - EntryDetailsPage: group all dropdown actions by relevance (Watch/Rate, Organize, Manage, Danger) with separators - RatingDialog: support half-star ratings (0.5 increments) with left/right click zones per star - RatingDialog: fix clear rating button by syncing state on dialog open and using dedicated handleClear function - LibraryGrowthChart: add "All" option to year selector (default) showing cumulative growth across all years - Frontend: add SeenAccuracy type to types/index.ts, update API layers and hooks to support accuracy - EntrySeenDialog: add Date Accuracy selector (Exact/Estimated/Unknown) with EXACT default - EpisodeSeenEditDialog: add Date Accuracy selector, updated overrideSubmit signature - SeasonPage: pass accuracy through bulk mark-all-watched flow --- backend/models/EntrySeen.js | 2 +- backend/models/EpisodeSeen.js | 2 +- react_frontend/src/api/entry-seen.ts | 2 +- react_frontend/src/api/episode-seen.ts | 1 + .../dashboard/LibraryGrowthChart.tsx | 49 ++++- .../components/dialogs/EntrySeenDialog.tsx | 43 +++-- .../dialogs/EpisodeSeenEditDialog.tsx | 29 ++- .../src/components/dialogs/RatingDialog.tsx | 80 +++++--- .../src/components/entries/EntryCard.tsx | 77 +++++++- react_frontend/src/hooks/useEntrySeen.ts | 3 +- react_frontend/src/hooks/useEpisodeSeen.ts | 3 +- react_frontend/src/pages/EntryDetailsPage.tsx | 174 ++++++++++++------ react_frontend/src/pages/EpisodePage.tsx | 19 +- react_frontend/src/pages/SeasonPage.tsx | 17 +- react_frontend/src/types/index.ts | 4 + 15 files changed, 396 insertions(+), 109 deletions(-) diff --git a/backend/models/EntrySeen.js b/backend/models/EntrySeen.js index b8f4761..52e57f9 100644 --- a/backend/models/EntrySeen.js +++ b/backend/models/EntrySeen.js @@ -26,4 +26,4 @@ const EntrySeen = sequelize.define("entrySeen", } ); -module.exports = EntrySeen; \ No newline at end of file +module.exports = EntrySeen; diff --git a/backend/models/EpisodeSeen.js b/backend/models/EpisodeSeen.js index 6181a06..1ddb298 100644 --- a/backend/models/EpisodeSeen.js +++ b/backend/models/EpisodeSeen.js @@ -31,4 +31,4 @@ const EpisodeSeen = sequelize.define("episodeSeen", } ); -module.exports = EpisodeSeen; \ No newline at end of file +module.exports = EpisodeSeen; diff --git a/react_frontend/src/api/entry-seen.ts b/react_frontend/src/api/entry-seen.ts index 4a3894b..cbbaceb 100644 --- a/react_frontend/src/api/entry-seen.ts +++ b/react_frontend/src/api/entry-seen.ts @@ -16,7 +16,7 @@ export const entrySeenApi = { throw err; }), - create: (data: { entry_id: number; date_seen: string; seen_with?: string }) => + create: (data: { entry_id: number; date_seen: string; seen_with?: string; accuracy?: string }) => api.post('/entry-seen', data).then((r) => r.data), update: (id: number, data: Partial) => diff --git a/react_frontend/src/api/episode-seen.ts b/react_frontend/src/api/episode-seen.ts index 91e09d1..c2372c5 100644 --- a/react_frontend/src/api/episode-seen.ts +++ b/react_frontend/src/api/episode-seen.ts @@ -21,6 +21,7 @@ export const episodeSeenApi = { episode_id: number; date_seen: string; seen_with?: string; + accuracy?: string; }) => api.post('/episode-seen', data).then((r) => r.data), update: (id: number, data: Partial) => diff --git a/react_frontend/src/components/dashboard/LibraryGrowthChart.tsx b/react_frontend/src/components/dashboard/LibraryGrowthChart.tsx index 2ff9b62..567c23b 100644 --- a/react_frontend/src/components/dashboard/LibraryGrowthChart.tsx +++ b/react_frontend/src/components/dashboard/LibraryGrowthChart.tsx @@ -56,13 +56,50 @@ export function LibraryGrowthChart() { return Array.from(set).sort((a, b) => b - a); }, [allEntries, currentYear]); - const [year, setYear] = useState(currentYear); + const [year, setYear] = useState('all'); - // Ensure selected year is always within the available years - const effectiveYear = years.includes(year) ? year : years[0]; + // Ensure selected year is always valid + const effectiveYear = year === 'all' ? 'all' : (years.includes(year) ? year : years[0]); const chartData = useMemo(() => { const library = allEntries.filter((e) => !e.watchlist); + + if (effectiveYear === 'all') { + // Build monthly data across all years + const dateEntries = library + .map((e) => { + const d = getEntryDate(e); + return d ? new Date(d) : null; + }) + .filter(Boolean) as Date[]; + + if (dateEntries.length === 0) { + return MONTH_LABELS.map((label) => ({ month: label, count: 0, cumulative: 0 })); + } + + const minYear = Math.min(...dateEntries.map((d) => d.getFullYear())); + const maxYear = Math.max(...dateEntries.map((d) => d.getFullYear())); + + // Build data points for each month across all years + const data: { month: string; count: number; cumulative: number }[] = []; + let cumulative = 0; + + for (let y = minYear; y <= maxYear; y++) { + for (let m = 0; m < 12; m++) { + const count = dateEntries.filter( + (d) => d.getFullYear() === y && d.getMonth() === m + ).length; + cumulative += count; + data.push({ + month: `${MONTH_LABELS[m]} ${y}`, + count, + cumulative, + }); + } + } + return data; + } + const beforeYear = library.filter((e) => { const d = getEntryDate(e); return d && new Date(d).getFullYear() < effectiveYear; @@ -97,9 +134,13 @@ export function LibraryGrowthChart() { + {/* Accuracy */} +
+ + +
+ diff --git a/react_frontend/src/components/dialogs/RatingDialog.tsx b/react_frontend/src/components/dialogs/RatingDialog.tsx index a2a7a42..fe73cc9 100644 --- a/react_frontend/src/components/dialogs/RatingDialog.tsx +++ b/react_frontend/src/components/dialogs/RatingDialog.tsx @@ -1,4 +1,4 @@ -import { useState } from 'react'; +import { useState, useEffect } from 'react'; import { Dialog, DialogContent, @@ -22,6 +22,13 @@ export function RatingDialog({ open, onOpenChange, entry }: RatingDialogProps) { const [selected, setSelected] = useState(currentRating); const updateRatings = useUpdateEntryRatings(); + // Sync selected when dialog opens or entry rating changes + useEffect(() => { + if (open) { + setSelected(entry.entryRatings?.user_rating ?? 0); + } + }, [open, entry.entryRatings?.user_rating]); + const displayRating = hovered ?? selected; const handleRate = (rating: number) => { @@ -36,6 +43,18 @@ export function RatingDialog({ open, onOpenChange, entry }: RatingDialogProps) { onOpenChange(false); }; + const handleClear = () => { + setSelected(0); + updateRatings.mutate({ + id: entry.id, + ratings: { + id: entry.entryRatings?.id, + user_rating: null, + }, + }); + onOpenChange(false); + }; + return ( @@ -45,32 +64,51 @@ export function RatingDialog({ open, onOpenChange, entry }: RatingDialogProps) {
-
- {Array.from({ length: 10 }, (_, i) => i + 1).map((star) => ( - - ))} +
+ {Array.from({ length: 10 }, (_, i) => i + 1).map((star) => { + const halfValue = star - 0.5; + return ( +
+ {/* Left half — half star */} +
+ ); + })}

{displayRating > 0 ? `${displayRating} / 10` : '—'}

- {selected > 0 && ( - )} diff --git a/react_frontend/src/components/entries/EntryCard.tsx b/react_frontend/src/components/entries/EntryCard.tsx index 9b5a4d0..d9c63db 100644 --- a/react_frontend/src/components/entries/EntryCard.tsx +++ b/react_frontend/src/components/entries/EntryCard.tsx @@ -1,9 +1,15 @@ import { useState } from 'react'; import { Link } from 'react-router-dom'; -import { Plus, Trash2, Star, Loader2 } from 'lucide-react'; +import { Plus, Trash2, Star, Loader2, Calendar, Clock } from 'lucide-react'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; import { Skeleton } from '@/components/ui/skeleton'; +import { + Dialog, + DialogContent, + DialogHeader, + DialogTitle, +} from '@/components/ui/dialog'; import { getPosterUrl, getYear, formatRuntime } from '@/lib/media-utils'; import { useCreateEntry, useDeleteEntry } from '@/hooks/useEntries'; import { useLibraryStore } from '@/stores/useLibraryStore'; @@ -18,6 +24,7 @@ interface EntryCardProps { export function EntryCard({ entry, tmdbEntry, showTypeBadge }: EntryCardProps) { const [showConfirm, setShowConfirm] = useState(false); + const [showDetailDialog, setShowDetailDialog] = useState(false); const createEntry = useCreateEntry(); const deleteEntry = useDeleteEntry(); const libraryEntry = useLibraryStore((s) => { @@ -174,7 +181,13 @@ export function EntryCard({ entry, tmdbEntry, showTypeBadge }: EntryCardProps) { return ( <> - {entryLink ? {card} : card} + {entryLink ? ( + {card} + ) : ( +
setShowDetailDialog(true)}> + {card} +
+ )} + {/* Details dialog for non-library entries */} + {!entryLink && tmdbEntry && ( + + + + {title} + +
+ {title} +
+
+ {year && ( + + + {year} + + )} + {isTv ? ( + TV Series + ) : ( + Movie + )} +
+ {tmdbEntry.vote_average > 0 && ( +
+ + {tmdbEntry.vote_average.toFixed(1)}/10 +
+ )} + {tmdbEntry.overview && ( +

+ {tmdbEntry.overview} +

+ )} + +
+
+
+
+ )} ); } diff --git a/react_frontend/src/hooks/useEntrySeen.ts b/react_frontend/src/hooks/useEntrySeen.ts index 96dec16..6666fee 100644 --- a/react_frontend/src/hooks/useEntrySeen.ts +++ b/react_frontend/src/hooks/useEntrySeen.ts @@ -24,6 +24,7 @@ export function useCreateEntrySeen() { entry_id: number; date_seen: string; seen_with?: string; + accuracy?: string; }) => entrySeenApi.create(data), onSuccess: (_data, variables) => { queryClient.invalidateQueries({ @@ -50,7 +51,7 @@ export function useUpdateEntrySeen() { data, }: { id: number; - data: { entry_id: number; date_seen?: string; seen_with?: string }; + data: { entry_id: number; date_seen?: string; seen_with?: string; accuracy?: 'EXACT' | 'ESTIMATED' | 'UNKNOWN' }; }) => entrySeenApi.update(id, data), onSuccess: (_data, variables) => { queryClient.invalidateQueries({ diff --git a/react_frontend/src/hooks/useEpisodeSeen.ts b/react_frontend/src/hooks/useEpisodeSeen.ts index 89b1659..381cf5d 100644 --- a/react_frontend/src/hooks/useEpisodeSeen.ts +++ b/react_frontend/src/hooks/useEpisodeSeen.ts @@ -27,6 +27,7 @@ export function useCreateEpisodeSeen() { episode_id: number; date_seen: string; seen_with?: string; + accuracy?: string; season_id?: number; }) => episodeSeenApi.create(data), onSuccess: (_data, variables) => { @@ -61,7 +62,7 @@ export function useUpdateEpisodeSeen() { data, }: { id: number; - data: { episode_id: number; entry_id: number; date_seen?: string; seen_with?: string | null }; + data: { episode_id: number; entry_id: number; date_seen?: string; seen_with?: string | null; accuracy?: 'EXACT' | 'ESTIMATED' | 'UNKNOWN' }; }) => episodeSeenApi.update(id, data), onSuccess: (_data, variables) => { queryClient.invalidateQueries({ diff --git a/react_frontend/src/pages/EntryDetailsPage.tsx b/react_frontend/src/pages/EntryDetailsPage.tsx index c77d4f5..e93c069 100644 --- a/react_frontend/src/pages/EntryDetailsPage.tsx +++ b/react_frontend/src/pages/EntryDetailsPage.tsx @@ -1,5 +1,5 @@ import { useState } from 'react'; -import { useParams, Link } from 'react-router-dom'; +import { useParams, Link, useNavigate } from 'react-router-dom'; import { useEntry, useEntrySeasons, useRefreshEntry } from '@/hooks/useEntries'; import { useEntrySeenByEntry, useDeleteEntrySeen } from '@/hooks/useEntrySeen'; import { useCollections } from '@/hooks/useCollections'; @@ -12,6 +12,7 @@ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, + DropdownMenuSeparator, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; import { @@ -24,8 +25,9 @@ import { ImageIcon, Settings, Star, - Loader2, History, + Trash2, + ExternalLink, } from 'lucide-react'; import { Tooltip, @@ -35,13 +37,14 @@ import { } from '@/components/ui/tooltip'; import { CastList } from '@/components/entries/CastList'; import { SeasonsContainer } from '@/components/entries/SeasonsContainer'; -import { EpisodeWatchHistory } from '@/components/entries/EpisodeWatchHistory'; +// EpisodeWatchHistory is available for future use import { EntrySettingsDialog } from '@/components/dialogs/EntrySettingsDialog'; import { EntrySeenDialog } from '@/components/dialogs/EntrySeenDialog'; import { EntryMediaDialog } from '@/components/dialogs/EntryMediaDialog'; import { AddEntryToCollectionDialog } from '@/components/dialogs/AddEntryToCollectionDialog'; import { RatingDialog } from '@/components/dialogs/RatingDialog'; import { MovieWatchHistoryDialog } from '@/components/dialogs/MovieWatchHistoryDialog'; +import { ConfirmDialog } from '@/components/dialogs/ConfirmDialog'; import { EntryDetailsSkeleton } from '@/components/skeletons/PageSkeletons'; import { getPosterUrl, @@ -51,18 +54,20 @@ import { formatRuntime, formatDate, } from '@/lib/media-utils'; -import { useUpdateEntry } from '@/hooks/useEntries'; +import { useUpdateEntry, useDeleteEntry } from '@/hooks/useEntries'; import type { Collection, Entry } from '@/types'; export function EntryDetailsPage() { const { id } = useParams<{ id: string }>(); const entryId = parseInt(id!, 10); + const navigate = useNavigate(); const { data: entry, isLoading } = useEntry(entryId); const { data: seasons } = useEntrySeasons(entryId); const { data: watchHistory = [] } = useEntrySeenByEntry(entryId); const updateEntry = useUpdateEntry(); const refreshEntry = useRefreshEntry(); const deleteEntrySeen = useDeleteEntrySeen(); + const deleteEntry = useDeleteEntry(); // Merge library entry with detail entry so we get both library flags AND full details (credits, etc.) const libraryEntry = useLibraryStore((s) => s.entries.get(entryId)); @@ -76,6 +81,7 @@ export function EntryDetailsPage() { const [showCollectionDialog, setShowCollectionDialog] = useState(false); const [showRatingDialog, setShowRatingDialog] = useState(false); const [showWatchHistoryDialog, setShowWatchHistoryDialog] = useState(false); + const [showDeleteConfirm, setShowDeleteConfirm] = useState(false); if (isLoading || !displayEntry) { return ; @@ -112,41 +118,6 @@ export function EntryDetailsPage() {
{/* Action buttons — top right */}
- - - - - - {e.favorit ? 'Unfavorite' : 'Favorite'} - - - - - - - Mark Watched - - - + {/* Watch & Rate */} + setShowSeenDialog(true)}> + + Mark as watched + setShowRatingDialog(true)}> Rate this @@ -164,6 +140,16 @@ export function EntryDetailsPage() { Watch History )} + + {/* Organize */} + + + {e.favorit ? 'Unfavorite' : 'Favorite'} + + setShowCollectionDialog(true)}> + + Add to collection + updateEntry.mutate({ id: e.id, data: { hidden: !e.hidden } }) @@ -172,14 +158,12 @@ export function EntryDetailsPage() { {e.hidden ? 'Unhide' : 'Hide'} + + {/* Manage */} refreshEntry.mutate(e.id)} disabled={refreshEntry.isPending}> {refreshEntry.isPending ? 'Refreshing...' : 'Refresh details'} - setShowCollectionDialog(true)}> - - Add to collection - setShowMediaDialog(true)}> Manage media @@ -188,6 +172,15 @@ export function EntryDetailsPage() { Settings + + {/* Danger */} + setShowDeleteConfirm(true)} + > + + Delete entry +
@@ -196,25 +189,52 @@ export function EntryDetailsPage() {
{/* LEFT: Sticky poster */}
- {e.title} +
+ {e.favorit && ( +
+ +
+ )} + {e.title} +
+ {/* External links */} + {e.entryIds && ( +
+ {e.entryIds.tmdb_id && ( + + + TMDB + + )} + {e.entryIds.imdb_id && ( + + + IMDb + + )} +
+ )}
{/* RIGHT: Entry info */}
- {/* Title + status + director */} + {/* Title + director */}
-
-

{e.title}

- {e.status && ( - - {e.status} - - )} -
+

{e.title}

{director?.people?.name && (

by{' '} @@ -244,6 +264,12 @@ export function EntryDetailsPage() { )} + {e.is_tvseries && e.status && ( + <> + • + {e.status} + + )} {e.runtime && !e.is_tvseries && ( <> • @@ -275,15 +301,29 @@ export function EntryDetailsPage() { )} )} + {!e.is_tvseries && watchHistory.length === 0 && ( + <> + • + + + )}

{/* Genres */} {e.genres && e.genres.length > 0 && (
{e.genres.map((g) => ( - - {g.name} - + + + {g.name} + + ))}
)} @@ -417,6 +457,20 @@ export function EntryDetailsPage() { } /> )} + { + deleteEntry.mutate(e.id, { + onSuccess: () => navigate('/library'), + }); + setShowDeleteConfirm(false); + }} + />
); } diff --git a/react_frontend/src/pages/EpisodePage.tsx b/react_frontend/src/pages/EpisodePage.tsx index 5736f74..a789bc0 100644 --- a/react_frontend/src/pages/EpisodePage.tsx +++ b/react_frontend/src/pages/EpisodePage.tsx @@ -1,5 +1,5 @@ import { useState } from 'react'; -import { useParams, useNavigate } from 'react-router-dom'; +import { useParams, useNavigate, Link } from 'react-router-dom'; import { useQuery } from '@tanstack/react-query'; import { seasonsApi } from '@/api/seasons'; import { @@ -57,6 +57,23 @@ export function EpisodePage() { return (
+ {/* Back navigation */} +
+ + Entry + + / + + Season + +
+ {/* Top bar: nav breadcrumb + Mark Watched */}
diff --git a/react_frontend/src/pages/SeasonPage.tsx b/react_frontend/src/pages/SeasonPage.tsx index 53507b6..fa61bc6 100644 --- a/react_frontend/src/pages/SeasonPage.tsx +++ b/react_frontend/src/pages/SeasonPage.tsx @@ -8,9 +8,10 @@ import { Skeleton } from '@/components/ui/skeleton'; import { Progress } from '@/components/ui/progress'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; -import { Eye, CheckCircle2, ListChecks } from 'lucide-react'; +import { Eye, CheckCircle2, ListChecks, ArrowLeft } from 'lucide-react'; import { getTmdbPosterUrl, getYear, formatDate } from '@/lib/media-utils'; import type { Episode } from '@/types'; +import type { SeenAccuracy } from '@/types'; export function SeasonPage() { const { entryId, seasonId } = useParams<{ @@ -25,6 +26,7 @@ export function SeasonPage() { const [showMarkAllDialog, setShowMarkAllDialog] = useState(false); const [markAllDate, setMarkAllDate] = useState(new Date().toISOString().split('T')[0]); const [markAllSeenWith, setMarkAllSeenWith] = useState(''); + const [markAllAccuracy, setMarkAllAccuracy] = useState('EXACT'); const [showMarkAllConfirm, setShowMarkAllConfirm] = useState(false); if (isLoading || !season) { @@ -52,6 +54,15 @@ export function SeasonPage() { return (
+ {/* Back to entry */} + + + Back to entry + + {/* Header */}
{ + overrideSubmit={(date, seenWith, accuracy) => { setMarkAllDate(date); setMarkAllSeenWith(seenWith); + setMarkAllAccuracy(accuracy); setShowMarkAllDialog(false); setShowMarkAllConfirm(true); }} @@ -233,6 +245,7 @@ export function SeasonPage() { episode_id: ep.id, date_seen: markAllDate, seen_with: markAllSeenWith || undefined, + accuracy: markAllAccuracy, season_id: parseInt(seasonId!, 10), }); } diff --git a/react_frontend/src/types/index.ts b/react_frontend/src/types/index.ts index e623b79..710cb53 100644 --- a/react_frontend/src/types/index.ts +++ b/react_frontend/src/types/index.ts @@ -102,11 +102,14 @@ export interface Episode { season?: Season; } +export type SeenAccuracy = 'EXACT' | 'ESTIMATED' | 'UNKNOWN'; + export interface EntrySeen { id: number; entry_id: number; date_seen: string; seen_with: string | null; + accuracy: SeenAccuracy; createdAt: string; updatedAt: string; } @@ -117,6 +120,7 @@ export interface EpisodeSeen { episode_id: number; date_seen: string; seen_with: string | null; + accuracy: SeenAccuracy; createdAt: string; updatedAt: string; }