Add per-library customizable file naming patterns

This commit is contained in:
aditya.chandel
2025-08-10 11:27:28 -06:00
committed by Aditya Chandel
parent 1f83dfa85d
commit 978bd05b1e
20 changed files with 394 additions and 342 deletions
@@ -5,6 +5,7 @@ export interface Library {
name: string;
icon: string;
watch: boolean;
fileNamingPattern?: string;
sort?: SortOption;
paths: LibraryPath[];
}
@@ -122,14 +122,27 @@ export class LibraryService {
getLibraryPathById(pathId: number): string | undefined {
const libraries = this.libraryStateSubject.value.libraries || [];
for (const library of libraries) {
const match = library.paths.find(p => p.id === pathId);
if (match) {
return match.path;
}
}
return undefined;
}
updateLibraryFileNamingPattern(libraryId: number, fileNamingPattern: string): Observable<Library> {
return this.http.patch<Library>(`${this.url}/${libraryId}/file-naming-pattern`, { fileNamingPattern }).pipe(
map(updatedLibrary => {
const currentState = this.libraryStateSubject.value;
const updatedLibraries = currentState.libraries ? currentState.libraries.map(existingLibrary =>
existingLibrary.id === updatedLibrary.id ? updatedLibrary : existingLibrary) : [updatedLibrary];
this.libraryStateSubject.next({...currentState, libraries: updatedLibraries});
return updatedLibrary;
}),
catchError(error => {
throw error;
})
);
}
}