Library Settings Modal + New Library Settings (#1660)

* Bump loader-utils from 2.0.3 to 2.0.4 in /UI/Web

Bumps [loader-utils](https://github.com/webpack/loader-utils) from 2.0.3 to 2.0.4.
- [Release notes](https://github.com/webpack/loader-utils/releases)
- [Changelog](https://github.com/webpack/loader-utils/blob/v2.0.4/CHANGELOG.md)
- [Commits](https://github.com/webpack/loader-utils/compare/v2.0.3...v2.0.4)

---
updated-dependencies:
- dependency-name: loader-utils
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fixed want to read button on series detail not performing the correct action

* Started the library settings. Added ability to update a cover image for a library.

Updated backup db to also copy reading list (and now library) cover images.

* Integrated Edit Library into new settings (not tested) and hooked up a wizard-like flow for new library.

* Fixed a missing update event in backend when updating a library.

* Disable Save when form invalid. Do inline validation on Library name when user types to ensure the name is valid.

* Trim library names before you check anything

* General code cleanup

* Implemented advanced settings for library (include in dashboard, search, recommended) and ability to turn off folder watching for individual libraries.

Refactored some code to streamline perf in some flows.

* Removed old components replaced with new modal

* Code smells

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
Joe Milazzo 2022-11-18 09:38:32 -06:00 committed by GitHub
parent 48b15e564d
commit 73d77e6264
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
47 changed files with 2530 additions and 276 deletions

View file

@ -9,6 +9,7 @@ using API.DTOs.JumpBar;
using API.DTOs.Metadata;
using API.Entities;
using API.Entities.Enums;
using API.Extensions;
using AutoMapper;
using AutoMapper.QueryableExtensions;
using Kavita.Common.Extensions;
@ -38,7 +39,7 @@ public interface ILibraryRepository
Task<IEnumerable<Library>> GetLibrariesAsync(LibraryIncludes includes = LibraryIncludes.None);
Task<bool> DeleteLibrary(int libraryId);
Task<IEnumerable<Library>> GetLibrariesForUserIdAsync(int userId);
Task<IEnumerable<int>> GetLibraryIdsForUserIdAsync(int userId);
IEnumerable<int> GetLibraryIdsForUserIdAsync(int userId, QueryContext queryContext = QueryContext.None);
Task<LibraryType> GetLibraryTypeAsync(int libraryId);
Task<IEnumerable<Library>> GetLibraryForIdsAsync(IEnumerable<int> libraryIds, LibraryIncludes includes = LibraryIncludes.None);
Task<int> GetTotalFiles();
@ -48,7 +49,8 @@ public interface ILibraryRepository
Task<IList<LanguageDto>> GetAllLanguagesForLibrariesAsync();
IEnumerable<PublicationStatusDto> GetAllPublicationStatusesDtosForLibrariesAsync(List<int> libraryIds);
Task<bool> DoAnySeriesFoldersMatch(IEnumerable<string> folders);
Library GetLibraryByFolder(string folder);
Task<string> GetLibraryCoverImageAsync(int libraryId);
Task<IList<string>> GetAllCoverImagesAsync();
}
public class LibraryRepository : ILibraryRepository
@ -126,12 +128,13 @@ public class LibraryRepository : ILibraryRepository
.ToListAsync();
}
public async Task<IEnumerable<int>> GetLibraryIdsForUserIdAsync(int userId)
public IEnumerable<int> GetLibraryIdsForUserIdAsync(int userId, QueryContext queryContext = QueryContext.None)
{
return await _context.Library
return _context.Library
.IsRestricted(queryContext)
.Where(l => l.AppUsers.Select(ap => ap.Id).Contains(userId))
.Select(l => l.Id)
.ToListAsync();
.AsEnumerable();
}
public async Task<LibraryType> GetLibraryTypeAsync(int libraryId)
@ -377,12 +380,21 @@ public class LibraryRepository : ILibraryRepository
return await _context.Series.AnyAsync(s => normalized.Contains(s.FolderPath));
}
public Library? GetLibraryByFolder(string folder)
public Task<string> GetLibraryCoverImageAsync(int libraryId)
{
var normalized = Services.Tasks.Scanner.Parser.Parser.NormalizePath(folder);
return _context.Library
.Include(l => l.Folders)
.AsSplitQuery()
.SingleOrDefault(l => l.Folders.Select(f => f.Path).Contains(normalized));
.Where(l => l.Id == libraryId)
.Select(l => l.CoverImage)
.SingleOrDefaultAsync();
}
public async Task<IList<string>> GetAllCoverImagesAsync()
{
return await _context.ReadingList
.Select(t => t.CoverImage)
.Where(t => !string.IsNullOrEmpty(t))
.AsNoTracking()
.ToListAsync();
}
}