Show shelf paths in settings and force rescan after path changes.

This commit is contained in:
Jos Vooges | STH 2026-08-26 02:18:19 +02:00
parent 8200b908e1
commit 71c0244dd9
3 changed files with 36 additions and 4 deletions

View file

@ -46,6 +46,7 @@ interface ShelfRow {
enabled: boolean; enabled: boolean;
scanRootCount: number; scanRootCount: number;
mediaFileCount: number; mediaFileCount: number;
paths?: Array<{ path: string; nodeName: string }>;
} }
export default function SettingsPage() { export default function SettingsPage() {
@ -318,7 +319,7 @@ export default function SettingsPage() {
<tr> <tr>
<th>Naam</th> <th>Naam</th>
<th>Type</th> <th>Type</th>
<th>Paden</th> <th>Pad(en)</th>
<th>Bestanden</th> <th>Bestanden</th>
<th></th> <th></th>
</tr> </tr>
@ -328,8 +329,25 @@ export default function SettingsPage() {
<tr key={s.id}> <tr key={s.id}>
<td>{s.name}</td> <td>{s.name}</td>
<td>{s.kind === "MOVIE" ? "Films" : "Series"}</td> <td>{s.kind === "MOVIE" ? "Films" : "Series"}</td>
<td>{s.scanRootCount}</td> <td style={{ fontSize: "0.8rem", maxWidth: 360 }}>
<td>{s.mediaFileCount}</td> {s.paths?.length
? s.paths.map((p) => (
<div key={`${p.nodeName}:${p.path}`} style={{ color: "#a1a1aa", marginBottom: 2 }}>
<span style={{ color: "#71717a" }}>{p.nodeName}:</span> {p.path}
</div>
))
: (
<span style={{ color: "#71717a" }}>{s.scanRootCount} pad(en)</span>
)}
</td>
<td>
{s.mediaFileCount}
{s.scanRootCount > 0 && s.mediaFileCount === 0 && (
<div style={{ color: "#f59e0b", fontSize: "0.75rem" }}>
Pad gekoppeld, nog geen scan/shelf-match
</div>
)}
</td>
<td> <td>
{s.slug !== "films" && s.slug !== "series" && ( {s.slug !== "films" && s.slug !== "series" && (
<button className="danger" onClick={() => deleteShelf(s.id, s.name)}> <button className="danger" onClick={() => deleteShelf(s.id, s.name)}>

View file

@ -517,7 +517,13 @@ export async function registerAdminRoutes(app: FastifyInstance, config: Config)
await ensureDefaultShelves(); await ensureDefaultShelves();
const shelves = await prisma.libraryShelf.findMany({ const shelves = await prisma.libraryShelf.findMany({
orderBy: [{ sortOrder: "asc" }, { name: "asc" }], orderBy: [{ sortOrder: "asc" }, { name: "asc" }],
include: { _count: { select: { scanRoots: true, mediaFiles: true } } }, include: {
_count: { select: { scanRoots: true, mediaFiles: true } },
scanRoots: {
select: { path: true, node: { select: { name: true } } },
orderBy: { path: "asc" },
},
},
}); });
return { return {
shelves: shelves.map((s) => ({ shelves: shelves.map((s) => ({
@ -529,6 +535,10 @@ export async function registerAdminRoutes(app: FastifyInstance, config: Config)
enabled: s.enabled, enabled: s.enabled,
scanRootCount: s._count.scanRoots, scanRootCount: s._count.scanRoots,
mediaFileCount: s._count.mediaFiles, mediaFileCount: s._count.mediaFiles,
paths: s.scanRoots.map((r) => ({
path: r.path,
nodeName: r.node.name,
})),
})), })),
}; };
}); });

View file

@ -305,6 +305,10 @@ export async function registerNodeRoutes(app: FastifyInstance) {
kind: r.kind, kind: r.kind,
})), })),
}); });
// Ensure a full inventory pass so shelfIds are rewritten for existing files.
if (replacedRoots) {
nodeConnectionManager.sendRescan(id, true);
}
} }
return { node: serializeNode(node) }; return { node: serializeNode(node) };