From e75b208d59172b1e9ce6ec348b2cac3bb219d2b5 Mon Sep 17 00:00:00 2001 From: Joe Milazzo Date: Mon, 14 Nov 2022 08:43:19 -0600 Subject: [PATCH 001/199] WebP Covers + Series Detail Enhancements (#1652) * Implemented save covers as webp. Reworked screen to provide more information up front about webp and what browsers can support it. * cleaned up pages to use compact numbering and made compact numbering expand into one decimal place (20.5K) * Fixed an issue with adding new device * If a book has an invalid language set, drop the language altogether rather than reading in a corrupted entry. * Ensure genres and tags render alphabetically. Improved support for partial volumes in Comic parser. * Ensure all people, tags, collections, and genres are in alphabetical order. * Moved some code to Extensions to clean up code. * More unit tests * Cleaned up release year filter css * Tweaked some code in all series to make bulk deletes cleaner on the UI. * Trying out want to read and unread count on series detail page * Added Want to Read button for series page to make it easy to see when something is in want to read list and toggle it. Added tooltips instead of title to buttons, but they don't style correctly. Added a continue point under cover image. * Code smells --- API.Tests/Parser/ComicParserTests.cs | 2 + API.Tests/Services/CacheServiceTests.cs | 2 +- API.Tests/Services/CleanupServiceTests.cs | 102 +++++++++++++++++- API.Tests/Services/ParseScannedFilesTests.cs | 2 +- API/Controllers/ServerController.cs | 4 +- API/Controllers/SettingsController.cs | 6 ++ API/Controllers/WantToReadController.cs | 7 ++ API/DTOs/SeriesDetail/SeriesDetailDto.cs | 8 ++ API/DTOs/Settings/ServerSettingDTO.cs | 4 + .../Repositories/CollectionTagRepository.cs | 38 ++++--- API/Data/Repositories/GenreRepository.cs | 3 +- API/Data/Repositories/SeriesRepository.cs | 81 +++++--------- API/Data/Repositories/TagRepository.cs | 4 +- API/Data/Seed.cs | 1 + API/Entities/Enums/ServerSettingKey.cs | 5 + API/Extensions/QueryableExtensions.cs | 48 +++++++++ API/Helpers/AutoMapperProfiles.cs | 62 +++++++---- .../Converters/ServerSettingConverter.cs | 3 + API/Services/ArchiveService.cs | 9 +- API/Services/BookService.cs | 34 ++++-- API/Services/BookmarkService.cs | 1 + API/Services/ImageService.cs | 13 +-- API/Services/MetadataService.cs | 28 +++-- API/Services/ReadingItemService.cs | 13 +-- API/Services/SeriesService.cs | 4 +- API/Services/Tasks/Scanner/Parser/Parser.cs | 2 +- .../_models/series-detail/series-detail.ts | 2 + UI/Web/src/app/_services/series.service.ts | 4 + .../src/app/admin/_models/server-settings.ts | 1 + .../manage-media-settings.component.html | 18 +++- .../manage-media-settings.component.ts | 3 + .../app/all-series/all-series.component.html | 1 - .../app/all-series/all-series.component.ts | 37 ++----- .../entity-info-cards.component.html | 4 +- .../series-info-cards.component.html | 4 +- .../metadata-filter.component.html | 4 +- UI/Web/src/app/pipe/compact-number.pipe.ts | 3 +- .../series-detail.component.html | 16 ++- .../series-detail.component.scss | 23 ++++ .../series-detail/series-detail.component.ts | 43 ++++++++ .../series-metadata-detail.component.html | 1 - .../edit-device/edit-device.component.html | 2 +- .../edit-device/edit-device.component.ts | 4 +- 43 files changed, 481 insertions(+), 175 deletions(-) diff --git a/API.Tests/Parser/ComicParserTests.cs b/API.Tests/Parser/ComicParserTests.cs index 689327d98..9b6bf212d 100644 --- a/API.Tests/Parser/ComicParserTests.cs +++ b/API.Tests/Parser/ComicParserTests.cs @@ -100,6 +100,7 @@ public class ComicParserTests [InlineData("Teen Titans v1 001 (1966-02) (digital) (OkC.O.M.P.U.T.O.-Novus)", "1")] [InlineData("Scott Pilgrim 02 - Scott Pilgrim vs. The World (2005)", "0")] [InlineData("Superman v1 024 (09-10 1943)", "1")] + [InlineData("Superman v1.5 024 (09-10 1943)", "1.5")] [InlineData("Amazing Man Comics chapter 25", "0")] [InlineData("Invincible 033.5 - Marvel Team-Up 14 (2006) (digital) (Minutemen-Slayer)", "0")] [InlineData("Cyberpunk 2077 - Trauma Team 04.cbz", "0")] @@ -118,6 +119,7 @@ public class ComicParserTests [InlineData("Cyberpunk 2077 - Trauma Team 04.cbz", "0")] [InlineData("2000 AD 0366 [1984-04-28] (flopbie)", "0")] [InlineData("Daredevil - v6 - 10 - (2019)", "6")] + [InlineData("Daredevil - v6.5", "6.5")] // Tome Tests [InlineData("Daredevil - t6 - 10 - (2019)", "6")] [InlineData("Batgirl T2000 #57", "2000")] diff --git a/API.Tests/Services/CacheServiceTests.cs b/API.Tests/Services/CacheServiceTests.cs index e3be8dce5..d05cc9113 100644 --- a/API.Tests/Services/CacheServiceTests.cs +++ b/API.Tests/Services/CacheServiceTests.cs @@ -41,7 +41,7 @@ internal class MockReadingItemServiceForCacheService : IReadingItemService return 1; } - public string GetCoverImage(string fileFilePath, string fileName, MangaFormat format) + public string GetCoverImage(string fileFilePath, string fileName, MangaFormat format, bool saveAsWebP) { return string.Empty; } diff --git a/API.Tests/Services/CleanupServiceTests.cs b/API.Tests/Services/CleanupServiceTests.cs index 5c60baf4d..0ffb61bb8 100644 --- a/API.Tests/Services/CleanupServiceTests.cs +++ b/API.Tests/Services/CleanupServiceTests.cs @@ -6,9 +6,11 @@ using System.IO.Abstractions.TestingHelpers; using System.Linq; using System.Threading.Tasks; using API.Data; +using API.Data.Repositories; using API.DTOs.Settings; using API.Entities; using API.Entities.Enums; +using API.Entities.Metadata; using API.Helpers; using API.Helpers.Converters; using API.Services; @@ -129,7 +131,6 @@ public class CleanupServiceTests #endregion - #region DeleteSeriesCoverImages [Fact] @@ -469,6 +470,105 @@ public class CleanupServiceTests #endregion + #region CleanupDbEntries + + [Fact] + public async Task CleanupDbEntries_CleanupAbandonedChapters() + { + var c = EntityFactory.CreateChapter("1", false, new List(), 1); + _context.Series.Add(new Series() + { + Name = "Test", + Library = new Library() { + Name = "Test LIb", + Type = LibraryType.Manga, + }, + Volumes = new List() + { + EntityFactory.CreateVolume("0", new List() + { + c, + }), + } + }); + + _context.AppUser.Add(new AppUser() + { + UserName = "majora2007" + }); + + await _context.SaveChangesAsync(); + + var readerService = new ReaderService(_unitOfWork, Substitute.For>(), Substitute.For()); + + var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync("majora2007", AppUserIncludes.Progress); + await readerService.MarkChaptersUntilAsRead(user, 1, 5); + await _context.SaveChangesAsync(); + + // Validate correct chapters have read status + Assert.Equal(1, (await _unitOfWork.AppUserProgressRepository.GetUserProgressAsync(1, 1)).PagesRead); + + var cleanupService = new CleanupService(Substitute.For>(), _unitOfWork, + Substitute.For(), + new DirectoryService(Substitute.For>(), new MockFileSystem())); + + // Delete the Chapter + _context.Chapter.Remove(c); + await _unitOfWork.CommitAsync(); + Assert.Single(await _unitOfWork.AppUserProgressRepository.GetUserProgressForSeriesAsync(1, 1)); + + await cleanupService.CleanupDbEntries(); + + Assert.Empty(await _unitOfWork.AppUserProgressRepository.GetUserProgressForSeriesAsync(1, 1)); + } + + [Fact] + public async Task CleanupDbEntries_RemoveTagsWithoutSeries() + { + var c = new CollectionTag() + { + Title = "Test Tag" + }; + var s = new Series() + { + Name = "Test", + Library = new Library() + { + Name = "Test LIb", + Type = LibraryType.Manga, + }, + Volumes = new List(), + Metadata = new SeriesMetadata() + { + CollectionTags = new List() + { + c + } + } + }; + _context.Series.Add(s); + + _context.AppUser.Add(new AppUser() + { + UserName = "majora2007" + }); + + await _context.SaveChangesAsync(); + + var cleanupService = new CleanupService(Substitute.For>(), _unitOfWork, + Substitute.For(), + new DirectoryService(Substitute.For>(), new MockFileSystem())); + + // Delete the Chapter + _context.Series.Remove(s); + await _unitOfWork.CommitAsync(); + + await cleanupService.CleanupDbEntries(); + + Assert.Empty(await _unitOfWork.CollectionTagRepository.GetAllTagsAsync()); + } + + #endregion // #region CleanupBookmarks // // [Fact] diff --git a/API.Tests/Services/ParseScannedFilesTests.cs b/API.Tests/Services/ParseScannedFilesTests.cs index d5e235a80..5ead303ae 100644 --- a/API.Tests/Services/ParseScannedFilesTests.cs +++ b/API.Tests/Services/ParseScannedFilesTests.cs @@ -46,7 +46,7 @@ internal class MockReadingItemService : IReadingItemService return 1; } - public string GetCoverImage(string fileFilePath, string fileName, MangaFormat format) + public string GetCoverImage(string fileFilePath, string fileName, MangaFormat format, bool saveAsWebP) { return string.Empty; } diff --git a/API/Controllers/ServerController.cs b/API/Controllers/ServerController.cs index f43bcf271..c19af1956 100644 --- a/API/Controllers/ServerController.cs +++ b/API/Controllers/ServerController.cs @@ -19,7 +19,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -using TaskScheduler = System.Threading.Tasks.TaskScheduler; +using TaskScheduler = API.Services.TaskScheduler; namespace API.Controllers; @@ -119,6 +119,8 @@ public class ServerController : BaseApiController [HttpPost("convert-bookmarks")] public ActionResult ScheduleConvertBookmarks() { + if (TaskScheduler.HasAlreadyEnqueuedTask(BookmarkService.Name, "ConvertAllBookmarkToWebP", Array.Empty(), + TaskScheduler.DefaultQueue, true)) return Ok(); BackgroundJob.Enqueue(() => _bookmarkService.ConvertAllBookmarkToWebP()); return Ok(); } diff --git a/API/Controllers/SettingsController.cs b/API/Controllers/SettingsController.cs index 739cb6e18..2ea4698e9 100644 --- a/API/Controllers/SettingsController.cs +++ b/API/Controllers/SettingsController.cs @@ -176,6 +176,12 @@ public class SettingsController : BaseApiController _unitOfWork.SettingsRepository.Update(setting); } + if (setting.Key == ServerSettingKey.ConvertCoverToWebP && updateSettingsDto.ConvertCoverToWebP + string.Empty != setting.Value) + { + setting.Value = updateSettingsDto.ConvertCoverToWebP + string.Empty; + _unitOfWork.SettingsRepository.Update(setting); + } + if (setting.Key == ServerSettingKey.BookmarkDirectory && bookmarkDirectory != setting.Value) { diff --git a/API/Controllers/WantToReadController.cs b/API/Controllers/WantToReadController.cs index 20ec4a0c4..c0465a988 100644 --- a/API/Controllers/WantToReadController.cs +++ b/API/Controllers/WantToReadController.cs @@ -41,6 +41,13 @@ public class WantToReadController : BaseApiController return Ok(pagedList); } + [HttpGet] + public async Task>> GetWantToRead([FromQuery] int seriesId) + { + var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername()); + return Ok(await _unitOfWork.SeriesRepository.IsSeriesInWantToRead(user.Id, seriesId)); + } + /// /// Given a list of Series Ids, add them to the current logged in user's Want To Read list /// diff --git a/API/DTOs/SeriesDetail/SeriesDetailDto.cs b/API/DTOs/SeriesDetail/SeriesDetailDto.cs index 9bc8a97d8..2438755c6 100644 --- a/API/DTOs/SeriesDetail/SeriesDetailDto.cs +++ b/API/DTOs/SeriesDetail/SeriesDetailDto.cs @@ -24,5 +24,13 @@ public class SeriesDetailDto /// These are chapters that are in Volume 0 and should be read AFTER the volumes /// public IEnumerable StorylineChapters { get; set; } + /// + /// How many chapters are unread + /// + public int UnreadCount { get; set; } + /// + /// How many chapters are there + /// + public int TotalCount { get; set; } } diff --git a/API/DTOs/Settings/ServerSettingDTO.cs b/API/DTOs/Settings/ServerSettingDTO.cs index 041c9300d..332d06a69 100644 --- a/API/DTOs/Settings/ServerSettingDTO.cs +++ b/API/DTOs/Settings/ServerSettingDTO.cs @@ -65,4 +65,8 @@ public class ServerSettingDto /// /// Value should be between 1 and 30 public int TotalLogs { get; set; } + /// + /// If the server should save covers as WebP encoding + /// + public bool ConvertCoverToWebP { get; set; } } diff --git a/API/Data/Repositories/CollectionTagRepository.cs b/API/Data/Repositories/CollectionTagRepository.cs index a5ea582f3..e4fcf5e50 100644 --- a/API/Data/Repositories/CollectionTagRepository.cs +++ b/API/Data/Repositories/CollectionTagRepository.cs @@ -1,5 +1,5 @@ -using System.Collections.Generic; -using System.IO; +using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using API.Data.Misc; @@ -12,6 +12,13 @@ using Microsoft.EntityFrameworkCore; namespace API.Data.Repositories; +[Flags] +public enum CollectionTagIncludes +{ + None = 1, + SeriesMetadata = 2, +} + public interface ICollectionTagRepository { void Add(CollectionTag tag); @@ -21,7 +28,7 @@ public interface ICollectionTagRepository Task GetCoverImageAsync(int collectionTagId); Task> GetAllPromotedTagDtosAsync(int userId); Task GetTagAsync(int tagId); - Task GetFullTagAsync(int tagId); + Task GetFullTagAsync(int tagId, CollectionTagIncludes includes = CollectionTagIncludes.SeriesMetadata); void Update(CollectionTag tag); Task RemoveTagsWithoutSeries(); Task> GetAllTagsAsync(); @@ -76,6 +83,15 @@ public class CollectionTagRepository : ICollectionTagRepository .ToListAsync(); } + public async Task GetCoverImageAsync(int collectionTagId) + { + return await _context.CollectionTag + .Where(c => c.Id == collectionTagId) + .Select(c => c.CoverImage) + .AsNoTracking() + .SingleOrDefaultAsync(); + } + public async Task> GetAllCoverImagesAsync() { return await _context.CollectionTag @@ -114,11 +130,11 @@ public class CollectionTagRepository : ICollectionTagRepository .SingleOrDefaultAsync(); } - public async Task GetFullTagAsync(int tagId) + public async Task GetFullTagAsync(int tagId, CollectionTagIncludes includes = CollectionTagIncludes.SeriesMetadata) { return await _context.CollectionTag .Where(c => c.Id == tagId) - .Include(c => c.SeriesMetadatas) + .Includes(includes) .AsSplitQuery() .SingleOrDefaultAsync(); } @@ -143,19 +159,9 @@ public class CollectionTagRepository : ICollectionTagRepository .Where(s => EF.Functions.Like(s.Title, $"%{searchQuery}%") || EF.Functions.Like(s.NormalizedTitle, $"%{searchQuery}%")) .RestrictAgainstAgeRestriction(userRating) - .OrderBy(s => s.Title) + .OrderBy(s => s.NormalizedTitle) .AsNoTracking() - .OrderBy(c => c.NormalizedTitle) .ProjectTo(_mapper.ConfigurationProvider) .ToListAsync(); } - - public async Task GetCoverImageAsync(int collectionTagId) - { - return await _context.CollectionTag - .Where(c => c.Id == collectionTagId) - .Select(c => c.CoverImage) - .AsNoTracking() - .SingleOrDefaultAsync(); - } } diff --git a/API/Data/Repositories/GenreRepository.cs b/API/Data/Repositories/GenreRepository.cs index df7fb5069..464914b70 100644 --- a/API/Data/Repositories/GenreRepository.cs +++ b/API/Data/Repositories/GenreRepository.cs @@ -80,7 +80,7 @@ public class GenreRepository : IGenreRepository .SelectMany(s => s.Metadata.Genres) .AsSplitQuery() .Distinct() - .OrderBy(p => p.Title) + .OrderBy(p => p.NormalizedTitle) .ProjectTo(_mapper.ConfigurationProvider) .ToListAsync(); } @@ -101,6 +101,7 @@ public class GenreRepository : IGenreRepository var ageRating = await _context.AppUser.GetUserAgeRestriction(userId); return await _context.Genre .RestrictAgainstAgeRestriction(ageRating) + .OrderBy(g => g.NormalizedTitle) .AsNoTracking() .ProjectTo(_mapper.ConfigurationProvider) .ToListAsync(); diff --git a/API/Data/Repositories/SeriesRepository.cs b/API/Data/Repositories/SeriesRepository.cs index 4423db98d..9151e6861 100644 --- a/API/Data/Repositories/SeriesRepository.cs +++ b/API/Data/Repositories/SeriesRepository.cs @@ -101,6 +101,7 @@ public interface ISeriesRepository Task GetSeriesForMangaFile(int mangaFileId, int userId); Task GetSeriesForChapter(int chapterId, int userId); Task> GetWantToReadForUserAsync(int userId, UserParams userParams, FilterDto filter); + Task IsSeriesInWantToRead(int userId, int seriesId); Task GetSeriesByFolderPath(string folder, SeriesIncludes includes = SeriesIncludes.None); Task GetFullSeriesByAnyName(string seriesName, string localizedName, int libraryId, MangaFormat format, bool withFullIncludes = true); Task> RemoveSeriesNotInList(IList seenSeries, int libraryId); @@ -161,12 +162,10 @@ public class SeriesRepository : ISeriesRepository public async Task> GetSeriesForLibraryIdAsync(int libraryId, SeriesIncludes includes = SeriesIncludes.None) { - var query = _context.Series - .Where(s => s.LibraryId == libraryId); - - query = AddIncludesToQuery(query, includes); - - return await query.OrderBy(s => s.SortName).ToListAsync(); + return await _context.Series + .Where(s => s.LibraryId == libraryId) + .Includes(includes) + .OrderBy(s => s.SortName).ToListAsync(); } /// @@ -427,13 +426,10 @@ public class SeriesRepository : ISeriesRepository /// public async Task GetSeriesByIdAsync(int seriesId, SeriesIncludes includes = SeriesIncludes.Volumes | SeriesIncludes.Metadata) { - var query = _context.Series + return await _context.Series .Where(s => s.Id == seriesId) - .AsSplitQuery(); - - query = AddIncludesToQuery(query, includes); - - return await query.SingleOrDefaultAsync(); + .Includes(includes) + .SingleOrDefaultAsync(); } /// @@ -833,8 +829,8 @@ public class SeriesRepository : ISeriesRepository { var metadataDto = await _context.SeriesMetadata .Where(metadata => metadata.SeriesId == seriesId) - .Include(m => m.Genres) - .Include(m => m.Tags) + .Include(m => m.Genres.OrderBy(g => g.NormalizedTitle)) + .Include(m => m.Tags.OrderBy(g => g.NormalizedTitle)) .Include(m => m.People) .AsNoTracking() .ProjectTo(_mapper.ConfigurationProvider) @@ -848,6 +844,7 @@ public class SeriesRepository : ISeriesRepository .Where(t => t.SeriesMetadatas.Select(s => s.SeriesId).Contains(seriesId)) .ProjectTo(_mapper.ConfigurationProvider) .AsNoTracking() + .OrderBy(t => t.Title) .AsSplitQuery() .ToListAsync(); } @@ -1147,11 +1144,10 @@ public class SeriesRepository : ISeriesRepository public async Task GetSeriesByFolderPath(string folder, SeriesIncludes includes = SeriesIncludes.None) { var normalized = Services.Tasks.Scanner.Parser.Parser.NormalizePath(folder); - var query = _context.Series.Where(s => s.FolderPath.Equals(normalized)); - - query = AddIncludesToQuery(query, includes); - - return await query.SingleOrDefaultAsync(); + return await _context.Series + .Where(s => s.FolderPath.Equals(normalized)) + .Includes(includes) + .SingleOrDefaultAsync(); } /// @@ -1479,6 +1475,17 @@ public class SeriesRepository : ISeriesRepository return await PagedList.CreateAsync(filteredQuery.ProjectTo(_mapper.ConfigurationProvider), userParams.PageNumber, userParams.PageSize); } + public async Task IsSeriesInWantToRead(int userId, int seriesId) + { + var libraryIds = GetLibraryIdsForUser(userId); + return await _context.AppUser + .Where(user => user.Id == userId) + .SelectMany(u => u.WantToRead) + .AsSplitQuery() + .AsNoTracking() + .AnyAsync(s => libraryIds.Contains(s.LibraryId) && s.Id == seriesId); + } + public async Task>> GetFolderPathMap(int libraryId) { var info = await _context.Series @@ -1528,40 +1535,4 @@ public class SeriesRepository : ISeriesRepository .OrderBy(s => s) .LastOrDefaultAsync(); } - - private static IQueryable AddIncludesToQuery(IQueryable query, SeriesIncludes includeFlags) - { - // TODO: Move this to an Extension Method - if (includeFlags.HasFlag(SeriesIncludes.Library)) - { - query = query.Include(u => u.Library); - } - - if (includeFlags.HasFlag(SeriesIncludes.Volumes)) - { - query = query.Include(s => s.Volumes); - } - - if (includeFlags.HasFlag(SeriesIncludes.Related)) - { - query = query.Include(s => s.Relations) - .ThenInclude(r => r.TargetSeries) - .Include(s => s.RelationOf); - } - - if (includeFlags.HasFlag(SeriesIncludes.Metadata)) - { - query = query.Include(s => s.Metadata) - .ThenInclude(m => m.CollectionTags) - .Include(s => s.Metadata) - .ThenInclude(m => m.Genres) - .Include(s => s.Metadata) - .ThenInclude(m => m.People) - .Include(s => s.Metadata) - .ThenInclude(m => m.Tags); - } - - - return query.AsSplitQuery(); - } } diff --git a/API/Data/Repositories/TagRepository.cs b/API/Data/Repositories/TagRepository.cs index e4e3987d0..ac88d04a7 100644 --- a/API/Data/Repositories/TagRepository.cs +++ b/API/Data/Repositories/TagRepository.cs @@ -64,7 +64,7 @@ public class TagRepository : ITagRepository .SelectMany(s => s.Metadata.Tags) .AsSplitQuery() .Distinct() - .OrderBy(t => t.Title) + .OrderBy(t => t.NormalizedTitle) .AsNoTracking() .ProjectTo(_mapper.ConfigurationProvider) .ToListAsync(); @@ -81,7 +81,7 @@ public class TagRepository : ITagRepository return await _context.Tag .AsNoTracking() .RestrictAgainstAgeRestriction(userRating) - .OrderBy(t => t.Title) + .OrderBy(t => t.NormalizedTitle) .ProjectTo(_mapper.ConfigurationProvider) .ToListAsync(); } diff --git a/API/Data/Seed.cs b/API/Data/Seed.cs index 61f3b086d..db8c788ff 100644 --- a/API/Data/Seed.cs +++ b/API/Data/Seed.cs @@ -102,6 +102,7 @@ public static class Seed new() {Key = ServerSettingKey.TotalBackups, Value = "30"}, new() {Key = ServerSettingKey.TotalLogs, Value = "30"}, new() {Key = ServerSettingKey.EnableFolderWatching, Value = "false"}, + new() {Key = ServerSettingKey.ConvertCoverToWebP, Value = "false"}, }.ToArray()); foreach (var defaultSetting in DefaultSettings) diff --git a/API/Entities/Enums/ServerSettingKey.cs b/API/Entities/Enums/ServerSettingKey.cs index 5c4ac7bf8..604d286ff 100644 --- a/API/Entities/Enums/ServerSettingKey.cs +++ b/API/Entities/Enums/ServerSettingKey.cs @@ -101,4 +101,9 @@ public enum ServerSettingKey /// [Description("TotalLogs")] TotalLogs = 18, + /// + /// If Kavita should save covers as WebP images + /// + [Description("ConvertCoverToWebP")] + ConvertCoverToWebP = 19, } diff --git a/API/Extensions/QueryableExtensions.cs b/API/Extensions/QueryableExtensions.cs index ec0b81257..cf8c0faa0 100644 --- a/API/Extensions/QueryableExtensions.cs +++ b/API/Extensions/QueryableExtensions.cs @@ -1,6 +1,7 @@ using System.Linq; using System.Threading.Tasks; using API.Data.Misc; +using API.Data.Repositories; using API.Entities; using API.Entities.Enums; using Microsoft.EntityFrameworkCore; @@ -110,4 +111,51 @@ public static class QueryableExtensions }) .SingleAsync(); } + + public static IQueryable Includes(this IQueryable queryable, + CollectionTagIncludes includes) + { + if (includes.HasFlag(CollectionTagIncludes.SeriesMetadata)) + { + queryable = queryable.Include(c => c.SeriesMetadatas); + } + + return queryable.AsSplitQuery(); + } + + public static IQueryable Includes(this IQueryable query, + SeriesIncludes includeFlags) + { + if (includeFlags.HasFlag(SeriesIncludes.Library)) + { + query = query.Include(u => u.Library); + } + + if (includeFlags.HasFlag(SeriesIncludes.Volumes)) + { + query = query.Include(s => s.Volumes); + } + + if (includeFlags.HasFlag(SeriesIncludes.Related)) + { + query = query.Include(s => s.Relations) + .ThenInclude(r => r.TargetSeries) + .Include(s => s.RelationOf); + } + + if (includeFlags.HasFlag(SeriesIncludes.Metadata)) + { + query = query.Include(s => s.Metadata) + .ThenInclude(m => m.CollectionTags.OrderBy(g => g.NormalizedTitle)) + .Include(s => s.Metadata) + .ThenInclude(m => m.Genres.OrderBy(g => g.NormalizedTitle)) + .Include(s => s.Metadata) + .ThenInclude(m => m.People) + .Include(s => s.Metadata) + .ThenInclude(m => m.Tags.OrderBy(g => g.NormalizedTitle)); + } + + + return query.AsSplitQuery(); + } } diff --git a/API/Helpers/AutoMapperProfiles.cs b/API/Helpers/AutoMapperProfiles.cs index d89a3f9e0..bef39e90d 100644 --- a/API/Helpers/AutoMapperProfiles.cs +++ b/API/Helpers/AutoMapperProfiles.cs @@ -37,66 +37,88 @@ public class AutoMapperProfiles : Profile CreateMap() .ForMember(dest => dest.Writers, opt => - opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Writer))) + opt.MapFrom( + src => src.People.Where(p => p.Role == PersonRole.Writer).OrderBy(p => p.NormalizedName))) .ForMember(dest => dest.CoverArtists, opt => - opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.CoverArtist))) + opt.MapFrom(src => + src.People.Where(p => p.Role == PersonRole.CoverArtist).OrderBy(p => p.NormalizedName))) .ForMember(dest => dest.Characters, opt => - opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Character))) + opt.MapFrom(src => + src.People.Where(p => p.Role == PersonRole.Character).OrderBy(p => p.NormalizedName))) .ForMember(dest => dest.Publishers, opt => - opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Publisher))) + opt.MapFrom(src => + src.People.Where(p => p.Role == PersonRole.Publisher).OrderBy(p => p.NormalizedName))) .ForMember(dest => dest.Colorists, opt => - opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Colorist))) + opt.MapFrom(src => + src.People.Where(p => p.Role == PersonRole.Colorist).OrderBy(p => p.NormalizedName))) .ForMember(dest => dest.Inkers, opt => - opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Inker))) + opt.MapFrom(src => + src.People.Where(p => p.Role == PersonRole.Inker).OrderBy(p => p.NormalizedName))) .ForMember(dest => dest.Letterers, opt => - opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Letterer))) + opt.MapFrom(src => + src.People.Where(p => p.Role == PersonRole.Letterer).OrderBy(p => p.NormalizedName))) .ForMember(dest => dest.Pencillers, opt => - opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Penciller))) + opt.MapFrom(src => + src.People.Where(p => p.Role == PersonRole.Penciller).OrderBy(p => p.NormalizedName))) .ForMember(dest => dest.Translators, opt => - opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Translator))) + opt.MapFrom(src => + src.People.Where(p => p.Role == PersonRole.Translator).OrderBy(p => p.NormalizedName))) .ForMember(dest => dest.Editors, opt => - opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Editor))); + opt.MapFrom( + src => src.People.Where(p => p.Role == PersonRole.Editor).OrderBy(p => p.NormalizedName))) + .ForMember(dest => dest.Genres, + opt => + opt.MapFrom( + src => src.Genres.OrderBy(p => p.NormalizedTitle))) + .ForMember(dest => dest.CollectionTags, + opt => + opt.MapFrom( + src => src.CollectionTags.OrderBy(p => p.NormalizedTitle))) + .ForMember(dest => dest.Tags, + opt => + opt.MapFrom( + src => src.Tags.OrderBy(p => p.NormalizedTitle))); CreateMap() .ForMember(dest => dest.Writers, opt => - opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Writer))) + opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Writer).OrderBy(p => p.NormalizedName))) .ForMember(dest => dest.CoverArtists, opt => - opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.CoverArtist))) + opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.CoverArtist).OrderBy(p => p.NormalizedName))) .ForMember(dest => dest.Colorists, opt => - opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Colorist))) + opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Colorist).OrderBy(p => p.NormalizedName))) .ForMember(dest => dest.Inkers, opt => - opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Inker))) + opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Inker).OrderBy(p => p.NormalizedName))) .ForMember(dest => dest.Letterers, opt => - opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Letterer))) + opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Letterer).OrderBy(p => p.NormalizedName))) .ForMember(dest => dest.Pencillers, opt => - opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Penciller))) + opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Penciller).OrderBy(p => p.NormalizedName))) .ForMember(dest => dest.Publishers, opt => - opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Publisher))) + opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Publisher).OrderBy(p => p.NormalizedName))) .ForMember(dest => dest.Translators, opt => - opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Translator))) + opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Translator).OrderBy(p => p.NormalizedName))) .ForMember(dest => dest.Characters, opt => - opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Character))) + opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Character).OrderBy(p => p.NormalizedName))) .ForMember(dest => dest.Editors, opt => - opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Editor))); + opt.MapFrom(src => src.People.Where(p => p.Role == PersonRole.Editor).OrderBy(p => p.NormalizedName))); CreateMap() .ForMember(dest => dest.AgeRestriction, diff --git a/API/Helpers/Converters/ServerSettingConverter.cs b/API/Helpers/Converters/ServerSettingConverter.cs index f23fddca7..008e08e90 100644 --- a/API/Helpers/Converters/ServerSettingConverter.cs +++ b/API/Helpers/Converters/ServerSettingConverter.cs @@ -51,6 +51,9 @@ public class ServerSettingConverter : ITypeConverter, case ServerSettingKey.ConvertBookmarkToWebP: destination.ConvertBookmarkToWebP = bool.Parse(row.Value); break; + case ServerSettingKey.ConvertCoverToWebP: + destination.ConvertCoverToWebP = bool.Parse(row.Value); + break; case ServerSettingKey.EnableSwaggerUi: destination.EnableSwaggerUi = bool.Parse(row.Value); break; diff --git a/API/Services/ArchiveService.cs b/API/Services/ArchiveService.cs index 211d85df7..a547dc36d 100644 --- a/API/Services/ArchiveService.cs +++ b/API/Services/ArchiveService.cs @@ -20,7 +20,7 @@ public interface IArchiveService { void ExtractArchive(string archivePath, string extractPath); int GetNumberOfPagesFromArchive(string archivePath); - string GetCoverImage(string archivePath, string fileName, string outputDirectory); + string GetCoverImage(string archivePath, string fileName, string outputDirectory, bool saveAsWebP = false); bool IsValidArchive(string archivePath); ComicInfo GetComicInfo(string archivePath); ArchiveLibrary CanOpen(string archivePath); @@ -196,8 +196,9 @@ public class ArchiveService : IArchiveService /// /// File name to use based on context of entity. /// Where to output the file, defaults to covers directory + /// When saving the file, use WebP encoding instead of PNG /// - public string GetCoverImage(string archivePath, string fileName, string outputDirectory) + public string GetCoverImage(string archivePath, string fileName, string outputDirectory, bool saveAsWebP = false) { if (archivePath == null || !IsValidArchive(archivePath)) return string.Empty; try @@ -213,7 +214,7 @@ public class ArchiveService : IArchiveService var entry = archive.Entries.Single(e => e.FullName == entryName); using var stream = entry.Open(); - return _imageService.WriteCoverThumbnail(stream, fileName, outputDirectory); + return _imageService.WriteCoverThumbnail(stream, fileName, outputDirectory, saveAsWebP); } case ArchiveLibrary.SharpCompress: { @@ -224,7 +225,7 @@ public class ArchiveService : IArchiveService var entry = archive.Entries.Single(e => e.Key == entryName); using var stream = entry.OpenEntryStream(); - return _imageService.WriteCoverThumbnail(stream, fileName, outputDirectory); + return _imageService.WriteCoverThumbnail(stream, fileName, outputDirectory, saveAsWebP); } case ArchiveLibrary.NotSupported: _logger.LogWarning("[GetCoverImage] This archive cannot be read: {ArchivePath}. Defaulting to no cover image", archivePath); diff --git a/API/Services/BookService.cs b/API/Services/BookService.cs index 8156a56ff..e358a46e2 100644 --- a/API/Services/BookService.cs +++ b/API/Services/BookService.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; using System.Text; @@ -31,7 +32,7 @@ namespace API.Services; public interface IBookService { int GetNumberOfPages(string filePath); - string GetCoverImage(string fileFilePath, string fileName, string outputDirectory); + string GetCoverImage(string fileFilePath, string fileName, string outputDirectory, bool saveAsWebP = false); Task> CreateKeyToPageMappingAsync(EpubBookRef book); /// @@ -432,7 +433,7 @@ public class BookService : IBookService Year = year, Title = epubBook.Title, Genre = string.Join(",", epubBook.Schema.Package.Metadata.Subjects.Select(s => s.ToLower().Trim())), - LanguageISO = epubBook.Schema.Package.Metadata.Languages.FirstOrDefault() ?? string.Empty + LanguageISO = ValidateLanguage(epubBook.Schema.Package.Metadata.Languages.FirstOrDefault()) }; ComicInfo.CleanComicInfo(info); @@ -477,6 +478,24 @@ public class BookService : IBookService return null; } + #nullable enable + private static string ValidateLanguage(string? language) + { + if (string.IsNullOrEmpty(language)) return string.Empty; + + try + { + CultureInfo.GetCultureInfo(language); + } + catch (Exception) + { + return string.Empty; + } + + return language; + } + #nullable disable + private bool IsValidFile(string filePath) { if (!File.Exists(filePath)) @@ -880,14 +899,15 @@ public class BookService : IBookService /// /// Name of the new file. /// Where to output the file, defaults to covers directory + /// When saving the file, use WebP encoding instead of PNG /// - public string GetCoverImage(string fileFilePath, string fileName, string outputDirectory) + public string GetCoverImage(string fileFilePath, string fileName, string outputDirectory, bool saveAsWebP = false) { if (!IsValidFile(fileFilePath)) return string.Empty; if (Tasks.Scanner.Parser.Parser.IsPdf(fileFilePath)) { - return GetPdfCoverImage(fileFilePath, fileName, outputDirectory); + return GetPdfCoverImage(fileFilePath, fileName, outputDirectory, saveAsWebP); } using var epubBook = EpubReader.OpenBook(fileFilePath, BookReaderOptions); @@ -902,7 +922,7 @@ public class BookService : IBookService if (coverImageContent == null) return string.Empty; using var stream = coverImageContent.GetContentStream(); - return _imageService.WriteCoverThumbnail(stream, fileName, outputDirectory); + return _imageService.WriteCoverThumbnail(stream, fileName, outputDirectory, saveAsWebP); } catch (Exception ex) { @@ -913,7 +933,7 @@ public class BookService : IBookService } - private string GetPdfCoverImage(string fileFilePath, string fileName, string outputDirectory) + private string GetPdfCoverImage(string fileFilePath, string fileName, string outputDirectory, bool saveAsWebP) { try { @@ -923,7 +943,7 @@ public class BookService : IBookService using var stream = StreamManager.GetStream("BookService.GetPdfPage"); GetPdfPage(docReader, 0, stream); - return _imageService.WriteCoverThumbnail(stream, fileName, outputDirectory); + return _imageService.WriteCoverThumbnail(stream, fileName, outputDirectory, saveAsWebP); } catch (Exception ex) diff --git a/API/Services/BookmarkService.cs b/API/Services/BookmarkService.cs index 4d9b88ff4..72dd72279 100644 --- a/API/Services/BookmarkService.cs +++ b/API/Services/BookmarkService.cs @@ -27,6 +27,7 @@ public interface IBookmarkService public class BookmarkService : IBookmarkService { + public const string Name = "BookmarkService"; private readonly ILogger _logger; private readonly IUnitOfWork _unitOfWork; private readonly IDirectoryService _directoryService; diff --git a/API/Services/ImageService.cs b/API/Services/ImageService.cs index bebb40d93..ab88e6f18 100644 --- a/API/Services/ImageService.cs +++ b/API/Services/ImageService.cs @@ -10,7 +10,7 @@ namespace API.Services; public interface IImageService { void ExtractImages(string fileFilePath, string targetDirectory, int fileCount = 1); - string GetCoverImage(string path, string fileName, string outputDirectory); + string GetCoverImage(string path, string fileName, string outputDirectory, bool saveAsWebP = false); /// /// Creates a Thumbnail version of a base64 image @@ -20,7 +20,7 @@ public interface IImageService /// File name with extension of the file. This will always write to string CreateThumbnailFromBase64(string encodedImage, string fileName); - string WriteCoverThumbnail(Stream stream, string fileName, string outputDirectory); + string WriteCoverThumbnail(Stream stream, string fileName, string outputDirectory, bool saveAsWebP = false); /// /// Converts the passed image to webP and outputs it in the same directory /// @@ -67,14 +67,14 @@ public class ImageService : IImageService } } - public string GetCoverImage(string path, string fileName, string outputDirectory) + public string GetCoverImage(string path, string fileName, string outputDirectory, bool saveAsWebP = false) { if (string.IsNullOrEmpty(path)) return string.Empty; try { using var thumbnail = Image.Thumbnail(path, ThumbnailWidth); - var filename = fileName + ".png"; + var filename = fileName + (saveAsWebP ? ".webp" : ".png"); thumbnail.WriteToFile(_directoryService.FileSystem.Path.Join(outputDirectory, filename)); return filename; } @@ -93,11 +93,12 @@ public class ImageService : IImageService /// Stream to write to disk. Ensure this is rewinded. /// filename to save as without extension /// Where to output the file, defaults to covers directory + /// Export the file as webP otherwise will default to png /// File name with extension of the file. This will always write to - public string WriteCoverThumbnail(Stream stream, string fileName, string outputDirectory) + public string WriteCoverThumbnail(Stream stream, string fileName, string outputDirectory, bool saveAsWebP = false) { using var thumbnail = Image.ThumbnailStream(stream, ThumbnailWidth); - var filename = fileName + ".png"; + var filename = fileName + (saveAsWebP ? ".webp" : ".png"); _directoryService.ExistOrCreate(outputDirectory); try { diff --git a/API/Services/MetadataService.cs b/API/Services/MetadataService.cs index 6be15bf8e..833ee83c8 100644 --- a/API/Services/MetadataService.cs +++ b/API/Services/MetadataService.cs @@ -39,7 +39,7 @@ public interface IMetadataService /// Overrides any cache logic and forces execution Task GenerateCoversForSeries(int libraryId, int seriesId, bool forceUpdate = true); - Task GenerateCoversForSeries(Series series, bool forceUpdate = false); + Task GenerateCoversForSeries(Series series, bool convertToWebP, bool forceUpdate = false); Task RemoveAbandonedMetadataKeys(); } @@ -70,7 +70,8 @@ public class MetadataService : IMetadataService /// /// /// Force updating cover image even if underlying file has not been modified or chapter already has a cover image - private Task UpdateChapterCoverImage(Chapter chapter, bool forceUpdate) + /// Convert image to WebP when extracting the cover + private Task UpdateChapterCoverImage(Chapter chapter, bool forceUpdate, bool convertToWebPOnWrite) { var firstFile = chapter.Files.MinBy(x => x.Chapter); @@ -80,7 +81,9 @@ public class MetadataService : IMetadataService if (firstFile == null) return Task.FromResult(false); _logger.LogDebug("[MetadataService] Generating cover image for {File}", firstFile.FilePath); - chapter.CoverImage = _readingItemService.GetCoverImage(firstFile.FilePath, ImageService.GetChapterFormat(chapter.Id, chapter.VolumeId), firstFile.Format); + + chapter.CoverImage = _readingItemService.GetCoverImage(firstFile.FilePath, + ImageService.GetChapterFormat(chapter.Id, chapter.VolumeId), firstFile.Format, convertToWebPOnWrite); _unitOfWork.ChapterRepository.Update(chapter); _updateEvents.Add(MessageFactory.CoverUpdateEvent(chapter.Id, MessageFactoryEntityTypes.Chapter)); return Task.FromResult(true); @@ -143,7 +146,8 @@ public class MetadataService : IMetadataService /// /// /// - private async Task ProcessSeriesCoverGen(Series series, bool forceUpdate) + /// + private async Task ProcessSeriesCoverGen(Series series, bool forceUpdate, bool convertToWebP) { _logger.LogDebug("[MetadataService] Processing cover image generation for series: {SeriesName}", series.OriginalName); try @@ -156,7 +160,7 @@ public class MetadataService : IMetadataService var index = 0; foreach (var chapter in volume.Chapters) { - var chapterUpdated = await UpdateChapterCoverImage(chapter, forceUpdate); + var chapterUpdated = await UpdateChapterCoverImage(chapter, forceUpdate, convertToWebP); // If cover was update, either the file has changed or first scan and we should force a metadata update UpdateChapterLastModified(chapter, forceUpdate || chapterUpdated); if (index == 0 && chapterUpdated) @@ -194,7 +198,7 @@ public class MetadataService : IMetadataService [AutomaticRetry(Attempts = 3, OnAttemptsExceeded = AttemptsExceededAction.Delete)] public async Task GenerateCoversForLibrary(int libraryId, bool forceUpdate = false) { - var library = await _unitOfWork.LibraryRepository.GetLibraryForIdAsync(libraryId, LibraryIncludes.None); + var library = await _unitOfWork.LibraryRepository.GetLibraryForIdAsync(libraryId); _logger.LogInformation("[MetadataService] Beginning cover generation refresh of {LibraryName}", library.Name); _updateEvents.Clear(); @@ -207,6 +211,8 @@ public class MetadataService : IMetadataService await _eventHub.SendMessageAsync(MessageFactory.NotificationProgress, MessageFactory.CoverUpdateProgressEvent(library.Id, 0F, ProgressEventType.Started, $"Starting {library.Name}")); + var convertToWebP = (await _unitOfWork.SettingsRepository.GetSettingsDtoAsync()).ConvertCoverToWebP; + for (var chunk = 1; chunk <= chunkInfo.TotalChunks; chunk++) { if (chunkInfo.TotalChunks == 0) continue; @@ -235,7 +241,7 @@ public class MetadataService : IMetadataService try { - await ProcessSeriesCoverGen(series, forceUpdate); + await ProcessSeriesCoverGen(series, forceUpdate, convertToWebP); } catch (Exception ex) { @@ -285,21 +291,23 @@ public class MetadataService : IMetadataService return; } - await GenerateCoversForSeries(series, forceUpdate); + var convertToWebP = (await _unitOfWork.SettingsRepository.GetSettingsDtoAsync()).ConvertCoverToWebP; + await GenerateCoversForSeries(series, convertToWebP, forceUpdate); } /// /// Generate Cover for a Series. This is used by Scan Loop and should not be invoked directly via User Interaction. /// /// A full Series, with metadata, chapters, etc + /// When saving the file, use WebP encoding instead of PNG /// - public async Task GenerateCoversForSeries(Series series, bool forceUpdate = false) + public async Task GenerateCoversForSeries(Series series, bool convertToWebP, bool forceUpdate = false) { var sw = Stopwatch.StartNew(); await _eventHub.SendMessageAsync(MessageFactory.NotificationProgress, MessageFactory.CoverUpdateProgressEvent(series.LibraryId, 0F, ProgressEventType.Started, series.Name)); - await ProcessSeriesCoverGen(series, forceUpdate); + await ProcessSeriesCoverGen(series, forceUpdate, convertToWebP); if (_unitOfWork.HasChanges()) diff --git a/API/Services/ReadingItemService.cs b/API/Services/ReadingItemService.cs index 551d1b668..a70f7f38e 100644 --- a/API/Services/ReadingItemService.cs +++ b/API/Services/ReadingItemService.cs @@ -10,7 +10,7 @@ public interface IReadingItemService { ComicInfo GetComicInfo(string filePath); int GetNumberOfPages(string filePath, MangaFormat format); - string GetCoverImage(string filePath, string fileName, MangaFormat format); + string GetCoverImage(string filePath, string fileName, MangaFormat format, bool saveAsWebP); void Extract(string fileFilePath, string targetDirectory, MangaFormat format, int imageCount = 1); ParserInfo Parse(string path, string rootPath, LibraryType type); ParserInfo ParseFile(string path, string rootPath, LibraryType type); @@ -162,19 +162,20 @@ public class ReadingItemService : IReadingItemService } } - public string GetCoverImage(string filePath, string fileName, MangaFormat format) + public string GetCoverImage(string filePath, string fileName, MangaFormat format, bool saveAsWebP) { if (string.IsNullOrEmpty(filePath) || string.IsNullOrEmpty(fileName)) { return string.Empty; } + return format switch { - MangaFormat.Epub => _bookService.GetCoverImage(filePath, fileName, _directoryService.CoverImageDirectory), - MangaFormat.Archive => _archiveService.GetCoverImage(filePath, fileName, _directoryService.CoverImageDirectory), - MangaFormat.Image => _imageService.GetCoverImage(filePath, fileName, _directoryService.CoverImageDirectory), - MangaFormat.Pdf => _bookService.GetCoverImage(filePath, fileName, _directoryService.CoverImageDirectory), + MangaFormat.Epub => _bookService.GetCoverImage(filePath, fileName, _directoryService.CoverImageDirectory, saveAsWebP), + MangaFormat.Archive => _archiveService.GetCoverImage(filePath, fileName, _directoryService.CoverImageDirectory, saveAsWebP), + MangaFormat.Image => _imageService.GetCoverImage(filePath, fileName, _directoryService.CoverImageDirectory, saveAsWebP), + MangaFormat.Pdf => _bookService.GetCoverImage(filePath, fileName, _directoryService.CoverImageDirectory, saveAsWebP), _ => string.Empty }; } diff --git a/API/Services/SeriesService.cs b/API/Services/SeriesService.cs index bba9876d2..cfd62d898 100644 --- a/API/Services/SeriesService.cs +++ b/API/Services/SeriesService.cs @@ -553,7 +553,9 @@ public class SeriesService : ISeriesService Specials = specials, Chapters = retChapters, Volumes = processedVolumes, - StorylineChapters = storylineChapters + StorylineChapters = storylineChapters, + TotalCount = chapters.Count, + UnreadCount = chapters.Count(c => c.Pages > 0 && c.PagesRead < c.Pages) }; } diff --git a/API/Services/Tasks/Scanner/Parser/Parser.cs b/API/Services/Tasks/Scanner/Parser/Parser.cs index 13cce0feb..4361a6433 100644 --- a/API/Services/Tasks/Scanner/Parser/Parser.cs +++ b/API/Services/Tasks/Scanner/Parser/Parser.cs @@ -408,7 +408,7 @@ public static class Parser { // Teen Titans v1 001 (1966-02) (digital) (OkC.O.M.P.U.T.O.-Novus) new Regex( - @"^(?.*)(?: |_)(t|v)(?\d+)", + @"^(?.+?)(?: |_)(t|v)(?" + NumberRange + @")", MatchOptions, RegexTimeout), // Batgirl Vol.2000 #57 (December, 2004) new Regex( diff --git a/UI/Web/src/app/_models/series-detail/series-detail.ts b/UI/Web/src/app/_models/series-detail/series-detail.ts index ddba7dec7..29e6e262b 100644 --- a/UI/Web/src/app/_models/series-detail/series-detail.ts +++ b/UI/Web/src/app/_models/series-detail/series-detail.ts @@ -9,4 +9,6 @@ export interface SeriesDetail { chapters: Array; volumes: Array; storylineChapters: Array; + unreadCount: number; + totalCount: number; } \ No newline at end of file diff --git a/UI/Web/src/app/_services/series.service.ts b/UI/Web/src/app/_services/series.service.ts index 3332fc771..f60767e85 100644 --- a/UI/Web/src/app/_services/series.service.ts +++ b/UI/Web/src/app/_services/series.service.ts @@ -130,6 +130,10 @@ export class SeriesService { })); } + isWantToRead(seriesId: number) { + return this.httpClient.get(this.baseUrl + 'want-to-read?seriesId=' + seriesId, {responseType: 'text' as 'json'}); + } + getOnDeck(libraryId: number = 0, pageNum?: number, itemsPerPage?: number, filter?: SeriesFilter) { const data = this.filterUtilitySerivce.createSeriesFilter(filter); diff --git a/UI/Web/src/app/admin/_models/server-settings.ts b/UI/Web/src/app/admin/_models/server-settings.ts index f7e05f895..b52c2ec9d 100644 --- a/UI/Web/src/app/admin/_models/server-settings.ts +++ b/UI/Web/src/app/admin/_models/server-settings.ts @@ -10,6 +10,7 @@ export interface ServerSettings { bookmarksDirectory: string; emailServiceUrl: string; convertBookmarkToWebP: boolean; + convertCoverToWebP: boolean; enableSwaggerUi: boolean; totalBackups: number; totalLogs: number; diff --git a/UI/Web/src/app/admin/manage-media-settings/manage-media-settings.component.html b/UI/Web/src/app/admin/manage-media-settings/manage-media-settings.component.html index 7447a4a56..22178a052 100644 --- a/UI/Web/src/app/admin/manage-media-settings/manage-media-settings.component.html +++ b/UI/Web/src/app/admin/manage-media-settings/manage-media-settings.component.html @@ -1,15 +1,29 @@
+
+

WebP can drastically reduce space requirements for files. WebP is not supported on all browsers or versions. To learn if these settings are appropriate for your setup, visit Can I Use.

-   - When saving bookmarks, covert them to WebP. WebP is not supported on Safari devices and will not render at all. WebP can drastically reduce space requirements for files. + + + When saving bookmarks, covert them to WebP.
+ +
+ + + When generating covers, covert them to WebP. + +
+ + +
+
diff --git a/UI/Web/src/app/admin/manage-media-settings/manage-media-settings.component.ts b/UI/Web/src/app/admin/manage-media-settings/manage-media-settings.component.ts index f3b19e012..12a97481c 100644 --- a/UI/Web/src/app/admin/manage-media-settings/manage-media-settings.component.ts +++ b/UI/Web/src/app/admin/manage-media-settings/manage-media-settings.component.ts @@ -21,17 +21,20 @@ export class ManageMediaSettingsComponent implements OnInit { this.settingsService.getServerSettings().pipe(take(1)).subscribe((settings: ServerSettings) => { this.serverSettings = settings; this.settingsForm.addControl('convertBookmarkToWebP', new FormControl(this.serverSettings.convertBookmarkToWebP, [Validators.required])); + this.settingsForm.addControl('convertCoverToWebP', new FormControl(this.serverSettings.convertCoverToWebP, [Validators.required])); }); } resetForm() { this.settingsForm.get('convertBookmarkToWebP')?.setValue(this.serverSettings.convertBookmarkToWebP); + this.settingsForm.get('convertCoverToWebP')?.setValue(this.serverSettings.convertCoverToWebP); this.settingsForm.markAsPristine(); } async saveSettings() { const modelSettings = Object.assign({}, this.serverSettings); modelSettings.convertBookmarkToWebP = this.settingsForm.get('convertBookmarkToWebP')?.value; + modelSettings.convertCoverToWebP = this.settingsForm.get('convertCoverToWebP')?.value; this.settingsService.updateServerSettings(modelSettings).pipe(take(1)).subscribe(async (settings: ServerSettings) => { this.serverSettings = settings; diff --git a/UI/Web/src/app/all-series/all-series.component.html b/UI/Web/src/app/all-series/all-series.component.html index d0e95234a..74296fe97 100644 --- a/UI/Web/src/app/all-series/all-series.component.html +++ b/UI/Web/src/app/all-series/all-series.component.html @@ -9,7 +9,6 @@ [isLoading]="loadingSeries" [items]="series" [trackByIdentity]="trackByIdentity" - [pagination]="pagination" [filterSettings]="filterSettings" [filterOpen]="filterOpen" [jumpBarKeys]="jumpbarKeys" diff --git a/UI/Web/src/app/all-series/all-series.component.ts b/UI/Web/src/app/all-series/all-series.component.ts index 3066d1bc7..f9ae5be77 100644 --- a/UI/Web/src/app/all-series/all-series.component.ts +++ b/UI/Web/src/app/all-series/all-series.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, HostListener, OnDestroy, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, HostListener, OnDestroy, OnInit } from '@angular/core'; import { Title } from '@angular/platform-browser'; import { ActivatedRoute, Router } from '@angular/router'; import { Subject } from 'rxjs'; @@ -13,13 +13,15 @@ import { Series } from '../_models/series'; import { FilterEvent, SeriesFilter } from '../_models/series-filter'; import { Action, ActionItem } from '../_services/action-factory.service'; import { ActionService } from '../_services/action.service'; +import { JumpbarService } from '../_services/jumpbar.service'; import { EVENTS, Message, MessageHubService } from '../_services/message-hub.service'; import { SeriesService } from '../_services/series.service'; @Component({ selector: 'app-all-series', templateUrl: './all-series.component.html', - styleUrls: ['./all-series.component.scss'] + styleUrls: ['./all-series.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush }) export class AllSeriesComponent implements OnInit, OnDestroy { @@ -85,7 +87,8 @@ export class AllSeriesComponent implements OnInit, OnDestroy { private titleService: Title, private actionService: ActionService, public bulkSelectionService: BulkSelectionService, private hubService: MessageHubService, private utilityService: UtilityService, private route: ActivatedRoute, - private filterUtilityService: FilterUtilitiesService) { + private filterUtilityService: FilterUtilitiesService, private jumpbarService: JumpbarService, + private readonly cdRef: ChangeDetectorRef) { this.router.routeReuseStrategy.shouldReuseRoute = () => false; this.titleService.setTitle('Kavita - All Series'); @@ -93,6 +96,7 @@ export class AllSeriesComponent implements OnInit, OnDestroy { this.pagination = this.filterUtilityService.pagination(this.route.snapshot); [this.filterSettings.presets, this.filterSettings.openByDefault] = this.filterUtilityService.filterPresetsFromUrl(this.route.snapshot); this.filterActiveCheck = this.filterUtilityService.createSeriesFilter(); + this.cdRef.markForCheck(); } ngOnInit(): void { @@ -131,33 +135,14 @@ export class AllSeriesComponent implements OnInit, OnDestroy { loadPage() { this.filterActive = !this.utilityService.deepEqual(this.filter, this.filterActiveCheck); + this.loadingSeries = true; + this.cdRef.markForCheck(); this.seriesService.getAllSeries(undefined, undefined, this.filter).pipe(take(1)).subscribe(series => { this.series = series.result; - const keys: {[key: string]: number} = {}; - series.result.forEach(s => { - let ch = s.name.charAt(0); - if (/\d|\#|!|%|@|\(|\)|\^|\*/g.test(ch)) { - ch = '#'; - } - if (!keys.hasOwnProperty(ch)) { - keys[ch] = 0; - } - keys[ch] += 1; - }); - this.jumpbarKeys = Object.keys(keys).map(k => { - return { - key: k, - size: keys[k], - title: k.toUpperCase() - } - }).sort((a, b) => { - if (a.key < b.key) return -1; - if (a.key > b.key) return 1; - return 0; - }); + this.jumpbarKeys = this.jumpbarService.getJumpKeys(this.series, (s: Series) => s.name); this.pagination = series.pagination; this.loadingSeries = false; - window.scrollTo(0, 0); + this.cdRef.markForCheck(); }); } diff --git a/UI/Web/src/app/cards/entity-info-cards/entity-info-cards.component.html b/UI/Web/src/app/cards/entity-info-cards/entity-info-cards.component.html index 106194377..ed15628ed 100644 --- a/UI/Web/src/app/cards/entity-info-cards/entity-info-cards.component.html +++ b/UI/Web/src/app/cards/entity-info-cards/entity-info-cards.component.html @@ -19,8 +19,8 @@
- - {{totalPages | number:''}} Pages + + {{totalPages | compactNumber}} Pages
diff --git a/UI/Web/src/app/cards/series-info-cards/series-info-cards.component.html b/UI/Web/src/app/cards/series-info-cards/series-info-cards.component.html index 309dab25f..9675711b5 100644 --- a/UI/Web/src/app/cards/series-info-cards/series-info-cards.component.html +++ b/UI/Web/src/app/cards/series-info-cards/series-info-cards.component.html @@ -71,8 +71,8 @@
- - {{series.pages | number:''}} Pages + + {{series.pages | compactNumber}} Pages
diff --git a/UI/Web/src/app/metadata-filter/metadata-filter.component.html b/UI/Web/src/app/metadata-filter/metadata-filter.component.html index bc199c1a6..c0be87a77 100644 --- a/UI/Web/src/app/metadata-filter/metadata-filter.component.html +++ b/UI/Web/src/app/metadata-filter/metadata-filter.component.html @@ -328,10 +328,10 @@
- +
-
+
diff --git a/UI/Web/src/app/pipe/compact-number.pipe.ts b/UI/Web/src/app/pipe/compact-number.pipe.ts index f8c017e17..78ff2ef82 100644 --- a/UI/Web/src/app/pipe/compact-number.pipe.ts +++ b/UI/Web/src/app/pipe/compact-number.pipe.ts @@ -3,7 +3,8 @@ import { Pipe, PipeTransform } from '@angular/core'; const formatter = new Intl.NumberFormat('en-GB', { //@ts-ignore - notation: 'compact' // https://github.com/microsoft/TypeScript/issues/36533 + notation: 'compact', // https://github.com/microsoft/TypeScript/issues/36533 + maximumSignificantDigits: 3 }); @Pipe({ diff --git a/UI/Web/src/app/series-detail/series-detail.component.html b/UI/Web/src/app/series-detail/series-detail.component.html index 6cefcbeed..e322e6f8c 100644 --- a/UI/Web/src/app/series-detail/series-detail.component.html +++ b/UI/Web/src/app/series-detail/series-detail.component.html @@ -59,8 +59,13 @@
+
+ {{unreadCount}} +
- +
+ From {{ContinuePointTitle}} +
@@ -72,8 +77,15 @@ {{(hasReadingProgress) ? 'Continue' : 'Read'}}
+
+ +
-
- From {{ContinuePointTitle}} + Continue {{ContinuePointTitle}}
@@ -78,14 +78,14 @@
-
-
public DateTime LastScanned { get; init; } public LibraryType Type { get; init; } + /// + /// An optional Cover Image or null + /// + public string CoverImage { get; init; } + /// + /// If Folder Watching is enabled for this library + /// + public bool FolderWatching { get; set; } = true; + /// + /// Include Library series on Dashboard Streams + /// + public bool IncludeInDashboard { get; set; } = true; + /// + /// Include Library series on Recommended Streams + /// + public bool IncludeInRecommended { get; set; } = true; + /// + /// Include library series in Search + /// + public bool IncludeInSearch { get; set; } = true; public ICollection Folders { get; init; } } diff --git a/API/DTOs/UpdateLibraryDto.cs b/API/DTOs/UpdateLibraryDto.cs index 4f527cb60..602351328 100644 --- a/API/DTOs/UpdateLibraryDto.cs +++ b/API/DTOs/UpdateLibraryDto.cs @@ -9,4 +9,9 @@ public class UpdateLibraryDto public string Name { get; init; } public LibraryType Type { get; set; } public IEnumerable Folders { get; init; } + public bool FolderWatching { get; init; } + public bool IncludeInDashboard { get; init; } + public bool IncludeInRecommended { get; init; } + public bool IncludeInSearch { get; init; } + } diff --git a/API/Data/DataContext.cs b/API/Data/DataContext.cs index 2e681c62d..a5cb6b191 100644 --- a/API/Data/DataContext.cs +++ b/API/Data/DataContext.cs @@ -89,6 +89,20 @@ public sealed class DataContext : IdentityDbContext() .Property(b => b.GlobalPageLayoutMode) .HasDefaultValue(PageLayoutMode.Cards); + + + builder.Entity() + .Property(b => b.FolderWatching) + .HasDefaultValue(true); + builder.Entity() + .Property(b => b.IncludeInDashboard) + .HasDefaultValue(true); + builder.Entity() + .Property(b => b.IncludeInRecommended) + .HasDefaultValue(true); + builder.Entity() + .Property(b => b.IncludeInSearch) + .HasDefaultValue(true); } diff --git a/API/Data/Migrations/20221118131123_ExtendedLibrarySettings.Designer.cs b/API/Data/Migrations/20221118131123_ExtendedLibrarySettings.Designer.cs new file mode 100644 index 000000000..e79dddcbc --- /dev/null +++ b/API/Data/Migrations/20221118131123_ExtendedLibrarySettings.Designer.cs @@ -0,0 +1,1693 @@ +// +using System; +using API.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace API.Data.Migrations +{ + [DbContext(typeof(DataContext))] + [Migration("20221118131123_ExtendedLibrarySettings")] + partial class ExtendedLibrarySettings + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.10"); + + modelBuilder.Entity("API.Entities.AppRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("API.Entities.AppUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AccessFailedCount") + .HasColumnType("INTEGER"); + + b.Property("AgeRestriction") + .HasColumnType("INTEGER"); + + b.Property("AgeRestrictionIncludeUnknowns") + .HasColumnType("INTEGER"); + + b.Property("ApiKey") + .HasColumnType("TEXT"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("ConfirmationToken") + .HasColumnType("TEXT"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("EmailConfirmed") + .HasColumnType("INTEGER"); + + b.Property("LastActive") + .HasColumnType("TEXT"); + + b.Property("LockoutEnabled") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnd") + .HasColumnType("TEXT"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("PasswordHash") + .HasColumnType("TEXT"); + + b.Property("PhoneNumber") + .HasColumnType("TEXT"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("INTEGER"); + + b.Property("RowVersion") + .IsConcurrencyToken() + .HasColumnType("INTEGER"); + + b.Property("SecurityStamp") + .HasColumnType("TEXT"); + + b.Property("TwoFactorEnabled") + .HasColumnType("INTEGER"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("API.Entities.AppUserBookmark", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AppUserId") + .HasColumnType("INTEGER"); + + b.Property("ChapterId") + .HasColumnType("INTEGER"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("FileName") + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("Page") + .HasColumnType("INTEGER"); + + b.Property("SeriesId") + .HasColumnType("INTEGER"); + + b.Property("VolumeId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("AppUserId"); + + b.ToTable("AppUserBookmark"); + }); + + modelBuilder.Entity("API.Entities.AppUserPreferences", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AppUserId") + .HasColumnType("INTEGER"); + + b.Property("AutoCloseMenu") + .HasColumnType("INTEGER"); + + b.Property("BackgroundColor") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT") + .HasDefaultValue("#000000"); + + b.Property("BlurUnreadSummaries") + .HasColumnType("INTEGER"); + + b.Property("BookReaderFontFamily") + .HasColumnType("TEXT"); + + b.Property("BookReaderFontSize") + .HasColumnType("INTEGER"); + + b.Property("BookReaderImmersiveMode") + .HasColumnType("INTEGER"); + + b.Property("BookReaderLayoutMode") + .HasColumnType("INTEGER"); + + b.Property("BookReaderLineSpacing") + .HasColumnType("INTEGER"); + + b.Property("BookReaderMargin") + .HasColumnType("INTEGER"); + + b.Property("BookReaderReadingDirection") + .HasColumnType("INTEGER"); + + b.Property("BookReaderTapToPaginate") + .HasColumnType("INTEGER"); + + b.Property("BookThemeName") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT") + .HasDefaultValue("Dark"); + + b.Property("GlobalPageLayoutMode") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(0); + + b.Property("LayoutMode") + .HasColumnType("INTEGER"); + + b.Property("NoTransitions") + .HasColumnType("INTEGER"); + + b.Property("PageSplitOption") + .HasColumnType("INTEGER"); + + b.Property("PromptForDownloadSize") + .HasColumnType("INTEGER"); + + b.Property("ReaderMode") + .HasColumnType("INTEGER"); + + b.Property("ReadingDirection") + .HasColumnType("INTEGER"); + + b.Property("ScalingOption") + .HasColumnType("INTEGER"); + + b.Property("ShowScreenHints") + .HasColumnType("INTEGER"); + + b.Property("ThemeId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("AppUserId") + .IsUnique(); + + b.HasIndex("ThemeId"); + + b.ToTable("AppUserPreferences"); + }); + + modelBuilder.Entity("API.Entities.AppUserProgress", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AppUserId") + .HasColumnType("INTEGER"); + + b.Property("BookScrollId") + .HasColumnType("TEXT"); + + b.Property("ChapterId") + .HasColumnType("INTEGER"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("PagesRead") + .HasColumnType("INTEGER"); + + b.Property("SeriesId") + .HasColumnType("INTEGER"); + + b.Property("VolumeId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("AppUserId"); + + b.HasIndex("SeriesId"); + + b.ToTable("AppUserProgresses"); + }); + + modelBuilder.Entity("API.Entities.AppUserRating", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AppUserId") + .HasColumnType("INTEGER"); + + b.Property("Rating") + .HasColumnType("INTEGER"); + + b.Property("Review") + .HasColumnType("TEXT"); + + b.Property("SeriesId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("AppUserId"); + + b.HasIndex("SeriesId"); + + b.ToTable("AppUserRating"); + }); + + modelBuilder.Entity("API.Entities.AppUserRole", b => + { + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.Property("RoleId") + .HasColumnType("INTEGER"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("API.Entities.Chapter", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AgeRating") + .HasColumnType("INTEGER"); + + b.Property("AvgHoursToRead") + .HasColumnType("INTEGER"); + + b.Property("Count") + .HasColumnType("INTEGER"); + + b.Property("CoverImage") + .HasColumnType("TEXT"); + + b.Property("CoverImageLocked") + .HasColumnType("INTEGER"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("IsSpecial") + .HasColumnType("INTEGER"); + + b.Property("Language") + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("MaxHoursToRead") + .HasColumnType("INTEGER"); + + b.Property("MinHoursToRead") + .HasColumnType("INTEGER"); + + b.Property("Number") + .HasColumnType("TEXT"); + + b.Property("Pages") + .HasColumnType("INTEGER"); + + b.Property("Range") + .HasColumnType("TEXT"); + + b.Property("ReleaseDate") + .HasColumnType("TEXT"); + + b.Property("Summary") + .HasColumnType("TEXT"); + + b.Property("Title") + .HasColumnType("TEXT"); + + b.Property("TitleName") + .HasColumnType("TEXT"); + + b.Property("TotalCount") + .HasColumnType("INTEGER"); + + b.Property("VolumeId") + .HasColumnType("INTEGER"); + + b.Property("WordCount") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("VolumeId"); + + b.ToTable("Chapter"); + }); + + modelBuilder.Entity("API.Entities.CollectionTag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CoverImage") + .HasColumnType("TEXT"); + + b.Property("CoverImageLocked") + .HasColumnType("INTEGER"); + + b.Property("NormalizedTitle") + .HasColumnType("TEXT"); + + b.Property("Promoted") + .HasColumnType("INTEGER"); + + b.Property("RowVersion") + .HasColumnType("INTEGER"); + + b.Property("Summary") + .HasColumnType("TEXT"); + + b.Property("Title") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Id", "Promoted") + .IsUnique(); + + b.ToTable("CollectionTag"); + }); + + modelBuilder.Entity("API.Entities.Device", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AppUserId") + .HasColumnType("INTEGER"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("EmailAddress") + .HasColumnType("TEXT"); + + b.Property("IpAddress") + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastUsed") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Platform") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("AppUserId"); + + b.ToTable("Device"); + }); + + modelBuilder.Entity("API.Entities.FolderPath", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("LastScanned") + .HasColumnType("TEXT"); + + b.Property("LibraryId") + .HasColumnType("INTEGER"); + + b.Property("Path") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("LibraryId"); + + b.ToTable("FolderPath"); + }); + + modelBuilder.Entity("API.Entities.Genre", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ExternalTag") + .HasColumnType("INTEGER"); + + b.Property("NormalizedTitle") + .HasColumnType("TEXT"); + + b.Property("Title") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedTitle", "ExternalTag") + .IsUnique(); + + b.ToTable("Genre"); + }); + + modelBuilder.Entity("API.Entities.Library", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CoverImage") + .HasColumnType("TEXT"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("FolderWatching") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("IncludeInDashboard") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("IncludeInRecommended") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("IncludeInSearch") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastScanned") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Type") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("Library"); + }); + + modelBuilder.Entity("API.Entities.MangaFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChapterId") + .HasColumnType("INTEGER"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("FilePath") + .HasColumnType("TEXT"); + + b.Property("Format") + .HasColumnType("INTEGER"); + + b.Property("LastFileAnalysis") + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("Pages") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ChapterId"); + + b.ToTable("MangaFile"); + }); + + modelBuilder.Entity("API.Entities.Metadata.SeriesMetadata", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AgeRating") + .HasColumnType("INTEGER"); + + b.Property("AgeRatingLocked") + .HasColumnType("INTEGER"); + + b.Property("CharacterLocked") + .HasColumnType("INTEGER"); + + b.Property("ColoristLocked") + .HasColumnType("INTEGER"); + + b.Property("CoverArtistLocked") + .HasColumnType("INTEGER"); + + b.Property("EditorLocked") + .HasColumnType("INTEGER"); + + b.Property("GenresLocked") + .HasColumnType("INTEGER"); + + b.Property("InkerLocked") + .HasColumnType("INTEGER"); + + b.Property("Language") + .HasColumnType("TEXT"); + + b.Property("LanguageLocked") + .HasColumnType("INTEGER"); + + b.Property("LettererLocked") + .HasColumnType("INTEGER"); + + b.Property("MaxCount") + .HasColumnType("INTEGER"); + + b.Property("PencillerLocked") + .HasColumnType("INTEGER"); + + b.Property("PublicationStatus") + .HasColumnType("INTEGER"); + + b.Property("PublicationStatusLocked") + .HasColumnType("INTEGER"); + + b.Property("PublisherLocked") + .HasColumnType("INTEGER"); + + b.Property("ReleaseYear") + .HasColumnType("INTEGER"); + + b.Property("ReleaseYearLocked") + .HasColumnType("INTEGER"); + + b.Property("RowVersion") + .IsConcurrencyToken() + .HasColumnType("INTEGER"); + + b.Property("SeriesId") + .HasColumnType("INTEGER"); + + b.Property("Summary") + .HasColumnType("TEXT"); + + b.Property("SummaryLocked") + .HasColumnType("INTEGER"); + + b.Property("TagsLocked") + .HasColumnType("INTEGER"); + + b.Property("TotalCount") + .HasColumnType("INTEGER"); + + b.Property("TranslatorLocked") + .HasColumnType("INTEGER"); + + b.Property("WriterLocked") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("SeriesId") + .IsUnique(); + + b.HasIndex("Id", "SeriesId") + .IsUnique(); + + b.ToTable("SeriesMetadata"); + }); + + modelBuilder.Entity("API.Entities.Metadata.SeriesRelation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("RelationKind") + .HasColumnType("INTEGER"); + + b.Property("SeriesId") + .HasColumnType("INTEGER"); + + b.Property("TargetSeriesId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("SeriesId"); + + b.HasIndex("TargetSeriesId"); + + b.ToTable("SeriesRelation"); + }); + + modelBuilder.Entity("API.Entities.Person", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("NormalizedName") + .HasColumnType("TEXT"); + + b.Property("Role") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("Person"); + }); + + modelBuilder.Entity("API.Entities.ReadingList", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AgeRating") + .HasColumnType("INTEGER"); + + b.Property("AppUserId") + .HasColumnType("INTEGER"); + + b.Property("CoverImage") + .HasColumnType("TEXT"); + + b.Property("CoverImageLocked") + .HasColumnType("INTEGER"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("NormalizedTitle") + .HasColumnType("TEXT"); + + b.Property("Promoted") + .HasColumnType("INTEGER"); + + b.Property("Summary") + .HasColumnType("TEXT"); + + b.Property("Title") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("AppUserId"); + + b.ToTable("ReadingList"); + }); + + modelBuilder.Entity("API.Entities.ReadingListItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChapterId") + .HasColumnType("INTEGER"); + + b.Property("Order") + .HasColumnType("INTEGER"); + + b.Property("ReadingListId") + .HasColumnType("INTEGER"); + + b.Property("SeriesId") + .HasColumnType("INTEGER"); + + b.Property("VolumeId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ChapterId"); + + b.HasIndex("ReadingListId"); + + b.HasIndex("SeriesId"); + + b.HasIndex("VolumeId"); + + b.ToTable("ReadingListItem"); + }); + + modelBuilder.Entity("API.Entities.Series", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AppUserId") + .HasColumnType("INTEGER"); + + b.Property("AvgHoursToRead") + .HasColumnType("INTEGER"); + + b.Property("CoverImage") + .HasColumnType("TEXT"); + + b.Property("CoverImageLocked") + .HasColumnType("INTEGER"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("FolderPath") + .HasColumnType("TEXT"); + + b.Property("Format") + .HasColumnType("INTEGER"); + + b.Property("LastChapterAdded") + .HasColumnType("TEXT"); + + b.Property("LastFolderScanned") + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LibraryId") + .HasColumnType("INTEGER"); + + b.Property("LocalizedName") + .HasColumnType("TEXT"); + + b.Property("LocalizedNameLocked") + .HasColumnType("INTEGER"); + + b.Property("MaxHoursToRead") + .HasColumnType("INTEGER"); + + b.Property("MinHoursToRead") + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("NameLocked") + .HasColumnType("INTEGER"); + + b.Property("NormalizedLocalizedName") + .HasColumnType("TEXT"); + + b.Property("NormalizedName") + .HasColumnType("TEXT"); + + b.Property("OriginalName") + .HasColumnType("TEXT"); + + b.Property("Pages") + .HasColumnType("INTEGER"); + + b.Property("SortName") + .HasColumnType("TEXT"); + + b.Property("SortNameLocked") + .HasColumnType("INTEGER"); + + b.Property("WordCount") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("AppUserId"); + + b.HasIndex("LibraryId"); + + b.ToTable("Series"); + }); + + modelBuilder.Entity("API.Entities.ServerSetting", b => + { + b.Property("Key") + .HasColumnType("INTEGER"); + + b.Property("RowVersion") + .IsConcurrencyToken() + .HasColumnType("INTEGER"); + + b.Property("Value") + .HasColumnType("TEXT"); + + b.HasKey("Key"); + + b.ToTable("ServerSetting"); + }); + + modelBuilder.Entity("API.Entities.SiteTheme", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("FileName") + .HasColumnType("TEXT"); + + b.Property("IsDefault") + .HasColumnType("INTEGER"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("NormalizedName") + .HasColumnType("TEXT"); + + b.Property("Provider") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("SiteTheme"); + }); + + modelBuilder.Entity("API.Entities.Tag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ExternalTag") + .HasColumnType("INTEGER"); + + b.Property("NormalizedTitle") + .HasColumnType("TEXT"); + + b.Property("Title") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedTitle", "ExternalTag") + .IsUnique(); + + b.ToTable("Tag"); + }); + + modelBuilder.Entity("API.Entities.Volume", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AvgHoursToRead") + .HasColumnType("INTEGER"); + + b.Property("CoverImage") + .HasColumnType("TEXT"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("MaxHoursToRead") + .HasColumnType("INTEGER"); + + b.Property("MinHoursToRead") + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Number") + .HasColumnType("INTEGER"); + + b.Property("Pages") + .HasColumnType("INTEGER"); + + b.Property("SeriesId") + .HasColumnType("INTEGER"); + + b.Property("WordCount") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("SeriesId"); + + b.ToTable("Volume"); + }); + + modelBuilder.Entity("AppUserLibrary", b => + { + b.Property("AppUsersId") + .HasColumnType("INTEGER"); + + b.Property("LibrariesId") + .HasColumnType("INTEGER"); + + b.HasKey("AppUsersId", "LibrariesId"); + + b.HasIndex("LibrariesId"); + + b.ToTable("AppUserLibrary"); + }); + + modelBuilder.Entity("ChapterGenre", b => + { + b.Property("ChaptersId") + .HasColumnType("INTEGER"); + + b.Property("GenresId") + .HasColumnType("INTEGER"); + + b.HasKey("ChaptersId", "GenresId"); + + b.HasIndex("GenresId"); + + b.ToTable("ChapterGenre"); + }); + + modelBuilder.Entity("ChapterPerson", b => + { + b.Property("ChapterMetadatasId") + .HasColumnType("INTEGER"); + + b.Property("PeopleId") + .HasColumnType("INTEGER"); + + b.HasKey("ChapterMetadatasId", "PeopleId"); + + b.HasIndex("PeopleId"); + + b.ToTable("ChapterPerson"); + }); + + modelBuilder.Entity("ChapterTag", b => + { + b.Property("ChaptersId") + .HasColumnType("INTEGER"); + + b.Property("TagsId") + .HasColumnType("INTEGER"); + + b.HasKey("ChaptersId", "TagsId"); + + b.HasIndex("TagsId"); + + b.ToTable("ChapterTag"); + }); + + modelBuilder.Entity("CollectionTagSeriesMetadata", b => + { + b.Property("CollectionTagsId") + .HasColumnType("INTEGER"); + + b.Property("SeriesMetadatasId") + .HasColumnType("INTEGER"); + + b.HasKey("CollectionTagsId", "SeriesMetadatasId"); + + b.HasIndex("SeriesMetadatasId"); + + b.ToTable("CollectionTagSeriesMetadata"); + }); + + modelBuilder.Entity("GenreSeriesMetadata", b => + { + b.Property("GenresId") + .HasColumnType("INTEGER"); + + b.Property("SeriesMetadatasId") + .HasColumnType("INTEGER"); + + b.HasKey("GenresId", "SeriesMetadatasId"); + + b.HasIndex("SeriesMetadatasId"); + + b.ToTable("GenreSeriesMetadata"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasColumnType("TEXT"); + + b.Property("RoleId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasColumnType("TEXT"); + + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("TEXT"); + + b.Property("ProviderKey") + .HasColumnType("TEXT"); + + b.Property("ProviderDisplayName") + .HasColumnType("TEXT"); + + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.Property("LoginProvider") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Value") + .HasColumnType("TEXT"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("PersonSeriesMetadata", b => + { + b.Property("PeopleId") + .HasColumnType("INTEGER"); + + b.Property("SeriesMetadatasId") + .HasColumnType("INTEGER"); + + b.HasKey("PeopleId", "SeriesMetadatasId"); + + b.HasIndex("SeriesMetadatasId"); + + b.ToTable("PersonSeriesMetadata"); + }); + + modelBuilder.Entity("SeriesMetadataTag", b => + { + b.Property("SeriesMetadatasId") + .HasColumnType("INTEGER"); + + b.Property("TagsId") + .HasColumnType("INTEGER"); + + b.HasKey("SeriesMetadatasId", "TagsId"); + + b.HasIndex("TagsId"); + + b.ToTable("SeriesMetadataTag"); + }); + + modelBuilder.Entity("API.Entities.AppUserBookmark", b => + { + b.HasOne("API.Entities.AppUser", "AppUser") + .WithMany("Bookmarks") + .HasForeignKey("AppUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AppUser"); + }); + + modelBuilder.Entity("API.Entities.AppUserPreferences", b => + { + b.HasOne("API.Entities.AppUser", "AppUser") + .WithOne("UserPreferences") + .HasForeignKey("API.Entities.AppUserPreferences", "AppUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.SiteTheme", "Theme") + .WithMany() + .HasForeignKey("ThemeId"); + + b.Navigation("AppUser"); + + b.Navigation("Theme"); + }); + + modelBuilder.Entity("API.Entities.AppUserProgress", b => + { + b.HasOne("API.Entities.AppUser", "AppUser") + .WithMany("Progresses") + .HasForeignKey("AppUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Series", null) + .WithMany("Progress") + .HasForeignKey("SeriesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AppUser"); + }); + + modelBuilder.Entity("API.Entities.AppUserRating", b => + { + b.HasOne("API.Entities.AppUser", "AppUser") + .WithMany("Ratings") + .HasForeignKey("AppUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Series", null) + .WithMany("Ratings") + .HasForeignKey("SeriesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AppUser"); + }); + + modelBuilder.Entity("API.Entities.AppUserRole", b => + { + b.HasOne("API.Entities.AppRole", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.AppUser", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("API.Entities.Chapter", b => + { + b.HasOne("API.Entities.Volume", "Volume") + .WithMany("Chapters") + .HasForeignKey("VolumeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Volume"); + }); + + modelBuilder.Entity("API.Entities.Device", b => + { + b.HasOne("API.Entities.AppUser", "AppUser") + .WithMany("Devices") + .HasForeignKey("AppUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AppUser"); + }); + + modelBuilder.Entity("API.Entities.FolderPath", b => + { + b.HasOne("API.Entities.Library", "Library") + .WithMany("Folders") + .HasForeignKey("LibraryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Library"); + }); + + modelBuilder.Entity("API.Entities.MangaFile", b => + { + b.HasOne("API.Entities.Chapter", "Chapter") + .WithMany("Files") + .HasForeignKey("ChapterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Chapter"); + }); + + modelBuilder.Entity("API.Entities.Metadata.SeriesMetadata", b => + { + b.HasOne("API.Entities.Series", "Series") + .WithOne("Metadata") + .HasForeignKey("API.Entities.Metadata.SeriesMetadata", "SeriesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("API.Entities.Metadata.SeriesRelation", b => + { + b.HasOne("API.Entities.Series", "Series") + .WithMany("Relations") + .HasForeignKey("SeriesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Series", "TargetSeries") + .WithMany("RelationOf") + .HasForeignKey("TargetSeriesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Series"); + + b.Navigation("TargetSeries"); + }); + + modelBuilder.Entity("API.Entities.ReadingList", b => + { + b.HasOne("API.Entities.AppUser", "AppUser") + .WithMany("ReadingLists") + .HasForeignKey("AppUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AppUser"); + }); + + modelBuilder.Entity("API.Entities.ReadingListItem", b => + { + b.HasOne("API.Entities.Chapter", "Chapter") + .WithMany() + .HasForeignKey("ChapterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.ReadingList", "ReadingList") + .WithMany("Items") + .HasForeignKey("ReadingListId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Series", "Series") + .WithMany() + .HasForeignKey("SeriesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Volume", "Volume") + .WithMany() + .HasForeignKey("VolumeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Chapter"); + + b.Navigation("ReadingList"); + + b.Navigation("Series"); + + b.Navigation("Volume"); + }); + + modelBuilder.Entity("API.Entities.Series", b => + { + b.HasOne("API.Entities.AppUser", null) + .WithMany("WantToRead") + .HasForeignKey("AppUserId"); + + b.HasOne("API.Entities.Library", "Library") + .WithMany("Series") + .HasForeignKey("LibraryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Library"); + }); + + modelBuilder.Entity("API.Entities.Volume", b => + { + b.HasOne("API.Entities.Series", "Series") + .WithMany("Volumes") + .HasForeignKey("SeriesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("AppUserLibrary", b => + { + b.HasOne("API.Entities.AppUser", null) + .WithMany() + .HasForeignKey("AppUsersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Library", null) + .WithMany() + .HasForeignKey("LibrariesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ChapterGenre", b => + { + b.HasOne("API.Entities.Chapter", null) + .WithMany() + .HasForeignKey("ChaptersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Genre", null) + .WithMany() + .HasForeignKey("GenresId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ChapterPerson", b => + { + b.HasOne("API.Entities.Chapter", null) + .WithMany() + .HasForeignKey("ChapterMetadatasId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Person", null) + .WithMany() + .HasForeignKey("PeopleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ChapterTag", b => + { + b.HasOne("API.Entities.Chapter", null) + .WithMany() + .HasForeignKey("ChaptersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Tag", null) + .WithMany() + .HasForeignKey("TagsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("CollectionTagSeriesMetadata", b => + { + b.HasOne("API.Entities.CollectionTag", null) + .WithMany() + .HasForeignKey("CollectionTagsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Metadata.SeriesMetadata", null) + .WithMany() + .HasForeignKey("SeriesMetadatasId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("GenreSeriesMetadata", b => + { + b.HasOne("API.Entities.Genre", null) + .WithMany() + .HasForeignKey("GenresId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Metadata.SeriesMetadata", null) + .WithMany() + .HasForeignKey("SeriesMetadatasId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("API.Entities.AppRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("API.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("API.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("API.Entities.AppUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("PersonSeriesMetadata", b => + { + b.HasOne("API.Entities.Person", null) + .WithMany() + .HasForeignKey("PeopleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Metadata.SeriesMetadata", null) + .WithMany() + .HasForeignKey("SeriesMetadatasId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SeriesMetadataTag", b => + { + b.HasOne("API.Entities.Metadata.SeriesMetadata", null) + .WithMany() + .HasForeignKey("SeriesMetadatasId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Tag", null) + .WithMany() + .HasForeignKey("TagsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("API.Entities.AppRole", b => + { + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("API.Entities.AppUser", b => + { + b.Navigation("Bookmarks"); + + b.Navigation("Devices"); + + b.Navigation("Progresses"); + + b.Navigation("Ratings"); + + b.Navigation("ReadingLists"); + + b.Navigation("UserPreferences"); + + b.Navigation("UserRoles"); + + b.Navigation("WantToRead"); + }); + + modelBuilder.Entity("API.Entities.Chapter", b => + { + b.Navigation("Files"); + }); + + modelBuilder.Entity("API.Entities.Library", b => + { + b.Navigation("Folders"); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("API.Entities.ReadingList", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("API.Entities.Series", b => + { + b.Navigation("Metadata"); + + b.Navigation("Progress"); + + b.Navigation("Ratings"); + + b.Navigation("RelationOf"); + + b.Navigation("Relations"); + + b.Navigation("Volumes"); + }); + + modelBuilder.Entity("API.Entities.Volume", b => + { + b.Navigation("Chapters"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/API/Data/Migrations/20221118131123_ExtendedLibrarySettings.cs b/API/Data/Migrations/20221118131123_ExtendedLibrarySettings.cs new file mode 100644 index 000000000..1c05b6b5b --- /dev/null +++ b/API/Data/Migrations/20221118131123_ExtendedLibrarySettings.cs @@ -0,0 +1,59 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace API.Data.Migrations +{ + public partial class ExtendedLibrarySettings : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "FolderWatching", + table: "Library", + type: "INTEGER", + nullable: false, + defaultValue: true); + + migrationBuilder.AddColumn( + name: "IncludeInDashboard", + table: "Library", + type: "INTEGER", + nullable: false, + defaultValue: true); + + migrationBuilder.AddColumn( + name: "IncludeInRecommended", + table: "Library", + type: "INTEGER", + nullable: false, + defaultValue: true); + + migrationBuilder.AddColumn( + name: "IncludeInSearch", + table: "Library", + type: "INTEGER", + nullable: false, + defaultValue: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "FolderWatching", + table: "Library"); + + migrationBuilder.DropColumn( + name: "IncludeInDashboard", + table: "Library"); + + migrationBuilder.DropColumn( + name: "IncludeInRecommended", + table: "Library"); + + migrationBuilder.DropColumn( + name: "IncludeInSearch", + table: "Library"); + } + } +} diff --git a/API/Data/Migrations/DataContextModelSnapshot.cs b/API/Data/Migrations/DataContextModelSnapshot.cs index c3f5c8e53..68065530b 100644 --- a/API/Data/Migrations/DataContextModelSnapshot.cs +++ b/API/Data/Migrations/DataContextModelSnapshot.cs @@ -545,6 +545,26 @@ namespace API.Data.Migrations b.Property("Created") .HasColumnType("TEXT"); + b.Property("FolderWatching") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("IncludeInDashboard") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("IncludeInRecommended") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("IncludeInSearch") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + b.Property("LastModified") .HasColumnType("TEXT"); diff --git a/API/Data/Repositories/LibraryRepository.cs b/API/Data/Repositories/LibraryRepository.cs index 7a50f365e..39ab5999e 100644 --- a/API/Data/Repositories/LibraryRepository.cs +++ b/API/Data/Repositories/LibraryRepository.cs @@ -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> GetLibrariesAsync(LibraryIncludes includes = LibraryIncludes.None); Task DeleteLibrary(int libraryId); Task> GetLibrariesForUserIdAsync(int userId); - Task> GetLibraryIdsForUserIdAsync(int userId); + IEnumerable GetLibraryIdsForUserIdAsync(int userId, QueryContext queryContext = QueryContext.None); Task GetLibraryTypeAsync(int libraryId); Task> GetLibraryForIdsAsync(IEnumerable libraryIds, LibraryIncludes includes = LibraryIncludes.None); Task GetTotalFiles(); @@ -48,7 +49,8 @@ public interface ILibraryRepository Task> GetAllLanguagesForLibrariesAsync(); IEnumerable GetAllPublicationStatusesDtosForLibrariesAsync(List libraryIds); Task DoAnySeriesFoldersMatch(IEnumerable folders); - Library GetLibraryByFolder(string folder); + Task GetLibraryCoverImageAsync(int libraryId); + Task> GetAllCoverImagesAsync(); } public class LibraryRepository : ILibraryRepository @@ -126,12 +128,13 @@ public class LibraryRepository : ILibraryRepository .ToListAsync(); } - public async Task> GetLibraryIdsForUserIdAsync(int userId) + public IEnumerable 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 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 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> GetAllCoverImagesAsync() + { + return await _context.ReadingList + .Select(t => t.CoverImage) + .Where(t => !string.IsNullOrEmpty(t)) + .AsNoTracking() + .ToListAsync(); } } diff --git a/API/Data/Repositories/SeriesRepository.cs b/API/Data/Repositories/SeriesRepository.cs index 97f1eebba..3ad2d93f4 100644 --- a/API/Data/Repositories/SeriesRepository.cs +++ b/API/Data/Repositories/SeriesRepository.cs @@ -37,6 +37,18 @@ public enum SeriesIncludes Library = 16, } +/// +/// For complex queries, Library has certain restrictions where the library should not be included in results. +/// This enum dictates which field to use for the lookup. +/// +public enum QueryContext +{ + None = 1, + Search = 2, + Recommended = 3, + Dashboard = 4, +} + public interface ISeriesRepository { void Add(Series series); @@ -62,7 +74,7 @@ public interface ISeriesRepository /// /// /// - Task SearchSeries(int userId, bool isAdmin, int[] libraryIds, string searchQuery); + Task SearchSeries(int userId, bool isAdmin, IList libraryIds, string searchQuery); Task> GetSeriesForLibraryIdAsync(int libraryId, SeriesIncludes includes = SeriesIncludes.None); Task GetSeriesDtoByIdAsync(int seriesId, int userId); Task GetSeriesByIdAsync(int seriesId, SeriesIncludes includes = SeriesIncludes.Volumes | SeriesIncludes.Metadata); @@ -257,7 +269,7 @@ public class SeriesRepository : ISeriesRepository /// public async Task> GetSeriesDtoForLibraryIdAsync(int libraryId, int userId, UserParams userParams, FilterDto filter) { - var query = await CreateFilteredSearchQueryable(userId, libraryId, filter); + var query = await CreateFilteredSearchQueryable(userId, libraryId, filter, QueryContext.None); var retSeries = query .ProjectTo(_mapper.ConfigurationProvider) @@ -267,13 +279,14 @@ public class SeriesRepository : ISeriesRepository return await PagedList.CreateAsync(retSeries, userParams.PageNumber, userParams.PageSize); } - private async Task> GetUserLibraries(int libraryId, int userId) + private async Task> GetUserLibrariesForFilteredQuery(int libraryId, int userId, QueryContext queryContext) { if (libraryId == 0) { return await _context.Library .Include(l => l.AppUsers) .Where(library => library.AppUsers.Any(user => user.Id == userId)) + .IsRestricted(queryContext) .AsNoTracking() .AsSplitQuery() .Select(library => library.Id) @@ -286,7 +299,7 @@ public class SeriesRepository : ISeriesRepository }; } - public async Task SearchSeries(int userId, bool isAdmin, int[] libraryIds, string searchQuery) + public async Task SearchSeries(int userId, bool isAdmin, IList libraryIds, string searchQuery) { const int maxRecords = 15; var result = new SearchResultGroupDto(); @@ -302,6 +315,7 @@ public class SeriesRepository : ISeriesRepository result.Libraries = await _context.Library .Where(l => libraryIds.Contains(l.Id)) .Where(l => EF.Functions.Like(l.Name, $"%{searchQuery}%")) + .IsRestricted(QueryContext.Search) .OrderBy(l => l.Name) .AsSplitQuery() .Take(maxRecords) @@ -549,7 +563,7 @@ public class SeriesRepository : ISeriesRepository /// public async Task> GetRecentlyAdded(int libraryId, int userId, UserParams userParams, FilterDto filter) { - var query = await CreateFilteredSearchQueryable(userId, libraryId, filter); + var query = await CreateFilteredSearchQueryable(userId, libraryId, filter, QueryContext.Dashboard); var retSeries = query .OrderByDescending(s => s.Created) @@ -658,7 +672,7 @@ public class SeriesRepository : ISeriesRepository var cutoffProgressPoint = DateTime.Now - TimeSpan.FromDays(30); var cutoffLastAddedPoint = DateTime.Now - TimeSpan.FromDays(7); - var libraryIds = GetLibraryIdsForUser(userId, libraryId); + var libraryIds = GetLibraryIdsForUser(userId, libraryId, QueryContext.Dashboard); var usersSeriesIds = GetSeriesIdsForLibraryIds(libraryIds); @@ -686,9 +700,9 @@ public class SeriesRepository : ISeriesRepository return await PagedList.CreateAsync(query, userParams.PageNumber, userParams.PageSize); } - private async Task> CreateFilteredSearchQueryable(int userId, int libraryId, FilterDto filter) + private async Task> CreateFilteredSearchQueryable(int userId, int libraryId, FilterDto filter, QueryContext queryContext) { - var userLibraries = await GetUserLibraries(libraryId, userId); + var userLibraries = await GetUserLibrariesForFilteredQuery(libraryId, userId, queryContext); var userRating = await _context.AppUser.GetUserAgeRestriction(userId); var formats = ExtractFilters(libraryId, userId, filter, ref userLibraries, @@ -762,7 +776,7 @@ public class SeriesRepository : ISeriesRepository private async Task> CreateFilteredSearchQueryable(int userId, int libraryId, FilterDto filter, IQueryable sQuery) { - var userLibraries = await GetUserLibraries(libraryId, userId); + var userLibraries = await GetUserLibrariesForFilteredQuery(libraryId, userId, QueryContext.Search); var formats = ExtractFilters(libraryId, userId, filter, ref userLibraries, out var allPeopleIds, out var hasPeopleFilter, out var hasGenresFilter, out var hasCollectionTagFilter, out var hasRatingFilter, out var hasProgressFilter, @@ -1059,7 +1073,7 @@ public class SeriesRepository : ISeriesRepository public async Task> GetMoreIn(int userId, int libraryId, int genreId, UserParams userParams) { - var libraryIds = GetLibraryIdsForUser(userId, libraryId); + var libraryIds = GetLibraryIdsForUser(userId, libraryId, QueryContext.Recommended); var usersSeriesIds = GetSeriesIdsForLibraryIds(libraryIds); var userRating = await _context.AppUser.GetUserAgeRestriction(userId); @@ -1086,7 +1100,7 @@ public class SeriesRepository : ISeriesRepository /// public async Task> GetRediscover(int userId, int libraryId, UserParams userParams) { - var libraryIds = GetLibraryIdsForUser(userId, libraryId); + var libraryIds = GetLibraryIdsForUser(userId, libraryId, QueryContext.Recommended); var usersSeriesIds = GetSeriesIdsForLibraryIds(libraryIds); var distinctSeriesIdsWithProgress = _context.AppUserProgresses .Where(s => usersSeriesIds.Contains(s.SeriesId)) @@ -1105,7 +1119,7 @@ public class SeriesRepository : ISeriesRepository public async Task GetSeriesForMangaFile(int mangaFileId, int userId) { - var libraryIds = GetLibraryIdsForUser(userId); + var libraryIds = GetLibraryIdsForUser(userId, 0, QueryContext.Search); var userRating = await _context.AppUser.GetUserAgeRestriction(userId); return await _context.MangaFile @@ -1264,7 +1278,7 @@ public class SeriesRepository : ISeriesRepository public async Task> GetHighlyRated(int userId, int libraryId, UserParams userParams) { - var libraryIds = GetLibraryIdsForUser(userId, libraryId); + var libraryIds = GetLibraryIdsForUser(userId, libraryId, QueryContext.Recommended); var usersSeriesIds = GetSeriesIdsForLibraryIds(libraryIds); var distinctSeriesIdsWithHighRating = _context.AppUserRating .Where(s => usersSeriesIds.Contains(s.SeriesId) && s.Rating > 4) @@ -1285,7 +1299,7 @@ public class SeriesRepository : ISeriesRepository public async Task> GetQuickReads(int userId, int libraryId, UserParams userParams) { - var libraryIds = GetLibraryIdsForUser(userId, libraryId); + var libraryIds = GetLibraryIdsForUser(userId, libraryId, QueryContext.Recommended); var usersSeriesIds = GetSeriesIdsForLibraryIds(libraryIds); var distinctSeriesIdsWithProgress = _context.AppUserProgresses .Where(s => usersSeriesIds.Contains(s.SeriesId)) @@ -1311,7 +1325,7 @@ public class SeriesRepository : ISeriesRepository public async Task> GetQuickCatchupReads(int userId, int libraryId, UserParams userParams) { - var libraryIds = GetLibraryIdsForUser(userId, libraryId); + var libraryIds = GetLibraryIdsForUser(userId, libraryId, QueryContext.Recommended); var usersSeriesIds = GetSeriesIdsForLibraryIds(libraryIds); var distinctSeriesIdsWithProgress = _context.AppUserProgresses .Where(s => usersSeriesIds.Contains(s.SeriesId)) @@ -1341,21 +1355,27 @@ public class SeriesRepository : ISeriesRepository ///
/// /// 0 for no library filter + /// Defaults to None - The context behind this query, so appropriate restrictions can be placed /// - private IQueryable GetLibraryIdsForUser(int userId, int libraryId = 0) + private IQueryable GetLibraryIdsForUser(int userId, int libraryId = 0, QueryContext queryContext = QueryContext.None) { - var query = _context.AppUser + var user = _context.AppUser .AsSplitQuery() .AsNoTracking() - .Where(u => u.Id == userId); + .Where(u => u.Id == userId) + .AsSingleQuery(); if (libraryId == 0) { - return query.SelectMany(l => l.Libraries.Select(lib => lib.Id)); + return user.SelectMany(l => l.Libraries) + .IsRestricted(queryContext) + .Select(lib => lib.Id); } - return query.SelectMany(l => - l.Libraries.Where(lib => lib.Id == libraryId).Select(lib => lib.Id)); + return user.SelectMany(l => l.Libraries) + .Where(lib => lib.Id == libraryId) + .IsRestricted(queryContext) + .Select(lib => lib.Id); } public async Task GetRelatedSeries(int userId, int seriesId) @@ -1430,8 +1450,9 @@ public class SeriesRepository : ISeriesRepository { var libraryIds = await _context.AppUser .Where(u => u.Id == userId) - .SelectMany(u => u.Libraries.Select(l => new {LibraryId = l.Id, LibraryType = l.Type})) - .Select(l => l.LibraryId) + .SelectMany(u => u.Libraries) + .Where(l => l.IncludeInDashboard) + .Select(l => l.Id) .ToListAsync(); var withinLastWeek = DateTime.Now - TimeSpan.FromDays(12); diff --git a/API/Entities/Library.cs b/API/Entities/Library.cs index b6fac76f3..84b4fa403 100644 --- a/API/Entities/Library.cs +++ b/API/Entities/Library.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.IO; -using System.Linq; using API.Entities.Enums; using API.Entities.Interfaces; @@ -11,12 +9,24 @@ public class Library : IEntityDate { public int Id { get; set; } public string Name { get; set; } - /// - /// This is not used, but planned once we build out a Library detail page - /// - [Obsolete("This has never been coded for. Likely we can remove it.")] public string CoverImage { get; set; } public LibraryType Type { get; set; } + /// + /// If Folder Watching is enabled for this library + /// + public bool FolderWatching { get; set; } = true; + /// + /// Include Library series on Dashboard Streams + /// + public bool IncludeInDashboard { get; set; } = true; + /// + /// Include Library series on Recommended Streams + /// + public bool IncludeInRecommended { get; set; } = true; + /// + /// Include library series in Search + /// + public bool IncludeInSearch { get; set; } = true; public DateTime Created { get; set; } public DateTime LastModified { get; set; } /// @@ -27,4 +37,5 @@ public class Library : IEntityDate public ICollection Folders { get; set; } public ICollection AppUsers { get; set; } public ICollection Series { get; set; } + } diff --git a/API/Extensions/QueryableExtensions.cs b/API/Extensions/QueryableExtensions.cs index cf8c0faa0..3deac20e4 100644 --- a/API/Extensions/QueryableExtensions.cs +++ b/API/Extensions/QueryableExtensions.cs @@ -158,4 +158,32 @@ public static class QueryableExtensions return query.AsSplitQuery(); } + + /// + /// Applies restriction based on if the Library has restrictions (like include in search) + /// + /// + /// + /// + public static IQueryable IsRestricted(this IQueryable query, QueryContext context) + { + if (context.HasFlag(QueryContext.None)) return query; + + if (context.HasFlag(QueryContext.Dashboard)) + { + query = query.Where(l => l.IncludeInDashboard); + } + + if (context.HasFlag(QueryContext.Recommended)) + { + query = query.Where(l => l.IncludeInRecommended); + } + + if (context.HasFlag(QueryContext.Search)) + { + query = query.Where(l => l.IncludeInSearch); + } + + return query; + } } diff --git a/API/Program.cs b/API/Program.cs index 01847faaa..3f2ff8bae 100644 --- a/API/Program.cs +++ b/API/Program.cs @@ -86,7 +86,7 @@ public class Program { await MigrateSeriesRelationsExport.Migrate(context, logger); } - catch (Exception ex) + catch (Exception) { // If fresh install, could fail and we should just carry on as it's not applicable } diff --git a/API/Services/ImageService.cs b/API/Services/ImageService.cs index ab88e6f18..9500b43ed 100644 --- a/API/Services/ImageService.cs +++ b/API/Services/ImageService.cs @@ -167,6 +167,16 @@ public class ImageService : IImageService return $"v{volumeId}_c{chapterId}"; } + /// + /// Returns the name format for a library cover image + /// + /// + /// + public static string GetLibraryFormat(int libraryId) + { + return $"l{libraryId}"; + } + /// /// Returns the name format for a series cover image /// diff --git a/API/Services/SeriesService.cs b/API/Services/SeriesService.cs index cfd62d898..b2e190e04 100644 --- a/API/Services/SeriesService.cs +++ b/API/Services/SeriesService.cs @@ -473,7 +473,7 @@ public class SeriesService : ISeriesService public async Task GetSeriesDetail(int seriesId, int userId) { var series = await _unitOfWork.SeriesRepository.GetSeriesDtoByIdAsync(seriesId, userId); - var libraryIds = (await _unitOfWork.LibraryRepository.GetLibraryIdsForUserIdAsync(userId)); + var libraryIds = _unitOfWork.LibraryRepository.GetLibraryIdsForUserIdAsync(userId); if (!libraryIds.Contains(series.LibraryId)) throw new UnauthorizedAccessException("User does not have access to the library this series belongs to"); diff --git a/API/Services/Tasks/BackupService.cs b/API/Services/Tasks/BackupService.cs index 4bb371ec9..c62e49ce2 100644 --- a/API/Services/Tasks/BackupService.cs +++ b/API/Services/Tasks/BackupService.cs @@ -162,6 +162,14 @@ public class BackupService : IBackupService var chapterImages = await _unitOfWork.ChapterRepository.GetCoverImagesForLockedChaptersAsync(); _directoryService.CopyFilesToDirectory( chapterImages.Select(s => _directoryService.FileSystem.Path.Join(_directoryService.CoverImageDirectory, s)), outputTempDir); + + var libraryImages = await _unitOfWork.LibraryRepository.GetAllCoverImagesAsync(); + _directoryService.CopyFilesToDirectory( + libraryImages.Select(s => _directoryService.FileSystem.Path.Join(_directoryService.CoverImageDirectory, s)), outputTempDir); + + var readingListImages = await _unitOfWork.ReadingListRepository.GetAllCoverImagesAsync(); + _directoryService.CopyFilesToDirectory( + readingListImages.Select(s => _directoryService.FileSystem.Path.Join(_directoryService.CoverImageDirectory, s)), outputTempDir); } catch (IOException) { diff --git a/API/Services/Tasks/Scanner/LibraryWatcher.cs b/API/Services/Tasks/Scanner/LibraryWatcher.cs index fee51f562..183793457 100644 --- a/API/Services/Tasks/Scanner/LibraryWatcher.cs +++ b/API/Services/Tasks/Scanner/LibraryWatcher.cs @@ -77,6 +77,7 @@ public class LibraryWatcher : ILibraryWatcher _logger.LogInformation("[LibraryWatcher] Starting file watchers"); var libraryFolders = (await _unitOfWork.LibraryRepository.GetLibraryDtosAsync()) + .Where(l => l.FolderWatching) .SelectMany(l => l.Folders) .Distinct() .Select(Parser.Parser.NormalizePath) diff --git a/API/Services/Tasks/Scanner/Parser/Parser.cs b/API/Services/Tasks/Scanner/Parser/Parser.cs index 4361a6433..6e0050724 100644 --- a/API/Services/Tasks/Scanner/Parser/Parser.cs +++ b/API/Services/Tasks/Scanner/Parser/Parser.cs @@ -1011,6 +1011,17 @@ public static class Parser return string.IsNullOrEmpty(author) ? string.Empty : author.Trim(); } + /// + /// Cleans user query string input + /// + /// + /// + public static string CleanQuery(string query) + { + return Uri.UnescapeDataString(query).Trim().Replace(@"%", string.Empty) + .Replace(":", string.Empty); + } + /// /// Normalizes the slashes in a path to be /// diff --git a/API/SignalR/MessageFactory.cs b/API/SignalR/MessageFactory.cs index a702396d3..f2020d86c 100644 --- a/API/SignalR/MessageFactory.cs +++ b/API/SignalR/MessageFactory.cs @@ -10,6 +10,7 @@ namespace API.SignalR; public static class MessageFactoryEntityTypes { + public const string Library = "library"; public const string Series = "series"; public const string Volume = "volume"; public const string Chapter = "chapter"; diff --git a/UI/Web/src/app/_models/library.ts b/UI/Web/src/app/_models/library.ts index 01a5727ae..f15fbab8c 100644 --- a/UI/Web/src/app/_models/library.ts +++ b/UI/Web/src/app/_models/library.ts @@ -10,4 +10,9 @@ export interface Library { lastScanned: string; type: LibraryType; folders: string[]; + coverImage?: string; + folderWatching: boolean; + includeInDashboard: boolean; + includeInRecommended: boolean; + includeInSearch: boolean; } \ No newline at end of file diff --git a/UI/Web/src/app/_services/action-factory.service.ts b/UI/Web/src/app/_services/action-factory.service.ts index cd72f2fce..cac8b743f 100644 --- a/UI/Web/src/app/_services/action-factory.service.ts +++ b/UI/Web/src/app/_services/action-factory.service.ts @@ -212,6 +212,13 @@ export class ActionFactoryService { }, ], }, + { + action: Action.Edit, + title: 'Settings', + callback: this.dummyCallback, + requiresAdmin: true, + children: [], + }, ]; this.collectionTagActions = [ diff --git a/UI/Web/src/app/_services/image.service.ts b/UI/Web/src/app/_services/image.service.ts index a6ab89927..3cc3a0355 100644 --- a/UI/Web/src/app/_services/image.service.ts +++ b/UI/Web/src/app/_services/image.service.ts @@ -61,6 +61,10 @@ export class ImageService implements OnDestroy { return part.substring(0, equalIndex).replace('Id', ''); } + getLibraryCoverImage(libraryId: number) { + return this.baseUrl + 'image/library-cover?libraryId=' + libraryId; + } + getVolumeCoverImage(volumeId: number) { return this.baseUrl + 'image/volume-cover?volumeId=' + volumeId; } diff --git a/UI/Web/src/app/_services/library.service.ts b/UI/Web/src/app/_services/library.service.ts index 403fd409e..23478db4d 100644 --- a/UI/Web/src/app/_services/library.service.ts +++ b/UI/Web/src/app/_services/library.service.ts @@ -50,6 +50,10 @@ export class LibraryService { })); } + libraryNameExists(name: string) { + return this.httpClient.get(this.baseUrl + 'library/name-exists?name=' + name); + } + listDirectories(rootPath: string) { let query = ''; if (rootPath !== undefined && rootPath.length > 0) { diff --git a/UI/Web/src/app/_services/upload.service.ts b/UI/Web/src/app/_services/upload.service.ts index 8f3c1d07a..77fde32aa 100644 --- a/UI/Web/src/app/_services/upload.service.ts +++ b/UI/Web/src/app/_services/upload.service.ts @@ -38,6 +38,10 @@ export class UploadService { return this.httpClient.post(this.baseUrl + 'upload/chapter', {id: chapterId, url: this._cleanBase64Url(url)}); } + updateLibraryCoverImage(libraryId: number, url: string) { + return this.httpClient.post(this.baseUrl + 'upload/library', {id: libraryId, url: this._cleanBase64Url(url)}); + } + resetChapterCoverLock(chapterId: number, ) { return this.httpClient.post(this.baseUrl + 'upload/reset-chapter-lock', {id: chapterId, url: ''}); } diff --git a/UI/Web/src/app/admin/_modals/library-editor-modal/library-editor-modal.component.html b/UI/Web/src/app/admin/_modals/library-editor-modal/library-editor-modal.component.html deleted file mode 100644 index 921ae6ca3..000000000 --- a/UI/Web/src/app/admin/_modals/library-editor-modal/library-editor-modal.component.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/UI/Web/src/app/admin/_modals/library-editor-modal/library-editor-modal.component.ts b/UI/Web/src/app/admin/_modals/library-editor-modal/library-editor-modal.component.ts deleted file mode 100644 index 710d0e4d7..000000000 --- a/UI/Web/src/app/admin/_modals/library-editor-modal/library-editor-modal.component.ts +++ /dev/null @@ -1,115 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { FormControl, FormGroup, Validators } from '@angular/forms'; -import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap'; -import { ToastrService } from 'ngx-toastr'; -import { ConfirmService } from 'src/app/shared/confirm.service'; -import { Library } from 'src/app/_models/library'; -import { LibraryService } from 'src/app/_services/library.service'; -import { SettingsService } from '../../settings.service'; -import { DirectoryPickerComponent, DirectoryPickerResult } from '../directory-picker/directory-picker.component'; - -@Component({ - selector: 'app-library-editor-modal', - templateUrl: './library-editor-modal.component.html', - styleUrls: ['./library-editor-modal.component.scss'] -}) -export class LibraryEditorModalComponent implements OnInit { - - @Input() library: Library | undefined = undefined; - - libraryForm: FormGroup = new FormGroup({ - name: new FormControl('', [Validators.required]), - type: new FormControl(0, [Validators.required]) - }); - - selectedFolders: string[] = []; - errorMessage = ''; - madeChanges = false; - libraryTypes: string[] = [] - - - constructor(private modalService: NgbModal, private libraryService: LibraryService, public modal: NgbActiveModal, private settingService: SettingsService, - private toastr: ToastrService, private confirmService: ConfirmService) { } - - ngOnInit(): void { - - this.settingService.getLibraryTypes().subscribe((types) => { - this.libraryTypes = types; - }); - this.setValues(); - - } - - - removeFolder(folder: string) { - this.selectedFolders = this.selectedFolders.filter(item => item !== folder); - this.madeChanges = true; - } - - async submitLibrary() { - const model = this.libraryForm.value; - model.folders = this.selectedFolders; - - if (this.libraryForm.errors) { - return; - } - - if (this.library !== undefined) { - model.id = this.library.id; - model.folders = model.folders.map((item: string) => item.startsWith('\\') ? item.substr(1, item.length) : item); - model.type = parseInt(model.type, 10); - - if (model.type !== this.library.type) { - if (!await this.confirmService.confirm(`Changing library type will trigger a new scan with different parsing rules and may lead to - series being re-created and hence you may loose progress and bookmarks. You should backup before you do this. Are you sure you want to continue?`)) return; - } - - this.libraryService.update(model).subscribe(() => { - this.close(true); - }, err => { - this.errorMessage = err; - }); - } else { - model.folders = model.folders.map((item: string) => item.startsWith('\\') ? item.substr(1, item.length) : item); - model.type = parseInt(model.type, 10); - this.libraryService.create(model).subscribe(() => { - this.toastr.success('Library created successfully.'); - this.toastr.info('A scan has been started.'); - this.close(true); - }, err => { - this.errorMessage = err; - }); - } - } - - close(returnVal= false) { - const model = this.libraryForm.value; - this.modal.close(returnVal); - } - - reset() { - this.setValues(); - } - - setValues() { - if (this.library !== undefined) { - this.libraryForm.get('name')?.setValue(this.library.name); - this.libraryForm.get('type')?.setValue(this.library.type); - this.selectedFolders = this.library.folders; - this.madeChanges = false; - } - } - - openDirectoryPicker() { - const modalRef = this.modalService.open(DirectoryPickerComponent, { scrollable: true, size: 'lg' }); - modalRef.closed.subscribe((closeResult: DirectoryPickerResult) => { - if (closeResult.success) { - if (!this.selectedFolders.includes(closeResult.folderPath)) { - this.selectedFolders.push(closeResult.folderPath); - this.madeChanges = true; - } - } - }); - } - -} diff --git a/UI/Web/src/app/admin/admin.module.ts b/UI/Web/src/app/admin/admin.module.ts index 2bee7e133..efad95baa 100644 --- a/UI/Web/src/app/admin/admin.module.ts +++ b/UI/Web/src/app/admin/admin.module.ts @@ -5,7 +5,6 @@ import { DashboardComponent } from './dashboard/dashboard.component'; import { NgbDropdownModule, NgbNavModule, NgbTooltipModule, NgbTypeaheadModule } from '@ng-bootstrap/ng-bootstrap'; import { ManageLibraryComponent } from './manage-library/manage-library.component'; import { ManageUsersComponent } from './manage-users/manage-users.component'; -import { LibraryEditorModalComponent } from './_modals/library-editor-modal/library-editor-modal.component'; import { SharedModule } from '../shared/shared.module'; import { LibraryAccessModalComponent } from './_modals/library-access-modal/library-access-modal.component'; import { DirectoryPickerComponent } from './_modals/directory-picker/directory-picker.component'; @@ -34,7 +33,6 @@ import { VirtualScrollerModule } from '@iharbeck/ngx-virtual-scroller'; ManageUsersComponent, DashboardComponent, ManageLibraryComponent, - LibraryEditorModalComponent, LibraryAccessModalComponent, DirectoryPickerComponent, ResetPasswordModalComponent, diff --git a/UI/Web/src/app/admin/manage-library/manage-library.component.html b/UI/Web/src/app/admin/manage-library/manage-library.component.html index e6418840d..873ef4141 100644 --- a/UI/Web/src/app/admin/manage-library/manage-library.component.html +++ b/UI/Web/src/app/admin/manage-library/manage-library.component.html @@ -3,7 +3,7 @@

Libraries

-
    +
    • @@ -34,7 +34,4 @@ There are no libraries. Try creating one.

    - - - \ No newline at end of file diff --git a/UI/Web/src/app/admin/manage-library/manage-library.component.ts b/UI/Web/src/app/admin/manage-library/manage-library.component.ts index de3a24697..8e53f11e7 100644 --- a/UI/Web/src/app/admin/manage-library/manage-library.component.ts +++ b/UI/Web/src/app/admin/manage-library/manage-library.component.ts @@ -4,12 +4,12 @@ import { ToastrService } from 'ngx-toastr'; import { Subject } from 'rxjs'; import { distinctUntilChanged, filter, take, takeUntil } from 'rxjs/operators'; import { ConfirmService } from 'src/app/shared/confirm.service'; +import { LibrarySettingsModalComponent } from 'src/app/sidenav/_components/library-settings-modal/library-settings-modal.component'; import { NotificationProgressEvent } from 'src/app/_models/events/notification-progress-event'; import { ScanSeriesEvent } from 'src/app/_models/events/scan-series-event'; -import { Library, LibraryType } from 'src/app/_models/library'; +import { Library } from 'src/app/_models/library'; import { LibraryService } from 'src/app/_services/library.service'; import { EVENTS, Message, MessageHubService } from 'src/app/_services/message-hub.service'; -import { LibraryEditorModalComponent } from '../_modals/library-editor-modal/library-editor-modal.component'; @Component({ selector: 'app-manage-library', @@ -20,7 +20,6 @@ import { LibraryEditorModalComponent } from '../_modals/library-editor-modal/lib export class ManageLibraryComponent implements OnInit, OnDestroy { libraries: Library[] = []; - createLibraryToggle = false; loading = false; /** * If a deletion is in progress for a library @@ -90,7 +89,7 @@ export class ManageLibraryComponent implements OnInit, OnDestroy { } editLibrary(library: Library) { - const modalRef = this.modalService.open(LibraryEditorModalComponent); + const modalRef = this.modalService.open(LibrarySettingsModalComponent, { size: 'xl' }); modalRef.componentInstance.library = library; modalRef.closed.pipe(takeUntil(this.onDestroy)).subscribe(refresh => { if (refresh) { @@ -100,7 +99,7 @@ export class ManageLibraryComponent implements OnInit, OnDestroy { } addLibrary() { - const modalRef = this.modalService.open(LibraryEditorModalComponent); + const modalRef = this.modalService.open(LibrarySettingsModalComponent, { size: 'xl' }); modalRef.closed.pipe(takeUntil(this.onDestroy)).subscribe(refresh => { if (refresh) { this.getLibraries(); diff --git a/UI/Web/src/app/admin/manage-settings/manage-settings.component.scss b/UI/Web/src/app/admin/manage-settings/manage-settings.component.scss index d58f774a2..042a4f5b4 100644 --- a/UI/Web/src/app/admin/manage-settings/manage-settings.component.scss +++ b/UI/Web/src/app/admin/manage-settings/manage-settings.component.scss @@ -1,12 +1,3 @@ -.accent { - font-style: italic; - font-size: 0.7rem; - background-color: lightgray; - padding: 10px; - color: black; - border-radius: 6px; -} - .invalid-feedback { display: inherit; } \ No newline at end of file diff --git a/UI/Web/src/app/library-detail/library-recommended/library-recommended.component.html b/UI/Web/src/app/library-detail/library-recommended/library-recommended.component.html index c544d0611..2b4e32750 100644 --- a/UI/Web/src/app/library-detail/library-recommended/library-recommended.component.html +++ b/UI/Web/src/app/library-detail/library-recommended/library-recommended.component.html @@ -1,7 +1,9 @@ -

    Nothing to show here. Add some metadata to your library, read something or rate something.

    +

    + Nothing to show here. Add some metadata to your library, read something or rate something. This library may also have recommendations turned off. +

    diff --git a/UI/Web/src/app/series-detail/series-detail.component.ts b/UI/Web/src/app/series-detail/series-detail.component.ts index c9e43440e..314424bf4 100644 --- a/UI/Web/src/app/series-detail/series-detail.component.ts +++ b/UI/Web/src/app/series-detail/series-detail.component.ts @@ -796,9 +796,9 @@ export class SeriesDetailComponent implements OnInit, OnDestroy, AfterContentChe toggleWantToRead() { if (this.isWantToRead) { - this.actionService.addMultipleSeriesToWantToReadList([this.series.id]); - } else { this.actionService.removeMultipleSeriesFromWantToReadList([this.series.id]); + } else { + this.actionService.addMultipleSeriesToWantToReadList([this.series.id]); } this.isWantToRead = !this.isWantToRead; diff --git a/UI/Web/src/app/sidenav/_components/library-settings-modal/library-settings-modal.component.html b/UI/Web/src/app/sidenav/_components/library-settings-modal/library-settings-modal.component.html new file mode 100644 index 000000000..41bf6d91e --- /dev/null +++ b/UI/Web/src/app/sidenav/_components/library-settings-modal/library-settings-modal.component.html @@ -0,0 +1,162 @@ + +
    + +
    + diff --git a/UI/Web/src/app/admin/_modals/library-editor-modal/library-editor-modal.component.scss b/UI/Web/src/app/sidenav/_components/library-settings-modal/library-settings-modal.component.scss similarity index 100% rename from UI/Web/src/app/admin/_modals/library-editor-modal/library-editor-modal.component.scss rename to UI/Web/src/app/sidenav/_components/library-settings-modal/library-settings-modal.component.scss diff --git a/UI/Web/src/app/sidenav/_components/library-settings-modal/library-settings-modal.component.ts b/UI/Web/src/app/sidenav/_components/library-settings-modal/library-settings-modal.component.ts new file mode 100644 index 000000000..c382af6b6 --- /dev/null +++ b/UI/Web/src/app/sidenav/_components/library-settings-modal/library-settings-modal.component.ts @@ -0,0 +1,216 @@ +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit } from '@angular/core'; +import { FormGroup, FormControl, Validators } from '@angular/forms'; +import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap'; +import { ToastrService } from 'ngx-toastr'; +import { debounceTime, distinctUntilChanged, filter, switchMap, tap } from 'rxjs'; +import { SettingsService } from 'src/app/admin/settings.service'; +import { DirectoryPickerComponent, DirectoryPickerResult } from 'src/app/admin/_modals/directory-picker/directory-picker.component'; +import { ConfirmService } from 'src/app/shared/confirm.service'; +import { Breakpoint, UtilityService } from 'src/app/shared/_services/utility.service'; +import { Library, LibraryType } from 'src/app/_models/library'; +import { LibraryService } from 'src/app/_services/library.service'; +import { UploadService } from 'src/app/_services/upload.service'; + +enum TabID { + General = 'General', + Folder = 'Folder', + Cover = 'Cover', + Advanced = 'Advanced' +} + +enum StepID { + General = 0, + Folder = 1, + Cover = 2, + Advanced = 3 +} + +@Component({ + selector: 'app-library-settings-modal', + templateUrl: './library-settings-modal.component.html', + styleUrls: ['./library-settings-modal.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class LibrarySettingsModalComponent implements OnInit { + + @Input() library!: Library; + + active = TabID.General; + imageUrls: Array = []; + + libraryForm: FormGroup = new FormGroup({ + name: new FormControl('', { nonNullable: true, validators: [Validators.required] }), + type: new FormControl(LibraryType.Manga, { nonNullable: true, validators: [Validators.required] }), + folderWatching: new FormControl(true, { nonNullable: true, validators: [Validators.required] }), + includeInDashboard: new FormControl(true, { nonNullable: true, validators: [Validators.required] }), + includeInRecommended: new FormControl(true, { nonNullable: true, validators: [Validators.required] }), + includeInSearch: new FormControl(true, { nonNullable: true, validators: [Validators.required] }), + }); + + selectedFolders: string[] = []; + madeChanges = false; + libraryTypes: string[] = [] + + isAddLibrary = false; + setupStep = StepID.General; + + get Breakpoint() { return Breakpoint; } + get TabID() { return TabID; } + get StepID() { return StepID; } + + constructor(public utilityService: UtilityService, private uploadService: UploadService, private modalService: NgbModal, + private settingService: SettingsService, public modal: NgbActiveModal, private confirmService: ConfirmService, + private libraryService: LibraryService, private toastr: ToastrService, private readonly cdRef: ChangeDetectorRef) { } + + ngOnInit(): void { + + this.settingService.getLibraryTypes().subscribe((types) => { + this.libraryTypes = types; + this.cdRef.markForCheck(); + }); + + + if (this.library === undefined) { + this.isAddLibrary = true; + this.cdRef.markForCheck(); + } + + if (this.library?.coverImage != null && this.library?.coverImage !== '') { + this.imageUrls.push(this.library.coverImage); + this.cdRef.markForCheck(); + } + + this.libraryForm.get('name')?.valueChanges.pipe( + debounceTime(100), + distinctUntilChanged(), + switchMap(name => this.libraryService.libraryNameExists(name)), + tap(exists => { + const isExistingName = this.libraryForm.get('name')?.value === this.library?.name; + console.log('isExistingName', isExistingName) + if (!exists || isExistingName) { + this.libraryForm.get('name')?.setErrors(null); + } else { + this.libraryForm.get('name')?.setErrors({duplicateName: true}) + } + this.cdRef.markForCheck(); + }) + ).subscribe(); + + + this.setValues(); + } + + setValues() { + if (this.library !== undefined) { + this.libraryForm.get('name')?.setValue(this.library.name); + this.libraryForm.get('type')?.setValue(this.library.type); + this.libraryForm.get('folderWatching')?.setValue(this.library.folderWatching); + this.libraryForm.get('includeInDashboard')?.setValue(this.library.includeInDashboard); + this.libraryForm.get('includeInRecommended')?.setValue(this.library.includeInRecommended); + this.libraryForm.get('includeInSearch')?.setValue(this.library.includeInSearch); + this.selectedFolders = this.library.folders; + this.madeChanges = false; + this.cdRef.markForCheck(); + } + } + + isDisabled() { + return !(this.libraryForm.valid && this.selectedFolders.length > 0); + } + + reset() { + this.setValues(); + } + + close(returnVal= false) { + this.modal.close(returnVal); + } + + async save() { + const model = this.libraryForm.value; + model.folders = this.selectedFolders; + + if (this.libraryForm.errors) { + return; + } + + if (this.library !== undefined) { + model.id = this.library.id; + model.folders = model.folders.map((item: string) => item.startsWith('\\') ? item.substr(1, item.length) : item); + model.type = parseInt(model.type, 10); + + if (model.type !== this.library.type) { + if (!await this.confirmService.confirm(`Changing library type will trigger a new scan with different parsing rules and may lead to + series being re-created and hence you may loose progress and bookmarks. You should backup before you do this. Are you sure you want to continue?`)) return; + } + + this.libraryService.update(model).subscribe(() => { + this.close(true); + }); + } else { + model.folders = model.folders.map((item: string) => item.startsWith('\\') ? item.substr(1, item.length) : item); + model.type = parseInt(model.type, 10); + this.libraryService.create(model).subscribe(() => { + this.toastr.success('Library created successfully. A scan has been started.'); + this.close(true); + }); + } + } + + nextStep() { + this.setupStep++; + switch(this.setupStep) { + case StepID.Folder: + this.active = TabID.Folder; + break; + case StepID.Cover: + this.active = TabID.Cover; + break; + case StepID.Advanced: + this.active = TabID.Advanced; + break; + } + this.cdRef.markForCheck(); + } + + applyCoverImage(coverUrl: string) { + this.uploadService.updateLibraryCoverImage(this.library.id, coverUrl).subscribe(() => {}); + } + + resetCoverImage() { + this.uploadService.updateLibraryCoverImage(this.library.id, '').subscribe(() => {}); + } + + openDirectoryPicker() { + const modalRef = this.modalService.open(DirectoryPickerComponent, { scrollable: true, size: 'lg' }); + modalRef.closed.subscribe((closeResult: DirectoryPickerResult) => { + if (closeResult.success) { + if (!this.selectedFolders.includes(closeResult.folderPath)) { + this.selectedFolders.push(closeResult.folderPath); + this.madeChanges = true; + this.cdRef.markForCheck(); + } + } + }); + } + + removeFolder(folder: string) { + this.selectedFolders = this.selectedFolders.filter(item => item !== folder); + this.madeChanges = true; + this.cdRef.markForCheck(); + } + + isNextDisabled() { + switch (this.setupStep) { + case StepID.General: + return this.libraryForm.get('name')?.invalid || this.libraryForm.get('type')?.invalid; + case StepID.Folder: + return this.selectedFolders.length === 0; + case StepID.Cover: + return false; // Covers are optional + case StepID.Advanced: + return false; // Advanced are optional + } + } + +} diff --git a/UI/Web/src/app/sidenav/side-nav-item/side-nav-item.component.html b/UI/Web/src/app/sidenav/side-nav-item/side-nav-item.component.html index 2a1854130..55543c11e 100644 --- a/UI/Web/src/app/sidenav/side-nav-item/side-nav-item.component.html +++ b/UI/Web/src/app/sidenav/side-nav-item/side-nav-item.component.html @@ -15,7 +15,10 @@
    - + + icon + +
    diff --git a/UI/Web/src/app/sidenav/side-nav-item/side-nav-item.component.scss b/UI/Web/src/app/sidenav/side-nav-item/side-nav-item.component.scss index 95de8b9eb..132ad88bb 100644 --- a/UI/Web/src/app/sidenav/side-nav-item/side-nav-item.component.scss +++ b/UI/Web/src/app/sidenav/side-nav-item/side-nav-item.component.scss @@ -21,6 +21,11 @@ } } + .side-nav-img { + width: 20px; + height: 18px; + } + span { &:last-child { @@ -81,7 +86,6 @@ } .side-nav-text, i { - color: var(--side-nav-item-active-text-color) !important; } @@ -107,46 +111,19 @@ a { @media (max-width: 576px) { .side-nav-item { align-items: center; - //display: flex; - //justify-content: space-between; padding: 15px 10px; - //width: 100%; height: 70px; - //min-height: 40px; - // overflow: hidden; font-size: 1rem; - - //cursor: pointer; - + .side-nav-text { - // padding-left: 10px; - // opacity: 1; - // min-width: 100px; width: 100%; - - // div { - // min-width: 102px; - // width: 100% - // } } &.closed { - // .side-nav-text { - // opacity: 0; - // } - .card-actions { - //opacity: 0; font-size: inherit; } } - - // span { - // &:last-child { - // flex-grow: 1; - // justify-content: end; - // } - // } } } \ No newline at end of file diff --git a/UI/Web/src/app/sidenav/side-nav-item/side-nav-item.component.ts b/UI/Web/src/app/sidenav/side-nav-item/side-nav-item.component.ts index 58661d320..71523fee0 100644 --- a/UI/Web/src/app/sidenav/side-nav-item/side-nav-item.component.ts +++ b/UI/Web/src/app/sidenav/side-nav-item/side-nav-item.component.ts @@ -14,6 +14,7 @@ export class SideNavItemComponent implements OnInit, OnDestroy { * Icon to display next to item. ie) 'fa-home' */ @Input() icon: string = ''; + @Input() imageUrl: string | null = ''; /** * Text for the item */ diff --git a/UI/Web/src/app/sidenav/side-nav/side-nav.component.html b/UI/Web/src/app/sidenav/side-nav/side-nav.component.html index ce8998ec4..2cfb35848 100644 --- a/UI/Web/src/app/sidenav/side-nav/side-nav.component.html +++ b/UI/Web/src/app/sidenav/side-nav/side-nav.component.html @@ -21,7 +21,7 @@ + [icon]="getLibraryTypeIcon(library.type)" [imageUrl]="getLibraryImage(library)" [title]="library.name" [comparisonMethod]="'startsWith'"> diff --git a/UI/Web/src/app/sidenav/side-nav/side-nav.component.ts b/UI/Web/src/app/sidenav/side-nav/side-nav.component.ts index 7364a8995..a8db4094f 100644 --- a/UI/Web/src/app/sidenav/side-nav/side-nav.component.ts +++ b/UI/Web/src/app/sidenav/side-nav/side-nav.component.ts @@ -1,7 +1,9 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'; import { NavigationEnd, Router } from '@angular/router'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { Subject } from 'rxjs'; import { filter, map, shareReplay, take, takeUntil } from 'rxjs/operators'; +import { ImageService } from 'src/app/_services/image.service'; import { EVENTS, MessageHubService } from 'src/app/_services/message-hub.service'; import { Breakpoint, UtilityService } from '../../shared/_services/utility.service'; import { Library, LibraryType } from '../../_models/library'; @@ -10,6 +12,7 @@ import { Action, ActionFactoryService, ActionItem } from '../../_services/action import { ActionService } from '../../_services/action.service'; import { LibraryService } from '../../_services/library.service'; import { NavService } from '../../_services/nav.service'; +import { LibrarySettingsModalComponent } from '../_components/library-settings-modal/library-settings-modal.component'; @Component({ selector: 'app-side-nav', @@ -33,7 +36,8 @@ export class SideNavComponent implements OnInit, OnDestroy { constructor(public accountService: AccountService, private libraryService: LibraryService, public utilityService: UtilityService, private messageHub: MessageHubService, private actionFactoryService: ActionFactoryService, private actionService: ActionService, - public navService: NavService, private router: Router, private readonly cdRef: ChangeDetectorRef) { + public navService: NavService, private router: Router, private readonly cdRef: ChangeDetectorRef, + private modalService: NgbModal, private imageService: ImageService) { this.router.events.pipe( filter(event => event instanceof NavigationEnd), @@ -64,7 +68,7 @@ export class SideNavComponent implements OnInit, OnDestroy { this.messageHub.messages$.pipe(takeUntil(this.onDestroy), filter(event => event.event === EVENTS.LibraryModified)).subscribe(event => { this.libraryService.getLibraries().pipe(take(1), shareReplay()).subscribe((libraries: Library[]) => { - this.libraries = libraries; + this.libraries = [...libraries]; this.cdRef.markForCheck(); }); }); @@ -86,6 +90,20 @@ export class SideNavComponent implements OnInit, OnDestroy { case (Action.AnalyzeFiles): this.actionService.analyzeFiles(library); break; + case (Action.Edit): + const modalRef = this.modalService.open(LibrarySettingsModalComponent, { size: 'xl' }); + modalRef.componentInstance.library = library; + modalRef.closed.subscribe((closeResult: {success: boolean, library: Library, coverImageUpdate: boolean}) => { + window.scrollTo(0, 0); + if (closeResult.success) { + + } + + if (closeResult.coverImageUpdate) { + + } + }); + break; default: break; } @@ -108,6 +126,11 @@ export class SideNavComponent implements OnInit, OnDestroy { } } + getLibraryImage(library: Library) { + if (library.coverImage) return this.imageService.getLibraryCoverImage(library.id); + return null; + } + toggleNavBar() { this.navService.toggleSideNav(); } diff --git a/UI/Web/src/app/sidenav/sidenav.module.ts b/UI/Web/src/app/sidenav/sidenav.module.ts index 119c2604b..08bc2a040 100644 --- a/UI/Web/src/app/sidenav/sidenav.module.ts +++ b/UI/Web/src/app/sidenav/sidenav.module.ts @@ -5,9 +5,10 @@ import { SideNavItemComponent } from './side-nav-item/side-nav-item.component'; import { SideNavComponent } from './side-nav/side-nav.component'; import { PipeModule } from '../pipe/pipe.module'; import { CardsModule } from '../cards/cards.module'; -import { FormsModule } from '@angular/forms'; -import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { NgbNavModule, NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap'; import { RouterModule } from '@angular/router'; +import { LibrarySettingsModalComponent } from './_components/library-settings-modal/library-settings-modal.component'; @@ -15,7 +16,8 @@ import { RouterModule } from '@angular/router'; declarations: [ SideNavCompanionBarComponent, SideNavItemComponent, - SideNavComponent + SideNavComponent, + LibrarySettingsModalComponent ], imports: [ CommonModule, @@ -24,6 +26,8 @@ import { RouterModule } from '@angular/router'; CardsModule, FormsModule, NgbTooltipModule, + NgbNavModule, + ReactiveFormsModule ], exports: [ SideNavCompanionBarComponent, diff --git a/UI/Web/src/theme/utilities/_global.scss b/UI/Web/src/theme/utilities/_global.scss index 3ff1fd933..5ba860e1b 100644 --- a/UI/Web/src/theme/utilities/_global.scss +++ b/UI/Web/src/theme/utilities/_global.scss @@ -25,6 +25,9 @@ hr { color: var(--accent-text-color) !important; box-shadow: inset 0px 0px 8px 1px var(--accent-bg-color) !important; font-size: var(--accent-text-size) !important; + font-style: italic; + padding: 10px; + border-radius: 6px; } .text-muted { @@ -37,4 +40,5 @@ hr { .form-switch .form-check-input:checked { background-color: var(--primary-color); -} \ No newline at end of file +} + From 86fb2a8c94466877ab21404e4d85352528787504 Mon Sep 17 00:00:00 2001 From: majora2007 Date: Fri, 18 Nov 2022 15:51:22 +0000 Subject: [PATCH 008/199] Bump versions by dotnet-bump-version. --- Kavita.Common/Kavita.Common.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kavita.Common/Kavita.Common.csproj b/Kavita.Common/Kavita.Common.csproj index 436b0d470..6017e2bfe 100644 --- a/Kavita.Common/Kavita.Common.csproj +++ b/Kavita.Common/Kavita.Common.csproj @@ -4,7 +4,7 @@ net6.0 kavitareader.com Kavita - 0.6.1.4 + 0.6.1.5 en true From 089658e4698dd604b99e153cf2b8580a8c5df37d Mon Sep 17 00:00:00 2001 From: Joe Milazzo Date: Sun, 20 Nov 2022 14:32:21 -0600 Subject: [PATCH 009/199] UX Alignment and bugfixes (#1663) * Refactored the design of reading list page to follow more in line with list view. Added release date on the reading list items, if it's set in underlying chapter. Fixed a bug where reordering the list items could sometimes not update correctly with drag and drop. * Removed a bug marker that I just fixed * When generating library covers, make them much smaller as they are only ever icons. * Fixed library settings not showing the correct image. * Fixed a bug where duplicate collection tags could be created. Fixed a bug where collection tag normalized title was being set to uppercase. Redesigned the edit collection tag modal to align with new library settings and provide inline name checks. * Updated edit reading list modal to align with new library settings modal pattern. Refactored the backend to ensure it flows correctly without allowing duplicate names. Don't show Continue point on series detail if the whole series is read. * Added some more unit tests around continue point * Fixed a bug on series detail when bulk selecting between volume and chapters, the code which determines which chapters are selected didn't take into account mixed layout for Storyline tab. * Refactored to generate an OpenAPI spec at root of Kavita. This will be loaded by a new API site for easy hosting. Deprecated EnableSwaggerUi preference as after validation new system works, this will be removed and instances can use our hosting to hit their server (or run a debug build). * Test GA * Reverted GA and instead do it in the build step. This will just force developers to commit it in. * GA please work * Removed redundant steps from test since build already does it. * Try another GA * Moved all test actions into initial build step, which should drastically cut down on time. Only run sonar if the secret is present (so not for forks). Updated build requirements for develop and stable docker pushes. * Fixed env variable * Okay not possible to do secrets in if statement * Fixed the build step to output the openapi.json where it's expected. --- .github/workflows/sonar-scan.yml | 43 +- API.Tests/Services/ReaderServiceTests.cs | 66 + API/API.csproj | 6 +- API/Controllers/CollectionController.cs | 24 +- API/Controllers/LibraryController.cs | 6 +- API/Controllers/ReadingListController.cs | 38 +- API/Controllers/UploadController.cs | 3 +- API/DTOs/ReadingLists/ReadingListItemDto.cs | 7 +- API/DTOs/Settings/ServerSettingDTO.cs | 4 +- .../Repositories/CollectionTagRepository.cs | 8 + API/Data/Repositories/LibraryRepository.cs | 2 +- .../Repositories/ReadingListRepository.cs | 17 +- API/Entities/Enums/ServerSettingKey.cs | 4 +- API/Services/ImageService.cs | 10 +- API/Startup.cs | 48 +- CONTRIBUTING.md | 9 +- UI/Web/src/app/_models/reading-list.ts | 1 + .../app/_services/collection-tag.service.ts | 4 + .../src/app/_services/reading-list.service.ts | 4 + .../edit-collection-tags.component.html | 102 +- .../edit-collection-tags.component.scss | 3 + .../edit-collection-tags.component.ts | 67 +- .../cards/card-item/card-item.component.scss | 3 +- .../cards/list-item/list-item.component.html | 2 +- .../cards/list-item/list-item.component.scss | 7 +- .../all-collections.component.ts | 2 +- .../edit-reading-list-modal.component.html | 55 +- .../edit-reading-list-modal.component.scss | 3 + .../edit-reading-list-modal.component.ts | 65 +- .../draggable-ordered-list.component.html | 3 +- .../draggable-ordered-list.component.ts | 4 + .../reading-list-detail.component.html | 6 +- .../reading-list-detail.component.ts | 10 +- .../reading-list-item.component.html | 64 +- .../reading-list-item.component.scss | 25 + .../reading-list-item.component.ts | 2 + .../app/reading-list/reading-list.module.ts | 4 +- .../reading-lists.component.html | 2 +- .../reading-lists/reading-lists.component.ts | 3 + .../series-detail.component.html | 2 +- .../series-detail/series-detail.component.ts | 7 +- .../library-settings-modal.component.ts | 23 +- UI/Web/src/theme/themes/dark.scss | 1 + openapi.json | 13362 ++++++++++++++++ 44 files changed, 13878 insertions(+), 253 deletions(-) create mode 100644 openapi.json diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index e0f98f393..d3a885b2e 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -22,6 +22,10 @@ jobs: with: dotnet-version: 6.0.x + - name: Install Swashbuckle CLI + shell: powershell + run: dotnet tool install -g --version 6.4.0 Swashbuckle.AspNetCore.Cli + - name: Install dependencies run: dotnet restore @@ -35,29 +39,6 @@ jobs: name: csproj path: Kavita.Common/Kavita.Common.csproj - test: - name: Install Sonar & Test - needs: build - runs-on: windows-latest - steps: - - name: Checkout Repo - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Setup .NET Core - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 6.0.x - - - name: Install dependencies - run: dotnet restore - - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 1.11 - - name: Cache SonarCloud packages uses: actions/cache@v1 with: @@ -93,9 +74,10 @@ jobs: - name: Test run: dotnet test --no-restore --verbosity normal + version: name: Bump version on Develop push - needs: [ build, test ] + needs: [ build ] runs-on: ubuntu-latest if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }} steps: @@ -108,6 +90,10 @@ jobs: with: dotnet-version: 6.0.x + - name: Install Swashbuckle CLI + shell: powershell + run: dotnet tool install -g --version 6.4.0 Swashbuckle.AspNetCore.Cli + - name: Install dependencies run: dotnet restore @@ -194,6 +180,11 @@ jobs: uses: actions/setup-dotnet@v2 with: dotnet-version: 6.0.x + + - name: Install Swashbuckle CLI + shell: powershell + run: dotnet tool install -g --version 6.4.0 Swashbuckle.AspNetCore.Cli + - run: ./monorepo-build.sh - name: Login to Docker Hub @@ -307,6 +298,10 @@ jobs: uses: actions/setup-dotnet@v2 with: dotnet-version: 6.0.x + - name: Install Swashbuckle CLI + shell: powershell + run: dotnet tool install -g --version 6.4.0 Swashbuckle.AspNetCore.Cli + - run: ./monorepo-build.sh - name: Login to Docker Hub diff --git a/API.Tests/Services/ReaderServiceTests.cs b/API.Tests/Services/ReaderServiceTests.cs index 71ecc1543..7c1011a69 100644 --- a/API.Tests/Services/ReaderServiceTests.cs +++ b/API.Tests/Services/ReaderServiceTests.cs @@ -1734,6 +1734,72 @@ public class ReaderServiceTests Assert.Equal("1", nextChapter.Range); } + [Fact] + public async Task GetContinuePoint_ShouldReturnLooseChapter_WhenAllVolumesAndAFewLooseChaptersRead() + { + _context.Series.Add(new Series() + { + Name = "Test", + Library = new Library() { + Name = "Test LIb", + Type = LibraryType.Manga, + }, + Volumes = new List() + { + EntityFactory.CreateVolume("0", new List() + { + EntityFactory.CreateChapter("100", false, new List(), 1), + EntityFactory.CreateChapter("101", false, new List(), 1), + EntityFactory.CreateChapter("102", false, new List(), 1), + }), + EntityFactory.CreateVolume("1", new List() + { + EntityFactory.CreateChapter("1", false, new List(), 1), + EntityFactory.CreateChapter("2", false, new List(), 1), + }), + EntityFactory.CreateVolume("2", new List() + { + EntityFactory.CreateChapter("21", false, new List(), 1), + }), + } + }); + + var user = new AppUser() + { + UserName = "majora2007" + }; + _context.AppUser.Add(user); + + await _context.SaveChangesAsync(); + + var readerService = new ReaderService(_unitOfWork, Substitute.For>(), Substitute.For()); + + // Mark everything but chapter 101 as read + await readerService.MarkSeriesAsRead(user, 1); + await _unitOfWork.CommitAsync(); + + // Unmark last chapter as read + await readerService.SaveReadingProgress(new ProgressDto() + { + PageNum = 0, + ChapterId = (await _unitOfWork.VolumeRepository.GetVolumeByIdAsync(1)).Chapters.ElementAt(1).Id, + SeriesId = 1, + VolumeId = 1 + }, 1); + await readerService.SaveReadingProgress(new ProgressDto() + { + PageNum = 0, + ChapterId = (await _unitOfWork.VolumeRepository.GetVolumeByIdAsync(1)).Chapters.ElementAt(2).Id, + SeriesId = 1, + VolumeId = 1 + }, 1); + await _context.SaveChangesAsync(); + + var nextChapter = await readerService.GetContinuePoint(1, 1); + + Assert.Equal("101", nextChapter.Range); + } + [Fact] public async Task GetContinuePoint_ShouldReturnFirstChapter_WhenAllRead() { diff --git a/API/API.csproj b/API/API.csproj index 1310f09a4..652e37a6c 100644 --- a/API/API.csproj +++ b/API/API.csproj @@ -5,10 +5,13 @@ net6.0 true Linux - true true true + + + + false @@ -91,6 +94,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/API/Controllers/CollectionController.cs b/API/Controllers/CollectionController.cs index 33bde22b6..1bdca14ea 100644 --- a/API/Controllers/CollectionController.cs +++ b/API/Controllers/CollectionController.cs @@ -9,7 +9,6 @@ using API.Extensions; using API.SignalR; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.SignalR; namespace API.Controllers; @@ -63,6 +62,19 @@ public class CollectionController : BaseApiController return await _unitOfWork.CollectionTagRepository.SearchTagDtosAsync(queryString, user.Id); } + /// + /// Checks if a collection exists with the name + /// + /// If empty or null, will return true as that is invalid + /// + [Authorize(Policy = "RequireAdminRole")] + [HttpGet("name-exists")] + public async Task> DoesNameExists(string name) + { + if (string.IsNullOrEmpty(name.Trim())) return Ok(true); + return Ok(await _unitOfWork.CollectionTagRepository.TagExists(name)); + } + /// /// Updates an existing tag with a new title, promotion status, and summary. /// UI does not contain controls to update title @@ -71,14 +83,18 @@ public class CollectionController : BaseApiController /// [Authorize(Policy = "RequireAdminRole")] [HttpPost("update")] - public async Task UpdateTagPromotion(CollectionTagDto updatedTag) + public async Task UpdateTag(CollectionTagDto updatedTag) { var existingTag = await _unitOfWork.CollectionTagRepository.GetTagAsync(updatedTag.Id); if (existingTag == null) return BadRequest("This tag does not exist"); + var title = updatedTag.Title.Trim(); + if (string.IsNullOrEmpty(title)) return BadRequest("Title cannot be empty"); + if (!title.Equals(existingTag.Title) && await _unitOfWork.CollectionTagRepository.TagExists(updatedTag.Title)) + return BadRequest("A tag with this name already exists"); + existingTag.Title = title; existingTag.Promoted = updatedTag.Promoted; - existingTag.Title = updatedTag.Title.Trim(); - existingTag.NormalizedTitle = Services.Tasks.Scanner.Parser.Parser.Normalize(updatedTag.Title).ToUpper(); + existingTag.NormalizedTitle = Services.Tasks.Scanner.Parser.Parser.Normalize(updatedTag.Title); existingTag.Summary = updatedTag.Summary.Trim(); if (_unitOfWork.HasChanges()) diff --git a/API/Controllers/LibraryController.cs b/API/Controllers/LibraryController.cs index 394fd7fa3..b8655322f 100644 --- a/API/Controllers/LibraryController.cs +++ b/API/Controllers/LibraryController.cs @@ -298,13 +298,15 @@ public class LibraryController : BaseApiController /// /// Checks if the library name exists or not /// - /// + /// If empty or null, will return true as that is invalid /// [Authorize(Policy = "RequireAdminRole")] [HttpGet("name-exists")] public async Task> IsLibraryNameValid(string name) { - return Ok(await _unitOfWork.LibraryRepository.LibraryExists(name.Trim())); + var trimmed = name.Trim(); + if (string.IsNullOrEmpty(trimmed)) return Ok(true); + return Ok(await _unitOfWork.LibraryRepository.LibraryExists(trimmed)); } /// diff --git a/API/Controllers/ReadingListController.cs b/API/Controllers/ReadingListController.cs index b6ee2724d..72678780c 100644 --- a/API/Controllers/ReadingListController.cs +++ b/API/Controllers/ReadingListController.cs @@ -218,22 +218,15 @@ public class ReadingListController : BaseApiController } dto.Title = dto.Title.Trim(); - if (!string.IsNullOrEmpty(dto.Title)) - { - readingList.Summary = dto.Summary; - if (!readingList.Title.Equals(dto.Title)) - { - var hasExisting = user.ReadingLists.Any(l => l.Title.Equals(dto.Title)); - if (hasExisting) - { - return BadRequest("A list of this name already exists"); - } - readingList.Title = dto.Title; - readingList.NormalizedTitle = Services.Tasks.Scanner.Parser.Parser.Normalize(readingList.Title); - } - } + if (string.IsNullOrEmpty(dto.Title)) return BadRequest("Title must be set"); + if (!dto.Title.Equals(readingList.Title) && await _unitOfWork.ReadingListRepository.ReadingListExists(dto.Title)) + return BadRequest("Reading list already exists"); + + readingList.Summary = dto.Summary; + readingList.Title = dto.Title; + readingList.NormalizedTitle = Services.Tasks.Scanner.Parser.Parser.Normalize(readingList.Title); readingList.Promoted = dto.Promoted; readingList.CoverImageLocked = dto.CoverImageLocked; @@ -246,10 +239,10 @@ public class ReadingListController : BaseApiController _unitOfWork.ReadingListRepository.Update(readingList); } - - _unitOfWork.ReadingListRepository.Update(readingList); + if (!_unitOfWork.HasChanges()) return Ok("Updated"); + if (await _unitOfWork.CommitAsync()) { return Ok("Updated"); @@ -498,4 +491,17 @@ public class ReadingListController : BaseApiController return Ok(-1); } + + /// + /// Checks if a reading list exists with the name + /// + /// If empty or null, will return true as that is invalid + /// + [Authorize(Policy = "RequireAdminRole")] + [HttpGet("name-exists")] + public async Task> DoesNameExists(string name) + { + if (string.IsNullOrEmpty(name)) return true; + return Ok(await _unitOfWork.ReadingListRepository.ReadingListExists(name)); + } } diff --git a/API/Controllers/UploadController.cs b/API/Controllers/UploadController.cs index dc4986910..3a52866e0 100644 --- a/API/Controllers/UploadController.cs +++ b/API/Controllers/UploadController.cs @@ -297,7 +297,8 @@ public class UploadController : BaseApiController try { - var filePath = _imageService.CreateThumbnailFromBase64(uploadFileDto.Url, $"{ImageService.GetLibraryFormat(uploadFileDto.Id)}"); + var filePath = _imageService.CreateThumbnailFromBase64(uploadFileDto.Url, + $"{ImageService.GetLibraryFormat(uploadFileDto.Id)}", ImageService.LibraryThumbnailWidth); if (!string.IsNullOrEmpty(filePath)) { diff --git a/API/DTOs/ReadingLists/ReadingListItemDto.cs b/API/DTOs/ReadingLists/ReadingListItemDto.cs index 39f844d8b..89be1d351 100644 --- a/API/DTOs/ReadingLists/ReadingListItemDto.cs +++ b/API/DTOs/ReadingLists/ReadingListItemDto.cs @@ -1,4 +1,5 @@ -using API.Entities.Enums; +using System; +using API.Entities.Enums; namespace API.DTOs.ReadingLists; @@ -18,6 +19,10 @@ public class ReadingListItemDto public int LibraryId { get; set; } public string Title { get; set; } /// + /// Release Date from Chapter + /// + public DateTime ReleaseDate { get; set; } + /// /// Used internally only /// public int ReadingListId { get; set; } diff --git a/API/DTOs/Settings/ServerSettingDTO.cs b/API/DTOs/Settings/ServerSettingDTO.cs index 332d06a69..9084e52e7 100644 --- a/API/DTOs/Settings/ServerSettingDTO.cs +++ b/API/DTOs/Settings/ServerSettingDTO.cs @@ -1,4 +1,5 @@ -using System.ComponentModel.DataAnnotations; +using System; +using System.ComponentModel.DataAnnotations; using API.Services; namespace API.DTOs.Settings; @@ -50,6 +51,7 @@ public class ServerSettingDto /// /// If the Swagger UI Should be exposed. Does not require authentication, but does require a JWT. /// + [Obsolete("Being removed in v0.7 in favor of dedicated hosted api")] public bool EnableSwaggerUi { get; set; } /// /// The amount of Backups before cleanup diff --git a/API/Data/Repositories/CollectionTagRepository.cs b/API/Data/Repositories/CollectionTagRepository.cs index e4fcf5e50..1c86d4826 100644 --- a/API/Data/Repositories/CollectionTagRepository.cs +++ b/API/Data/Repositories/CollectionTagRepository.cs @@ -33,6 +33,7 @@ public interface ICollectionTagRepository Task RemoveTagsWithoutSeries(); Task> GetAllTagsAsync(); Task> GetAllCoverImagesAsync(); + Task TagExists(string title); } public class CollectionTagRepository : ICollectionTagRepository { @@ -101,6 +102,13 @@ public class CollectionTagRepository : ICollectionTagRepository .ToListAsync(); } + public async Task TagExists(string title) + { + var normalized = Services.Tasks.Scanner.Parser.Parser.Normalize(title); + return await _context.CollectionTag + .AnyAsync(x => x.NormalizedTitle.Equals(normalized)); + } + public async Task> GetAllTagDtosAsync() { diff --git a/API/Data/Repositories/LibraryRepository.cs b/API/Data/Repositories/LibraryRepository.cs index 39ab5999e..04687c9f7 100644 --- a/API/Data/Repositories/LibraryRepository.cs +++ b/API/Data/Repositories/LibraryRepository.cs @@ -283,7 +283,7 @@ public class LibraryRepository : ILibraryRepository { return await _context.Library .AsNoTracking() - .AnyAsync(x => x.Name == libraryName); + .AnyAsync(x => x.Name.Equals(libraryName)); } public async Task> GetLibrariesForUserAsync(AppUser user) diff --git a/API/Data/Repositories/ReadingListRepository.cs b/API/Data/Repositories/ReadingListRepository.cs index 3401205d1..327a470fe 100644 --- a/API/Data/Repositories/ReadingListRepository.cs +++ b/API/Data/Repositories/ReadingListRepository.cs @@ -19,7 +19,6 @@ public interface IReadingListRepository Task> AddReadingProgressModifiers(int userId, IList items); Task GetReadingListDtoByTitleAsync(int userId, string title); Task> GetReadingListItemsByIdAsync(int readingListId); - Task> GetReadingListDtosForSeriesAndUserAsync(int userId, int seriesId, bool includePromoted); void Remove(ReadingListItem item); @@ -29,6 +28,7 @@ public interface IReadingListRepository Task Count(); Task GetCoverImageAsync(int readingListId); Task> GetAllCoverImagesAsync(); + Task ReadingListExists(string name); } public class ReadingListRepository : IReadingListRepository @@ -75,6 +75,13 @@ public class ReadingListRepository : IReadingListRepository .ToListAsync(); } + public async Task ReadingListExists(string name) + { + var normalized = Services.Tasks.Scanner.Parser.Parser.Normalize(name); + return await _context.ReadingList + .AnyAsync(x => x.NormalizedTitle.Equals(normalized)); + } + public void Remove(ReadingListItem item) { _context.ReadingListItem.Remove(item); @@ -137,6 +144,7 @@ public class ReadingListRepository : IReadingListRepository { TotalPages = chapter.Pages, ChapterNumber = chapter.Range, + ReleaseDate = chapter.ReleaseDate, readingListItem = data }) .Join(_context.Volume, s => s.readingListItem.VolumeId, volume => volume.Id, (data, volume) => new @@ -144,6 +152,7 @@ public class ReadingListRepository : IReadingListRepository data.readingListItem, data.TotalPages, data.ChapterNumber, + data.ReleaseDate, VolumeId = volume.Id, VolumeNumber = volume.Name, }) @@ -157,7 +166,8 @@ public class ReadingListRepository : IReadingListRepository data.TotalPages, data.ChapterNumber, data.VolumeNumber, - data.VolumeId + data.VolumeId, + data.ReleaseDate, }) .Select(data => new ReadingListItemDto() { @@ -172,7 +182,8 @@ public class ReadingListRepository : IReadingListRepository VolumeNumber = data.VolumeNumber, LibraryId = data.LibraryId, VolumeId = data.VolumeId, - ReadingListId = data.readingListItem.ReadingListId + ReadingListId = data.readingListItem.ReadingListId, + ReleaseDate = data.ReleaseDate }) .Where(o => userLibraries.Contains(o.LibraryId)) .OrderBy(rli => rli.Order) diff --git a/API/Entities/Enums/ServerSettingKey.cs b/API/Entities/Enums/ServerSettingKey.cs index 604d286ff..5c4fbd601 100644 --- a/API/Entities/Enums/ServerSettingKey.cs +++ b/API/Entities/Enums/ServerSettingKey.cs @@ -1,4 +1,5 @@ -using System.ComponentModel; +using System; +using System.ComponentModel; namespace API.Entities.Enums; @@ -85,6 +86,7 @@ public enum ServerSettingKey /// If the Swagger UI Should be exposed. Does not require authentication, but does require a JWT. /// [Description("EnableSwaggerUi")] + [Obsolete("Being removed in v0.7 in favor of dedicated hosted api")] EnableSwaggerUi = 15, /// /// Total Number of Backups to maintain before cleaning. Default 30, min 1. diff --git a/API/Services/ImageService.cs b/API/Services/ImageService.cs index 9500b43ed..b9fc252f7 100644 --- a/API/Services/ImageService.cs +++ b/API/Services/ImageService.cs @@ -17,8 +17,9 @@ public interface IImageService /// /// base64 encoded image /// + /// Width of thumbnail /// File name with extension of the file. This will always write to - string CreateThumbnailFromBase64(string encodedImage, string fileName); + string CreateThumbnailFromBase64(string encodedImage, string fileName, int thumbnailWidth = 0); string WriteCoverThumbnail(Stream stream, string fileName, string outputDirectory, bool saveAsWebP = false); /// @@ -46,6 +47,10 @@ public class ImageService : IImageService /// Width of the Thumbnail generation /// private const int ThumbnailWidth = 320; + /// + /// Width of a cover for Library + /// + public const int LibraryThumbnailWidth = 32; public ImageService(ILogger logger, IDirectoryService directoryService) { @@ -114,7 +119,6 @@ public class ImageService : IImageService var fileName = file.Name.Replace(file.Extension, string.Empty); var outputFile = Path.Join(outputPath, fileName + ".webp"); - using var sourceImage = await SixLabors.ImageSharp.Image.LoadAsync(filePath); await sourceImage.SaveAsWebpAsync(outputFile); return outputFile; @@ -139,7 +143,7 @@ public class ImageService : IImageService /// - public string CreateThumbnailFromBase64(string encodedImage, string fileName) + public string CreateThumbnailFromBase64(string encodedImage, string fileName, int thumbnailWidth = ThumbnailWidth) { try { diff --git a/API/Startup.cs b/API/Startup.cs index a22422d6a..55694a923 100644 --- a/API/Startup.cs +++ b/API/Startup.cs @@ -1,9 +1,11 @@ using System; +using System.Collections.Generic; using System.IO; using System.IO.Compression; using System.Linq; using System.Net; using System.Net.Sockets; +using System.Reflection; using System.Threading.Tasks; using API.Data; using API.Entities; @@ -103,15 +105,20 @@ public class Startup services.AddIdentityServices(_config); services.AddSwaggerGen(c => { - c.SwaggerDoc("v1", new OpenApiInfo() + c.SwaggerDoc("v1", new OpenApiInfo { + Version = BuildInfo.Version.ToString(), + Title = "Kavita", Description = "Kavita provides a set of APIs that are authenticated by JWT. JWT token can be copied from local storage.", - Title = "Kavita API", - Version = "v1", + License = new OpenApiLicense + { + Name = "GPL-3.0", + Url = new Uri("https://github.com/Kareadita/Kavita/blob/develop/LICENSE") + } }); - - var filePath = Path.Combine(AppContext.BaseDirectory, "API.xml"); + var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; + var filePath = Path.Combine(AppContext.BaseDirectory, xmlFile); c.IncludeXmlComments(filePath, true); c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme { In = ParameterLocation.Header, @@ -119,6 +126,7 @@ public class Startup Name = "Authorization", Type = SecuritySchemeType.ApiKey }); + c.AddSecurityRequirement(new OpenApiSecurityRequirement { { new OpenApiSecurityScheme @@ -133,30 +141,15 @@ public class Startup } }); - c.AddServer(new OpenApiServer() + c.AddServer(new OpenApiServer { - Description = "Custom Url", - Url = "/" + Url = "{protocol}://{hostpath}", + Variables = new Dictionary + { + { "protocol", new OpenApiServerVariable { Default = "http", Enum = new List { "http", "https" } } }, + { "hostpath", new OpenApiServerVariable { Default = "localhost:5000" } } + } }); - - c.AddServer(new OpenApiServer() - { - Description = "Local Server", - Url = "http://localhost:5000/", - }); - - c.AddServer(new OpenApiServer() - { - Url = "https://demo.kavitareader.com/", - Description = "Kavita Demo" - }); - - c.AddServer(new OpenApiServer() - { - Url = "http://" + GetLocalIpAddress() + ":5000/", - Description = "Local IP" - }); - }); services.AddResponseCompression(options => { @@ -256,6 +249,7 @@ public class Startup { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Kavita API " + BuildInfo.Version); }); + } }); diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7e1fae0be..4d81e02a9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,8 +12,9 @@ Setup guides, FAQ, the more information we have on the [wiki](https://wiki.kavit - Rider (optional to Visual Studio) (https://www.jetbrains.com/rider/) - HTML/Javascript editor of choice (VS Code/Sublime Text/Webstorm/Atom/etc) - [Git](https://git-scm.com/downloads) -- [NodeJS](https://nodejs.org/en/download/) (Node 14.X.X or higher) -- .NET 5.0+ +- [NodeJS](https://nodejs.org/en/download/) (Node 16.X.X or higher) +- .NET 6.0+ +- dotnet tool install -g --version 6.4.0 Swashbuckle.AspNetCore.Cli ### Getting started ### @@ -47,8 +48,8 @@ Setup guides, FAQ, the more information we have on the [wiki](https://wiki.kavit - You're probably going to get some comments or questions from us, they will be to ensure consistency and maintainability - We'll try to respond to pull requests as soon as possible, if its been a day or two, please reach out to us, we may have missed it - Each PR should come from its own [feature branch](http://martinfowler.com/bliki/FeatureBranch.html) not develop in your fork, it should have a meaningful branch name (what is being added/fixed) - - new-feature (Good) - - fix-bug (Good) + - new-feature (Bad) + - fix-bug (Bad) - patch (Bad) - develop (Bad) - feature/parser-enhancements (Great) diff --git a/UI/Web/src/app/_models/reading-list.ts b/UI/Web/src/app/_models/reading-list.ts index 3a1dd7297..54ba3ec8a 100644 --- a/UI/Web/src/app/_models/reading-list.ts +++ b/UI/Web/src/app/_models/reading-list.ts @@ -12,6 +12,7 @@ export interface ReadingListItem { volumeNumber: string; libraryId: number; id: number; + releaseDate: string; } export interface ReadingList { diff --git a/UI/Web/src/app/_services/collection-tag.service.ts b/UI/Web/src/app/_services/collection-tag.service.ts index 6c58753c3..b53f4d5b7 100644 --- a/UI/Web/src/app/_services/collection-tag.service.ts +++ b/UI/Web/src/app/_services/collection-tag.service.ts @@ -36,4 +36,8 @@ export class CollectionTagService { addByMultiple(tagId: number, seriesIds: Array, tagTitle: string = '') { return this.httpClient.post(this.baseUrl + 'collection/update-for-series', {collectionTagId: tagId, collectionTagTitle: tagTitle, seriesIds}, {responseType: 'text' as 'json'}); } + + tagNameExists(name: string) { + return this.httpClient.get(this.baseUrl + 'collection/name-exists?name=' + name); + } } diff --git a/UI/Web/src/app/_services/reading-list.service.ts b/UI/Web/src/app/_services/reading-list.service.ts index dae0708b6..486c51f0f 100644 --- a/UI/Web/src/app/_services/reading-list.service.ts +++ b/UI/Web/src/app/_services/reading-list.service.ts @@ -87,4 +87,8 @@ export class ReadingListService { if (readingList?.promoted && !isAdmin) return false; return true; } + + nameExists(name: string) { + return this.httpClient.get(this.baseUrl + 'readinglist/name-exists?name=' + name); + } } diff --git a/UI/Web/src/app/cards/_modals/edit-collection-tags/edit-collection-tags.component.html b/UI/Web/src/app/cards/_modals/edit-collection-tags/edit-collection-tags.component.html index 5d90fe9cd..ec8c1a170 100644 --- a/UI/Web/src/app/cards/_modals/edit-collection-tags/edit-collection-tags.component.html +++ b/UI/Web/src/app/cards/_modals/edit-collection-tags/edit-collection-tags.component.html @@ -3,22 +3,50 @@ -
-
- +
diff --git a/UI/Web/src/app/cards/_modals/edit-collection-tags/edit-collection-tags.component.scss b/UI/Web/src/app/cards/_modals/edit-collection-tags/edit-collection-tags.component.scss index e69de29bb..3fd15f534 100644 --- a/UI/Web/src/app/cards/_modals/edit-collection-tags/edit-collection-tags.component.scss +++ b/UI/Web/src/app/cards/_modals/edit-collection-tags/edit-collection-tags.component.scss @@ -0,0 +1,3 @@ +.form-switch { + margin-top: 2.4rem; +} \ No newline at end of file diff --git a/UI/Web/src/app/cards/_modals/edit-collection-tags/edit-collection-tags.component.ts b/UI/Web/src/app/cards/_modals/edit-collection-tags/edit-collection-tags.component.ts index ee084dce4..b94427051 100644 --- a/UI/Web/src/app/cards/_modals/edit-collection-tags/edit-collection-tags.component.ts +++ b/UI/Web/src/app/cards/_modals/edit-collection-tags/edit-collection-tags.component.ts @@ -1,8 +1,8 @@ -import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit } from '@angular/core'; -import { FormControl, FormGroup } from '@angular/forms'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnDestroy, OnInit } from '@angular/core'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { ToastrService } from 'ngx-toastr'; -import { forkJoin } from 'rxjs'; +import { debounceTime, distinctUntilChanged, forkJoin, Subject, switchMap, takeUntil, tap } from 'rxjs'; import { ConfirmService } from 'src/app/shared/confirm.service'; import { Breakpoint, UtilityService } from 'src/app/shared/_services/utility.service'; import { SelectionModel } from 'src/app/typeahead/typeahead.component'; @@ -17,8 +17,9 @@ import { UploadService } from 'src/app/_services/upload.service'; enum TabID { - General = 0, - CoverImage = 1, + General = 'General', + CoverImage = 'Cover Image', + Series = 'Series' } @Component({ @@ -27,7 +28,7 @@ enum TabID { styleUrls: ['./edit-collection-tags.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush }) -export class EditCollectionTagsComponent implements OnInit { +export class EditCollectionTagsComponent implements OnInit, OnDestroy { @Input() tag!: CollectionTag; series: Array = []; @@ -38,11 +39,12 @@ export class EditCollectionTagsComponent implements OnInit { selectAll: boolean = true; libraryNames!: any; collectionTagForm!: FormGroup; - tabs = [{title: 'General', id: TabID.General}, {title: 'Cover Image', id: TabID.CoverImage}]; active = TabID.General; imageUrls: Array = []; selectedCover: string = ''; + private readonly onDestroy = new Subject(); + get hasSomeSelected() { return this.selections != null && this.selections.hasSomeSelected(); } @@ -66,15 +68,38 @@ export class EditCollectionTagsComponent implements OnInit { this.pagination = {totalPages: 1, totalItems: 200, itemsPerPage: 200, currentPage: 0}; } this.collectionTagForm = new FormGroup({ - summary: new FormControl(this.tag.summary, []), - coverImageLocked: new FormControl(this.tag.coverImageLocked, []), - coverImageIndex: new FormControl(0, []), - + title: new FormControl(this.tag.title, { nonNullable: true, validators: [Validators.required] }), + summary: new FormControl(this.tag.summary, { nonNullable: true, validators: [] }), + coverImageLocked: new FormControl(this.tag.coverImageLocked, { nonNullable: true, validators: [] }), + coverImageIndex: new FormControl(0, { nonNullable: true, validators: [] }), + promoted: new FormControl(this.tag.promoted, { nonNullable: true, validators: [] }), }); + + this.collectionTagForm.get('title')?.valueChanges.pipe( + debounceTime(100), + distinctUntilChanged(), + switchMap(name => this.collectionService.tagNameExists(name)), + tap(exists => { + const isExistingName = this.collectionTagForm.get('title')?.value === this.tag.title; + if (!exists || isExistingName) { + this.collectionTagForm.get('title')?.setErrors(null); + } else { + this.collectionTagForm.get('title')?.setErrors({duplicateName: true}) + } + this.cdRef.markForCheck(); + }), + takeUntil(this.onDestroy) + ).subscribe(); + this.imageUrls.push(this.imageService.randomize(this.imageService.getCollectionCoverImage(this.tag.id))); this.loadSeries(); } + ngOnDestroy() { + this.onDestroy.next(); + this.onDestroy.complete(); + } + onPageChange(pageNum: number) { this.pagination.currentPage = pageNum; this.loadSeries(); @@ -83,6 +108,7 @@ export class EditCollectionTagsComponent implements OnInit { toggleAll() { this.selectAll = !this.selectAll; this.series.forEach(s => this.selections.toggle(s, this.selectAll)); + this.cdRef.markForCheck(); } loadSeries() { @@ -91,9 +117,9 @@ export class EditCollectionTagsComponent implements OnInit { this.libraryService.getLibraryNames() ]).subscribe(results => { const series = results[0]; - this.pagination = series.pagination; this.series = series.result; + this.imageUrls.push(...this.series.map(s => this.imageService.getSeriesCoverImage(s.id))); this.selections = new SelectionModel(true, this.series); this.isLoading = false; @@ -114,18 +140,6 @@ export class EditCollectionTagsComponent implements OnInit { this.cdRef.markForCheck(); } - togglePromotion() { - const originalPromotion = this.tag.promoted; - this.tag.promoted = !this.tag.promoted; - this.cdRef.markForCheck(); - this.collectionService.updateTag(this.tag).subscribe(res => { - this.toastr.success('Tag updated successfully'); - }, err => { - this.tag.promoted = originalPromotion; - this.cdRef.markForCheck(); - }); - } - libraryName(libraryId: number) { return this.libraryNames[libraryId]; } @@ -140,12 +154,13 @@ export class EditCollectionTagsComponent implements OnInit { const tag: CollectionTag = {...this.tag}; tag.summary = this.collectionTagForm.get('summary')?.value; tag.coverImageLocked = this.collectionTagForm.get('coverImageLocked')?.value; + tag.promoted = this.collectionTagForm.get('promoted')?.value; if (unselectedIds.length == this.series.length && !await this.confirmSerivce.confirm('Warning! No series are selected, saving will delete the tag. Are you sure you want to continue?')) { return; } - const apis = [this.collectionService.updateTag(this.tag), + const apis = [this.collectionService.updateTag(tag), this.collectionService.updateSeriesForTag(tag, this.selections.unselected().map(s => s.id)) ]; @@ -153,7 +168,7 @@ export class EditCollectionTagsComponent implements OnInit { apis.push(this.uploadService.updateCollectionCoverImage(this.tag.id, this.selectedCover)); } - forkJoin(apis).subscribe(results => { + forkJoin(apis).subscribe(() => { this.modal.close({success: true, coverImageUpdated: selectedIndex > 0}); this.toastr.success('Tag updated'); }); diff --git a/UI/Web/src/app/cards/card-item/card-item.component.scss b/UI/Web/src/app/cards/card-item/card-item.component.scss index acaf835c4..cd3b100cf 100644 --- a/UI/Web/src/app/cards/card-item/card-item.component.scss +++ b/UI/Web/src/app/cards/card-item/card-item.component.scss @@ -1,6 +1,5 @@ -$triangle-size: 30px; $image-height: 230px; $image-width: 160px; @@ -75,7 +74,7 @@ $image-width: 160px; width: 0; height: 0; border-style: solid; - border-width: 0 $triangle-size $triangle-size 0; + border-width: 0 var(--card-progress-triangle-size) var(--card-progress-triangle-size) 0; border-color: transparent var(--primary-color) transparent transparent; } diff --git a/UI/Web/src/app/cards/list-item/list-item.component.html b/UI/Web/src/app/cards/list-item/list-item.component.html index bba132ad4..391acd274 100644 --- a/UI/Web/src/app/cards/list-item/list-item.component.html +++ b/UI/Web/src/app/cards/list-item/list-item.component.html @@ -11,7 +11,7 @@
-
+
-