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,9 +1,9 @@
|
|||||||
const EntryRating = require("../models/EntryRating");
|
const EntryRating = require('../models/EntryRating');
|
||||||
const collectionManager = require("../services/collectionManager");
|
const collectionManager = require('../services/collectionManager');
|
||||||
const entryManager = require("../services/entryManager");
|
const entryManager = require('../services/entryManager');
|
||||||
const entryService = require("../services/entryService");
|
const entryService = require('../services/entryService');
|
||||||
const tmdbService = require("../services/tmdbService");
|
const tmdbService = require('../services/tmdbService');
|
||||||
const asyncWrapper = require("../utils/asyncWrapper");
|
const asyncWrapper = require('../utils/asyncWrapper');
|
||||||
|
|
||||||
const _collectionManager = collectionManager;
|
const _collectionManager = collectionManager;
|
||||||
const _entryManager = entryManager;
|
const _entryManager = entryManager;
|
||||||
@@ -105,7 +105,7 @@ class EntryController {
|
|||||||
const seasons = await _entryService.getEntrySeasons(id);
|
const seasons = await _entryService.getEntrySeasons(id);
|
||||||
|
|
||||||
if (seasons.length == 0) {
|
if (seasons.length == 0) {
|
||||||
res.status(204).json({ message: "Provided entry has no seasons" });
|
return res.status(204).json({ message: 'Provided entry has no seasons' });
|
||||||
}
|
}
|
||||||
|
|
||||||
res.status(200).json(seasons);
|
res.status(200).json(seasons);
|
||||||
@@ -145,7 +145,7 @@ class EntryController {
|
|||||||
const { page } = req.query;
|
const { page } = req.query;
|
||||||
const data = await tmdbService.fetchTrending(type, page || 1);
|
const data = await tmdbService.fetchTrending(type, page || 1);
|
||||||
if (!data)
|
if (!data)
|
||||||
return res.status(500).json({ message: "Failed to fetch trending data" });
|
return res.status(500).json({ message: 'Failed to fetch trending data' });
|
||||||
res.status(200).json(data);
|
res.status(200).json(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ class EntryController {
|
|||||||
const { page } = req.query;
|
const { page } = req.query;
|
||||||
const data = await tmdbService.fetchPopular(type, page || 1);
|
const data = await tmdbService.fetchPopular(type, page || 1);
|
||||||
if (!data)
|
if (!data)
|
||||||
return res.status(500).json({ message: "Failed to fetch popular data" });
|
return res.status(500).json({ message: 'Failed to fetch popular data' });
|
||||||
res.status(200).json(data);
|
res.status(200).json(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -163,10 +163,10 @@ class EntryController {
|
|||||||
getTmdbSearch = asyncWrapper(async (req, res) => {
|
getTmdbSearch = asyncWrapper(async (req, res) => {
|
||||||
const { query, page } = req.query;
|
const { query, page } = req.query;
|
||||||
if (!query)
|
if (!query)
|
||||||
return res.status(400).json({ message: "Query parameter is required" });
|
return res.status(400).json({ message: 'Query parameter is required' });
|
||||||
const data = await tmdbService.searchMulti(query, page || 1);
|
const data = await tmdbService.searchMulti(query, page || 1);
|
||||||
if (!data)
|
if (!data)
|
||||||
return res.status(500).json({ message: "Failed to search TMDB" });
|
return res.status(500).json({ message: 'Failed to search TMDB' });
|
||||||
res.status(200).json(data);
|
res.status(200).json(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -178,7 +178,7 @@ class EntryController {
|
|||||||
if (!data)
|
if (!data)
|
||||||
return res
|
return res
|
||||||
.status(500)
|
.status(500)
|
||||||
.json({ message: "Failed to fetch top rated data" });
|
.json({ message: 'Failed to fetch top rated data' });
|
||||||
res.status(200).json(data);
|
res.status(200).json(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -187,17 +187,17 @@ class EntryController {
|
|||||||
const { page } = req.query;
|
const { page } = req.query;
|
||||||
const data = await tmdbService.fetchUpcoming(page || 1);
|
const data = await tmdbService.fetchUpcoming(page || 1);
|
||||||
if (!data)
|
if (!data)
|
||||||
return res.status(500).json({ message: "Failed to fetch upcoming data" });
|
return res.status(500).json({ message: 'Failed to fetch upcoming data' });
|
||||||
res.status(200).json(data);
|
res.status(200).json(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
// * GET - TMDB PREVIEW (fetch details without saving to library)
|
// * GET - TMDB PREVIEW (fetch details without saving to library)
|
||||||
getTmdbPreview = asyncWrapper(async (req, res) => {
|
getTmdbPreview = asyncWrapper(async (req, res) => {
|
||||||
const { type, tmdbId } = req.params;
|
const { type, tmdbId } = req.params;
|
||||||
const is_tvserie = type === "tv";
|
const is_tvserie = type === 'tv';
|
||||||
const data = await tmdbService.fetchEntryData(tmdbId, is_tvserie);
|
const data = await tmdbService.fetchEntryData(tmdbId, is_tvserie);
|
||||||
if (!data)
|
if (!data)
|
||||||
return res.status(404).json({ message: "Entry not found on TMDB" });
|
return res.status(404).json({ message: 'Entry not found on TMDB' });
|
||||||
|
|
||||||
// Fetch credits in parallel
|
// Fetch credits in parallel
|
||||||
const creditsData = await tmdbService.fetchEntryCredits(tmdbId, is_tvserie);
|
const creditsData = await tmdbService.fetchEntryCredits(tmdbId, is_tvserie);
|
||||||
@@ -208,7 +208,7 @@ class EntryController {
|
|||||||
for (const c of creditsData.cast) {
|
for (const c of creditsData.cast) {
|
||||||
credits.push({
|
credits.push({
|
||||||
id: c.credit_id || c.id,
|
id: c.credit_id || c.id,
|
||||||
cast_type: "cast",
|
cast_type: 'cast',
|
||||||
character: is_tvserie
|
character: is_tvserie
|
||||||
? c.roles?.[0]?.character || c.character || null
|
? c.roles?.[0]?.character || c.character || null
|
||||||
: c.character || null,
|
: c.character || null,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const maintenanceService = require("../services/maintenanceService");
|
const maintenanceService = require('../services/maintenanceService');
|
||||||
|
|
||||||
const _maintenanceService = maintenanceService;
|
const _maintenanceService = maintenanceService;
|
||||||
|
|
||||||
@@ -63,6 +63,11 @@ class MaintenanceController {
|
|||||||
const result = await _maintenanceService.cleanDuplicateCredits();
|
const result = await _maintenanceService.cleanDuplicateCredits();
|
||||||
return res.status(200).json(result);
|
return res.status(200).json(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async autoFixWatchStatuses(req, res) {
|
||||||
|
const result = await _maintenanceService.autoFixWatchStatuses();
|
||||||
|
return res.status(200).json(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = new MaintenanceController();
|
module.exports = new MaintenanceController();
|
||||||
+24
-18
@@ -1,13 +1,13 @@
|
|||||||
const { DataTypes } = require("sequelize");
|
const { DataTypes } = require('sequelize');
|
||||||
const sequelize = require("../config/database");
|
const sequelize = require('../config/database');
|
||||||
|
|
||||||
const Entry = sequelize.define("entry", {
|
const Entry = sequelize.define('entry', {
|
||||||
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
|
||||||
|
|
||||||
title: { type: DataTypes.STRING(500) },
|
title: { type: DataTypes.STRING(500) },
|
||||||
original_title: { type: DataTypes.STRING(100), field: "original_title" },
|
original_title: { type: DataTypes.STRING(100), field: 'original_title' },
|
||||||
release_date: { type: DataTypes.DATE, field: "release_date" },
|
release_date: { type: DataTypes.DATE, field: 'release_date' },
|
||||||
release_status: { type: DataTypes.STRING(50), field: "release_status" },
|
release_status: { type: DataTypes.STRING(50), field: 'release_status' },
|
||||||
runtime: { type: DataTypes.INTEGER },
|
runtime: { type: DataTypes.INTEGER },
|
||||||
|
|
||||||
tagline: { type: DataTypes.STRING(200) },
|
tagline: { type: DataTypes.STRING(200) },
|
||||||
@@ -15,13 +15,13 @@ const Entry = sequelize.define("entry", {
|
|||||||
country: { type: DataTypes.STRING(30) },
|
country: { type: DataTypes.STRING(30) },
|
||||||
|
|
||||||
certification: { type: DataTypes.INTEGER },
|
certification: { type: DataTypes.INTEGER },
|
||||||
network_studio: { type: DataTypes.STRING(40), field: "network_studio" },
|
network_studio: { type: DataTypes.STRING(40), field: 'network_studio' },
|
||||||
collection_id: { type: DataTypes.INTEGER, field: "collection_id" },
|
collection_id: { type: DataTypes.INTEGER, field: 'collection_id' },
|
||||||
max_cast: { type: DataTypes.INTEGER, field: "max_cast", defaultValue: 10 },
|
max_cast: { type: DataTypes.INTEGER, field: 'max_cast', defaultValue: 10 },
|
||||||
credit_fetched: {
|
credit_fetched: {
|
||||||
type: DataTypes.BOOLEAN,
|
type: DataTypes.BOOLEAN,
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
field: "credit_fetched",
|
field: 'credit_fetched',
|
||||||
},
|
},
|
||||||
|
|
||||||
watchlist: { type: DataTypes.BOOLEAN, defaultValue: false },
|
watchlist: { type: DataTypes.BOOLEAN, defaultValue: false },
|
||||||
@@ -30,29 +30,35 @@ const Entry = sequelize.define("entry", {
|
|||||||
showInCalendar: {
|
showInCalendar: {
|
||||||
type: DataTypes.BOOLEAN,
|
type: DataTypes.BOOLEAN,
|
||||||
defaultValue: true,
|
defaultValue: true,
|
||||||
field: "show_in_calendar",
|
field: 'show_in_calendar',
|
||||||
},
|
},
|
||||||
autoSync: { type: DataTypes.BOOLEAN, defaultValue: true, field: "auto_sync" },
|
autoSync: { type: DataTypes.BOOLEAN, defaultValue: true, field: 'auto_sync' },
|
||||||
|
|
||||||
note: { type: DataTypes.STRING(2000) },
|
note: { type: DataTypes.STRING(2000) },
|
||||||
|
|
||||||
is_tvseries: { type: DataTypes.BOOLEAN, field: "is_tvseries" },
|
is_tvseries: { type: DataTypes.BOOLEAN, field: 'is_tvseries' },
|
||||||
status: { type: DataTypes.STRING(20) },
|
status: { type: DataTypes.STRING(20) },
|
||||||
|
|
||||||
poster_path: { type: DataTypes.STRING(200), field: "poster_path" },
|
poster_path: { type: DataTypes.STRING(200), field: 'poster_path' },
|
||||||
banner_path: { type: DataTypes.STRING(200), field: "banner_path" },
|
banner_path: { type: DataTypes.STRING(200), field: 'banner_path' },
|
||||||
|
|
||||||
date_first_seen: { type: DataTypes.DATEONLY, field: "date_first_seen" },
|
date_first_seen: { type: DataTypes.DATEONLY, field: 'date_first_seen' },
|
||||||
date_last_seen: { type: DataTypes.DATEONLY, field: "date_last_seen" },
|
date_last_seen: { type: DataTypes.DATEONLY, field: 'date_last_seen' },
|
||||||
|
|
||||||
last_fetch: { type: DataTypes.DATEONLY },
|
last_fetch: { type: DataTypes.DATEONLY },
|
||||||
|
|
||||||
entry_sync_status: {
|
entry_sync_status: {
|
||||||
type: DataTypes.STRING(50),
|
type: DataTypes.STRING(50),
|
||||||
field: "entry_sync_status",
|
field: 'entry_sync_status',
|
||||||
allowNull: true,
|
allowNull: true,
|
||||||
},
|
},
|
||||||
director: { type: DataTypes.STRING(200), allowNull: true },
|
director: { type: DataTypes.STRING(200), allowNull: true },
|
||||||
|
watch_status: {
|
||||||
|
type: DataTypes.STRING(20),
|
||||||
|
field: 'watch_status',
|
||||||
|
allowNull: true,
|
||||||
|
defaultValue: null,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = Entry;
|
module.exports = Entry;
|
||||||
@@ -1,61 +1,67 @@
|
|||||||
const express = require("express");
|
const express = require('express');
|
||||||
const maintenanceRouter = express.Router();
|
const maintenanceRouter = express.Router();
|
||||||
|
|
||||||
const maintenanceController = require("../controllers/maintenanceController");
|
const maintenanceController = require('../controllers/maintenanceController');
|
||||||
|
|
||||||
// ! /maintenance
|
// ! /maintenance
|
||||||
// * GET - Orphan files
|
// * GET - Orphan files
|
||||||
maintenanceRouter.get("/orphan-files", maintenanceController.getOrpanFiles);
|
maintenanceRouter.get('/orphan-files', maintenanceController.getOrpanFiles);
|
||||||
|
|
||||||
// * GET - Missing files
|
// * GET - Missing files
|
||||||
maintenanceRouter.get(
|
maintenanceRouter.get(
|
||||||
"/orphan-media-records",
|
'/orphan-media-records',
|
||||||
maintenanceController.getOrphanMediaRecords,
|
maintenanceController.getOrphanMediaRecords,
|
||||||
);
|
);
|
||||||
|
|
||||||
// * DELETE - Orphan files
|
// * DELETE - Orphan files
|
||||||
maintenanceRouter.delete(
|
maintenanceRouter.delete(
|
||||||
"/orphan-files",
|
'/orphan-files',
|
||||||
maintenanceController.deleteOrpanFiles,
|
maintenanceController.deleteOrpanFiles,
|
||||||
);
|
);
|
||||||
|
|
||||||
// * DELETE - Missing files
|
// * DELETE - Missing files
|
||||||
maintenanceRouter.delete(
|
maintenanceRouter.delete(
|
||||||
"/orphan-media-records",
|
'/orphan-media-records',
|
||||||
maintenanceController.deleteOrphanMediaRecords,
|
maintenanceController.deleteOrphanMediaRecords,
|
||||||
);
|
);
|
||||||
|
|
||||||
// * GET - Orphan people (dry run)
|
// * GET - Orphan people (dry run)
|
||||||
maintenanceRouter.get("/orphan-people", maintenanceController.getOrphanPeople);
|
maintenanceRouter.get('/orphan-people', maintenanceController.getOrphanPeople);
|
||||||
|
|
||||||
// * DELETE - Orphan people
|
// * DELETE - Orphan people
|
||||||
maintenanceRouter.delete(
|
maintenanceRouter.delete(
|
||||||
"/orphan-people",
|
'/orphan-people',
|
||||||
maintenanceController.deleteOrphanPeople,
|
maintenanceController.deleteOrphanPeople,
|
||||||
);
|
);
|
||||||
|
|
||||||
// * GET - Missing directors count
|
// * GET - Missing directors count
|
||||||
maintenanceRouter.get(
|
maintenanceRouter.get(
|
||||||
"/missing-directors",
|
'/missing-directors',
|
||||||
maintenanceController.getMissingDirectors,
|
maintenanceController.getMissingDirectors,
|
||||||
);
|
);
|
||||||
|
|
||||||
// * POST - Fix missing directors
|
// * POST - Fix missing directors
|
||||||
maintenanceRouter.post(
|
maintenanceRouter.post(
|
||||||
"/missing-directors",
|
'/missing-directors',
|
||||||
maintenanceController.fixMissingDirectors,
|
maintenanceController.fixMissingDirectors,
|
||||||
);
|
);
|
||||||
|
|
||||||
// * GET - Duplicate credits count
|
// * GET - Duplicate credits count
|
||||||
maintenanceRouter.get(
|
maintenanceRouter.get(
|
||||||
"/duplicate-credits",
|
'/duplicate-credits',
|
||||||
maintenanceController.getDuplicateCredits,
|
maintenanceController.getDuplicateCredits,
|
||||||
);
|
);
|
||||||
|
|
||||||
// * DELETE - Clean duplicate credits
|
// * DELETE - Clean duplicate credits
|
||||||
maintenanceRouter.delete(
|
maintenanceRouter.delete(
|
||||||
"/duplicate-credits",
|
'/duplicate-credits',
|
||||||
maintenanceController.cleanDuplicateCredits,
|
maintenanceController.cleanDuplicateCredits,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// * POST - Auto-fix watch statuses based on watched episodes
|
||||||
|
maintenanceRouter.post(
|
||||||
|
'/auto-fix-watch-statuses',
|
||||||
|
maintenanceController.autoFixWatchStatuses,
|
||||||
|
);
|
||||||
|
|
||||||
module.exports = maintenanceRouter;
|
module.exports = maintenanceRouter;
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
const path = require("path");
|
const path = require('path');
|
||||||
const fsPromises = require("fs").promises;
|
const fsPromises = require('fs').promises;
|
||||||
const fs = require("fs");
|
const fs = require('fs');
|
||||||
|
|
||||||
const Media = require("../models/Media");
|
const Media = require('../models/Media');
|
||||||
const People = require("../models/People");
|
const People = require('../models/People');
|
||||||
const Credit = require("../models/Credit");
|
const Credit = require('../models/Credit');
|
||||||
const Entry = require("../models/Entry");
|
const Entry = require('../models/Entry');
|
||||||
|
|
||||||
const { logToFile } = require("./logService");
|
const { logToFile } = require('./logService');
|
||||||
const configService = require("./configService");
|
const configService = require('./configService');
|
||||||
|
|
||||||
const _configService = configService;
|
const _configService = configService;
|
||||||
|
|
||||||
@@ -32,30 +32,30 @@ class MaintenanceService {
|
|||||||
const dataPath = await _configService.getMediaFolder();
|
const dataPath = await _configService.getMediaFolder();
|
||||||
|
|
||||||
const mediaTypeFolder = {
|
const mediaTypeFolder = {
|
||||||
"entry;poster": path.join(dataPath, "images", "entries", "posters"),
|
'entry;poster': path.join(dataPath, 'images', 'entries', 'posters'),
|
||||||
"entry;logo": path.join(dataPath, "images", "entries", "logos"),
|
'entry;logo': path.join(dataPath, 'images', 'entries', 'logos'),
|
||||||
"entry;backdrop": path.join(dataPath, "images", "entries", "backdrops"),
|
'entry;backdrop': path.join(dataPath, 'images', 'entries', 'backdrops'),
|
||||||
|
|
||||||
"collection;poster": path.join(
|
'collection;poster': path.join(
|
||||||
dataPath,
|
dataPath,
|
||||||
"images",
|
'images',
|
||||||
"collections",
|
'collections',
|
||||||
"posters",
|
'posters',
|
||||||
),
|
),
|
||||||
"collection;backdrop": path.join(
|
'collection;backdrop': path.join(
|
||||||
dataPath,
|
dataPath,
|
||||||
"images",
|
'images',
|
||||||
"collections",
|
'collections',
|
||||||
"backdrops",
|
'backdrops',
|
||||||
),
|
),
|
||||||
|
|
||||||
"season;poster": path.join(dataPath, "images", "seasons", "posters"),
|
'season;poster': path.join(dataPath, 'images', 'seasons', 'posters'),
|
||||||
"episode;still": path.join(dataPath, "images", "episodes", "stills"),
|
'episode;still': path.join(dataPath, 'images', 'episodes', 'stills'),
|
||||||
};
|
};
|
||||||
|
|
||||||
let missingFiles = [];
|
let missingFiles = [];
|
||||||
for (let i = 0; i < allMedia.length; i++) {
|
for (let i = 0; i < allMedia.length; i++) {
|
||||||
const folderType = `${allMedia[i].mediaable};${allMedia[i].type.replace("_preview", "")}`;
|
const folderType = `${allMedia[i].mediaable};${allMedia[i].type.replace('_preview', '')}`;
|
||||||
|
|
||||||
if (!mediaTypeFolder[folderType]) continue;
|
if (!mediaTypeFolder[folderType]) continue;
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ class MaintenanceService {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (let i = 0; i < missingFiles.length; i++) {
|
for (let i = 0; i < missingFiles.length; i++) {
|
||||||
removed[missingFiles[i].type + "s"] += 1;
|
removed[missingFiles[i].type + 's'] += 1;
|
||||||
if (!dry) missingFiles[i].destroy();
|
if (!dry) missingFiles[i].destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,31 +100,31 @@ class MaintenanceService {
|
|||||||
|
|
||||||
// ? Getting the name (without extention) of all media in database
|
// ? Getting the name (without extention) of all media in database
|
||||||
const allMedia = (await Media.findAll()).map((m) => {
|
const allMedia = (await Media.findAll()).map((m) => {
|
||||||
return m.path.split(".")[0];
|
return m.path.split('.')[0];
|
||||||
});
|
});
|
||||||
|
|
||||||
// ? Loop trough the files of the images folder and check
|
// ? Loop trough the files of the images folder and check
|
||||||
// ? if a file doesnt exist in the allMedia array and mark it to delete
|
// ? if a file doesnt exist in the allMedia array and mark it to delete
|
||||||
const mediaTypeFolder = {
|
const mediaTypeFolder = {
|
||||||
"entry;poster": path.join(dataPath, "images", "entries", "posters"),
|
'entry;poster': path.join(dataPath, 'images', 'entries', 'posters'),
|
||||||
"entry;logo": path.join(dataPath, "images", "entries", "logos"),
|
'entry;logo': path.join(dataPath, 'images', 'entries', 'logos'),
|
||||||
"entry;backdrop": path.join(dataPath, "images", "entries", "backdrops"),
|
'entry;backdrop': path.join(dataPath, 'images', 'entries', 'backdrops'),
|
||||||
|
|
||||||
"collection;poster": path.join(
|
'collection;poster': path.join(
|
||||||
dataPath,
|
dataPath,
|
||||||
"images",
|
'images',
|
||||||
"collections",
|
'collections',
|
||||||
"posters",
|
'posters',
|
||||||
),
|
),
|
||||||
"collection;backdrop": path.join(
|
'collection;backdrop': path.join(
|
||||||
dataPath,
|
dataPath,
|
||||||
"images",
|
'images',
|
||||||
"collections",
|
'collections',
|
||||||
"backdrops",
|
'backdrops',
|
||||||
),
|
),
|
||||||
|
|
||||||
"season;poster": path.join(dataPath, "images", "seasons", "posters"),
|
'season;poster': path.join(dataPath, 'images', 'seasons', 'posters'),
|
||||||
"episode;still": path.join(dataPath, "images", "episodes", "stills"),
|
'episode;still': path.join(dataPath, 'images', 'episodes', 'stills'),
|
||||||
};
|
};
|
||||||
|
|
||||||
// * counter
|
// * counter
|
||||||
@@ -146,12 +146,12 @@ class MaintenanceService {
|
|||||||
// Check each file in the directory
|
// Check each file in the directory
|
||||||
for (let file of files) {
|
for (let file of files) {
|
||||||
// preparing the file name
|
// preparing the file name
|
||||||
const fileName = file.split(".")[0].replace("_preview", "");
|
const fileName = file.split('.')[0].replace('_preview', '');
|
||||||
const isInDatabase = allMedia.includes(fileName);
|
const isInDatabase = allMedia.includes(fileName);
|
||||||
|
|
||||||
// if the file isn't in database even on other extentions then delete it
|
// if the file isn't in database even on other extentions then delete it
|
||||||
if (!isInDatabase) {
|
if (!isInDatabase) {
|
||||||
removed[folderType.split(";")[1] + "s"]++; // Increment the count of removed files
|
removed[folderType.split(';')[1] + 's']++; // Increment the count of removed files
|
||||||
if (!dry) {
|
if (!dry) {
|
||||||
const filePath = path.join(directory, file);
|
const filePath = path.join(directory, file);
|
||||||
await fsPromises.unlink(filePath);
|
await fsPromises.unlink(filePath);
|
||||||
@@ -182,14 +182,14 @@ class MaintenanceService {
|
|||||||
* @param {boolean} [dry=false] - if true only return the count
|
* @param {boolean} [dry=false] - if true only return the count
|
||||||
*/
|
*/
|
||||||
async deleteOrphanPeople(dry = false) {
|
async deleteOrphanPeople(dry = false) {
|
||||||
const { Sequelize } = require("sequelize");
|
const { Sequelize } = require('sequelize');
|
||||||
|
|
||||||
// Find all people who have no credits and are not pinned
|
// Find all people who have no credits and are not pinned
|
||||||
const allPeople = await People.findAll({
|
const allPeople = await People.findAll({
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
model: Credit,
|
model: Credit,
|
||||||
as: "roles",
|
as: 'roles',
|
||||||
required: false,
|
required: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -222,9 +222,9 @@ class MaintenanceService {
|
|||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
model: Credit,
|
model: Credit,
|
||||||
as: "credits",
|
as: 'credits',
|
||||||
where: { cast_type: "crew", job: "Director" },
|
where: { cast_type: 'crew', job: 'Director' },
|
||||||
include: [{ model: People, as: "person", attributes: ["name"] }],
|
include: [{ model: People, as: 'person', attributes: ['name'] }],
|
||||||
required: false,
|
required: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -257,20 +257,20 @@ class MaintenanceService {
|
|||||||
* @param {boolean} [dry=false] - if true only count, if false also delete
|
* @param {boolean} [dry=false] - if true only count, if false also delete
|
||||||
*/
|
*/
|
||||||
async cleanDuplicateCredits(dry = false) {
|
async cleanDuplicateCredits(dry = false) {
|
||||||
const { Sequelize } = require("sequelize");
|
const { Sequelize } = require('sequelize');
|
||||||
|
|
||||||
const duplicates = await Credit.findAll({
|
const duplicates = await Credit.findAll({
|
||||||
attributes: [
|
attributes: [
|
||||||
"entry_id",
|
'entry_id',
|
||||||
"people_id",
|
'people_id',
|
||||||
"cast_type",
|
'cast_type',
|
||||||
"character",
|
'character',
|
||||||
"job",
|
'job',
|
||||||
[Sequelize.fn("COUNT", Sequelize.col("id")), "cnt"],
|
[Sequelize.fn('COUNT', Sequelize.col('id')), 'cnt'],
|
||||||
[Sequelize.fn("GROUP_CONCAT", Sequelize.col("id")), "ids"],
|
[Sequelize.fn('GROUP_CONCAT', Sequelize.col('id')), 'ids'],
|
||||||
],
|
],
|
||||||
group: ["entry_id", "people_id", "cast_type", "character", "job"],
|
group: ['entry_id', 'people_id', 'cast_type', 'character', 'job'],
|
||||||
having: Sequelize.literal("COUNT(id) > 1"),
|
having: Sequelize.literal('COUNT(id) > 1'),
|
||||||
raw: true,
|
raw: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -280,7 +280,7 @@ class MaintenanceService {
|
|||||||
if (!dry) {
|
if (!dry) {
|
||||||
for (const row of duplicates) {
|
for (const row of duplicates) {
|
||||||
const idList = row.ids
|
const idList = row.ids
|
||||||
.split(",")
|
.split(',')
|
||||||
.map(Number)
|
.map(Number)
|
||||||
.sort((a, b) => a - b);
|
.sort((a, b) => a - b);
|
||||||
// Keep the newest (highest ID), delete the older ones
|
// Keep the newest (highest ID), delete the older ones
|
||||||
@@ -310,6 +310,92 @@ class MaintenanceService {
|
|||||||
deleted: deletedCount,
|
deleted: deletedCount,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async autoFixWatchStatuses() {
|
||||||
|
const Episode = require('../models/Episode');
|
||||||
|
const EpisodeSeen = require('../models/EpisodeSeen');
|
||||||
|
const Season = require('../models/Season');
|
||||||
|
const { Op } = require('sequelize');
|
||||||
|
|
||||||
|
const tvEntries = await Entry.findAll({
|
||||||
|
where: { is_tvseries: true },
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
model: Season,
|
||||||
|
as: 'seasons',
|
||||||
|
where: { season_number: { [Op.gt]: 0 } },
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
model: Episode,
|
||||||
|
as: 'episodes',
|
||||||
|
include: [{ model: EpisodeSeen, as: 'episodeSeens' }],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
let toCompleted = 0;
|
||||||
|
let toWatching = 0;
|
||||||
|
let toPlanToWatch = 0;
|
||||||
|
|
||||||
|
for (const entry of tvEntries) {
|
||||||
|
let totalEpisodes = 0;
|
||||||
|
let watchedEpisodes = 0;
|
||||||
|
|
||||||
|
for (const season of entry.seasons || []) {
|
||||||
|
for (const ep of season.episodes || []) {
|
||||||
|
totalEpisodes++;
|
||||||
|
if (ep.episodeSeens && ep.episodeSeens.length > 0) {
|
||||||
|
watchedEpisodes++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const allWatched = totalEpisodes > 0 && watchedEpisodes === totalEpisodes;
|
||||||
|
const hasSomeWatched = watchedEpisodes > 0;
|
||||||
|
|
||||||
|
// Completed but not all watched → downgrade to watching
|
||||||
|
if (entry.watch_status === 'completed' && !allWatched) {
|
||||||
|
entry.watch_status = 'watching';
|
||||||
|
await entry.save();
|
||||||
|
toWatching++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// All watched → completed (unless already completed)
|
||||||
|
if (allWatched && entry.watch_status !== 'completed') {
|
||||||
|
entry.watch_status = 'completed';
|
||||||
|
await entry.save();
|
||||||
|
toCompleted++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Has some watched but no status → watching
|
||||||
|
if (hasSomeWatched && !entry.watch_status) {
|
||||||
|
entry.watch_status = 'watching';
|
||||||
|
await entry.save();
|
||||||
|
toWatching++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// In watchlist with no status → plan to watch
|
||||||
|
if (entry.watchlist && !entry.watch_status) {
|
||||||
|
entry.watch_status = 'plan_to_watch';
|
||||||
|
await entry.save();
|
||||||
|
toPlanToWatch++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logToFile(
|
||||||
|
`Auto-fixed watch statuses: ${toCompleted} completed, ${toWatching} watching, ${toPlanToWatch} plan_to_watch`,
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
completed: toCompleted,
|
||||||
|
watching: toWatching,
|
||||||
|
planToWatch: toPlanToWatch,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = new MaintenanceService();
|
module.exports = new MaintenanceService();
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { api } from "@/lib/api";
|
import { api } from '@/lib/api';
|
||||||
|
|
||||||
export interface OrphanResult {
|
export interface OrphanResult {
|
||||||
posters: number;
|
posters: number;
|
||||||
@@ -13,39 +13,39 @@ export interface OrphanPeopleResult {
|
|||||||
|
|
||||||
export const maintenanceApi = {
|
export const maintenanceApi = {
|
||||||
scanOrphanFiles: () =>
|
scanOrphanFiles: () =>
|
||||||
api.get<OrphanResult>("/maintenance/orphan-files").then((r) => r.data),
|
api.get<OrphanResult>('/maintenance/orphan-files').then((r) => r.data),
|
||||||
|
|
||||||
deleteOrphanFiles: () =>
|
deleteOrphanFiles: () =>
|
||||||
api.delete<OrphanResult>("/maintenance/orphan-files").then((r) => r.data),
|
api.delete<OrphanResult>('/maintenance/orphan-files').then((r) => r.data),
|
||||||
|
|
||||||
scanOrphanMediaRecords: () =>
|
scanOrphanMediaRecords: () =>
|
||||||
api
|
api
|
||||||
.get<OrphanResult>("/maintenance/orphan-media-records")
|
.get<OrphanResult>('/maintenance/orphan-media-records')
|
||||||
.then((r) => r.data),
|
.then((r) => r.data),
|
||||||
|
|
||||||
deleteOrphanMediaRecords: () =>
|
deleteOrphanMediaRecords: () =>
|
||||||
api
|
api
|
||||||
.delete<OrphanResult>("/maintenance/orphan-media-records")
|
.delete<OrphanResult>('/maintenance/orphan-media-records')
|
||||||
.then((r) => r.data),
|
.then((r) => r.data),
|
||||||
|
|
||||||
scanOrphanPeople: () =>
|
scanOrphanPeople: () =>
|
||||||
api
|
api
|
||||||
.get<OrphanPeopleResult>("/maintenance/orphan-people")
|
.get<OrphanPeopleResult>('/maintenance/orphan-people')
|
||||||
.then((r) => r.data),
|
.then((r) => r.data),
|
||||||
|
|
||||||
deleteOrphanPeople: () =>
|
deleteOrphanPeople: () =>
|
||||||
api
|
api
|
||||||
.delete<OrphanPeopleResult>("/maintenance/orphan-people")
|
.delete<OrphanPeopleResult>('/maintenance/orphan-people')
|
||||||
.then((r) => r.data),
|
.then((r) => r.data),
|
||||||
|
|
||||||
scanMissingDirectors: () =>
|
scanMissingDirectors: () =>
|
||||||
api
|
api
|
||||||
.get<{ count: number; fixed: number }>("/maintenance/missing-directors")
|
.get<{ count: number; fixed: number }>('/maintenance/missing-directors')
|
||||||
.then((r) => r.data),
|
.then((r) => r.data),
|
||||||
|
|
||||||
fixMissingDirectors: () =>
|
fixMissingDirectors: () =>
|
||||||
api
|
api
|
||||||
.post<{ count: number; fixed: number }>("/maintenance/missing-directors")
|
.post<{ count: number; fixed: number }>('/maintenance/missing-directors')
|
||||||
.then((r) => r.data),
|
.then((r) => r.data),
|
||||||
|
|
||||||
scanDuplicateCredits: () =>
|
scanDuplicateCredits: () =>
|
||||||
@@ -54,7 +54,7 @@ export const maintenanceApi = {
|
|||||||
groups: number;
|
groups: number;
|
||||||
duplicates: number;
|
duplicates: number;
|
||||||
deleted: number;
|
deleted: number;
|
||||||
}>("/maintenance/duplicate-credits")
|
}>('/maintenance/duplicate-credits')
|
||||||
.then((r) => r.data),
|
.then((r) => r.data),
|
||||||
|
|
||||||
cleanDuplicateCredits: () =>
|
cleanDuplicateCredits: () =>
|
||||||
@@ -63,6 +63,15 @@ export const maintenanceApi = {
|
|||||||
groups: number;
|
groups: number;
|
||||||
duplicates: number;
|
duplicates: number;
|
||||||
deleted: 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),
|
.then((r) => r.data),
|
||||||
};
|
};
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useState } from "react";
|
import { useState } from 'react';
|
||||||
import { Link, useNavigate } from "react-router-dom";
|
import { Link, useNavigate } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
Plus,
|
Plus,
|
||||||
Star,
|
Star,
|
||||||
@@ -15,35 +15,50 @@ import {
|
|||||||
RefreshCw,
|
RefreshCw,
|
||||||
ImageIcon,
|
ImageIcon,
|
||||||
Settings,
|
Settings,
|
||||||
} from "lucide-react";
|
BookmarkCheck,
|
||||||
import { Badge } from "@/components/ui/badge";
|
} from 'lucide-react';
|
||||||
import { Button } from "@/components/ui/button";
|
import { Badge } from '@/components/ui/badge';
|
||||||
import { Skeleton } from "@/components/ui/skeleton";
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { Skeleton } from '@/components/ui/skeleton';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from '@/components/ui/dropdown-menu';
|
||||||
import { getPosterUrl, getYear, formatRuntime } from "@/lib/media-utils";
|
import { getPosterUrl, getYear, formatRuntime } from '@/lib/media-utils';
|
||||||
import {
|
import {
|
||||||
useCreateEntry,
|
useCreateEntry,
|
||||||
useDeleteEntry,
|
useDeleteEntry,
|
||||||
useUpdateEntry,
|
useUpdateEntry,
|
||||||
useRefreshEntry,
|
useRefreshEntry,
|
||||||
useEntrySeasons,
|
useEntrySeasons,
|
||||||
} from "@/hooks/useEntries";
|
} from '@/hooks/useEntries';
|
||||||
import { useEntrySeenByEntry, useDeleteEntrySeen } from "@/hooks/useEntrySeen";
|
import { useEntrySeenByEntry, useDeleteEntrySeen } from '@/hooks/useEntrySeen';
|
||||||
import { useLibraryStore } from "@/stores/useLibraryStore";
|
import { useLibraryStore } from '@/stores/useLibraryStore';
|
||||||
import { ConfirmDialog } from "@/components/dialogs/ConfirmDialog";
|
import { ConfirmDialog } from '@/components/dialogs/ConfirmDialog';
|
||||||
import { EntrySeenDialog } from "@/components/dialogs/EntrySeenDialog";
|
import { EntrySeenDialog } from '@/components/dialogs/EntrySeenDialog';
|
||||||
import { RatingDialog } from "@/components/dialogs/RatingDialog";
|
import { RatingDialog } from '@/components/dialogs/RatingDialog';
|
||||||
import { MovieWatchHistoryDialog } from "@/components/dialogs/MovieWatchHistoryDialog";
|
import { MovieWatchHistoryDialog } from '@/components/dialogs/MovieWatchHistoryDialog';
|
||||||
import { AddEntryToCollectionDialog } from "@/components/dialogs/AddEntryToCollectionDialog";
|
import { AddEntryToCollectionDialog } from '@/components/dialogs/AddEntryToCollectionDialog';
|
||||||
import { EntryMediaDialog } from "@/components/dialogs/EntryMediaDialog";
|
import { EntryMediaDialog } from '@/components/dialogs/EntryMediaDialog';
|
||||||
import { EntrySettingsDialog } from "@/components/dialogs/EntrySettingsDialog";
|
import { EntrySettingsDialog } from '@/components/dialogs/EntrySettingsDialog';
|
||||||
import type { Entry, TmdbEntry } from "@/types";
|
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 {
|
interface EntryCardProps {
|
||||||
entry?: Entry;
|
entry?: Entry;
|
||||||
@@ -75,6 +90,7 @@ export function EntryCard({
|
|||||||
const [showMediaDialog, setShowMediaDialog] = useState(false);
|
const [showMediaDialog, setShowMediaDialog] = useState(false);
|
||||||
const [showSettingsDialog, setShowSettingsDialog] = useState(false);
|
const [showSettingsDialog, setShowSettingsDialog] = useState(false);
|
||||||
const [dropdownOpen, setDropdownOpen] = useState(false);
|
const [dropdownOpen, setDropdownOpen] = useState(false);
|
||||||
|
const [showStatusDialog, setShowStatusDialog] = useState(false);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const createEntry = useCreateEntry();
|
const createEntry = useCreateEntry();
|
||||||
const deleteEntry = useDeleteEntry();
|
const deleteEntry = useDeleteEntry();
|
||||||
@@ -100,7 +116,7 @@ export function EntryCard({
|
|||||||
|
|
||||||
// Resolve display data
|
// Resolve display data
|
||||||
const title =
|
const title =
|
||||||
displayEntry?.title || tmdbEntry?.title || tmdbEntry?.name || "Untitled";
|
displayEntry?.title || tmdbEntry?.title || tmdbEntry?.name || 'Untitled';
|
||||||
const year = displayEntry
|
const year = displayEntry
|
||||||
? getYear(displayEntry.release_date)
|
? getYear(displayEntry.release_date)
|
||||||
: getYear(tmdbEntry?.release_date || tmdbEntry?.first_air_date || null);
|
: getYear(tmdbEntry?.release_date || tmdbEntry?.first_air_date || null);
|
||||||
@@ -111,22 +127,22 @@ export function EntryCard({
|
|||||||
const runtime =
|
const runtime =
|
||||||
displayEntry && !displayEntry.is_tvseries
|
displayEntry && !displayEntry.is_tvseries
|
||||||
? formatRuntime(displayEntry.runtime)
|
? formatRuntime(displayEntry.runtime)
|
||||||
: "";
|
: '';
|
||||||
const isTv =
|
const isTv =
|
||||||
displayEntry?.is_tvseries ||
|
displayEntry?.is_tvseries ||
|
||||||
tmdbEntry?.media_type === "tv" ||
|
tmdbEntry?.media_type === 'tv' ||
|
||||||
!!tmdbEntry?.name;
|
!!tmdbEntry?.name;
|
||||||
|
|
||||||
const posterUrl = displayEntry
|
const posterUrl = displayEntry
|
||||||
? getPosterUrl(displayEntry)
|
? getPosterUrl(displayEntry)
|
||||||
: tmdbEntry?.poster_path
|
: tmdbEntry?.poster_path
|
||||||
? `https://image.tmdb.org/t/p/w342${tmdbEntry.poster_path}`
|
? `https://image.tmdb.org/t/p/w342${tmdbEntry.poster_path}`
|
||||||
: "/images/default-poster.png";
|
: '/images/default-poster.png';
|
||||||
|
|
||||||
const entryLink = displayEntry
|
const entryLink = displayEntry
|
||||||
? `/entry/${displayEntry.id}`
|
? `/entry/${displayEntry.id}`
|
||||||
: tmdbEntry
|
: tmdbEntry
|
||||||
? `/entry/tmdb/${isTv ? "tv" : "movie"}/${tmdbEntry.id}`
|
? `/entry/tmdb/${isTv ? 'tv' : 'movie'}/${tmdbEntry.id}`
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const handleAdd = (e: React.MouseEvent) => {
|
const handleAdd = (e: React.MouseEvent) => {
|
||||||
@@ -173,7 +189,7 @@ export function EntryCard({
|
|||||||
src={posterUrl}
|
src={posterUrl}
|
||||||
alt={title}
|
alt={title}
|
||||||
className={`h-full w-full object-cover transition-all duration-300 group-hover:scale-105 ${
|
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"
|
loading="lazy"
|
||||||
/>
|
/>
|
||||||
@@ -193,7 +209,7 @@ export function EntryCard({
|
|||||||
{/* Quick actions button – top right, shown on hover */}
|
{/* Quick actions button – top right, shown on hover */}
|
||||||
{isInLibrary && (
|
{isInLibrary && (
|
||||||
<div
|
<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}>
|
<DropdownMenu open={dropdownOpen} onOpenChange={setDropdownOpen}>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
@@ -233,6 +249,20 @@ export function EntryCard({
|
|||||||
<Star className="mr-2 h-4 w-4" />
|
<Star className="mr-2 h-4 w-4" />
|
||||||
Rate this
|
Rate this
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
|
{isTv && (
|
||||||
|
<>
|
||||||
|
<DropdownMenuSeparator />
|
||||||
|
<DropdownMenuItem
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
setShowStatusDialog(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<BookmarkCheck className="mr-2 h-4 w-4" />
|
||||||
|
Set Status
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
{!isTv && (
|
{!isTv && (
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
@@ -253,9 +283,9 @@ export function EntryCard({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Heart
|
<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>
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
@@ -273,7 +303,7 @@ export function EntryCard({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<EyeOff className="mr-2 h-4 w-4" />
|
<EyeOff className="mr-2 h-4 w-4" />
|
||||||
{libraryEntry?.hidden ? "Unhide" : "Hide"}
|
{libraryEntry?.hidden ? 'Unhide' : 'Hide'}
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
{/* Manage */}
|
{/* Manage */}
|
||||||
@@ -285,9 +315,9 @@ export function EntryCard({
|
|||||||
disabled={refreshEntry.isPending}
|
disabled={refreshEntry.isPending}
|
||||||
>
|
>
|
||||||
<RefreshCw
|
<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>
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
@@ -346,7 +376,7 @@ export function EntryCard({
|
|||||||
variant="secondary"
|
variant="secondary"
|
||||||
className="absolute bottom-2 right-2 text-[10px] px-1.5 py-0.5 opacity-90 z-10 pointer-events-none"
|
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>
|
</Badge>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -360,7 +390,7 @@ export function EntryCard({
|
|||||||
{rating != null && rating > 0 && (
|
{rating != null && rating > 0 && (
|
||||||
<span className="flex items-center gap-1">
|
<span className="flex items-center gap-1">
|
||||||
<Star className="h-3 w-3 fill-yellow-400 text-yellow-400" />
|
<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>
|
</span>
|
||||||
)}
|
)}
|
||||||
{year && <span>{year}</span>}
|
{year && <span>{year}</span>}
|
||||||
@@ -381,7 +411,7 @@ export function EntryCard({
|
|||||||
) : (
|
) : (
|
||||||
<Plus className="mr-1 h-3 w-3" />
|
<Plus className="mr-1 h-3 w-3" />
|
||||||
)}
|
)}
|
||||||
{createEntry.isPending ? "Adding..." : "Add to Library"}
|
{createEntry.isPending ? 'Adding...' : 'Add to Library'}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -460,6 +490,37 @@ export function EntryCard({
|
|||||||
entry={libraryEntry}
|
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 { useState, useEffect } from 'react';
|
||||||
import { useParams, Link, useNavigate } from "react-router-dom";
|
import { useParams, Link, useNavigate } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
useEntry,
|
useEntry,
|
||||||
useEntrySeasons,
|
useEntrySeasons,
|
||||||
useRefreshEntry,
|
useRefreshEntry,
|
||||||
useEntryCredits,
|
useEntryCredits,
|
||||||
} from "@/hooks/useEntries";
|
} from '@/hooks/useEntries';
|
||||||
import { useEntrySeenByEntry, useDeleteEntrySeen } from "@/hooks/useEntrySeen";
|
import { useEntrySeenByEntry, useDeleteEntrySeen } from '@/hooks/useEntrySeen';
|
||||||
import { useCollections } from "@/hooks/useCollections";
|
import { useCollections } from '@/hooks/useCollections';
|
||||||
import { useLibraryStore } from "@/stores/useLibraryStore";
|
import { useLibraryStore } from '@/stores/useLibraryStore';
|
||||||
import { useCommandPaletteStore } from "@/stores/useCommandPaletteStore";
|
import { useCommandPaletteStore } from '@/stores/useCommandPaletteStore';
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from '@/components/ui/badge';
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import { Separator } from "@/components/ui/separator";
|
import { Separator } from '@/components/ui/separator';
|
||||||
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
|
import { ScrollArea, ScrollBar } from '@/components/ui/scroll-area';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from '@/components/ui/dropdown-menu';
|
||||||
import {
|
import {
|
||||||
Heart,
|
Heart,
|
||||||
MoreHorizontal,
|
MoreHorizontal,
|
||||||
@@ -35,25 +35,32 @@ import {
|
|||||||
Trash2,
|
Trash2,
|
||||||
ExternalLink,
|
ExternalLink,
|
||||||
Play,
|
Play,
|
||||||
} from "lucide-react";
|
BookmarkCheck,
|
||||||
|
} from 'lucide-react';
|
||||||
import {
|
import {
|
||||||
Tooltip,
|
Tooltip,
|
||||||
TooltipContent,
|
TooltipContent,
|
||||||
TooltipProvider,
|
TooltipProvider,
|
||||||
TooltipTrigger,
|
TooltipTrigger,
|
||||||
} from "@/components/ui/tooltip";
|
} from '@/components/ui/tooltip';
|
||||||
import { CastList } from "@/components/entries/CastList";
|
import { CastList } from '@/components/entries/CastList';
|
||||||
import { SeasonsContainer } from "@/components/entries/SeasonsContainer";
|
import { SeasonsContainer } from '@/components/entries/SeasonsContainer';
|
||||||
import { StreamingSection } from "@/components/streaming/StreamingSection";
|
import { StreamingSection } from '@/components/streaming/StreamingSection';
|
||||||
// EpisodeWatchHistory is available for future use
|
// EpisodeWatchHistory is available for future use
|
||||||
import { EntrySettingsDialog } from "@/components/dialogs/EntrySettingsDialog";
|
import { EntrySettingsDialog } from '@/components/dialogs/EntrySettingsDialog';
|
||||||
import { EntrySeenDialog } from "@/components/dialogs/EntrySeenDialog";
|
import { EntrySeenDialog } from '@/components/dialogs/EntrySeenDialog';
|
||||||
import { EntryMediaDialog } from "@/components/dialogs/EntryMediaDialog";
|
import { EntryMediaDialog } from '@/components/dialogs/EntryMediaDialog';
|
||||||
import { AddEntryToCollectionDialog } from "@/components/dialogs/AddEntryToCollectionDialog";
|
import { AddEntryToCollectionDialog } from '@/components/dialogs/AddEntryToCollectionDialog';
|
||||||
import { RatingDialog } from "@/components/dialogs/RatingDialog";
|
import { RatingDialog } from '@/components/dialogs/RatingDialog';
|
||||||
import { MovieWatchHistoryDialog } from "@/components/dialogs/MovieWatchHistoryDialog";
|
import { MovieWatchHistoryDialog } from '@/components/dialogs/MovieWatchHistoryDialog';
|
||||||
import { ConfirmDialog } from "@/components/dialogs/ConfirmDialog";
|
import { ConfirmDialog } from '@/components/dialogs/ConfirmDialog';
|
||||||
import { EntryDetailsSkeleton } from "@/components/skeletons/PageSkeletons";
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
} from '@/components/ui/dialog';
|
||||||
|
import { EntryDetailsSkeleton } from '@/components/skeletons/PageSkeletons';
|
||||||
import {
|
import {
|
||||||
getPosterUrl,
|
getPosterUrl,
|
||||||
getBackdropUrl,
|
getBackdropUrl,
|
||||||
@@ -61,9 +68,44 @@ import {
|
|||||||
getYear,
|
getYear,
|
||||||
formatRuntime,
|
formatRuntime,
|
||||||
formatDate,
|
formatDate,
|
||||||
} from "@/lib/media-utils";
|
} from '@/lib/media-utils';
|
||||||
import { useUpdateEntry, useDeleteEntry } from "@/hooks/useEntries";
|
import { useUpdateEntry, useDeleteEntry } from '@/hooks/useEntries';
|
||||||
import type { Collection, Entry } from "@/types";
|
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() {
|
export function EntryDetailsPage() {
|
||||||
const { id } = useParams<{ id: string }>();
|
const { id } = useParams<{ id: string }>();
|
||||||
@@ -92,6 +134,7 @@ export function EntryDetailsPage() {
|
|||||||
const [showRatingDialog, setShowRatingDialog] = useState(false);
|
const [showRatingDialog, setShowRatingDialog] = useState(false);
|
||||||
const [showWatchHistoryDialog, setShowWatchHistoryDialog] = useState(false);
|
const [showWatchHistoryDialog, setShowWatchHistoryDialog] = useState(false);
|
||||||
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
||||||
|
const [showStatusDialog, setShowStatusDialog] = useState(false);
|
||||||
|
|
||||||
// Track recently viewed for command palette
|
// Track recently viewed for command palette
|
||||||
const addRecentlyViewed = useCommandPaletteStore((s) => s.addRecentlyViewed);
|
const addRecentlyViewed = useCommandPaletteStore((s) => s.addRecentlyViewed);
|
||||||
@@ -100,7 +143,7 @@ export function EntryDetailsPage() {
|
|||||||
addRecentlyViewed({
|
addRecentlyViewed({
|
||||||
id: `lib-${entryId}`,
|
id: `lib-${entryId}`,
|
||||||
title: displayEntry.title,
|
title: displayEntry.title,
|
||||||
type: displayEntry.is_tvseries ? "tv" : "movie",
|
type: displayEntry.is_tvseries ? 'tv' : 'movie',
|
||||||
poster_path: displayEntry.poster_path,
|
poster_path: displayEntry.poster_path,
|
||||||
libraryId: entryId,
|
libraryId: entryId,
|
||||||
tmdbId: displayEntry.entryIds?.tmdb_id ?? undefined,
|
tmdbId: displayEntry.entryIds?.tmdb_id ?? undefined,
|
||||||
@@ -119,7 +162,7 @@ export function EntryDetailsPage() {
|
|||||||
const backdrop = getBackdropUrl(e);
|
const backdrop = getBackdropUrl(e);
|
||||||
const poster = getPosterUrl(e);
|
const poster = getPosterUrl(e);
|
||||||
const director = credits.find(
|
const director = credits.find(
|
||||||
(c) => c.cast_type === "crew" && c.job === "Director",
|
(c) => c.cast_type === 'crew' && c.job === 'Director',
|
||||||
);
|
);
|
||||||
|
|
||||||
const toggleFavorite = () => {
|
const toggleFavorite = () => {
|
||||||
@@ -162,6 +205,13 @@ export function EntryDetailsPage() {
|
|||||||
<Star className="mr-2 h-4 w-4" />
|
<Star className="mr-2 h-4 w-4" />
|
||||||
Rate this
|
Rate this
|
||||||
</DropdownMenuItem>
|
</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 && (
|
{!e.is_tvseries && (
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onClick={() => setShowWatchHistoryDialog(true)}
|
onClick={() => setShowWatchHistoryDialog(true)}
|
||||||
@@ -177,9 +227,9 @@ export function EntryDetailsPage() {
|
|||||||
disabled={updateEntry.isPending}
|
disabled={updateEntry.isPending}
|
||||||
>
|
>
|
||||||
<Heart
|
<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>
|
||||||
<DropdownMenuItem onClick={() => setShowCollectionDialog(true)}>
|
<DropdownMenuItem onClick={() => setShowCollectionDialog(true)}>
|
||||||
<FolderPlus className="mr-2 h-4 w-4" />
|
<FolderPlus className="mr-2 h-4 w-4" />
|
||||||
@@ -191,7 +241,7 @@ export function EntryDetailsPage() {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<EyeOff className="mr-2 h-4 w-4" />
|
<EyeOff className="mr-2 h-4 w-4" />
|
||||||
{e.hidden ? "Unhide" : "Hide"}
|
{e.hidden ? 'Unhide' : 'Hide'}
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
{/* Manage */}
|
{/* Manage */}
|
||||||
@@ -200,9 +250,9 @@ export function EntryDetailsPage() {
|
|||||||
disabled={refreshEntry.isPending}
|
disabled={refreshEntry.isPending}
|
||||||
>
|
>
|
||||||
<RefreshCw
|
<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>
|
||||||
<DropdownMenuItem onClick={() => setShowMediaDialog(true)}>
|
<DropdownMenuItem onClick={() => setShowMediaDialog(true)}>
|
||||||
<ImageIcon className="mr-2 h-4 w-4" />
|
<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">
|
<div className="flex items-center justify-center gap-3 mt-3">
|
||||||
{e.entryIds.tmdb_id && (
|
{e.entryIds.tmdb_id && (
|
||||||
<a
|
<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"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors"
|
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>
|
<h1 className="text-3xl font-bold leading-tight">{e.title}</h1>
|
||||||
{director?.people?.name && (
|
{director?.people?.name && (
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
by{" "}
|
by{' '}
|
||||||
<Link
|
<Link
|
||||||
to={`/people/${director.people_id}`}
|
to={`/people/${director.people_id}`}
|
||||||
className="font-medium text-foreground hover:underline"
|
className="font-medium text-foreground hover:underline"
|
||||||
@@ -414,23 +464,39 @@ export function EntryDetailsPage() {
|
|||||||
disabled={updateEntry.isPending}
|
disabled={updateEntry.isPending}
|
||||||
className={`inline-flex items-center gap-1 rounded-full border px-3 py-1 text-sm font-medium transition-colors ${
|
className={`inline-flex items-center gap-1 rounded-full border px-3 py-1 text-sm font-medium transition-colors ${
|
||||||
e.favorit
|
e.favorit
|
||||||
? "bg-yellow-500/15 border-yellow-500/30 text-yellow-600 dark:text-yellow-400 hover:bg-yellow-500/25"
|
? '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"
|
: 'border-dashed border-border text-muted-foreground hover:border-yellow-500/40 hover:text-yellow-500'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<Star
|
<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
|
Favorit
|
||||||
</button>
|
</button>
|
||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
<TooltipContent>
|
<TooltipContent>
|
||||||
<p>
|
<p>
|
||||||
{e.favorit ? "Remove from favorites" : "Add to favorites"}
|
{e.favorit ? 'Remove from favorites' : 'Add to favorites'}
|
||||||
</p>
|
</p>
|
||||||
</TooltipContent>
|
</TooltipContent>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</TooltipProvider>
|
</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>
|
</div>
|
||||||
|
|
||||||
{/* Storyline */}
|
{/* Storyline */}
|
||||||
@@ -448,7 +514,7 @@ export function EntryDetailsPage() {
|
|||||||
<div className="flex flex-wrap items-center justify-center gap-2">
|
<div className="flex flex-wrap items-center justify-center gap-2">
|
||||||
<StreamingSection entry={e} seasons={seasons} />
|
<StreamingSection entry={e} seasons={seasons} />
|
||||||
<a
|
<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"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
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"
|
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"
|
variant="destructive"
|
||||||
onConfirm={() => {
|
onConfirm={() => {
|
||||||
deleteEntry.mutate(e.id, {
|
deleteEntry.mutate(e.id, {
|
||||||
onSuccess: () => navigate("/library"),
|
onSuccess: () => navigate('/library'),
|
||||||
});
|
});
|
||||||
setShowDeleteConfirm(false);
|
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>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -598,8 +692,8 @@ function EntryCollectionsSection({ entryId }: { entryId: number }) {
|
|||||||
</p>
|
</p>
|
||||||
{col.entries && (
|
{col.entries && (
|
||||||
<p className="text-xs text-white/70 mt-0.5">
|
<p className="text-xs text-white/70 mt-0.5">
|
||||||
{col.entries.length}{" "}
|
{col.entries.length}{' '}
|
||||||
{col.entries.length === 1 ? "title" : "titles"}
|
{col.entries.length === 1 ? 'title' : 'titles'}
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,49 +1,49 @@
|
|||||||
import { useState, useMemo, useCallback, useEffect, useRef } from "react";
|
import { useState, useMemo, useCallback, useEffect, useRef } from 'react';
|
||||||
import { useSearchParams, useNavigationType } from "react-router-dom";
|
import { useSearchParams, useNavigationType } from 'react-router-dom';
|
||||||
import { useLibrary } from "@/hooks/useEntries";
|
import { useLibrary } from '@/hooks/useEntries';
|
||||||
import { useLibraryEntries } from "@/stores/useLibraryStore";
|
import { useLibraryEntries } from '@/stores/useLibraryStore';
|
||||||
import {
|
import {
|
||||||
useLibraryFiltersStore,
|
useLibraryFiltersStore,
|
||||||
defaultFilters,
|
defaultFilters,
|
||||||
} from "@/stores/useLibraryFiltersStore";
|
} from '@/stores/useLibraryFiltersStore';
|
||||||
import type {
|
import type {
|
||||||
FilterTab,
|
FilterTab,
|
||||||
SortField,
|
SortField,
|
||||||
SortDir,
|
SortDir,
|
||||||
Filters,
|
Filters,
|
||||||
} from "@/stores/useLibraryFiltersStore";
|
} from '@/stores/useLibraryFiltersStore';
|
||||||
import { EntryLibraryGrid } from "@/components/entries/EntryLibraryGrid";
|
import { EntryLibraryGrid } from '@/components/entries/EntryLibraryGrid';
|
||||||
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from '@/components/ui/input';
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from '@/components/ui/badge';
|
||||||
import {
|
import {
|
||||||
Popover,
|
Popover,
|
||||||
PopoverContent,
|
PopoverContent,
|
||||||
PopoverTrigger,
|
PopoverTrigger,
|
||||||
} from "@/components/ui/popover";
|
} from '@/components/ui/popover';
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
SelectItem,
|
SelectItem,
|
||||||
SelectTrigger,
|
SelectTrigger,
|
||||||
SelectValue,
|
SelectValue,
|
||||||
} from "@/components/ui/select";
|
} from '@/components/ui/select';
|
||||||
import { Search, X, SlidersHorizontal, ArrowUpDown, Info } from "lucide-react";
|
import { Search, X, SlidersHorizontal, ArrowUpDown, Info } from 'lucide-react';
|
||||||
import type { Entry } from "@/types";
|
import type { Entry } from '@/types';
|
||||||
import {
|
import {
|
||||||
Tooltip,
|
Tooltip,
|
||||||
TooltipContent,
|
TooltipContent,
|
||||||
TooltipProvider,
|
TooltipProvider,
|
||||||
TooltipTrigger,
|
TooltipTrigger,
|
||||||
} from "@/components/ui/tooltip";
|
} from '@/components/ui/tooltip';
|
||||||
|
|
||||||
const sortLabels: Record<SortField, string> = {
|
const sortLabels: Record<SortField, string> = {
|
||||||
date_last_seen: "Last Watched",
|
date_last_seen: 'Last Watched',
|
||||||
createdAt: "Date Added",
|
createdAt: 'Date Added',
|
||||||
title: "Title",
|
title: 'Title',
|
||||||
release_date: "Release Date",
|
release_date: 'Release Date',
|
||||||
rating: "Rating",
|
rating: 'Rating',
|
||||||
};
|
};
|
||||||
|
|
||||||
function sortEntries(
|
function sortEntries(
|
||||||
@@ -54,29 +54,29 @@ function sortEntries(
|
|||||||
return [...entries].sort((a, b) => {
|
return [...entries].sort((a, b) => {
|
||||||
let cmp = 0;
|
let cmp = 0;
|
||||||
switch (field) {
|
switch (field) {
|
||||||
case "title":
|
case 'title':
|
||||||
cmp = a.title.localeCompare(b.title);
|
cmp = a.title.localeCompare(b.title);
|
||||||
break;
|
break;
|
||||||
case "release_date":
|
case 'release_date':
|
||||||
cmp =
|
cmp =
|
||||||
new Date(a.release_date || "1900").getTime() -
|
new Date(a.release_date || '1900').getTime() -
|
||||||
new Date(b.release_date || "1900").getTime();
|
new Date(b.release_date || '1900').getTime();
|
||||||
break;
|
break;
|
||||||
case "rating":
|
case 'rating':
|
||||||
cmp =
|
cmp =
|
||||||
(a.entryRatings?.user_rating ?? 0) -
|
(a.entryRatings?.user_rating ?? 0) -
|
||||||
(b.entryRatings?.user_rating ?? 0);
|
(b.entryRatings?.user_rating ?? 0);
|
||||||
break;
|
break;
|
||||||
case "date_last_seen":
|
case 'date_last_seen':
|
||||||
cmp =
|
cmp =
|
||||||
new Date(a.date_last_seen || "1900").getTime() -
|
new Date(a.date_last_seen || '1900').getTime() -
|
||||||
new Date(b.date_last_seen || "1900").getTime();
|
new Date(b.date_last_seen || '1900').getTime();
|
||||||
break;
|
break;
|
||||||
case "createdAt":
|
case 'createdAt':
|
||||||
cmp = new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime();
|
cmp = new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime();
|
||||||
break;
|
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 [debouncedFilters, setDebouncedFilters] = useState<Filters>(filters);
|
||||||
const [visibleCount, setVisibleCount] = useState(PAGE_SIZE);
|
const [visibleCount, setVisibleCount] = useState(PAGE_SIZE);
|
||||||
const filtersInitialized = useRef(false);
|
const filtersInitialized = useRef(false);
|
||||||
|
const [statusFilter, setStatusFilter] = useState<string>('');
|
||||||
|
|
||||||
const allEntries = useLibraryEntries();
|
const allEntries = useLibraryEntries();
|
||||||
|
|
||||||
// Reset filters when navigating TO the library (not when pressing back)
|
// Reset filters when navigating TO the library (not when pressing back)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (navigationType !== "POP") {
|
if (navigationType !== 'POP') {
|
||||||
resetAll();
|
resetAll();
|
||||||
}
|
}
|
||||||
// Only run on mount
|
// Only run on mount
|
||||||
@@ -121,9 +122,9 @@ export function LibraryPage() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (filtersInitialized.current) return;
|
if (filtersInitialized.current) return;
|
||||||
filtersInitialized.current = true;
|
filtersInitialized.current = true;
|
||||||
const genre = searchParams.get("genre") || "";
|
const genre = searchParams.get('genre') || '';
|
||||||
const ratingMin = searchParams.get("ratingMin") || "";
|
const ratingMin = searchParams.get('ratingMin') || '';
|
||||||
const ratingMax = searchParams.get("ratingMax") || "";
|
const ratingMax = searchParams.get('ratingMax') || '';
|
||||||
if (genre || ratingMin || ratingMax) {
|
if (genre || ratingMin || ratingMax) {
|
||||||
const newFilters = {
|
const newFilters = {
|
||||||
...defaultFilters,
|
...defaultFilters,
|
||||||
@@ -169,21 +170,22 @@ export function LibraryPage() {
|
|||||||
filters.userRatingMin ||
|
filters.userRatingMin ||
|
||||||
filters.userRatingMax ||
|
filters.userRatingMax ||
|
||||||
filters.yearMin ||
|
filters.yearMin ||
|
||||||
filters.yearMax;
|
filters.yearMax ||
|
||||||
|
!!statusFilter;
|
||||||
|
|
||||||
const baseEntries = useMemo(() => {
|
const baseEntries = useMemo(() => {
|
||||||
switch (activeTab) {
|
switch (activeTab) {
|
||||||
case "movies":
|
case 'movies':
|
||||||
return allEntries.filter(
|
return allEntries.filter(
|
||||||
(e) => !e.is_tvseries && !e.watchlist && !e.hidden,
|
(e) => !e.is_tvseries && !e.watchlist && !e.hidden,
|
||||||
);
|
);
|
||||||
case "tv":
|
case 'tv':
|
||||||
return allEntries.filter(
|
return allEntries.filter(
|
||||||
(e) => e.is_tvseries && !e.watchlist && !e.hidden,
|
(e) => e.is_tvseries && !e.watchlist && !e.hidden,
|
||||||
);
|
);
|
||||||
case "favorites":
|
case 'favorites':
|
||||||
return allEntries.filter((e) => e.favorit && !e.watchlist && !e.hidden);
|
return allEntries.filter((e) => e.favorit && !e.watchlist && !e.hidden);
|
||||||
case "hidden":
|
case 'hidden':
|
||||||
return allEntries.filter((e) => e.hidden);
|
return allEntries.filter((e) => e.hidden);
|
||||||
default:
|
default:
|
||||||
return allEntries.filter((e) => !e.watchlist && !e.hidden);
|
return allEntries.filter((e) => !e.watchlist && !e.hidden);
|
||||||
@@ -195,7 +197,7 @@ export function LibraryPage() {
|
|||||||
|
|
||||||
if (debouncedSearch) {
|
if (debouncedSearch) {
|
||||||
const q = debouncedSearch.toLowerCase();
|
const q = debouncedSearch.toLowerCase();
|
||||||
const directorPrefix = "@director:";
|
const directorPrefix = '@director:';
|
||||||
if (q.startsWith(directorPrefix)) {
|
if (q.startsWith(directorPrefix)) {
|
||||||
const dirQuery = q.slice(directorPrefix.length).trim();
|
const dirQuery = q.slice(directorPrefix.length).trim();
|
||||||
if (dirQuery) {
|
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) {
|
if (debouncedFilters.genre) {
|
||||||
result = result.filter((e) =>
|
result = result.filter((e) =>
|
||||||
e.genres?.some((g) => g.name === debouncedFilters.genre),
|
e.genres?.some((g) => g.name === debouncedFilters.genre),
|
||||||
@@ -272,7 +281,7 @@ export function LibraryPage() {
|
|||||||
/>
|
/>
|
||||||
{search && (
|
{search && (
|
||||||
<button
|
<button
|
||||||
onClick={() => setSearch("")}
|
onClick={() => setSearch('')}
|
||||||
className="absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground"
|
className="absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground"
|
||||||
>
|
>
|
||||||
<X className="h-4 w-4" />
|
<X className="h-4 w-4" />
|
||||||
@@ -294,19 +303,19 @@ export function LibraryPage() {
|
|||||||
<p className="mb-0.5">
|
<p className="mb-0.5">
|
||||||
<code className="bg-accent px-1 rounded text-[11px]">
|
<code className="bg-accent px-1 rounded text-[11px]">
|
||||||
@director:name
|
@director:name
|
||||||
</code>{" "}
|
</code>{' '}
|
||||||
— by director
|
— by director
|
||||||
</p>
|
</p>
|
||||||
<p className="text-muted-foreground mb-0.5">
|
<p className="text-muted-foreground mb-0.5">
|
||||||
<code className="bg-accent px-1 rounded text-[11px]">
|
<code className="bg-accent px-1 rounded text-[11px]">
|
||||||
@country:name
|
@country:name
|
||||||
</code>{" "}
|
</code>{' '}
|
||||||
— coming soon
|
— coming soon
|
||||||
</p>
|
</p>
|
||||||
<p className="text-muted-foreground">
|
<p className="text-muted-foreground">
|
||||||
<code className="bg-accent px-1 rounded text-[11px]">
|
<code className="bg-accent px-1 rounded text-[11px]">
|
||||||
@year:year
|
@year:year
|
||||||
</code>{" "}
|
</code>{' '}
|
||||||
— coming soon
|
— coming soon
|
||||||
</p>
|
</p>
|
||||||
</PopoverContent>
|
</PopoverContent>
|
||||||
@@ -321,7 +330,7 @@ export function LibraryPage() {
|
|||||||
className="h-9 w-9 shrink-0 relative"
|
className="h-9 w-9 shrink-0 relative"
|
||||||
>
|
>
|
||||||
<ArrowUpDown className="h-4 w-4" />
|
<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" />
|
<span className="absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary" />
|
||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -337,8 +346,8 @@ export function LibraryPage() {
|
|||||||
onClick={() => setSortField(value as SortField)}
|
onClick={() => setSortField(value as SortField)}
|
||||||
className={`w-full rounded-md px-3 py-1.5 text-left text-sm transition-colors ${
|
className={`w-full rounded-md px-3 py-1.5 text-left text-sm transition-colors ${
|
||||||
sortField === value
|
sortField === value
|
||||||
? "bg-accent text-accent-foreground font-medium"
|
? 'bg-accent text-accent-foreground font-medium'
|
||||||
: "hover:bg-accent/50"
|
: 'hover:bg-accent/50'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
@@ -347,18 +356,18 @@ export function LibraryPage() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex gap-1 pt-1 border-t border-border">
|
<div className="flex gap-1 pt-1 border-t border-border">
|
||||||
<Button
|
<Button
|
||||||
variant={sortDir === "desc" ? "default" : "outline"}
|
variant={sortDir === 'desc' ? 'default' : 'outline'}
|
||||||
size="sm"
|
size="sm"
|
||||||
className="flex-1 h-8 text-xs"
|
className="flex-1 h-8 text-xs"
|
||||||
onClick={() => setSortDir("desc")}
|
onClick={() => setSortDir('desc')}
|
||||||
>
|
>
|
||||||
↓ Desc
|
↓ Desc
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant={sortDir === "asc" ? "default" : "outline"}
|
variant={sortDir === 'asc' ? 'default' : 'outline'}
|
||||||
size="sm"
|
size="sm"
|
||||||
className="flex-1 h-8 text-xs"
|
className="flex-1 h-8 text-xs"
|
||||||
onClick={() => setSortDir("asc")}
|
onClick={() => setSortDir('asc')}
|
||||||
>
|
>
|
||||||
↑ Asc
|
↑ Asc
|
||||||
</Button>
|
</Button>
|
||||||
@@ -388,7 +397,7 @@ export function LibraryPage() {
|
|||||||
onValueChange={(v) =>
|
onValueChange={(v) =>
|
||||||
setFilters((f) => ({
|
setFilters((f) => ({
|
||||||
...f,
|
...f,
|
||||||
genre: v === "_all" ? "" : v || "",
|
genre: v === '_all' ? '' : v || '',
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
@@ -405,6 +414,25 @@ export function LibraryPage() {
|
|||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</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="">
|
<div className="">
|
||||||
<label className="text-sm font-medium">TMDB Rating</label>
|
<label className="text-sm font-medium">TMDB Rating</label>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
@@ -559,26 +587,26 @@ export function LibraryPage() {
|
|||||||
<p className="mb-0.5">
|
<p className="mb-0.5">
|
||||||
<code className="bg-accent px-1 rounded text-[11px]">
|
<code className="bg-accent px-1 rounded text-[11px]">
|
||||||
@director:name
|
@director:name
|
||||||
</code>{" "}
|
</code>{' '}
|
||||||
— by director
|
— by director
|
||||||
</p>
|
</p>
|
||||||
<p className="text-muted-foreground mb-0.5">
|
<p className="text-muted-foreground mb-0.5">
|
||||||
<code className="bg-accent px-1 rounded text-[11px]">
|
<code className="bg-accent px-1 rounded text-[11px]">
|
||||||
@country:name
|
@country:name
|
||||||
</code>{" "}
|
</code>{' '}
|
||||||
— coming soon
|
— coming soon
|
||||||
</p>
|
</p>
|
||||||
<p className="text-muted-foreground">
|
<p className="text-muted-foreground">
|
||||||
<code className="bg-accent px-1 rounded text-[11px]">
|
<code className="bg-accent px-1 rounded text-[11px]">
|
||||||
@year:year
|
@year:year
|
||||||
</code>{" "}
|
</code>{' '}
|
||||||
— coming soon
|
— coming soon
|
||||||
</p>
|
</p>
|
||||||
</PopoverContent>
|
</PopoverContent>
|
||||||
</Popover>
|
</Popover>
|
||||||
|
|
||||||
{search && (
|
{search && (
|
||||||
<Button variant="ghost" size="sm" onClick={() => setSearch("")}>
|
<Button variant="ghost" size="sm" onClick={() => setSearch('')}>
|
||||||
<X className="mr-1 h-4 w-4" /> Clear
|
<X className="mr-1 h-4 w-4" /> Clear
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
@@ -592,7 +620,7 @@ export function LibraryPage() {
|
|||||||
<ArrowUpDown className="h-4 w-4" />
|
<ArrowUpDown className="h-4 w-4" />
|
||||||
{sortLabels[sortField]}
|
{sortLabels[sortField]}
|
||||||
<span className="text-xs opacity-60">
|
<span className="text-xs opacity-60">
|
||||||
{sortDir === "desc" ? "↓" : "↑"}
|
{sortDir === 'desc' ? '↓' : '↑'}
|
||||||
</span>
|
</span>
|
||||||
</Button>
|
</Button>
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
@@ -607,8 +635,8 @@ export function LibraryPage() {
|
|||||||
onClick={() => setSortField(value as SortField)}
|
onClick={() => setSortField(value as SortField)}
|
||||||
className={`w-full rounded-md px-3 py-1.5 text-left text-sm transition-colors ${
|
className={`w-full rounded-md px-3 py-1.5 text-left text-sm transition-colors ${
|
||||||
sortField === value
|
sortField === value
|
||||||
? "bg-accent text-accent-foreground font-medium"
|
? 'bg-accent text-accent-foreground font-medium'
|
||||||
: "hover:bg-accent/50"
|
: 'hover:bg-accent/50'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
@@ -617,18 +645,18 @@ export function LibraryPage() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex gap-1 pt-1 border-t border-border">
|
<div className="flex gap-1 pt-1 border-t border-border">
|
||||||
<Button
|
<Button
|
||||||
variant={sortDir === "desc" ? "default" : "outline"}
|
variant={sortDir === 'desc' ? 'default' : 'outline'}
|
||||||
size="sm"
|
size="sm"
|
||||||
className="flex-1 h-8 text-xs"
|
className="flex-1 h-8 text-xs"
|
||||||
onClick={() => setSortDir("desc")}
|
onClick={() => setSortDir('desc')}
|
||||||
>
|
>
|
||||||
↓ Desc
|
↓ Desc
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant={sortDir === "asc" ? "default" : "outline"}
|
variant={sortDir === 'asc' ? 'default' : 'outline'}
|
||||||
size="sm"
|
size="sm"
|
||||||
className="flex-1 h-8 text-xs"
|
className="flex-1 h-8 text-xs"
|
||||||
onClick={() => setSortDir("asc")}
|
onClick={() => setSortDir('asc')}
|
||||||
>
|
>
|
||||||
↑ Asc
|
↑ Asc
|
||||||
</Button>
|
</Button>
|
||||||
@@ -660,7 +688,7 @@ export function LibraryPage() {
|
|||||||
onValueChange={(v) =>
|
onValueChange={(v) =>
|
||||||
setFilters((f) => ({
|
setFilters((f) => ({
|
||||||
...f,
|
...f,
|
||||||
genre: v === "_all" ? "" : v || "",
|
genre: v === '_all' ? '' : v || '',
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
@@ -677,6 +705,25 @@ export function LibraryPage() {
|
|||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</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">
|
<div className="space-y-2 mb-0">
|
||||||
<label className="text-sm font-medium">TMDB Rating</label>
|
<label className="text-sm font-medium">TMDB Rating</label>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
|
|||||||
@@ -1,26 +1,26 @@
|
|||||||
import { useState } from "react";
|
import { useState } from 'react';
|
||||||
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
import { settingsApi } from "@/api/settings";
|
import { settingsApi } from '@/api/settings';
|
||||||
import { maintenanceApi, type OrphanResult } from "@/api/maintenance";
|
import { maintenanceApi, type OrphanResult } from '@/api/maintenance';
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from 'react-hook-form';
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
import { z } from "zod";
|
import { z } from 'zod';
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
CardContent,
|
CardContent,
|
||||||
CardHeader,
|
CardHeader,
|
||||||
CardTitle,
|
CardTitle,
|
||||||
CardDescription,
|
CardDescription,
|
||||||
} from "@/components/ui/card";
|
} from '@/components/ui/card';
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from '@/components/ui/input';
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from '@/components/ui/label';
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from '@/components/ui/button';
|
||||||
import { Skeleton } from "@/components/ui/skeleton";
|
import { Skeleton } from '@/components/ui/skeleton';
|
||||||
import { Save, Search, Trash2, Loader2 } from "lucide-react";
|
import { Save, Search, Trash2, Loader2 } from 'lucide-react';
|
||||||
import type { Settings } from "@/types";
|
import type { Settings } from '@/types';
|
||||||
|
|
||||||
const settingsSchema = z.object({
|
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(),
|
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.logos) parts.push(`${result.logos} logo(s)`);
|
||||||
if (result.backdrops) parts.push(`${result.backdrops} backdrop(s)`);
|
if (result.backdrops) parts.push(`${result.backdrops} backdrop(s)`);
|
||||||
if (result.stills) parts.push(`${result.stills} still(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 {
|
function hasOrphans(result: OrphanResult | null): boolean {
|
||||||
@@ -88,7 +88,7 @@ function MissingDirectorsSection() {
|
|||||||
{result && (
|
{result && (
|
||||||
<p className="text-xs text-muted-foreground">
|
<p className="text-xs text-muted-foreground">
|
||||||
{result.count === 0
|
{result.count === 0
|
||||||
? "All entries have directors."
|
? 'All entries have directors.'
|
||||||
: result.fixed > 0
|
: result.fixed > 0
|
||||||
? `Fixed ${result.fixed} of ${result.count} missing directors.`
|
? `Fixed ${result.fixed} of ${result.count} missing directors.`
|
||||||
: `${result.count} entries missing director.`}
|
: `${result.count} entries missing director.`}
|
||||||
@@ -150,7 +150,7 @@ function DuplicateCreditsSection() {
|
|||||||
{result && (
|
{result && (
|
||||||
<p className="text-xs text-muted-foreground">
|
<p className="text-xs text-muted-foreground">
|
||||||
{result.duplicates === 0
|
{result.duplicates === 0
|
||||||
? "No duplicate credits found."
|
? 'No duplicate credits found.'
|
||||||
: result.deleted > 0
|
: result.deleted > 0
|
||||||
? `Removed ${result.deleted} duplicates across ${result.groups} groups.`
|
? `Removed ${result.deleted} duplicates across ${result.groups} groups.`
|
||||||
: `${result.duplicates} 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() {
|
export function SettingsPage() {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const { data: settings, isLoading } = useQuery({
|
const { data: settings, isLoading } = useQuery({
|
||||||
queryKey: ["settings"],
|
queryKey: ['settings'],
|
||||||
queryFn: settingsApi.get,
|
queryFn: settingsApi.get,
|
||||||
});
|
});
|
||||||
|
|
||||||
const updateSettings = useMutation({
|
const updateSettings = useMutation({
|
||||||
mutationFn: (data: Partial<Settings>) => settingsApi.update(data),
|
mutationFn: (data: Partial<Settings>) => settingsApi.update(data),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ["settings"] });
|
queryClient.invalidateQueries({ queryKey: ['settings'] });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -241,7 +289,7 @@ export function SettingsPage() {
|
|||||||
<Input
|
<Input
|
||||||
id="tmdbApiKey"
|
id="tmdbApiKey"
|
||||||
type="password"
|
type="password"
|
||||||
{...register("tmdbApiKey")}
|
{...register('tmdbApiKey')}
|
||||||
/>
|
/>
|
||||||
{errors.tmdbApiKey && (
|
{errors.tmdbApiKey && (
|
||||||
<p className="text-xs text-destructive">
|
<p className="text-xs text-destructive">
|
||||||
@@ -252,7 +300,7 @@ export function SettingsPage() {
|
|||||||
|
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<Label htmlFor="backPort">Backend Port</Label>
|
<Label htmlFor="backPort">Backend Port</Label>
|
||||||
<Input id="backPort" type="number" {...register("backPort")} />
|
<Input id="backPort" type="number" {...register('backPort')} />
|
||||||
{errors.backPort && (
|
{errors.backPort && (
|
||||||
<p className="text-xs text-destructive">
|
<p className="text-xs text-destructive">
|
||||||
{errors.backPort.message}
|
{errors.backPort.message}
|
||||||
@@ -265,7 +313,7 @@ export function SettingsPage() {
|
|||||||
disabled={!isDirty || updateSettings.isPending}
|
disabled={!isDirty || updateSettings.isPending}
|
||||||
>
|
>
|
||||||
<Save className="mr-2 h-4 w-4" />
|
<Save className="mr-2 h-4 w-4" />
|
||||||
{updateSettings.isPending ? "Saving..." : "Save Settings"}
|
{updateSettings.isPending ? 'Saving...' : 'Save Settings'}
|
||||||
</Button>
|
</Button>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
@@ -396,6 +444,20 @@ export function SettingsPage() {
|
|||||||
<DuplicateCreditsSection />
|
<DuplicateCreditsSection />
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</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>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -15,9 +15,9 @@ export interface EntryRatings {
|
|||||||
|
|
||||||
export interface Media {
|
export interface Media {
|
||||||
id: number;
|
id: number;
|
||||||
mediaable: "entry" | "people" | "collection" | "season" | "episode";
|
mediaable: 'entry' | 'people' | 'collection' | 'season' | 'episode';
|
||||||
mediaable_id: number;
|
mediaable_id: number;
|
||||||
type: "poster" | "backdrop" | "logo" | "still" | "profile";
|
type: 'poster' | 'backdrop' | 'logo' | 'still' | 'profile';
|
||||||
path: string;
|
path: string;
|
||||||
is_local: boolean;
|
is_local: boolean;
|
||||||
is_selected: boolean;
|
is_selected: boolean;
|
||||||
@@ -55,6 +55,7 @@ export interface Entry {
|
|||||||
credits?: Credit[];
|
credits?: Credit[];
|
||||||
/** Computed — director name string for search (not persisted in DB) */
|
/** Computed — director name string for search (not persisted in DB) */
|
||||||
director?: string | null;
|
director?: string | null;
|
||||||
|
watch_status?: string | null;
|
||||||
seasons?: Season[];
|
seasons?: Season[];
|
||||||
entrySeens?: EntrySeen[];
|
entrySeens?: EntrySeen[];
|
||||||
episodeSeens?: EpisodeSeen[];
|
episodeSeens?: EpisodeSeen[];
|
||||||
@@ -104,7 +105,7 @@ export interface Episode {
|
|||||||
season?: Season;
|
season?: Season;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SeenAccuracy = "EXACT" | "ESTIMATED" | "UNKNOWN";
|
export type SeenAccuracy = 'EXACT' | 'ESTIMATED' | 'UNKNOWN';
|
||||||
|
|
||||||
export interface EntrySeen {
|
export interface EntrySeen {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -168,7 +169,7 @@ export interface Credit {
|
|||||||
entry_id: number;
|
entry_id: number;
|
||||||
people_id: number;
|
people_id: number;
|
||||||
character: string | null; // might contain multiple separated by ;
|
character: string | null; // might contain multiple separated by ;
|
||||||
cast_type: "cast" | "crew";
|
cast_type: 'cast' | 'crew';
|
||||||
department: string | null;
|
department: string | null;
|
||||||
job: string | null;
|
job: string | null;
|
||||||
episode_count?: number | null;
|
episode_count?: number | null;
|
||||||
@@ -250,7 +251,7 @@ export interface TmdbPaginatedResponse<T> {
|
|||||||
|
|
||||||
export interface TmdbPreviewCredit {
|
export interface TmdbPreviewCredit {
|
||||||
id: string | number;
|
id: string | number;
|
||||||
cast_type: "cast";
|
cast_type: 'cast';
|
||||||
character: string | null;
|
character: string | null;
|
||||||
people_id: number;
|
people_id: number;
|
||||||
people: {
|
people: {
|
||||||
|
|||||||
Reference in new issue
Block a user