Auto-upgrade TV status on watch, full-width layout, settings tabs
Marking episode/entry as watched now auto-upgrades TV series from plan_to_watch/null to watching. Settings page uses tabs (General/Maintenance) with 2-column grid. AppLayout container removed for full-width pages.
This commit is contained in:
1 parent
cdbaedd7d0
commit
b001ee2240
4 files changed
+267
-215
No files matched your search
@@ -16,6 +16,7 @@ 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 { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||
import { Save, Search, Trash2, Loader2 } from 'lucide-react';
|
||||
import type { Settings } from '@/types';
|
||||
|
||||
@@ -275,189 +276,220 @@ export function SettingsPage() {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6 max-w-2xl">
|
||||
<div className="space-y-6">
|
||||
<h1 className="text-2xl font-bold">Settings</h1>
|
||||
|
||||
<form onSubmit={handleSubmit(onSubmit)}>
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>General</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="tmdbApiKey">TMDB API Key</Label>
|
||||
<Input
|
||||
id="tmdbApiKey"
|
||||
type="password"
|
||||
{...register('tmdbApiKey')}
|
||||
/>
|
||||
{errors.tmdbApiKey && (
|
||||
<p className="text-xs text-destructive">
|
||||
{errors.tmdbApiKey.message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<Tabs defaultValue="general">
|
||||
<TabsList>
|
||||
<TabsTrigger value="general">General</TabsTrigger>
|
||||
<TabsTrigger value="maintenance">Maintenance</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="backPort">Backend Port</Label>
|
||||
<Input id="backPort" type="number" {...register('backPort')} />
|
||||
{errors.backPort && (
|
||||
<p className="text-xs text-destructive">
|
||||
{errors.backPort.message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={!isDirty || updateSettings.isPending}
|
||||
>
|
||||
<Save className="mr-2 h-4 w-4" />
|
||||
{updateSettings.isPending ? 'Saving...' : 'Save Settings'}
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</form>
|
||||
|
||||
{/* Cleanup Section */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Media Cleanup</CardTitle>
|
||||
<CardDescription>
|
||||
Scan and remove orphan files or database records that no longer have
|
||||
a matching counterpart.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-6">
|
||||
{/* Orphan Files */}
|
||||
<div className="space-y-2">
|
||||
<Label className="text-sm font-medium">Orphan Files</Label>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Files on disk that have no matching database record.
|
||||
</p>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => scanOrphanFiles.mutate()}
|
||||
disabled={scanOrphanFiles.isPending}
|
||||
>
|
||||
{scanOrphanFiles.isPending ? (
|
||||
<Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />
|
||||
) : (
|
||||
<Search className="mr-1.5 h-3.5 w-3.5" />
|
||||
)}
|
||||
Scan
|
||||
</Button>
|
||||
{hasOrphans(orphanFilesResult) && (
|
||||
<Button
|
||||
variant="destructive"
|
||||
size="sm"
|
||||
onClick={() => deleteOrphanFiles.mutate()}
|
||||
disabled={deleteOrphanFiles.isPending}
|
||||
>
|
||||
{deleteOrphanFiles.isPending ? (
|
||||
<Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />
|
||||
) : (
|
||||
<Trash2 className="mr-1.5 h-3.5 w-3.5" />
|
||||
<TabsContent value="general" className="mt-4">
|
||||
<form onSubmit={handleSubmit(onSubmit)}>
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>General</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="tmdbApiKey">TMDB API Key</Label>
|
||||
<Input
|
||||
id="tmdbApiKey"
|
||||
type="password"
|
||||
{...register('tmdbApiKey')}
|
||||
/>
|
||||
{errors.tmdbApiKey && (
|
||||
<p className="text-xs text-destructive">
|
||||
{errors.tmdbApiKey.message}
|
||||
</p>
|
||||
)}
|
||||
Delete
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
{orphanFilesResult && (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{formatOrphanResult(orphanFilesResult)}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Orphan Media Records */}
|
||||
<div className="space-y-2">
|
||||
<Label className="text-sm font-medium">Orphan Media Records</Label>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Database records that have no matching file on disk.
|
||||
</p>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => scanOrphanRecords.mutate()}
|
||||
disabled={scanOrphanRecords.isPending}
|
||||
>
|
||||
{scanOrphanRecords.isPending ? (
|
||||
<Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />
|
||||
) : (
|
||||
<Search className="mr-1.5 h-3.5 w-3.5" />
|
||||
)}
|
||||
Scan
|
||||
</Button>
|
||||
{hasOrphans(orphanRecordsResult) && (
|
||||
<Button
|
||||
variant="destructive"
|
||||
size="sm"
|
||||
onClick={() => deleteOrphanRecords.mutate()}
|
||||
disabled={deleteOrphanRecords.isPending}
|
||||
>
|
||||
{deleteOrphanRecords.isPending ? (
|
||||
<Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />
|
||||
) : (
|
||||
<Trash2 className="mr-1.5 h-3.5 w-3.5" />
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="backPort">Backend Port</Label>
|
||||
<Input
|
||||
id="backPort"
|
||||
type="number"
|
||||
{...register('backPort')}
|
||||
/>
|
||||
{errors.backPort && (
|
||||
<p className="text-xs text-destructive">
|
||||
{errors.backPort.message}
|
||||
</p>
|
||||
)}
|
||||
Delete
|
||||
</div>
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={!isDirty || updateSettings.isPending}
|
||||
>
|
||||
<Save className="mr-2 h-4 w-4" />
|
||||
{updateSettings.isPending ? 'Saving...' : 'Save Settings'}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
{orphanRecordsResult && (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{formatOrphanResult(orphanRecordsResult)}
|
||||
</p>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</form>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="maintenance" className="mt-4">
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Media Cleanup</CardTitle>
|
||||
<CardDescription>
|
||||
Scan and remove orphan files or database records that no
|
||||
longer have a matching counterpart.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-6">
|
||||
<div className="space-y-2">
|
||||
<Label className="text-sm font-medium">Orphan Files</Label>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Files on disk that have no matching database record.
|
||||
</p>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => scanOrphanFiles.mutate()}
|
||||
disabled={scanOrphanFiles.isPending}
|
||||
>
|
||||
{scanOrphanFiles.isPending ? (
|
||||
<Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />
|
||||
) : (
|
||||
<Search className="mr-1.5 h-3.5 w-3.5" />
|
||||
)}
|
||||
Scan
|
||||
</Button>
|
||||
{hasOrphans(orphanFilesResult) && (
|
||||
<Button
|
||||
variant="destructive"
|
||||
size="sm"
|
||||
onClick={() => deleteOrphanFiles.mutate()}
|
||||
disabled={deleteOrphanFiles.isPending}
|
||||
>
|
||||
{deleteOrphanFiles.isPending ? (
|
||||
<Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />
|
||||
) : (
|
||||
<Trash2 className="mr-1.5 h-3.5 w-3.5" />
|
||||
)}
|
||||
Delete
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
{orphanFilesResult && (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{formatOrphanResult(orphanFilesResult)}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label className="text-sm font-medium">
|
||||
Orphan Media Records
|
||||
</Label>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Database records that have no matching file on disk.
|
||||
</p>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => scanOrphanRecords.mutate()}
|
||||
disabled={scanOrphanRecords.isPending}
|
||||
>
|
||||
{scanOrphanRecords.isPending ? (
|
||||
<Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />
|
||||
) : (
|
||||
<Search className="mr-1.5 h-3.5 w-3.5" />
|
||||
)}
|
||||
Scan
|
||||
</Button>
|
||||
{hasOrphans(orphanRecordsResult) && (
|
||||
<Button
|
||||
variant="destructive"
|
||||
size="sm"
|
||||
onClick={() => deleteOrphanRecords.mutate()}
|
||||
disabled={deleteOrphanRecords.isPending}
|
||||
>
|
||||
{deleteOrphanRecords.isPending ? (
|
||||
<Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />
|
||||
) : (
|
||||
<Trash2 className="mr-1.5 h-3.5 w-3.5" />
|
||||
)}
|
||||
Delete
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
{orphanRecordsResult && (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{formatOrphanResult(orphanRecordsResult)}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Watch Statuses</CardTitle>
|
||||
<CardDescription>
|
||||
Auto-fix watch statuses for TV series based on watched
|
||||
episodes (excl. season 0).
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<ul className="text-xs text-muted-foreground list-disc pl-4 mb-3 space-y-0.5">
|
||||
<li>
|
||||
Entries with all episodes watched → set to{' '}
|
||||
<strong>Completed</strong>
|
||||
</li>
|
||||
<li>
|
||||
Entries marked Completed but missing episodes → downgrade to{' '}
|
||||
<strong>Watching</strong>
|
||||
</li>
|
||||
<li>
|
||||
Entries with at least one episode watched and no status →
|
||||
set to <strong>Watching</strong>
|
||||
</li>
|
||||
<li>
|
||||
Entries in Watchlist with no status → set to{' '}
|
||||
<strong>Plan to Watch</strong>
|
||||
</li>
|
||||
</ul>
|
||||
<WatchStatusesSection />
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Duplicate Credits</CardTitle>
|
||||
<CardDescription>
|
||||
Find and remove duplicate credits where the same person
|
||||
appears multiple times with the same role on the same entry.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<DuplicateCreditsSection />
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Missing Directors</CardTitle>
|
||||
<CardDescription>
|
||||
Populate the director field for entries that don't have one
|
||||
yet, using existing credit data.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<MissingDirectorsSection />
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Missing Directors */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Missing Directors</CardTitle>
|
||||
<CardDescription>
|
||||
Populate the director field for entries that don't have one yet,
|
||||
using existing credit data.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<MissingDirectorsSection />
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Duplicate Credits */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Duplicate Credits</CardTitle>
|
||||
<CardDescription>
|
||||
Find and remove duplicate credits where the same person appears
|
||||
multiple times with the same role on the same entry.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<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>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user