Add watch status for TV series with UI and auto-fix
Added watch_status column to Entry model (plan_to_watch/watching/completed/ on_hold/dropped). Status pill on entry details page opens selection dialog. Set Status in quick actions menu and EntryCard dropdown (TV only). Status filter in Library filter popover. Maintenance auto-fix endpoint that sets statuses based on watched episodes (excl. season 0).
This commit is contained in:
1 parent
a5659cf4c8
commit
cdbaedd7d0
11 files changed
+663
-286
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { api } from "@/lib/api";
|
||||
import { api } from '@/lib/api';
|
||||
|
||||
export interface OrphanResult {
|
||||
posters: number;
|
||||
@@ -13,39 +13,39 @@ export interface OrphanPeopleResult {
|
||||
|
||||
export const maintenanceApi = {
|
||||
scanOrphanFiles: () =>
|
||||
api.get<OrphanResult>("/maintenance/orphan-files").then((r) => r.data),
|
||||
api.get<OrphanResult>('/maintenance/orphan-files').then((r) => r.data),
|
||||
|
||||
deleteOrphanFiles: () =>
|
||||
api.delete<OrphanResult>("/maintenance/orphan-files").then((r) => r.data),
|
||||
api.delete<OrphanResult>('/maintenance/orphan-files').then((r) => r.data),
|
||||
|
||||
scanOrphanMediaRecords: () =>
|
||||
api
|
||||
.get<OrphanResult>("/maintenance/orphan-media-records")
|
||||
.get<OrphanResult>('/maintenance/orphan-media-records')
|
||||
.then((r) => r.data),
|
||||
|
||||
deleteOrphanMediaRecords: () =>
|
||||
api
|
||||
.delete<OrphanResult>("/maintenance/orphan-media-records")
|
||||
.delete<OrphanResult>('/maintenance/orphan-media-records')
|
||||
.then((r) => r.data),
|
||||
|
||||
scanOrphanPeople: () =>
|
||||
api
|
||||
.get<OrphanPeopleResult>("/maintenance/orphan-people")
|
||||
.get<OrphanPeopleResult>('/maintenance/orphan-people')
|
||||
.then((r) => r.data),
|
||||
|
||||
deleteOrphanPeople: () =>
|
||||
api
|
||||
.delete<OrphanPeopleResult>("/maintenance/orphan-people")
|
||||
.delete<OrphanPeopleResult>('/maintenance/orphan-people')
|
||||
.then((r) => r.data),
|
||||
|
||||
scanMissingDirectors: () =>
|
||||
api
|
||||
.get<{ count: number; fixed: number }>("/maintenance/missing-directors")
|
||||
.get<{ count: number; fixed: number }>('/maintenance/missing-directors')
|
||||
.then((r) => r.data),
|
||||
|
||||
fixMissingDirectors: () =>
|
||||
api
|
||||
.post<{ count: number; fixed: number }>("/maintenance/missing-directors")
|
||||
.post<{ count: number; fixed: number }>('/maintenance/missing-directors')
|
||||
.then((r) => r.data),
|
||||
|
||||
scanDuplicateCredits: () =>
|
||||
@@ -54,7 +54,7 @@ export const maintenanceApi = {
|
||||
groups: number;
|
||||
duplicates: number;
|
||||
deleted: number;
|
||||
}>("/maintenance/duplicate-credits")
|
||||
}>('/maintenance/duplicate-credits')
|
||||
.then((r) => r.data),
|
||||
|
||||
cleanDuplicateCredits: () =>
|
||||
@@ -63,6 +63,15 @@ export const maintenanceApi = {
|
||||
groups: number;
|
||||
duplicates: number;
|
||||
deleted: number;
|
||||
}>("/maintenance/duplicate-credits")
|
||||
}>('/maintenance/duplicate-credits')
|
||||
.then((r) => r.data),
|
||||
|
||||
autoFixWatchStatuses: () =>
|
||||
api
|
||||
.post<{
|
||||
completed: number;
|
||||
watching: number;
|
||||
planToWatch: number;
|
||||
}>('/maintenance/auto-fix-watch-statuses')
|
||||
.then((r) => r.data),
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState } from "react";
|
||||
import { Link, useNavigate } from "react-router-dom";
|
||||
import { useState } from 'react';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
import {
|
||||
Plus,
|
||||
Star,
|
||||
@@ -15,35 +15,50 @@ import {
|
||||
RefreshCw,
|
||||
ImageIcon,
|
||||
Settings,
|
||||
} from "lucide-react";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
BookmarkCheck,
|
||||
} from 'lucide-react';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import { getPosterUrl, getYear, formatRuntime } from "@/lib/media-utils";
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import { getPosterUrl, getYear, formatRuntime } from '@/lib/media-utils';
|
||||
import {
|
||||
useCreateEntry,
|
||||
useDeleteEntry,
|
||||
useUpdateEntry,
|
||||
useRefreshEntry,
|
||||
useEntrySeasons,
|
||||
} from "@/hooks/useEntries";
|
||||
import { useEntrySeenByEntry, useDeleteEntrySeen } from "@/hooks/useEntrySeen";
|
||||
import { useLibraryStore } from "@/stores/useLibraryStore";
|
||||
import { ConfirmDialog } from "@/components/dialogs/ConfirmDialog";
|
||||
import { EntrySeenDialog } from "@/components/dialogs/EntrySeenDialog";
|
||||
import { RatingDialog } from "@/components/dialogs/RatingDialog";
|
||||
import { MovieWatchHistoryDialog } from "@/components/dialogs/MovieWatchHistoryDialog";
|
||||
import { AddEntryToCollectionDialog } from "@/components/dialogs/AddEntryToCollectionDialog";
|
||||
import { EntryMediaDialog } from "@/components/dialogs/EntryMediaDialog";
|
||||
import { EntrySettingsDialog } from "@/components/dialogs/EntrySettingsDialog";
|
||||
import type { Entry, TmdbEntry } from "@/types";
|
||||
} from '@/hooks/useEntries';
|
||||
import { useEntrySeenByEntry, useDeleteEntrySeen } from '@/hooks/useEntrySeen';
|
||||
import { useLibraryStore } from '@/stores/useLibraryStore';
|
||||
import { ConfirmDialog } from '@/components/dialogs/ConfirmDialog';
|
||||
import { EntrySeenDialog } from '@/components/dialogs/EntrySeenDialog';
|
||||
import { RatingDialog } from '@/components/dialogs/RatingDialog';
|
||||
import { MovieWatchHistoryDialog } from '@/components/dialogs/MovieWatchHistoryDialog';
|
||||
import { AddEntryToCollectionDialog } from '@/components/dialogs/AddEntryToCollectionDialog';
|
||||
import { EntryMediaDialog } from '@/components/dialogs/EntryMediaDialog';
|
||||
import { EntrySettingsDialog } from '@/components/dialogs/EntrySettingsDialog';
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog';
|
||||
import type { Entry, TmdbEntry } from '@/types';
|
||||
|
||||
const CARD_WATCH_STATUSES = [
|
||||
{ value: 'plan_to_watch', label: 'Plan to Watch' },
|
||||
{ value: 'watching', label: 'Watching' },
|
||||
{ value: 'completed', label: 'Completed' },
|
||||
{ value: 'on_hold', label: 'On Hold' },
|
||||
{ value: 'dropped', label: 'Dropped' },
|
||||
];
|
||||
|
||||
interface EntryCardProps {
|
||||
entry?: Entry;
|
||||
@@ -75,6 +90,7 @@ export function EntryCard({
|
||||
const [showMediaDialog, setShowMediaDialog] = useState(false);
|
||||
const [showSettingsDialog, setShowSettingsDialog] = useState(false);
|
||||
const [dropdownOpen, setDropdownOpen] = useState(false);
|
||||
const [showStatusDialog, setShowStatusDialog] = useState(false);
|
||||
const navigate = useNavigate();
|
||||
const createEntry = useCreateEntry();
|
||||
const deleteEntry = useDeleteEntry();
|
||||
@@ -100,7 +116,7 @@ export function EntryCard({
|
||||
|
||||
// Resolve display data
|
||||
const title =
|
||||
displayEntry?.title || tmdbEntry?.title || tmdbEntry?.name || "Untitled";
|
||||
displayEntry?.title || tmdbEntry?.title || tmdbEntry?.name || 'Untitled';
|
||||
const year = displayEntry
|
||||
? getYear(displayEntry.release_date)
|
||||
: getYear(tmdbEntry?.release_date || tmdbEntry?.first_air_date || null);
|
||||
@@ -111,22 +127,22 @@ export function EntryCard({
|
||||
const runtime =
|
||||
displayEntry && !displayEntry.is_tvseries
|
||||
? formatRuntime(displayEntry.runtime)
|
||||
: "";
|
||||
: '';
|
||||
const isTv =
|
||||
displayEntry?.is_tvseries ||
|
||||
tmdbEntry?.media_type === "tv" ||
|
||||
tmdbEntry?.media_type === 'tv' ||
|
||||
!!tmdbEntry?.name;
|
||||
|
||||
const posterUrl = displayEntry
|
||||
? getPosterUrl(displayEntry)
|
||||
: tmdbEntry?.poster_path
|
||||
? `https://image.tmdb.org/t/p/w342${tmdbEntry.poster_path}`
|
||||
: "/images/default-poster.png";
|
||||
: '/images/default-poster.png';
|
||||
|
||||
const entryLink = displayEntry
|
||||
? `/entry/${displayEntry.id}`
|
||||
: tmdbEntry
|
||||
? `/entry/tmdb/${isTv ? "tv" : "movie"}/${tmdbEntry.id}`
|
||||
? `/entry/tmdb/${isTv ? 'tv' : 'movie'}/${tmdbEntry.id}`
|
||||
: undefined;
|
||||
|
||||
const handleAdd = (e: React.MouseEvent) => {
|
||||
@@ -173,7 +189,7 @@ export function EntryCard({
|
||||
src={posterUrl}
|
||||
alt={title}
|
||||
className={`h-full w-full object-cover transition-all duration-300 group-hover:scale-105 ${
|
||||
grayOutUnseen && !isSeen ? "grayscale opacity-40" : ""
|
||||
grayOutUnseen && !isSeen ? 'grayscale opacity-40' : ''
|
||||
}`}
|
||||
loading="lazy"
|
||||
/>
|
||||
@@ -193,7 +209,7 @@ export function EntryCard({
|
||||
{/* Quick actions button – top right, shown on hover */}
|
||||
{isInLibrary && (
|
||||
<div
|
||||
className={`absolute right-2 top-2 z-20 transition-opacity ${dropdownOpen ? "opacity-100" : "opacity-0 group-hover:opacity-100"}`}
|
||||
className={`absolute right-2 top-2 z-20 transition-opacity ${dropdownOpen ? 'opacity-100' : 'opacity-0 group-hover:opacity-100'}`}
|
||||
>
|
||||
<DropdownMenu open={dropdownOpen} onOpenChange={setDropdownOpen}>
|
||||
<DropdownMenuTrigger asChild>
|
||||
@@ -233,6 +249,20 @@ export function EntryCard({
|
||||
<Star className="mr-2 h-4 w-4" />
|
||||
Rate this
|
||||
</DropdownMenuItem>
|
||||
{isTv && (
|
||||
<>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setShowStatusDialog(true);
|
||||
}}
|
||||
>
|
||||
<BookmarkCheck className="mr-2 h-4 w-4" />
|
||||
Set Status
|
||||
</DropdownMenuItem>
|
||||
</>
|
||||
)}
|
||||
{!isTv && (
|
||||
<DropdownMenuItem
|
||||
onClick={(e) => {
|
||||
@@ -253,9 +283,9 @@ export function EntryCard({
|
||||
}}
|
||||
>
|
||||
<Heart
|
||||
className={`mr-2 h-4 w-4 ${libraryEntry?.favorit ? "fill-current" : ""}`}
|
||||
className={`mr-2 h-4 w-4 ${libraryEntry?.favorit ? 'fill-current' : ''}`}
|
||||
/>
|
||||
{libraryEntry?.favorit ? "Unfavorite" : "Favorite"}
|
||||
{libraryEntry?.favorit ? 'Unfavorite' : 'Favorite'}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
onClick={(e) => {
|
||||
@@ -273,7 +303,7 @@ export function EntryCard({
|
||||
}}
|
||||
>
|
||||
<EyeOff className="mr-2 h-4 w-4" />
|
||||
{libraryEntry?.hidden ? "Unhide" : "Hide"}
|
||||
{libraryEntry?.hidden ? 'Unhide' : 'Hide'}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
{/* Manage */}
|
||||
@@ -285,9 +315,9 @@ export function EntryCard({
|
||||
disabled={refreshEntry.isPending}
|
||||
>
|
||||
<RefreshCw
|
||||
className={`mr-2 h-4 w-4 ${refreshEntry.isPending ? "animate-spin" : ""}`}
|
||||
className={`mr-2 h-4 w-4 ${refreshEntry.isPending ? 'animate-spin' : ''}`}
|
||||
/>
|
||||
{refreshEntry.isPending ? "Refreshing..." : "Refresh details"}
|
||||
{refreshEntry.isPending ? 'Refreshing...' : 'Refresh details'}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
onClick={(e) => {
|
||||
@@ -346,7 +376,7 @@ export function EntryCard({
|
||||
variant="secondary"
|
||||
className="absolute bottom-2 right-2 text-[10px] px-1.5 py-0.5 opacity-90 z-10 pointer-events-none"
|
||||
>
|
||||
{isTv ? "TV Series" : "Movie"}
|
||||
{isTv ? 'TV Series' : 'Movie'}
|
||||
</Badge>
|
||||
)}
|
||||
|
||||
@@ -360,7 +390,7 @@ export function EntryCard({
|
||||
{rating != null && rating > 0 && (
|
||||
<span className="flex items-center gap-1">
|
||||
<Star className="h-3 w-3 fill-yellow-400 text-yellow-400" />
|
||||
{typeof rating === "number" ? rating.toFixed(1) : rating}
|
||||
{typeof rating === 'number' ? rating.toFixed(1) : rating}
|
||||
</span>
|
||||
)}
|
||||
{year && <span>{year}</span>}
|
||||
@@ -381,7 +411,7 @@ export function EntryCard({
|
||||
) : (
|
||||
<Plus className="mr-1 h-3 w-3" />
|
||||
)}
|
||||
{createEntry.isPending ? "Adding..." : "Add to Library"}
|
||||
{createEntry.isPending ? 'Adding...' : 'Add to Library'}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
@@ -460,6 +490,37 @@ export function EntryCard({
|
||||
entry={libraryEntry}
|
||||
/>
|
||||
)}
|
||||
|
||||
<Dialog open={showStatusDialog} onOpenChange={setShowStatusDialog}>
|
||||
<DialogContent className="sm:max-w-xs">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Set Watch Status</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="space-y-1">
|
||||
{CARD_WATCH_STATUSES.map((s) => (
|
||||
<button
|
||||
key={s.value}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
updateEntry.mutate({
|
||||
id: libraryEntry!.id,
|
||||
data: { watch_status: s.value },
|
||||
});
|
||||
setShowStatusDialog(false);
|
||||
}}
|
||||
className={`w-full flex items-center gap-2 rounded-md px-3 py-2 text-sm transition-colors hover:bg-accent ${
|
||||
libraryEntry?.watch_status === s.value
|
||||
? 'bg-accent font-medium'
|
||||
: ''
|
||||
}`}
|
||||
>
|
||||
<BookmarkCheck className="h-4 w-4" />
|
||||
{s.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import { useParams, Link, useNavigate } from "react-router-dom";
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useParams, Link, useNavigate } from 'react-router-dom';
|
||||
import {
|
||||
useEntry,
|
||||
useEntrySeasons,
|
||||
useRefreshEntry,
|
||||
useEntryCredits,
|
||||
} from "@/hooks/useEntries";
|
||||
import { useEntrySeenByEntry, useDeleteEntrySeen } from "@/hooks/useEntrySeen";
|
||||
import { useCollections } from "@/hooks/useCollections";
|
||||
import { useLibraryStore } from "@/stores/useLibraryStore";
|
||||
import { useCommandPaletteStore } from "@/stores/useCommandPaletteStore";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
|
||||
} from '@/hooks/useEntries';
|
||||
import { useEntrySeenByEntry, useDeleteEntrySeen } from '@/hooks/useEntrySeen';
|
||||
import { useCollections } from '@/hooks/useCollections';
|
||||
import { useLibraryStore } from '@/stores/useLibraryStore';
|
||||
import { useCommandPaletteStore } from '@/stores/useCommandPaletteStore';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Separator } from '@/components/ui/separator';
|
||||
import { ScrollArea, ScrollBar } from '@/components/ui/scroll-area';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import {
|
||||
Heart,
|
||||
MoreHorizontal,
|
||||
@@ -35,25 +35,32 @@ import {
|
||||
Trash2,
|
||||
ExternalLink,
|
||||
Play,
|
||||
} from "lucide-react";
|
||||
BookmarkCheck,
|
||||
} from 'lucide-react';
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipProvider,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
import { CastList } from "@/components/entries/CastList";
|
||||
import { SeasonsContainer } from "@/components/entries/SeasonsContainer";
|
||||
import { StreamingSection } from "@/components/streaming/StreamingSection";
|
||||
} from '@/components/ui/tooltip';
|
||||
import { CastList } from '@/components/entries/CastList';
|
||||
import { SeasonsContainer } from '@/components/entries/SeasonsContainer';
|
||||
import { StreamingSection } from '@/components/streaming/StreamingSection';
|
||||
// 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 { 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 {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog';
|
||||
import { EntryDetailsSkeleton } from '@/components/skeletons/PageSkeletons';
|
||||
import {
|
||||
getPosterUrl,
|
||||
getBackdropUrl,
|
||||
@@ -61,9 +68,44 @@ import {
|
||||
getYear,
|
||||
formatRuntime,
|
||||
formatDate,
|
||||
} from "@/lib/media-utils";
|
||||
import { useUpdateEntry, useDeleteEntry } from "@/hooks/useEntries";
|
||||
import type { Collection, Entry } from "@/types";
|
||||
} from '@/lib/media-utils';
|
||||
import { useUpdateEntry, useDeleteEntry } from '@/hooks/useEntries';
|
||||
import type { Collection, Entry } from '@/types';
|
||||
|
||||
const WATCH_STATUSES = [
|
||||
{
|
||||
value: 'plan_to_watch',
|
||||
label: 'Plan to Watch',
|
||||
color:
|
||||
'bg-slate-500/15 border-slate-500/30 text-slate-600 dark:text-slate-400',
|
||||
},
|
||||
{
|
||||
value: 'watching',
|
||||
label: 'Watching',
|
||||
color: 'bg-blue-500/15 border-blue-500/30 text-blue-600 dark:text-blue-400',
|
||||
},
|
||||
{
|
||||
value: 'completed',
|
||||
label: 'Completed',
|
||||
color:
|
||||
'bg-green-500/15 border-green-500/30 text-green-600 dark:text-green-400',
|
||||
},
|
||||
{
|
||||
value: 'on_hold',
|
||||
label: 'On Hold',
|
||||
color:
|
||||
'bg-amber-500/15 border-amber-500/30 text-amber-600 dark:text-amber-400',
|
||||
},
|
||||
{
|
||||
value: 'dropped',
|
||||
label: 'Dropped',
|
||||
color: 'bg-red-500/15 border-red-500/30 text-red-600 dark:text-red-400',
|
||||
},
|
||||
];
|
||||
|
||||
function getWatchStatusInfo(value: string | null | undefined) {
|
||||
return WATCH_STATUSES.find((s) => s.value === value);
|
||||
}
|
||||
|
||||
export function EntryDetailsPage() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
@@ -92,6 +134,7 @@ export function EntryDetailsPage() {
|
||||
const [showRatingDialog, setShowRatingDialog] = useState(false);
|
||||
const [showWatchHistoryDialog, setShowWatchHistoryDialog] = useState(false);
|
||||
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
||||
const [showStatusDialog, setShowStatusDialog] = useState(false);
|
||||
|
||||
// Track recently viewed for command palette
|
||||
const addRecentlyViewed = useCommandPaletteStore((s) => s.addRecentlyViewed);
|
||||
@@ -100,7 +143,7 @@ export function EntryDetailsPage() {
|
||||
addRecentlyViewed({
|
||||
id: `lib-${entryId}`,
|
||||
title: displayEntry.title,
|
||||
type: displayEntry.is_tvseries ? "tv" : "movie",
|
||||
type: displayEntry.is_tvseries ? 'tv' : 'movie',
|
||||
poster_path: displayEntry.poster_path,
|
||||
libraryId: entryId,
|
||||
tmdbId: displayEntry.entryIds?.tmdb_id ?? undefined,
|
||||
@@ -119,7 +162,7 @@ export function EntryDetailsPage() {
|
||||
const backdrop = getBackdropUrl(e);
|
||||
const poster = getPosterUrl(e);
|
||||
const director = credits.find(
|
||||
(c) => c.cast_type === "crew" && c.job === "Director",
|
||||
(c) => c.cast_type === 'crew' && c.job === 'Director',
|
||||
);
|
||||
|
||||
const toggleFavorite = () => {
|
||||
@@ -162,6 +205,13 @@ export function EntryDetailsPage() {
|
||||
<Star className="mr-2 h-4 w-4" />
|
||||
Rate this
|
||||
</DropdownMenuItem>
|
||||
{e.is_tvseries && <DropdownMenuSeparator />}
|
||||
{e.is_tvseries && (
|
||||
<DropdownMenuItem onClick={() => setShowStatusDialog(true)}>
|
||||
<BookmarkCheck className="mr-2 h-4 w-4" />
|
||||
Set Status
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{!e.is_tvseries && (
|
||||
<DropdownMenuItem
|
||||
onClick={() => setShowWatchHistoryDialog(true)}
|
||||
@@ -177,9 +227,9 @@ export function EntryDetailsPage() {
|
||||
disabled={updateEntry.isPending}
|
||||
>
|
||||
<Heart
|
||||
className={`mr-2 h-4 w-4 ${e.favorit ? "fill-current" : ""}`}
|
||||
className={`mr-2 h-4 w-4 ${e.favorit ? 'fill-current' : ''}`}
|
||||
/>
|
||||
{e.favorit ? "Unfavorite" : "Favorite"}
|
||||
{e.favorit ? 'Unfavorite' : 'Favorite'}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => setShowCollectionDialog(true)}>
|
||||
<FolderPlus className="mr-2 h-4 w-4" />
|
||||
@@ -191,7 +241,7 @@ export function EntryDetailsPage() {
|
||||
}
|
||||
>
|
||||
<EyeOff className="mr-2 h-4 w-4" />
|
||||
{e.hidden ? "Unhide" : "Hide"}
|
||||
{e.hidden ? 'Unhide' : 'Hide'}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
{/* Manage */}
|
||||
@@ -200,9 +250,9 @@ export function EntryDetailsPage() {
|
||||
disabled={refreshEntry.isPending}
|
||||
>
|
||||
<RefreshCw
|
||||
className={`mr-2 h-4 w-4 ${refreshEntry.isPending ? "animate-spin" : ""}`}
|
||||
className={`mr-2 h-4 w-4 ${refreshEntry.isPending ? 'animate-spin' : ''}`}
|
||||
/>
|
||||
{refreshEntry.isPending ? "Refreshing..." : "Refresh details"}
|
||||
{refreshEntry.isPending ? 'Refreshing...' : 'Refresh details'}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => setShowMediaDialog(true)}>
|
||||
<ImageIcon className="mr-2 h-4 w-4" />
|
||||
@@ -241,7 +291,7 @@ export function EntryDetailsPage() {
|
||||
<div className="flex items-center justify-center gap-3 mt-3">
|
||||
{e.entryIds.tmdb_id && (
|
||||
<a
|
||||
href={`https://www.themoviedb.org/${e.is_tvseries ? "tv" : "movie"}/${e.entryIds.tmdb_id}`}
|
||||
href={`https://www.themoviedb.org/${e.is_tvseries ? 'tv' : 'movie'}/${e.entryIds.tmdb_id}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors"
|
||||
@@ -272,7 +322,7 @@ export function EntryDetailsPage() {
|
||||
<h1 className="text-3xl font-bold leading-tight">{e.title}</h1>
|
||||
{director?.people?.name && (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
by{" "}
|
||||
by{' '}
|
||||
<Link
|
||||
to={`/people/${director.people_id}`}
|
||||
className="font-medium text-foreground hover:underline"
|
||||
@@ -414,23 +464,39 @@ export function EntryDetailsPage() {
|
||||
disabled={updateEntry.isPending}
|
||||
className={`inline-flex items-center gap-1 rounded-full border px-3 py-1 text-sm font-medium transition-colors ${
|
||||
e.favorit
|
||||
? "bg-yellow-500/15 border-yellow-500/30 text-yellow-600 dark:text-yellow-400 hover:bg-yellow-500/25"
|
||||
: "border-dashed border-border text-muted-foreground hover:border-yellow-500/40 hover:text-yellow-500"
|
||||
? 'bg-yellow-500/15 border-yellow-500/30 text-yellow-600 dark:text-yellow-400 hover:bg-yellow-500/25'
|
||||
: 'border-dashed border-border text-muted-foreground hover:border-yellow-500/40 hover:text-yellow-500'
|
||||
}`}
|
||||
>
|
||||
<Star
|
||||
className={`h-3.5 w-3.5 ${e.favorit ? "fill-yellow-400 text-yellow-400" : ""}`}
|
||||
className={`h-3.5 w-3.5 ${e.favorit ? 'fill-yellow-400 text-yellow-400' : ''}`}
|
||||
/>
|
||||
Favorit
|
||||
</button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<p>
|
||||
{e.favorit ? "Remove from favorites" : "Add to favorites"}
|
||||
{e.favorit ? 'Remove from favorites' : 'Add to favorites'}
|
||||
</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
|
||||
{/* Watch status pill — TV only */}
|
||||
{e.is_tvseries &&
|
||||
e.watch_status &&
|
||||
(() => {
|
||||
const info = getWatchStatusInfo(e.watch_status);
|
||||
return (
|
||||
<button
|
||||
onClick={() => setShowStatusDialog(true)}
|
||||
className={`inline-flex items-center gap-1 rounded-full border px-3 py-1 text-sm font-medium transition-colors cursor-pointer ${info?.color ?? ''}`}
|
||||
>
|
||||
<BookmarkCheck className="h-3.5 w-3.5" />
|
||||
{info?.label}
|
||||
</button>
|
||||
);
|
||||
})()}
|
||||
</div>
|
||||
|
||||
{/* Storyline */}
|
||||
@@ -448,7 +514,7 @@ export function EntryDetailsPage() {
|
||||
<div className="flex flex-wrap items-center justify-center gap-2">
|
||||
<StreamingSection entry={e} seasons={seasons} />
|
||||
<a
|
||||
href={`https://www.youtube.com/results?search_query=${encodeURIComponent(e.title + " official trailer")}`}
|
||||
href={`https://www.youtube.com/results?search_query=${encodeURIComponent(e.title + ' official trailer')}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center gap-2 h-11 px-6 text-sm font-medium rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground transition-colors"
|
||||
@@ -552,11 +618,39 @@ export function EntryDetailsPage() {
|
||||
variant="destructive"
|
||||
onConfirm={() => {
|
||||
deleteEntry.mutate(e.id, {
|
||||
onSuccess: () => navigate("/library"),
|
||||
onSuccess: () => navigate('/library'),
|
||||
});
|
||||
setShowDeleteConfirm(false);
|
||||
}}
|
||||
/>
|
||||
|
||||
<Dialog open={showStatusDialog} onOpenChange={setShowStatusDialog}>
|
||||
<DialogContent className="sm:max-w-xs">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Set Watch Status</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="space-y-1">
|
||||
{WATCH_STATUSES.map((s) => (
|
||||
<button
|
||||
key={s.value}
|
||||
onClick={() => {
|
||||
updateEntry.mutate({
|
||||
id: e.id,
|
||||
data: { watch_status: s.value },
|
||||
});
|
||||
setShowStatusDialog(false);
|
||||
}}
|
||||
className={`w-full flex items-center gap-2 rounded-md px-3 py-2 text-sm transition-colors hover:bg-accent ${
|
||||
e.watch_status === s.value ? 'bg-accent font-medium' : ''
|
||||
}`}
|
||||
>
|
||||
<BookmarkCheck className="h-4 w-4" />
|
||||
{s.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -598,8 +692,8 @@ function EntryCollectionsSection({ entryId }: { entryId: number }) {
|
||||
</p>
|
||||
{col.entries && (
|
||||
<p className="text-xs text-white/70 mt-0.5">
|
||||
{col.entries.length}{" "}
|
||||
{col.entries.length === 1 ? "title" : "titles"}
|
||||
{col.entries.length}{' '}
|
||||
{col.entries.length === 1 ? 'title' : 'titles'}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -1,49 +1,49 @@
|
||||
import { useState, useMemo, useCallback, useEffect, useRef } from "react";
|
||||
import { useSearchParams, useNavigationType } from "react-router-dom";
|
||||
import { useLibrary } from "@/hooks/useEntries";
|
||||
import { useLibraryEntries } from "@/stores/useLibraryStore";
|
||||
import { useState, useMemo, useCallback, useEffect, useRef } from 'react';
|
||||
import { useSearchParams, useNavigationType } from 'react-router-dom';
|
||||
import { useLibrary } from '@/hooks/useEntries';
|
||||
import { useLibraryEntries } from '@/stores/useLibraryStore';
|
||||
import {
|
||||
useLibraryFiltersStore,
|
||||
defaultFilters,
|
||||
} from "@/stores/useLibraryFiltersStore";
|
||||
} from '@/stores/useLibraryFiltersStore';
|
||||
import type {
|
||||
FilterTab,
|
||||
SortField,
|
||||
SortDir,
|
||||
Filters,
|
||||
} from "@/stores/useLibraryFiltersStore";
|
||||
import { EntryLibraryGrid } from "@/components/entries/EntryLibraryGrid";
|
||||
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
} from '@/stores/useLibraryFiltersStore';
|
||||
import { EntryLibraryGrid } from '@/components/entries/EntryLibraryGrid';
|
||||
import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import {
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverTrigger,
|
||||
} from "@/components/ui/popover";
|
||||
} from '@/components/ui/popover';
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import { Search, X, SlidersHorizontal, ArrowUpDown, Info } from "lucide-react";
|
||||
import type { Entry } from "@/types";
|
||||
} from '@/components/ui/select';
|
||||
import { Search, X, SlidersHorizontal, ArrowUpDown, Info } from 'lucide-react';
|
||||
import type { Entry } from '@/types';
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipProvider,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip";
|
||||
} from '@/components/ui/tooltip';
|
||||
|
||||
const sortLabels: Record<SortField, string> = {
|
||||
date_last_seen: "Last Watched",
|
||||
createdAt: "Date Added",
|
||||
title: "Title",
|
||||
release_date: "Release Date",
|
||||
rating: "Rating",
|
||||
date_last_seen: 'Last Watched',
|
||||
createdAt: 'Date Added',
|
||||
title: 'Title',
|
||||
release_date: 'Release Date',
|
||||
rating: 'Rating',
|
||||
};
|
||||
|
||||
function sortEntries(
|
||||
@@ -54,29 +54,29 @@ function sortEntries(
|
||||
return [...entries].sort((a, b) => {
|
||||
let cmp = 0;
|
||||
switch (field) {
|
||||
case "title":
|
||||
case 'title':
|
||||
cmp = a.title.localeCompare(b.title);
|
||||
break;
|
||||
case "release_date":
|
||||
case 'release_date':
|
||||
cmp =
|
||||
new Date(a.release_date || "1900").getTime() -
|
||||
new Date(b.release_date || "1900").getTime();
|
||||
new Date(a.release_date || '1900').getTime() -
|
||||
new Date(b.release_date || '1900').getTime();
|
||||
break;
|
||||
case "rating":
|
||||
case 'rating':
|
||||
cmp =
|
||||
(a.entryRatings?.user_rating ?? 0) -
|
||||
(b.entryRatings?.user_rating ?? 0);
|
||||
break;
|
||||
case "date_last_seen":
|
||||
case 'date_last_seen':
|
||||
cmp =
|
||||
new Date(a.date_last_seen || "1900").getTime() -
|
||||
new Date(b.date_last_seen || "1900").getTime();
|
||||
new Date(a.date_last_seen || '1900').getTime() -
|
||||
new Date(b.date_last_seen || '1900').getTime();
|
||||
break;
|
||||
case "createdAt":
|
||||
case 'createdAt':
|
||||
cmp = new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime();
|
||||
break;
|
||||
}
|
||||
return dir === "desc" ? -cmp : cmp;
|
||||
return dir === 'desc' ? -cmp : cmp;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -105,12 +105,13 @@ export function LibraryPage() {
|
||||
const [debouncedFilters, setDebouncedFilters] = useState<Filters>(filters);
|
||||
const [visibleCount, setVisibleCount] = useState(PAGE_SIZE);
|
||||
const filtersInitialized = useRef(false);
|
||||
const [statusFilter, setStatusFilter] = useState<string>('');
|
||||
|
||||
const allEntries = useLibraryEntries();
|
||||
|
||||
// Reset filters when navigating TO the library (not when pressing back)
|
||||
useEffect(() => {
|
||||
if (navigationType !== "POP") {
|
||||
if (navigationType !== 'POP') {
|
||||
resetAll();
|
||||
}
|
||||
// Only run on mount
|
||||
@@ -121,9 +122,9 @@ export function LibraryPage() {
|
||||
useEffect(() => {
|
||||
if (filtersInitialized.current) return;
|
||||
filtersInitialized.current = true;
|
||||
const genre = searchParams.get("genre") || "";
|
||||
const ratingMin = searchParams.get("ratingMin") || "";
|
||||
const ratingMax = searchParams.get("ratingMax") || "";
|
||||
const genre = searchParams.get('genre') || '';
|
||||
const ratingMin = searchParams.get('ratingMin') || '';
|
||||
const ratingMax = searchParams.get('ratingMax') || '';
|
||||
if (genre || ratingMin || ratingMax) {
|
||||
const newFilters = {
|
||||
...defaultFilters,
|
||||
@@ -169,21 +170,22 @@ export function LibraryPage() {
|
||||
filters.userRatingMin ||
|
||||
filters.userRatingMax ||
|
||||
filters.yearMin ||
|
||||
filters.yearMax;
|
||||
filters.yearMax ||
|
||||
!!statusFilter;
|
||||
|
||||
const baseEntries = useMemo(() => {
|
||||
switch (activeTab) {
|
||||
case "movies":
|
||||
case 'movies':
|
||||
return allEntries.filter(
|
||||
(e) => !e.is_tvseries && !e.watchlist && !e.hidden,
|
||||
);
|
||||
case "tv":
|
||||
case 'tv':
|
||||
return allEntries.filter(
|
||||
(e) => e.is_tvseries && !e.watchlist && !e.hidden,
|
||||
);
|
||||
case "favorites":
|
||||
case 'favorites':
|
||||
return allEntries.filter((e) => e.favorit && !e.watchlist && !e.hidden);
|
||||
case "hidden":
|
||||
case 'hidden':
|
||||
return allEntries.filter((e) => e.hidden);
|
||||
default:
|
||||
return allEntries.filter((e) => !e.watchlist && !e.hidden);
|
||||
@@ -195,7 +197,7 @@ export function LibraryPage() {
|
||||
|
||||
if (debouncedSearch) {
|
||||
const q = debouncedSearch.toLowerCase();
|
||||
const directorPrefix = "@director:";
|
||||
const directorPrefix = '@director:';
|
||||
if (q.startsWith(directorPrefix)) {
|
||||
const dirQuery = q.slice(directorPrefix.length).trim();
|
||||
if (dirQuery) {
|
||||
@@ -208,6 +210,13 @@ export function LibraryPage() {
|
||||
}
|
||||
}
|
||||
|
||||
// Status filter (TV series only)
|
||||
if (statusFilter) {
|
||||
result = result.filter(
|
||||
(e) => e.is_tvseries && e.watch_status === statusFilter,
|
||||
);
|
||||
}
|
||||
|
||||
if (debouncedFilters.genre) {
|
||||
result = result.filter((e) =>
|
||||
e.genres?.some((g) => g.name === debouncedFilters.genre),
|
||||
@@ -272,7 +281,7 @@ export function LibraryPage() {
|
||||
/>
|
||||
{search && (
|
||||
<button
|
||||
onClick={() => setSearch("")}
|
||||
onClick={() => setSearch('')}
|
||||
className="absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
<X className="h-4 w-4" />
|
||||
@@ -294,19 +303,19 @@ export function LibraryPage() {
|
||||
<p className="mb-0.5">
|
||||
<code className="bg-accent px-1 rounded text-[11px]">
|
||||
@director:name
|
||||
</code>{" "}
|
||||
</code>{' '}
|
||||
— by director
|
||||
</p>
|
||||
<p className="text-muted-foreground mb-0.5">
|
||||
<code className="bg-accent px-1 rounded text-[11px]">
|
||||
@country:name
|
||||
</code>{" "}
|
||||
</code>{' '}
|
||||
— coming soon
|
||||
</p>
|
||||
<p className="text-muted-foreground">
|
||||
<code className="bg-accent px-1 rounded text-[11px]">
|
||||
@year:year
|
||||
</code>{" "}
|
||||
</code>{' '}
|
||||
— coming soon
|
||||
</p>
|
||||
</PopoverContent>
|
||||
@@ -321,7 +330,7 @@ export function LibraryPage() {
|
||||
className="h-9 w-9 shrink-0 relative"
|
||||
>
|
||||
<ArrowUpDown className="h-4 w-4" />
|
||||
{sortField !== "date_last_seen" && (
|
||||
{sortField !== 'date_last_seen' && (
|
||||
<span className="absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary" />
|
||||
)}
|
||||
</Button>
|
||||
@@ -337,8 +346,8 @@ export function LibraryPage() {
|
||||
onClick={() => setSortField(value as SortField)}
|
||||
className={`w-full rounded-md px-3 py-1.5 text-left text-sm transition-colors ${
|
||||
sortField === value
|
||||
? "bg-accent text-accent-foreground font-medium"
|
||||
: "hover:bg-accent/50"
|
||||
? 'bg-accent text-accent-foreground font-medium'
|
||||
: 'hover:bg-accent/50'
|
||||
}`}
|
||||
>
|
||||
{label}
|
||||
@@ -347,18 +356,18 @@ export function LibraryPage() {
|
||||
</div>
|
||||
<div className="flex gap-1 pt-1 border-t border-border">
|
||||
<Button
|
||||
variant={sortDir === "desc" ? "default" : "outline"}
|
||||
variant={sortDir === 'desc' ? 'default' : 'outline'}
|
||||
size="sm"
|
||||
className="flex-1 h-8 text-xs"
|
||||
onClick={() => setSortDir("desc")}
|
||||
onClick={() => setSortDir('desc')}
|
||||
>
|
||||
↓ Desc
|
||||
</Button>
|
||||
<Button
|
||||
variant={sortDir === "asc" ? "default" : "outline"}
|
||||
variant={sortDir === 'asc' ? 'default' : 'outline'}
|
||||
size="sm"
|
||||
className="flex-1 h-8 text-xs"
|
||||
onClick={() => setSortDir("asc")}
|
||||
onClick={() => setSortDir('asc')}
|
||||
>
|
||||
↑ Asc
|
||||
</Button>
|
||||
@@ -388,7 +397,7 @@ export function LibraryPage() {
|
||||
onValueChange={(v) =>
|
||||
setFilters((f) => ({
|
||||
...f,
|
||||
genre: v === "_all" ? "" : v || "",
|
||||
genre: v === '_all' ? '' : v || '',
|
||||
}))
|
||||
}
|
||||
>
|
||||
@@ -405,6 +414,25 @@ export function LibraryPage() {
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="">
|
||||
<label className="text-sm font-medium">Status</label>
|
||||
<Select
|
||||
value={statusFilter}
|
||||
onValueChange={(v) => setStatusFilter(v === '_all' ? '' : v)}
|
||||
>
|
||||
<SelectTrigger className="h-9">
|
||||
<SelectValue placeholder="Any status" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="_all">Any status</SelectItem>
|
||||
<SelectItem value="plan_to_watch">Plan to Watch</SelectItem>
|
||||
<SelectItem value="watching">Watching</SelectItem>
|
||||
<SelectItem value="completed">Completed</SelectItem>
|
||||
<SelectItem value="on_hold">On Hold</SelectItem>
|
||||
<SelectItem value="dropped">Dropped</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="">
|
||||
<label className="text-sm font-medium">TMDB Rating</label>
|
||||
<div className="flex items-center gap-2">
|
||||
@@ -559,26 +587,26 @@ export function LibraryPage() {
|
||||
<p className="mb-0.5">
|
||||
<code className="bg-accent px-1 rounded text-[11px]">
|
||||
@director:name
|
||||
</code>{" "}
|
||||
</code>{' '}
|
||||
— by director
|
||||
</p>
|
||||
<p className="text-muted-foreground mb-0.5">
|
||||
<code className="bg-accent px-1 rounded text-[11px]">
|
||||
@country:name
|
||||
</code>{" "}
|
||||
</code>{' '}
|
||||
— coming soon
|
||||
</p>
|
||||
<p className="text-muted-foreground">
|
||||
<code className="bg-accent px-1 rounded text-[11px]">
|
||||
@year:year
|
||||
</code>{" "}
|
||||
</code>{' '}
|
||||
— coming soon
|
||||
</p>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
|
||||
{search && (
|
||||
<Button variant="ghost" size="sm" onClick={() => setSearch("")}>
|
||||
<Button variant="ghost" size="sm" onClick={() => setSearch('')}>
|
||||
<X className="mr-1 h-4 w-4" /> Clear
|
||||
</Button>
|
||||
)}
|
||||
@@ -592,7 +620,7 @@ export function LibraryPage() {
|
||||
<ArrowUpDown className="h-4 w-4" />
|
||||
{sortLabels[sortField]}
|
||||
<span className="text-xs opacity-60">
|
||||
{sortDir === "desc" ? "↓" : "↑"}
|
||||
{sortDir === 'desc' ? '↓' : '↑'}
|
||||
</span>
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
@@ -607,8 +635,8 @@ export function LibraryPage() {
|
||||
onClick={() => setSortField(value as SortField)}
|
||||
className={`w-full rounded-md px-3 py-1.5 text-left text-sm transition-colors ${
|
||||
sortField === value
|
||||
? "bg-accent text-accent-foreground font-medium"
|
||||
: "hover:bg-accent/50"
|
||||
? 'bg-accent text-accent-foreground font-medium'
|
||||
: 'hover:bg-accent/50'
|
||||
}`}
|
||||
>
|
||||
{label}
|
||||
@@ -617,18 +645,18 @@ export function LibraryPage() {
|
||||
</div>
|
||||
<div className="flex gap-1 pt-1 border-t border-border">
|
||||
<Button
|
||||
variant={sortDir === "desc" ? "default" : "outline"}
|
||||
variant={sortDir === 'desc' ? 'default' : 'outline'}
|
||||
size="sm"
|
||||
className="flex-1 h-8 text-xs"
|
||||
onClick={() => setSortDir("desc")}
|
||||
onClick={() => setSortDir('desc')}
|
||||
>
|
||||
↓ Desc
|
||||
</Button>
|
||||
<Button
|
||||
variant={sortDir === "asc" ? "default" : "outline"}
|
||||
variant={sortDir === 'asc' ? 'default' : 'outline'}
|
||||
size="sm"
|
||||
className="flex-1 h-8 text-xs"
|
||||
onClick={() => setSortDir("asc")}
|
||||
onClick={() => setSortDir('asc')}
|
||||
>
|
||||
↑ Asc
|
||||
</Button>
|
||||
@@ -660,7 +688,7 @@ export function LibraryPage() {
|
||||
onValueChange={(v) =>
|
||||
setFilters((f) => ({
|
||||
...f,
|
||||
genre: v === "_all" ? "" : v || "",
|
||||
genre: v === '_all' ? '' : v || '',
|
||||
}))
|
||||
}
|
||||
>
|
||||
@@ -677,6 +705,25 @@ export function LibraryPage() {
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="space-y-2 mb-0">
|
||||
<label className="text-sm font-medium">Status</label>
|
||||
<Select
|
||||
value={statusFilter}
|
||||
onValueChange={(v) => setStatusFilter(v === '_all' ? '' : v)}
|
||||
>
|
||||
<SelectTrigger className="h-9 w-full">
|
||||
<SelectValue placeholder="Any status" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="_all">Any status</SelectItem>
|
||||
<SelectItem value="plan_to_watch">Plan to Watch</SelectItem>
|
||||
<SelectItem value="watching">Watching</SelectItem>
|
||||
<SelectItem value="completed">Completed</SelectItem>
|
||||
<SelectItem value="on_hold">On Hold</SelectItem>
|
||||
<SelectItem value="dropped">Dropped</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="space-y-2 mb-0">
|
||||
<label className="text-sm font-medium">TMDB Rating</label>
|
||||
<div className="flex items-center gap-2">
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
import { useState } from "react";
|
||||
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { settingsApi } from "@/api/settings";
|
||||
import { maintenanceApi, type OrphanResult } from "@/api/maintenance";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { z } from "zod";
|
||||
import { useState } from 'react';
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { settingsApi } from '@/api/settings';
|
||||
import { maintenanceApi, type OrphanResult } from '@/api/maintenance';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { z } from 'zod';
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
CardDescription,
|
||||
} from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Save, Search, Trash2, Loader2 } from "lucide-react";
|
||||
import type { Settings } from "@/types";
|
||||
} from '@/components/ui/card';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Save, Search, Trash2, Loader2 } from 'lucide-react';
|
||||
import type { Settings } from '@/types';
|
||||
|
||||
const settingsSchema = z.object({
|
||||
tmdbApiKey: z.string().min(1, "TMDB API key is required"),
|
||||
tmdbApiKey: z.string().min(1, 'TMDB API key is required'),
|
||||
backPort: z.coerce.number().int().positive(),
|
||||
});
|
||||
|
||||
@@ -30,7 +30,7 @@ function formatOrphanResult(result: OrphanResult): string {
|
||||
if (result.logos) parts.push(`${result.logos} logo(s)`);
|
||||
if (result.backdrops) parts.push(`${result.backdrops} backdrop(s)`);
|
||||
if (result.stills) parts.push(`${result.stills} still(s)`);
|
||||
return parts.length > 0 ? parts.join(", ") : "None found";
|
||||
return parts.length > 0 ? parts.join(', ') : 'None found';
|
||||
}
|
||||
|
||||
function hasOrphans(result: OrphanResult | null): boolean {
|
||||
@@ -88,7 +88,7 @@ function MissingDirectorsSection() {
|
||||
{result && (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{result.count === 0
|
||||
? "All entries have directors."
|
||||
? 'All entries have directors.'
|
||||
: result.fixed > 0
|
||||
? `Fixed ${result.fixed} of ${result.count} missing directors.`
|
||||
: `${result.count} entries missing director.`}
|
||||
@@ -150,7 +150,7 @@ function DuplicateCreditsSection() {
|
||||
{result && (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{result.duplicates === 0
|
||||
? "No duplicate credits found."
|
||||
? 'No duplicate credits found.'
|
||||
: result.deleted > 0
|
||||
? `Removed ${result.deleted} duplicates across ${result.groups} groups.`
|
||||
: `${result.duplicates} duplicates across ${result.groups} groups.`}
|
||||
@@ -160,17 +160,65 @@ function DuplicateCreditsSection() {
|
||||
);
|
||||
}
|
||||
|
||||
function WatchStatusesSection() {
|
||||
const [fixResult, setFixResult] = useState<{
|
||||
completed: number;
|
||||
watching: number;
|
||||
planToWatch: number;
|
||||
} | null>(null);
|
||||
|
||||
const autoFix = useMutation({
|
||||
mutationFn: maintenanceApi.autoFixWatchStatuses,
|
||||
onSuccess: (data) => setFixResult(data),
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<p className="text-xs text-muted-foreground">
|
||||
TV series only. Sets status based on watched episodes (excl. season 0).
|
||||
</p>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => autoFix.mutate()}
|
||||
disabled={autoFix.isPending}
|
||||
>
|
||||
{autoFix.isPending ? (
|
||||
<Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />
|
||||
) : (
|
||||
<Save className="mr-1.5 h-3.5 w-3.5" />
|
||||
)}
|
||||
Auto-Fix
|
||||
</Button>
|
||||
</div>
|
||||
{fixResult && (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{fixResult.completed > 0 && `${fixResult.completed} → Completed. `}
|
||||
{fixResult.watching > 0 && `${fixResult.watching} → Watching. `}
|
||||
{fixResult.planToWatch > 0 &&
|
||||
`${fixResult.planToWatch} → Plan to Watch. `}
|
||||
{fixResult.completed === 0 &&
|
||||
fixResult.watching === 0 &&
|
||||
fixResult.planToWatch === 0 &&
|
||||
'All statuses up to date.'}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function SettingsPage() {
|
||||
const queryClient = useQueryClient();
|
||||
const { data: settings, isLoading } = useQuery({
|
||||
queryKey: ["settings"],
|
||||
queryKey: ['settings'],
|
||||
queryFn: settingsApi.get,
|
||||
});
|
||||
|
||||
const updateSettings = useMutation({
|
||||
mutationFn: (data: Partial<Settings>) => settingsApi.update(data),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["settings"] });
|
||||
queryClient.invalidateQueries({ queryKey: ['settings'] });
|
||||
},
|
||||
});
|
||||
|
||||
@@ -241,7 +289,7 @@ export function SettingsPage() {
|
||||
<Input
|
||||
id="tmdbApiKey"
|
||||
type="password"
|
||||
{...register("tmdbApiKey")}
|
||||
{...register('tmdbApiKey')}
|
||||
/>
|
||||
{errors.tmdbApiKey && (
|
||||
<p className="text-xs text-destructive">
|
||||
@@ -252,7 +300,7 @@ export function SettingsPage() {
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="backPort">Backend Port</Label>
|
||||
<Input id="backPort" type="number" {...register("backPort")} />
|
||||
<Input id="backPort" type="number" {...register('backPort')} />
|
||||
{errors.backPort && (
|
||||
<p className="text-xs text-destructive">
|
||||
{errors.backPort.message}
|
||||
@@ -265,7 +313,7 @@ export function SettingsPage() {
|
||||
disabled={!isDirty || updateSettings.isPending}
|
||||
>
|
||||
<Save className="mr-2 h-4 w-4" />
|
||||
{updateSettings.isPending ? "Saving..." : "Save Settings"}
|
||||
{updateSettings.isPending ? 'Saving...' : 'Save Settings'}
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
@@ -396,6 +444,20 @@ export function SettingsPage() {
|
||||
<DuplicateCreditsSection />
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Watch Statuses */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Watch Statuses</CardTitle>
|
||||
<CardDescription>
|
||||
Initialize or auto-fix watch statuses for TV series based on watched
|
||||
episodes.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<WatchStatusesSection />
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -15,9 +15,9 @@ export interface EntryRatings {
|
||||
|
||||
export interface Media {
|
||||
id: number;
|
||||
mediaable: "entry" | "people" | "collection" | "season" | "episode";
|
||||
mediaable: 'entry' | 'people' | 'collection' | 'season' | 'episode';
|
||||
mediaable_id: number;
|
||||
type: "poster" | "backdrop" | "logo" | "still" | "profile";
|
||||
type: 'poster' | 'backdrop' | 'logo' | 'still' | 'profile';
|
||||
path: string;
|
||||
is_local: boolean;
|
||||
is_selected: boolean;
|
||||
@@ -55,6 +55,7 @@ export interface Entry {
|
||||
credits?: Credit[];
|
||||
/** Computed — director name string for search (not persisted in DB) */
|
||||
director?: string | null;
|
||||
watch_status?: string | null;
|
||||
seasons?: Season[];
|
||||
entrySeens?: EntrySeen[];
|
||||
episodeSeens?: EpisodeSeen[];
|
||||
@@ -104,7 +105,7 @@ export interface Episode {
|
||||
season?: Season;
|
||||
}
|
||||
|
||||
export type SeenAccuracy = "EXACT" | "ESTIMATED" | "UNKNOWN";
|
||||
export type SeenAccuracy = 'EXACT' | 'ESTIMATED' | 'UNKNOWN';
|
||||
|
||||
export interface EntrySeen {
|
||||
id: number;
|
||||
@@ -168,7 +169,7 @@ export interface Credit {
|
||||
entry_id: number;
|
||||
people_id: number;
|
||||
character: string | null; // might contain multiple separated by ;
|
||||
cast_type: "cast" | "crew";
|
||||
cast_type: 'cast' | 'crew';
|
||||
department: string | null;
|
||||
job: string | null;
|
||||
episode_count?: number | null;
|
||||
@@ -250,7 +251,7 @@ export interface TmdbPaginatedResponse<T> {
|
||||
|
||||
export interface TmdbPreviewCredit {
|
||||
id: string | number;
|
||||
cast_type: "cast";
|
||||
cast_type: 'cast';
|
||||
character: string | null;
|
||||
people_id: number;
|
||||
people: {
|
||||
|
||||
Reference in new issue
Block a user