From 1856b01a46df91b1b813c616e080ccafb489a546 Mon Sep 17 00:00:00 2001 From: Fesaa <77553571+Fesaa@users.noreply.github.com> Date: Sun, 8 Jun 2025 16:16:44 +0200 Subject: [PATCH] Reading Profiles (#3845) Co-authored-by: Joseph Milazzo --- API.Tests/Helpers/RandfHelper.cs | 124 + .../Services/ReadingProfileServiceTest.cs | 561 +++ API/Controllers/AccountController.cs | 18 +- API/Controllers/PluginController.cs | 2 +- API/Controllers/ReadingProfileController.cs | 198 + API/Controllers/UsersController.cs | 26 - API/DTOs/UserPreferencesDto.cs | 74 - API/DTOs/UserReadingProfileDto.cs | 129 + API/Data/DataContext.cs | 27 + .../v0.8.7/ManualMigrateReadingProfiles.cs | 84 + ...20250601200056_ReadingProfiles.Designer.cs | 3698 +++++++++++++++++ .../20250601200056_ReadingProfiles.cs | 75 + .../Migrations/DataContextModelSnapshot.cs | 127 + .../AppUserReadingProfileRepository.cs | 112 + API/Data/Repositories/GenreRepository.cs | 2 +- API/Data/Repositories/UserRepository.cs | 2 +- API/Data/UnitOfWork.cs | 3 + API/Entities/AppUser.cs | 1 + API/Entities/AppUserPreferences.cs | 3 +- API/Entities/AppUserReadingProfile.cs | 143 + API/Entities/Enums/ReadingProfileKind.cs | 17 + .../ApplicationServiceExtensions.cs | 1 + API/Helpers/AutoMapperProfiles.cs | 9 +- API/Helpers/Builders/AppUserBuilder.cs | 5 +- .../Builders/AppUserReadingProfileBuilder.cs | 54 + API/I18N/en.json | 4 +- API/Services/Plus/ScrobblingService.cs | 22 +- API/Services/ReadingProfileService.cs | 453 ++ API/Startup.cs | 3 + Kavita.Common/Configuration.cs | 2 +- .../src/app/_models/preferences/book-theme.ts | 4 +- .../app/_models/preferences/preferences.ts | 52 - .../_models/preferences/reading-profiles.ts | 77 + .../_resolvers/reading-profile.resolver.ts | 18 + .../app/_routes/book-reader.router.module.ts | 8 +- .../app/_routes/manga-reader.router.module.ts | 15 +- .../app/_routes/pdf-reader.router.module.ts | 8 +- .../app/_services/action-factory.service.ts | 80 +- UI/Web/src/app/_services/action.service.ts | 55 + .../app/_services/reading-profile.service.ts | 70 + .../manage-media-settings.component.ts | 2 +- .../book-reader/book-reader.component.html | 2 + .../book-reader/book-reader.component.ts | 39 +- .../reader-settings.component.html | 278 +- .../reader-settings.component.ts | 359 +- .../book-reader/_models/book-paper-theme.ts | 3 + .../book-reader/_models/book-white-theme.ts | 1 + ...k-set-reading-profile-modal.component.html | 56 + ...k-set-reading-profile-modal.component.scss | 14 + ...ulk-set-reading-profile-modal.component.ts | 120 + .../src/app/cards/bulk-selection.service.ts | 2 +- .../series-card/series-card.component.ts | 13 +- .../library-detail.component.ts | 8 + .../manga-reader/manga-reader.component.html | 13 +- .../manga-reader/manga-reader.component.ts | 330 +- .../pdf-reader/pdf-reader.component.ts | 27 +- .../series-detail/series-detail.component.ts | 10 + .../settings/settings.component.html | 9 + .../settings/settings.component.ts | 72 +- .../side-nav/side-nav.component.ts | 15 +- .../preference-nav.component.ts | 2 + .../manage-reading-profiles.component.html | 509 +++ .../manage-reading-profiles.component.scss | 38 + .../manage-reading-profiles.component.ts | 319 ++ .../manage-user-preferences.component.html | 376 -- .../manage-user-preferences.component.ts | 100 +- UI/Web/src/assets/langs/en.json | 194 +- 67 files changed, 8118 insertions(+), 1159 deletions(-) create mode 100644 API.Tests/Helpers/RandfHelper.cs create mode 100644 API.Tests/Services/ReadingProfileServiceTest.cs create mode 100644 API/Controllers/ReadingProfileController.cs create mode 100644 API/DTOs/UserReadingProfileDto.cs create mode 100644 API/Data/ManualMigrations/v0.8.7/ManualMigrateReadingProfiles.cs create mode 100644 API/Data/Migrations/20250601200056_ReadingProfiles.Designer.cs create mode 100644 API/Data/Migrations/20250601200056_ReadingProfiles.cs create mode 100644 API/Data/Repositories/AppUserReadingProfileRepository.cs create mode 100644 API/Entities/AppUserReadingProfile.cs create mode 100644 API/Entities/Enums/ReadingProfileKind.cs create mode 100644 API/Helpers/Builders/AppUserReadingProfileBuilder.cs create mode 100644 API/Services/ReadingProfileService.cs create mode 100644 UI/Web/src/app/_models/preferences/reading-profiles.ts create mode 100644 UI/Web/src/app/_resolvers/reading-profile.resolver.ts create mode 100644 UI/Web/src/app/_services/reading-profile.service.ts create mode 100644 UI/Web/src/app/cards/_modals/bulk-set-reading-profile-modal/bulk-set-reading-profile-modal.component.html create mode 100644 UI/Web/src/app/cards/_modals/bulk-set-reading-profile-modal/bulk-set-reading-profile-modal.component.scss create mode 100644 UI/Web/src/app/cards/_modals/bulk-set-reading-profile-modal/bulk-set-reading-profile-modal.component.ts create mode 100644 UI/Web/src/app/user-settings/manage-reading-profiles/manage-reading-profiles.component.html create mode 100644 UI/Web/src/app/user-settings/manage-reading-profiles/manage-reading-profiles.component.scss create mode 100644 UI/Web/src/app/user-settings/manage-reading-profiles/manage-reading-profiles.component.ts diff --git a/API.Tests/Helpers/RandfHelper.cs b/API.Tests/Helpers/RandfHelper.cs new file mode 100644 index 000000000..d8c007df7 --- /dev/null +++ b/API.Tests/Helpers/RandfHelper.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace API.Tests.Helpers; + +public class RandfHelper +{ + private static readonly Random Random = new (); + + /// + /// Returns true if all simple fields are equal + /// + /// + /// + /// fields to ignore, note that the names are very weird sometimes + /// + /// + /// + public static bool AreSimpleFieldsEqual(object obj1, object obj2, IList ignoreFields) + { + if (obj1 == null || obj2 == null) + throw new ArgumentNullException("Neither object can be null."); + + Type type1 = obj1.GetType(); + Type type2 = obj2.GetType(); + + if (type1 != type2) + throw new ArgumentException("Objects must be of the same type."); + + FieldInfo[] fields = type1.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic); + + foreach (var field in fields) + { + if (field.IsInitOnly) continue; + if (ignoreFields.Contains(field.Name)) continue; + + Type fieldType = field.FieldType; + + if (IsRelevantType(fieldType)) + { + object value1 = field.GetValue(obj1); + object value2 = field.GetValue(obj2); + + if (!Equals(value1, value2)) + { + throw new ArgumentException("Fields must be of the same type: " + field.Name + " was " + value1 + " and " + value2); + } + } + } + + return true; + } + + private static bool IsRelevantType(Type type) + { + return type.IsPrimitive + || type == typeof(string) + || type.IsEnum; + } + + /// + /// Sets all simple fields of the given object to a random value + /// + /// + /// Simple is, primitive, string, or enum + /// + public static void SetRandomValues(object obj) + { + if (obj == null) throw new ArgumentNullException(nameof(obj)); + + Type type = obj.GetType(); + FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + foreach (var field in fields) + { + if (field.IsInitOnly) continue; // Skip readonly fields + + object value = GenerateRandomValue(field.FieldType); + if (value != null) + { + field.SetValue(obj, value); + } + } + } + + private static object GenerateRandomValue(Type type) + { + if (type == typeof(int)) + return Random.Next(); + if (type == typeof(float)) + return (float)Random.NextDouble() * 100; + if (type == typeof(double)) + return Random.NextDouble() * 100; + if (type == typeof(bool)) + return Random.Next(2) == 1; + if (type == typeof(char)) + return (char)Random.Next('A', 'Z' + 1); + if (type == typeof(byte)) + return (byte)Random.Next(0, 256); + if (type == typeof(short)) + return (short)Random.Next(short.MinValue, short.MaxValue); + if (type == typeof(long)) + return (long)(Random.NextDouble() * long.MaxValue); + if (type == typeof(string)) + return GenerateRandomString(10); + if (type.IsEnum) + { + var values = Enum.GetValues(type); + return values.GetValue(Random.Next(values.Length)); + } + + // Unsupported type + return null; + } + + private static string GenerateRandomString(int length) + { + const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + return new string(Enumerable.Repeat(chars, length) + .Select(s => s[Random.Next(s.Length)]).ToArray()); + } +} diff --git a/API.Tests/Services/ReadingProfileServiceTest.cs b/API.Tests/Services/ReadingProfileServiceTest.cs new file mode 100644 index 000000000..b3d81e5ac --- /dev/null +++ b/API.Tests/Services/ReadingProfileServiceTest.cs @@ -0,0 +1,561 @@ +using System.Linq; +using System.Threading.Tasks; +using API.Data.Repositories; +using API.DTOs; +using API.Entities; +using API.Entities.Enums; +using API.Helpers.Builders; +using API.Services; +using API.Tests.Helpers; +using Kavita.Common; +using Microsoft.EntityFrameworkCore; +using NSubstitute; +using Xunit; + +namespace API.Tests.Services; + +public class ReadingProfileServiceTest: AbstractDbTest +{ + + /// + /// Does not add a default reading profile + /// + /// + public async Task<(ReadingProfileService, AppUser, Library, Series)> Setup() + { + var user = new AppUserBuilder("amelia", "amelia@localhost").Build(); + Context.AppUser.Add(user); + await UnitOfWork.CommitAsync(); + + var series = new SeriesBuilder("Spice and Wolf").Build(); + + var library = new LibraryBuilder("Manga") + .WithSeries(series) + .Build(); + + user.Libraries.Add(library); + await UnitOfWork.CommitAsync(); + + var rps = new ReadingProfileService(UnitOfWork, Substitute.For(), Mapper); + user = await UnitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.UserPreferences); + + return (rps, user, library, series); + } + + [Fact] + public async Task ImplicitProfileFirst() + { + await ResetDb(); + var (rps, user, library, series) = await Setup(); + + var profile = new AppUserReadingProfileBuilder(user.Id) + .WithKind(ReadingProfileKind.Implicit) + .WithSeries(series) + .WithName("Implicit Profile") + .Build(); + + var profile2 = new AppUserReadingProfileBuilder(user.Id) + .WithSeries(series) + .WithName("Non-implicit Profile") + .Build(); + + user.ReadingProfiles.Add(profile); + user.ReadingProfiles.Add(profile2); + await UnitOfWork.CommitAsync(); + + var seriesProfile = await rps.GetReadingProfileDtoForSeries(user.Id, series.Id); + Assert.NotNull(seriesProfile); + Assert.Equal("Implicit Profile", seriesProfile.Name); + + // Find parent + seriesProfile = await rps.GetReadingProfileDtoForSeries(user.Id, series.Id, true); + Assert.NotNull(seriesProfile); + Assert.Equal("Non-implicit Profile", seriesProfile.Name); + } + + [Fact] + public async Task CantDeleteDefaultReadingProfile() + { + await ResetDb(); + var (rps, user, _, _) = await Setup(); + + var profile = new AppUserReadingProfileBuilder(user.Id) + .WithKind(ReadingProfileKind.Default) + .Build(); + Context.AppUserReadingProfiles.Add(profile); + await UnitOfWork.CommitAsync(); + + await Assert.ThrowsAsync(async () => + { + await rps.DeleteReadingProfile(user.Id, profile.Id); + }); + + var profile2 = new AppUserReadingProfileBuilder(user.Id).Build(); + Context.AppUserReadingProfiles.Add(profile2); + await UnitOfWork.CommitAsync(); + + await rps.DeleteReadingProfile(user.Id, profile2.Id); + await UnitOfWork.CommitAsync(); + + var allProfiles = await Context.AppUserReadingProfiles.ToListAsync(); + Assert.Single(allProfiles); + } + + [Fact] + public async Task CreateImplicitSeriesReadingProfile() + { + await ResetDb(); + var (rps, user, _, series) = await Setup(); + + var dto = new UserReadingProfileDto + { + ReaderMode = ReaderMode.Webtoon, + ScalingOption = ScalingOption.FitToHeight, + WidthOverride = 53, + }; + + await rps.UpdateImplicitReadingProfile(user.Id, series.Id, dto); + + var profile = await rps.GetReadingProfileForSeries(user.Id, series.Id); + Assert.NotNull(profile); + Assert.Contains(profile.SeriesIds, s => s == series.Id); + Assert.Equal(ReadingProfileKind.Implicit, profile.Kind); + } + + [Fact] + public async Task UpdateImplicitReadingProfile_DoesNotCreateNew() + { + await ResetDb(); + var (rps, user, _, series) = await Setup(); + + var dto = new UserReadingProfileDto + { + ReaderMode = ReaderMode.Webtoon, + ScalingOption = ScalingOption.FitToHeight, + WidthOverride = 53, + }; + + await rps.UpdateImplicitReadingProfile(user.Id, series.Id, dto); + + var profile = await rps.GetReadingProfileForSeries(user.Id, series.Id); + Assert.NotNull(profile); + Assert.Contains(profile.SeriesIds, s => s == series.Id); + Assert.Equal(ReadingProfileKind.Implicit, profile.Kind); + + dto = new UserReadingProfileDto + { + ReaderMode = ReaderMode.LeftRight, + }; + + await rps.UpdateImplicitReadingProfile(user.Id, series.Id, dto); + profile = await rps.GetReadingProfileForSeries(user.Id, series.Id); + Assert.NotNull(profile); + Assert.Contains(profile.SeriesIds, s => s == series.Id); + Assert.Equal(ReadingProfileKind.Implicit, profile.Kind); + Assert.Equal(ReaderMode.LeftRight, profile.ReaderMode); + + var implicitCount = await Context.AppUserReadingProfiles + .Where(p => p.Kind == ReadingProfileKind.Implicit) + .CountAsync(); + Assert.Equal(1, implicitCount); + } + + [Fact] + public async Task GetCorrectProfile() + { + await ResetDb(); + var (rps, user, lib, series) = await Setup(); + + var profile = new AppUserReadingProfileBuilder(user.Id) + .WithSeries(series) + .WithName("Series Specific") + .Build(); + var profile2 = new AppUserReadingProfileBuilder(user.Id) + .WithLibrary(lib) + .WithName("Library Specific") + .Build(); + var profile3 = new AppUserReadingProfileBuilder(user.Id) + .WithKind(ReadingProfileKind.Default) + .WithName("Global") + .Build(); + Context.AppUserReadingProfiles.Add(profile); + Context.AppUserReadingProfiles.Add(profile2); + Context.AppUserReadingProfiles.Add(profile3); + + var series2 = new SeriesBuilder("Rainbows After Storms").Build(); + lib.Series.Add(series2); + + var lib2 = new LibraryBuilder("Manga2").Build(); + var series3 = new SeriesBuilder("A Tropical Fish Yearns for Snow").Build(); + lib2.Series.Add(series3); + + user.Libraries.Add(lib2); + await UnitOfWork.CommitAsync(); + + var p = await rps.GetReadingProfileDtoForSeries(user.Id, series.Id); + Assert.NotNull(p); + Assert.Equal("Series Specific", p.Name); + + p = await rps.GetReadingProfileDtoForSeries(user.Id, series2.Id); + Assert.NotNull(p); + Assert.Equal("Library Specific", p.Name); + + p = await rps.GetReadingProfileDtoForSeries(user.Id, series3.Id); + Assert.NotNull(p); + Assert.Equal("Global", p.Name); + } + + [Fact] + public async Task ReplaceReadingProfile() + { + await ResetDb(); + var (rps, user, lib, series) = await Setup(); + + var profile1 = new AppUserReadingProfileBuilder(user.Id) + .WithSeries(series) + .WithName("Profile 1") + .Build(); + + var profile2 = new AppUserReadingProfileBuilder(user.Id) + .WithName("Profile 2") + .Build(); + + Context.AppUserReadingProfiles.Add(profile1); + Context.AppUserReadingProfiles.Add(profile2); + await UnitOfWork.CommitAsync(); + + var profile = await rps.GetReadingProfileDtoForSeries(user.Id, series.Id); + Assert.NotNull(profile); + Assert.Equal("Profile 1", profile.Name); + + await rps.AddProfileToSeries(user.Id, profile2.Id, series.Id); + profile = await rps.GetReadingProfileDtoForSeries(user.Id, series.Id); + Assert.NotNull(profile); + Assert.Equal("Profile 2", profile.Name); + } + + [Fact] + public async Task DeleteReadingProfile() + { + await ResetDb(); + var (rps, user, lib, series) = await Setup(); + + var profile1 = new AppUserReadingProfileBuilder(user.Id) + .WithSeries(series) + .WithName("Profile 1") + .Build(); + + Context.AppUserReadingProfiles.Add(profile1); + await UnitOfWork.CommitAsync(); + + await rps.ClearSeriesProfile(user.Id, series.Id); + var profiles = await UnitOfWork.AppUserReadingProfileRepository.GetProfilesForUser(user.Id); + Assert.DoesNotContain(profiles, rp => rp.SeriesIds.Contains(series.Id)); + + } + + [Fact] + public async Task BulkAddReadingProfiles() + { + await ResetDb(); + var (rps, user, lib, series) = await Setup(); + + for (var i = 0; i < 10; i++) + { + var generatedSeries = new SeriesBuilder($"Generated Series #{i}").Build(); + lib.Series.Add(generatedSeries); + } + + var profile = new AppUserReadingProfileBuilder(user.Id) + .WithSeries(series) + .WithName("Profile") + .Build(); + Context.AppUserReadingProfiles.Add(profile); + + var profile2 = new AppUserReadingProfileBuilder(user.Id) + .WithSeries(series) + .WithName("Profile2") + .Build(); + Context.AppUserReadingProfiles.Add(profile2); + + await UnitOfWork.CommitAsync(); + + var someSeriesIds = lib.Series.Take(lib.Series.Count / 2).Select(s => s.Id).ToList(); + await rps.BulkAddProfileToSeries(user.Id, profile.Id, someSeriesIds); + + foreach (var id in someSeriesIds) + { + var foundProfile = await rps.GetReadingProfileDtoForSeries(user.Id, id); + Assert.NotNull(foundProfile); + Assert.Equal(profile.Id, foundProfile.Id); + } + + var allIds = lib.Series.Select(s => s.Id).ToList(); + await rps.BulkAddProfileToSeries(user.Id, profile2.Id, allIds); + + foreach (var id in allIds) + { + var foundProfile = await rps.GetReadingProfileDtoForSeries(user.Id, id); + Assert.NotNull(foundProfile); + Assert.Equal(profile2.Id, foundProfile.Id); + } + + + } + + [Fact] + public async Task BulkAssignDeletesImplicit() + { + await ResetDb(); + var (rps, user, lib, series) = await Setup(); + + var implicitProfile = Mapper.Map(new AppUserReadingProfileBuilder(user.Id) + .Build()); + + var profile = new AppUserReadingProfileBuilder(user.Id) + .WithName("Profile 1") + .Build(); + Context.AppUserReadingProfiles.Add(profile); + + for (var i = 0; i < 10; i++) + { + var generatedSeries = new SeriesBuilder($"Generated Series #{i}").Build(); + lib.Series.Add(generatedSeries); + } + await UnitOfWork.CommitAsync(); + + var ids = lib.Series.Select(s => s.Id).ToList(); + + foreach (var id in ids) + { + await rps.UpdateImplicitReadingProfile(user.Id, id, implicitProfile); + var seriesProfile = await rps.GetReadingProfileDtoForSeries(user.Id, id); + Assert.NotNull(seriesProfile); + Assert.Equal(ReadingProfileKind.Implicit, seriesProfile.Kind); + } + + await rps.BulkAddProfileToSeries(user.Id, profile.Id, ids); + + foreach (var id in ids) + { + var seriesProfile = await rps.GetReadingProfileDtoForSeries(user.Id, id); + Assert.NotNull(seriesProfile); + Assert.Equal(ReadingProfileKind.User, seriesProfile.Kind); + } + + var implicitCount = await Context.AppUserReadingProfiles + .Where(p => p.Kind == ReadingProfileKind.Implicit) + .CountAsync(); + Assert.Equal(0, implicitCount); + } + + [Fact] + public async Task AddDeletesImplicit() + { + await ResetDb(); + var (rps, user, lib, series) = await Setup(); + + var implicitProfile = Mapper.Map(new AppUserReadingProfileBuilder(user.Id) + .WithKind(ReadingProfileKind.Implicit) + .Build()); + + var profile = new AppUserReadingProfileBuilder(user.Id) + .WithName("Profile 1") + .Build(); + Context.AppUserReadingProfiles.Add(profile); + await UnitOfWork.CommitAsync(); + + await rps.UpdateImplicitReadingProfile(user.Id, series.Id, implicitProfile); + + var seriesProfile = await rps.GetReadingProfileDtoForSeries(user.Id, series.Id); + Assert.NotNull(seriesProfile); + Assert.Equal(ReadingProfileKind.Implicit, seriesProfile.Kind); + + await rps.AddProfileToSeries(user.Id, profile.Id, series.Id); + + seriesProfile = await rps.GetReadingProfileDtoForSeries(user.Id, series.Id); + Assert.NotNull(seriesProfile); + Assert.Equal(ReadingProfileKind.User, seriesProfile.Kind); + + var implicitCount = await Context.AppUserReadingProfiles + .Where(p => p.Kind == ReadingProfileKind.Implicit) + .CountAsync(); + Assert.Equal(0, implicitCount); + } + + [Fact] + public async Task CreateReadingProfile() + { + await ResetDb(); + var (rps, user, lib, series) = await Setup(); + + var dto = new UserReadingProfileDto + { + Name = "Profile 1", + ReaderMode = ReaderMode.LeftRight, + EmulateBook = false, + }; + + await rps.CreateReadingProfile(user.Id, dto); + + var dto2 = new UserReadingProfileDto + { + Name = "Profile 2", + ReaderMode = ReaderMode.LeftRight, + EmulateBook = false, + }; + + await rps.CreateReadingProfile(user.Id, dto2); + + var dto3 = new UserReadingProfileDto + { + Name = "Profile 1", // Not unique name + ReaderMode = ReaderMode.LeftRight, + EmulateBook = false, + }; + + await Assert.ThrowsAsync(async () => + { + await rps.CreateReadingProfile(user.Id, dto3); + }); + + var allProfiles = Context.AppUserReadingProfiles.ToList(); + Assert.Equal(2, allProfiles.Count); + } + + [Fact] + public async Task ClearSeriesProfile_RemovesImplicitAndUnlinksExplicit() + { + await ResetDb(); + var (rps, user, _, series) = await Setup(); + + var implicitProfile = new AppUserReadingProfileBuilder(user.Id) + .WithSeries(series) + .WithKind(ReadingProfileKind.Implicit) + .WithName("Implicit Profile") + .Build(); + + var explicitProfile = new AppUserReadingProfileBuilder(user.Id) + .WithSeries(series) + .WithName("Explicit Profile") + .Build(); + + Context.AppUserReadingProfiles.Add(implicitProfile); + Context.AppUserReadingProfiles.Add(explicitProfile); + await UnitOfWork.CommitAsync(); + + var allBefore = await UnitOfWork.AppUserReadingProfileRepository.GetProfilesForUser(user.Id); + Assert.Equal(2, allBefore.Count(rp => rp.SeriesIds.Contains(series.Id))); + + await rps.ClearSeriesProfile(user.Id, series.Id); + + var remainingProfiles = await Context.AppUserReadingProfiles.ToListAsync(); + Assert.Single(remainingProfiles); + Assert.Equal("Explicit Profile", remainingProfiles[0].Name); + Assert.Empty(remainingProfiles[0].SeriesIds); + + var profilesForSeries = await UnitOfWork.AppUserReadingProfileRepository.GetProfilesForUser(user.Id); + Assert.DoesNotContain(profilesForSeries, rp => rp.SeriesIds.Contains(series.Id)); + } + + [Fact] + public async Task AddProfileToLibrary_AddsAndOverridesExisting() + { + await ResetDb(); + var (rps, user, lib, _) = await Setup(); + + var profile = new AppUserReadingProfileBuilder(user.Id) + .WithName("Library Profile") + .Build(); + Context.AppUserReadingProfiles.Add(profile); + await UnitOfWork.CommitAsync(); + + await rps.AddProfileToLibrary(user.Id, profile.Id, lib.Id); + await UnitOfWork.CommitAsync(); + + var linkedProfile = (await UnitOfWork.AppUserReadingProfileRepository.GetProfilesForUser(user.Id)) + .FirstOrDefault(rp => rp.LibraryIds.Contains(lib.Id)); + Assert.NotNull(linkedProfile); + Assert.Equal(profile.Id, linkedProfile.Id); + + var newProfile = new AppUserReadingProfileBuilder(user.Id) + .WithName("New Profile") + .Build(); + Context.AppUserReadingProfiles.Add(newProfile); + await UnitOfWork.CommitAsync(); + + await rps.AddProfileToLibrary(user.Id, newProfile.Id, lib.Id); + await UnitOfWork.CommitAsync(); + + linkedProfile = (await UnitOfWork.AppUserReadingProfileRepository.GetProfilesForUser(user.Id)) + .FirstOrDefault(rp => rp.LibraryIds.Contains(lib.Id)); + Assert.NotNull(linkedProfile); + Assert.Equal(newProfile.Id, linkedProfile.Id); + } + + [Fact] + public async Task ClearLibraryProfile_RemovesImplicitOrUnlinksExplicit() + { + await ResetDb(); + var (rps, user, lib, _) = await Setup(); + + var implicitProfile = new AppUserReadingProfileBuilder(user.Id) + .WithKind(ReadingProfileKind.Implicit) + .WithLibrary(lib) + .Build(); + Context.AppUserReadingProfiles.Add(implicitProfile); + await UnitOfWork.CommitAsync(); + + await rps.ClearLibraryProfile(user.Id, lib.Id); + var profile = (await UnitOfWork.AppUserReadingProfileRepository.GetProfilesForUser(user.Id)) + .FirstOrDefault(rp => rp.LibraryIds.Contains(lib.Id)); + Assert.Null(profile); + + var explicitProfile = new AppUserReadingProfileBuilder(user.Id) + .WithLibrary(lib) + .Build(); + Context.AppUserReadingProfiles.Add(explicitProfile); + await UnitOfWork.CommitAsync(); + + await rps.ClearLibraryProfile(user.Id, lib.Id); + profile = (await UnitOfWork.AppUserReadingProfileRepository.GetProfilesForUser(user.Id)) + .FirstOrDefault(rp => rp.LibraryIds.Contains(lib.Id)); + Assert.Null(profile); + + var stillExists = await Context.AppUserReadingProfiles.FindAsync(explicitProfile.Id); + Assert.NotNull(stillExists); + } + + /// + /// As response to #3793, I'm not sure if we want to keep this. It's not the most nice. But I think the idea of this test + /// is worth having. + /// + [Fact] + public void UpdateFields_UpdatesAll() + { + // Repeat to ensure booleans are flipped and actually tested + for (int i = 0; i < 10; i++) + { + var profile = new AppUserReadingProfile(); + var dto = new UserReadingProfileDto(); + + RandfHelper.SetRandomValues(profile); + RandfHelper.SetRandomValues(dto); + + ReadingProfileService.UpdateReaderProfileFields(profile, dto); + + var newDto = Mapper.Map(profile); + + Assert.True(RandfHelper.AreSimpleFieldsEqual(dto, newDto, + ["k__BackingField", "k__BackingField"])); + } + } + + + + protected override async Task ResetDb() + { + Context.AppUserReadingProfiles.RemoveRange(Context.AppUserReadingProfiles); + await UnitOfWork.CommitAsync(); + } +} diff --git a/API/Controllers/AccountController.cs b/API/Controllers/AccountController.cs index c504e1ce7..d8b9164af 100644 --- a/API/Controllers/AccountController.cs +++ b/API/Controllers/AccountController.cs @@ -153,6 +153,9 @@ public class AccountController : BaseApiController // Assign default streams AddDefaultStreamsToUser(user); + // Assign default reading profile + await AddDefaultReadingProfileToUser(user); + var token = await _userManager.GenerateEmailConfirmationTokenAsync(user); if (string.IsNullOrEmpty(token)) return BadRequest(await _localizationService.Get("en", "confirm-token-gen")); if (!await ConfirmEmailToken(token, user)) return BadRequest(await _localizationService.Get("en", "validate-email", token)); @@ -609,7 +612,7 @@ public class AccountController : BaseApiController } /// - /// Requests the Invite Url for the UserId. Will return error if user is already validated. + /// Requests the Invite Url for the AppUserId. Will return error if user is already validated. /// /// /// Include the "https://ip:port/" in the generated link @@ -669,6 +672,9 @@ public class AccountController : BaseApiController // Assign default streams AddDefaultStreamsToUser(user); + // Assign default reading profile + await AddDefaultReadingProfileToUser(user); + // Assign Roles var roles = dto.Roles; var hasAdminRole = dto.Roles.Contains(PolicyConstants.AdminRole); @@ -779,6 +785,16 @@ public class AccountController : BaseApiController } } + private async Task AddDefaultReadingProfileToUser(AppUser user) + { + var profile = new AppUserReadingProfileBuilder(user.Id) + .WithName("Default Profile") + .WithKind(ReadingProfileKind.Default) + .Build(); + _unitOfWork.AppUserReadingProfileRepository.Add(profile); + await _unitOfWork.CommitAsync(); + } + /// /// Last step in authentication flow, confirms the email token for email /// diff --git a/API/Controllers/PluginController.cs b/API/Controllers/PluginController.cs index c7f48cf54..f39462bbf 100644 --- a/API/Controllers/PluginController.cs +++ b/API/Controllers/PluginController.cs @@ -45,7 +45,7 @@ public class PluginController(IUnitOfWork unitOfWork, ITokenService tokenService throw new KavitaUnauthenticatedUserException(); } var user = await unitOfWork.UserRepository.GetUserByIdAsync(userId); - logger.LogInformation("Plugin {PluginName} has authenticated with {UserName} ({UserId})'s API Key", pluginName.Replace(Environment.NewLine, string.Empty), user!.UserName, userId); + logger.LogInformation("Plugin {PluginName} has authenticated with {UserName} ({AppUserId})'s API Key", pluginName.Replace(Environment.NewLine, string.Empty), user!.UserName, userId); return new UserDto { diff --git a/API/Controllers/ReadingProfileController.cs b/API/Controllers/ReadingProfileController.cs new file mode 100644 index 000000000..bc1b4fa52 --- /dev/null +++ b/API/Controllers/ReadingProfileController.cs @@ -0,0 +1,198 @@ +#nullable enable +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using API.Data; +using API.Data.Repositories; +using API.DTOs; +using API.Extensions; +using API.Services; +using AutoMapper; +using Kavita.Common; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; + +namespace API.Controllers; + +[Route("api/reading-profile")] +public class ReadingProfileController(ILogger logger, IUnitOfWork unitOfWork, + IReadingProfileService readingProfileService): BaseApiController +{ + + /// + /// Gets all non-implicit reading profiles for a user + /// + /// + [HttpGet("all")] + public async Task>> GetAllReadingProfiles() + { + return Ok(await unitOfWork.AppUserReadingProfileRepository.GetProfilesDtoForUser(User.GetUserId(), true)); + } + + /// + /// Returns the ReadingProfile that should be applied to the given series, walks up the tree. + /// Series -> Library -> Default + /// + /// + /// + /// + [HttpGet("{seriesId:int}")] + public async Task> GetProfileForSeries(int seriesId, [FromQuery] bool skipImplicit) + { + return Ok(await readingProfileService.GetReadingProfileDtoForSeries(User.GetUserId(), seriesId, skipImplicit)); + } + + /// + /// Returns the (potential) Reading Profile bound to the library + /// + /// + /// + [HttpGet("library")] + public async Task> GetProfileForLibrary(int libraryId) + { + return Ok(await readingProfileService.GetReadingProfileDtoForLibrary(User.GetUserId(), libraryId)); + } + + /// + /// Creates a new reading profile for the current user + /// + /// + /// + [HttpPost("create")] + public async Task> CreateReadingProfile([FromBody] UserReadingProfileDto dto) + { + return Ok(await readingProfileService.CreateReadingProfile(User.GetUserId(), dto)); + } + + /// + /// Promotes the implicit profile to a user profile. Removes the series from other profiles + /// + /// + /// + [HttpPost("promote")] + public async Task> PromoteImplicitReadingProfile([FromQuery] int profileId) + { + return Ok(await readingProfileService.PromoteImplicitProfile(User.GetUserId(), profileId)); + } + + /// + /// Update the implicit reading profile for a series, creates one if none exists + /// + /// Any modification to the reader settings during reading will create an implicit profile. Use "update-parent" to save to the bound series profile. + /// + /// + /// + [HttpPost("series")] + public async Task> UpdateReadingProfileForSeries([FromBody] UserReadingProfileDto dto, [FromQuery] int seriesId) + { + var updatedProfile = await readingProfileService.UpdateImplicitReadingProfile(User.GetUserId(), seriesId, dto); + return Ok(updatedProfile); + } + + /// + /// Updates the non-implicit reading profile for the given series, and removes implicit profiles + /// + /// + /// + /// + [HttpPost("update-parent")] + public async Task> UpdateParentProfileForSeries([FromBody] UserReadingProfileDto dto, [FromQuery] int seriesId) + { + var newParentProfile = await readingProfileService.UpdateParent(User.GetUserId(), seriesId, dto); + return Ok(newParentProfile); + } + + /// + /// Updates the given reading profile, must belong to the current user + /// + /// + /// The updated reading profile + /// + /// This does not update connected series and libraries. + /// + [HttpPost] + public async Task> UpdateReadingProfile(UserReadingProfileDto dto) + { + return Ok(await readingProfileService.UpdateReadingProfile(User.GetUserId(), dto)); + } + + /// + /// Deletes the given profile, requires the profile to belong to the logged-in user + /// + /// + /// + /// + /// + [HttpDelete] + public async Task DeleteReadingProfile([FromQuery] int profileId) + { + await readingProfileService.DeleteReadingProfile(User.GetUserId(), profileId); + return Ok(); + } + + /// + /// Sets the reading profile for a given series, removes the old one + /// + /// + /// + /// + [HttpPost("series/{seriesId:int}")] + public async Task AddProfileToSeries(int seriesId, [FromQuery] int profileId) + { + await readingProfileService.AddProfileToSeries(User.GetUserId(), profileId, seriesId); + return Ok(); + } + + /// + /// Clears the reading profile for the given series for the currently logged-in user + /// + /// + /// + [HttpDelete("series/{seriesId:int}")] + public async Task ClearSeriesProfile(int seriesId) + { + await readingProfileService.ClearSeriesProfile(User.GetUserId(), seriesId); + return Ok(); + } + + /// + /// Sets the reading profile for a given library, removes the old one + /// + /// + /// + /// + [HttpPost("library/{libraryId:int}")] + public async Task AddProfileToLibrary(int libraryId, [FromQuery] int profileId) + { + await readingProfileService.AddProfileToLibrary(User.GetUserId(), profileId, libraryId); + return Ok(); + } + + /// + /// Clears the reading profile for the given library for the currently logged-in user + /// + /// + /// + /// + [HttpDelete("library/{libraryId:int}")] + public async Task ClearLibraryProfile(int libraryId) + { + await readingProfileService.ClearLibraryProfile(User.GetUserId(), libraryId); + return Ok(); + } + + /// + /// Assigns the reading profile to all passes series, and deletes their implicit profiles + /// + /// + /// + /// + [HttpPost("bulk")] + public async Task BulkAddReadingProfile([FromQuery] int profileId, [FromBody] IList seriesIds) + { + await readingProfileService.BulkAddProfileToSeries(User.GetUserId(), profileId, seriesIds); + return Ok(); + } + +} diff --git a/API/Controllers/UsersController.cs b/API/Controllers/UsersController.cs index e5cfb626a..17ebc758e 100644 --- a/API/Controllers/UsersController.cs +++ b/API/Controllers/UsersController.cs @@ -103,39 +103,13 @@ public class UsersController : BaseApiController var existingPreferences = user!.UserPreferences; - existingPreferences.ReadingDirection = preferencesDto.ReadingDirection; - existingPreferences.ScalingOption = preferencesDto.ScalingOption; - existingPreferences.PageSplitOption = preferencesDto.PageSplitOption; - existingPreferences.AutoCloseMenu = preferencesDto.AutoCloseMenu; - existingPreferences.ShowScreenHints = preferencesDto.ShowScreenHints; - existingPreferences.EmulateBook = preferencesDto.EmulateBook; - existingPreferences.ReaderMode = preferencesDto.ReaderMode; - existingPreferences.LayoutMode = preferencesDto.LayoutMode; - existingPreferences.BackgroundColor = string.IsNullOrEmpty(preferencesDto.BackgroundColor) ? "#000000" : preferencesDto.BackgroundColor; - existingPreferences.BookReaderMargin = preferencesDto.BookReaderMargin; - existingPreferences.BookReaderLineSpacing = preferencesDto.BookReaderLineSpacing; - existingPreferences.BookReaderFontFamily = preferencesDto.BookReaderFontFamily; - existingPreferences.BookReaderFontSize = preferencesDto.BookReaderFontSize; - existingPreferences.BookReaderTapToPaginate = preferencesDto.BookReaderTapToPaginate; - existingPreferences.BookReaderReadingDirection = preferencesDto.BookReaderReadingDirection; - existingPreferences.BookReaderWritingStyle = preferencesDto.BookReaderWritingStyle; - existingPreferences.BookThemeName = preferencesDto.BookReaderThemeName; - existingPreferences.BookReaderLayoutMode = preferencesDto.BookReaderLayoutMode; - existingPreferences.BookReaderImmersiveMode = preferencesDto.BookReaderImmersiveMode; existingPreferences.GlobalPageLayoutMode = preferencesDto.GlobalPageLayoutMode; existingPreferences.BlurUnreadSummaries = preferencesDto.BlurUnreadSummaries; - existingPreferences.LayoutMode = preferencesDto.LayoutMode; existingPreferences.PromptForDownloadSize = preferencesDto.PromptForDownloadSize; existingPreferences.NoTransitions = preferencesDto.NoTransitions; - existingPreferences.SwipeToPaginate = preferencesDto.SwipeToPaginate; - existingPreferences.AllowAutomaticWebtoonReaderDetection = preferencesDto.AllowAutomaticWebtoonReaderDetection; existingPreferences.CollapseSeriesRelationships = preferencesDto.CollapseSeriesRelationships; existingPreferences.ShareReviews = preferencesDto.ShareReviews; - existingPreferences.PdfTheme = preferencesDto.PdfTheme; - existingPreferences.PdfScrollMode = preferencesDto.PdfScrollMode; - existingPreferences.PdfSpreadMode = preferencesDto.PdfSpreadMode; - if (await _licenseService.HasActiveLicense()) { existingPreferences.AniListScrobblingEnabled = preferencesDto.AniListScrobblingEnabled; diff --git a/API/DTOs/UserPreferencesDto.cs b/API/DTOs/UserPreferencesDto.cs index 6645a8f39..46f42306e 100644 --- a/API/DTOs/UserPreferencesDto.cs +++ b/API/DTOs/UserPreferencesDto.cs @@ -9,61 +9,6 @@ namespace API.DTOs; public sealed record UserPreferencesDto { - /// - [Required] - public ReadingDirection ReadingDirection { get; set; } - /// - [Required] - public ScalingOption ScalingOption { get; set; } - /// - [Required] - public PageSplitOption PageSplitOption { get; set; } - /// - [Required] - public ReaderMode ReaderMode { get; set; } - /// - [Required] - public LayoutMode LayoutMode { get; set; } - /// - [Required] - public bool EmulateBook { get; set; } - /// - [Required] - public string BackgroundColor { get; set; } = "#000000"; - /// - [Required] - public bool SwipeToPaginate { get; set; } - /// - [Required] - public bool AutoCloseMenu { get; set; } - /// - [Required] - public bool ShowScreenHints { get; set; } = true; - /// - [Required] - public bool AllowAutomaticWebtoonReaderDetection { get; set; } - - /// - [Required] - public int BookReaderMargin { get; set; } - /// - [Required] - public int BookReaderLineSpacing { get; set; } - /// - [Required] - public int BookReaderFontSize { get; set; } - /// - [Required] - public string BookReaderFontFamily { get; set; } = null!; - /// - [Required] - public bool BookReaderTapToPaginate { get; set; } - /// - [Required] - public ReadingDirection BookReaderReadingDirection { get; set; } - /// - [Required] - public WritingStyle BookReaderWritingStyle { get; set; } /// /// UI Site Global Setting: The UI theme the user should use. @@ -72,15 +17,6 @@ public sealed record UserPreferencesDto [Required] public SiteThemeDto? Theme { get; set; } - [Required] public string BookReaderThemeName { get; set; } = null!; - /// - [Required] - public BookPageLayoutMode BookReaderLayoutMode { get; set; } - /// - [Required] - public bool BookReaderImmersiveMode { get; set; } = false; - /// - [Required] public PageLayoutMode GlobalPageLayoutMode { get; set; } = PageLayoutMode.Cards; /// [Required] @@ -101,16 +37,6 @@ public sealed record UserPreferencesDto [Required] public string Locale { get; set; } - /// - [Required] - public PdfTheme PdfTheme { get; set; } = PdfTheme.Dark; - /// - [Required] - public PdfScrollMode PdfScrollMode { get; set; } = PdfScrollMode.Vertical; - /// - [Required] - public PdfSpreadMode PdfSpreadMode { get; set; } = PdfSpreadMode.None; - /// public bool AniListScrobblingEnabled { get; set; } /// diff --git a/API/DTOs/UserReadingProfileDto.cs b/API/DTOs/UserReadingProfileDto.cs new file mode 100644 index 000000000..23f67ce4d --- /dev/null +++ b/API/DTOs/UserReadingProfileDto.cs @@ -0,0 +1,129 @@ +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using API.Entities; +using API.Entities.Enums; +using API.Entities.Enums.UserPreferences; + +namespace API.DTOs; + +public sealed record UserReadingProfileDto +{ + + public int Id { get; set; } + public int UserId { get; init; } + + public string Name { get; init; } + public ReadingProfileKind Kind { get; init; } + + #region MangaReader + + /// + [Required] + public ReadingDirection ReadingDirection { get; set; } + + /// + [Required] + public ScalingOption ScalingOption { get; set; } + + /// + [Required] + public PageSplitOption PageSplitOption { get; set; } + + /// + [Required] + public ReaderMode ReaderMode { get; set; } + + /// + [Required] + public bool AutoCloseMenu { get; set; } + + /// + [Required] + public bool ShowScreenHints { get; set; } = true; + + /// + [Required] + public bool EmulateBook { get; set; } + + /// + [Required] + public LayoutMode LayoutMode { get; set; } + + /// + [Required] + public string BackgroundColor { get; set; } = "#000000"; + + /// + [Required] + public bool SwipeToPaginate { get; set; } + + /// + [Required] + public bool AllowAutomaticWebtoonReaderDetection { get; set; } + + /// + public int? WidthOverride { get; set; } + + #endregion + + #region EpubReader + + /// + [Required] + public int BookReaderMargin { get; set; } + + /// + [Required] + public int BookReaderLineSpacing { get; set; } + + /// + [Required] + public int BookReaderFontSize { get; set; } + + /// + [Required] + public string BookReaderFontFamily { get; set; } = null!; + + /// + [Required] + public bool BookReaderTapToPaginate { get; set; } + + /// + [Required] + public ReadingDirection BookReaderReadingDirection { get; set; } + + /// + [Required] + public WritingStyle BookReaderWritingStyle { get; set; } + + /// + [Required] + public string BookReaderThemeName { get; set; } = null!; + + /// + [Required] + public BookPageLayoutMode BookReaderLayoutMode { get; set; } + + /// + [Required] + public bool BookReaderImmersiveMode { get; set; } = false; + + #endregion + + #region PdfReader + + /// + [Required] + public PdfTheme PdfTheme { get; set; } = PdfTheme.Dark; + + /// + [Required] + public PdfScrollMode PdfScrollMode { get; set; } = PdfScrollMode.Vertical; + + /// + [Required] + public PdfSpreadMode PdfSpreadMode { get; set; } = PdfSpreadMode.None; + + #endregion + +} diff --git a/API/Data/DataContext.cs b/API/Data/DataContext.cs index ce35ba7ec..3bbf45e23 100644 --- a/API/Data/DataContext.cs +++ b/API/Data/DataContext.cs @@ -81,6 +81,7 @@ public sealed class DataContext : IdentityDbContext MetadataSettings { get; set; } = null!; public DbSet MetadataFieldMapping { get; set; } = null!; public DbSet AppUserChapterRating { get; set; } = null!; + public DbSet AppUserReadingProfiles { get; set; } = null!; protected override void OnModelCreating(ModelBuilder builder) { @@ -256,6 +257,32 @@ public sealed class DataContext : IdentityDbContext() .Property(b => b.EnableCoverImage) .HasDefaultValue(true); + + builder.Entity() + .Property(b => b.BookThemeName) + .HasDefaultValue("Dark"); + builder.Entity() + .Property(b => b.BackgroundColor) + .HasDefaultValue("#000000"); + builder.Entity() + .Property(b => b.BookReaderWritingStyle) + .HasDefaultValue(WritingStyle.Horizontal); + builder.Entity() + .Property(b => b.AllowAutomaticWebtoonReaderDetection) + .HasDefaultValue(true); + + builder.Entity() + .Property(rp => rp.LibraryIds) + .HasConversion( + v => JsonSerializer.Serialize(v, JsonSerializerOptions.Default), + v => JsonSerializer.Deserialize>(v, JsonSerializerOptions.Default) ?? new List()) + .HasColumnType("TEXT"); + builder.Entity() + .Property(rp => rp.SeriesIds) + .HasConversion( + v => JsonSerializer.Serialize(v, JsonSerializerOptions.Default), + v => JsonSerializer.Deserialize>(v, JsonSerializerOptions.Default) ?? new List()) + .HasColumnType("TEXT"); } #nullable enable diff --git a/API/Data/ManualMigrations/v0.8.7/ManualMigrateReadingProfiles.cs b/API/Data/ManualMigrations/v0.8.7/ManualMigrateReadingProfiles.cs new file mode 100644 index 000000000..b2afde98a --- /dev/null +++ b/API/Data/ManualMigrations/v0.8.7/ManualMigrateReadingProfiles.cs @@ -0,0 +1,84 @@ +using System; +using System.Threading.Tasks; +using API.Entities; +using API.Entities.Enums; +using API.Entities.History; +using API.Extensions; +using API.Helpers.Builders; +using Kavita.Common.EnvironmentInfo; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; + +namespace API.Data.ManualMigrations; + +public static class ManualMigrateReadingProfiles +{ + public static async Task Migrate(DataContext context, ILogger logger) + { + if (await context.ManualMigrationHistory.AnyAsync(m => m.Name == "ManualMigrateReadingProfiles")) + { + return; + } + + logger.LogCritical("Running ManualMigrateReadingProfiles migration - Please be patient, this may take some time. This is not an error"); + + var users = await context.AppUser + .Include(u => u.UserPreferences) + .Include(u => u.ReadingProfiles) + .ToListAsync(); + + foreach (var user in users) + { + var readingProfile = new AppUserReadingProfile + { + Name = "Default", + NormalizedName = "Default".ToNormalized(), + Kind = ReadingProfileKind.Default, + LibraryIds = [], + SeriesIds = [], + BackgroundColor = user.UserPreferences.BackgroundColor, + EmulateBook = user.UserPreferences.EmulateBook, + AppUser = user, + PdfTheme = user.UserPreferences.PdfTheme, + ReaderMode = user.UserPreferences.ReaderMode, + ReadingDirection = user.UserPreferences.ReadingDirection, + ScalingOption = user.UserPreferences.ScalingOption, + LayoutMode = user.UserPreferences.LayoutMode, + WidthOverride = null, + AppUserId = user.Id, + AutoCloseMenu = user.UserPreferences.AutoCloseMenu, + BookReaderMargin = user.UserPreferences.BookReaderMargin, + PageSplitOption = user.UserPreferences.PageSplitOption, + BookThemeName = user.UserPreferences.BookThemeName, + PdfSpreadMode = user.UserPreferences.PdfSpreadMode, + PdfScrollMode = user.UserPreferences.PdfScrollMode, + SwipeToPaginate = user.UserPreferences.SwipeToPaginate, + BookReaderFontFamily = user.UserPreferences.BookReaderFontFamily, + BookReaderFontSize = user.UserPreferences.BookReaderFontSize, + BookReaderImmersiveMode = user.UserPreferences.BookReaderImmersiveMode, + BookReaderLayoutMode = user.UserPreferences.BookReaderLayoutMode, + BookReaderLineSpacing = user.UserPreferences.BookReaderLineSpacing, + BookReaderReadingDirection = user.UserPreferences.BookReaderReadingDirection, + BookReaderWritingStyle = user.UserPreferences.BookReaderWritingStyle, + AllowAutomaticWebtoonReaderDetection = user.UserPreferences.AllowAutomaticWebtoonReaderDetection, + BookReaderTapToPaginate = user.UserPreferences.BookReaderTapToPaginate, + ShowScreenHints = user.UserPreferences.ShowScreenHints, + }; + user.ReadingProfiles.Add(readingProfile); + } + + await context.SaveChangesAsync(); + + context.ManualMigrationHistory.Add(new ManualMigrationHistory + { + Name = "ManualMigrateReadingProfiles", + ProductVersion = BuildInfo.Version.ToString(), + RanAt = DateTime.UtcNow, + }); + await context.SaveChangesAsync(); + + + logger.LogCritical("Running ManualMigrateReadingProfiles migration - Completed. This is not an error"); + + } +} diff --git a/API/Data/Migrations/20250601200056_ReadingProfiles.Designer.cs b/API/Data/Migrations/20250601200056_ReadingProfiles.Designer.cs new file mode 100644 index 000000000..762eae142 --- /dev/null +++ b/API/Data/Migrations/20250601200056_ReadingProfiles.Designer.cs @@ -0,0 +1,3698 @@ +// +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("20250601200056_ReadingProfiles")] + partial class ReadingProfiles + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "9.0.4"); + + 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("AniListAccessToken") + .HasColumnType("TEXT"); + + b.Property("ApiKey") + .HasColumnType("TEXT"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("ConfirmationToken") + .HasColumnType("TEXT"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("CreatedUtc") + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("EmailConfirmed") + .HasColumnType("INTEGER"); + + b.Property("HasRunScrobbleEventGeneration") + .HasColumnType("INTEGER"); + + b.Property("LastActive") + .HasColumnType("TEXT"); + + b.Property("LastActiveUtc") + .HasColumnType("TEXT"); + + b.Property("LockoutEnabled") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnd") + .HasColumnType("TEXT"); + + b.Property("MalAccessToken") + .HasColumnType("TEXT"); + + b.Property("MalUserName") + .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("ScrobbleEventGenerationRan") + .HasColumnType("TEXT"); + + 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("CreatedUtc") + .HasColumnType("TEXT"); + + b.Property("FileName") + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastModifiedUtc") + .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.AppUserChapterRating", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AppUserId") + .HasColumnType("INTEGER"); + + b.Property("ChapterId") + .HasColumnType("INTEGER"); + + b.Property("HasBeenRated") + .HasColumnType("INTEGER"); + + b.Property("Rating") + .HasColumnType("REAL"); + + b.Property("Review") + .HasColumnType("TEXT"); + + b.Property("SeriesId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("AppUserId"); + + b.HasIndex("ChapterId"); + + b.HasIndex("SeriesId"); + + b.ToTable("AppUserChapterRating"); + }); + + modelBuilder.Entity("API.Entities.AppUserCollection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AgeRating") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(0); + + b.Property("AppUserId") + .HasColumnType("INTEGER"); + + b.Property("CoverImage") + .HasColumnType("TEXT"); + + b.Property("CoverImageLocked") + .HasColumnType("INTEGER"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("CreatedUtc") + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastModifiedUtc") + .HasColumnType("TEXT"); + + b.Property("LastSyncUtc") + .HasColumnType("TEXT"); + + b.Property("MissingSeriesFromSource") + .HasColumnType("TEXT"); + + b.Property("NormalizedTitle") + .HasColumnType("TEXT"); + + b.Property("PrimaryColor") + .HasColumnType("TEXT"); + + b.Property("Promoted") + .HasColumnType("INTEGER"); + + b.Property("SecondaryColor") + .HasColumnType("TEXT"); + + b.Property("Source") + .HasColumnType("INTEGER"); + + b.Property("SourceUrl") + .HasColumnType("TEXT"); + + b.Property("Summary") + .HasColumnType("TEXT"); + + b.Property("Title") + .HasColumnType("TEXT"); + + b.Property("TotalSourceCount") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("AppUserId"); + + b.ToTable("AppUserCollection"); + }); + + modelBuilder.Entity("API.Entities.AppUserDashboardStream", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AppUserId") + .HasColumnType("INTEGER"); + + b.Property("IsProvided") + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Order") + .HasColumnType("INTEGER"); + + b.Property("SmartFilterId") + .HasColumnType("INTEGER"); + + b.Property("StreamType") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(4); + + b.Property("Visible") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("AppUserId"); + + b.HasIndex("SmartFilterId"); + + b.HasIndex("Visible"); + + b.ToTable("AppUserDashboardStream"); + }); + + modelBuilder.Entity("API.Entities.AppUserExternalSource", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ApiKey") + .HasColumnType("TEXT"); + + b.Property("AppUserId") + .HasColumnType("INTEGER"); + + b.Property("Host") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("AppUserId"); + + b.ToTable("AppUserExternalSource"); + }); + + modelBuilder.Entity("API.Entities.AppUserOnDeckRemoval", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AppUserId") + .HasColumnType("INTEGER"); + + b.Property("SeriesId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("AppUserId"); + + b.HasIndex("SeriesId"); + + b.ToTable("AppUserOnDeckRemoval"); + }); + + modelBuilder.Entity("API.Entities.AppUserPreferences", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AllowAutomaticWebtoonReaderDetection") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("AniListScrobblingEnabled") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + 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("BookReaderWritingStyle") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(0); + + b.Property("BookThemeName") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT") + .HasDefaultValue("Dark"); + + b.Property("CollapseSeriesRelationships") + .HasColumnType("INTEGER"); + + b.Property("EmulateBook") + .HasColumnType("INTEGER"); + + b.Property("GlobalPageLayoutMode") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(0); + + b.Property("LayoutMode") + .HasColumnType("INTEGER"); + + b.Property("Locale") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("TEXT") + .HasDefaultValue("en"); + + b.Property("NoTransitions") + .HasColumnType("INTEGER"); + + b.Property("PageSplitOption") + .HasColumnType("INTEGER"); + + b.Property("PdfScrollMode") + .HasColumnType("INTEGER"); + + b.Property("PdfSpreadMode") + .HasColumnType("INTEGER"); + + b.Property("PdfTheme") + .HasColumnType("INTEGER"); + + b.Property("PromptForDownloadSize") + .HasColumnType("INTEGER"); + + b.Property("ReaderMode") + .HasColumnType("INTEGER"); + + b.Property("ReadingDirection") + .HasColumnType("INTEGER"); + + b.Property("ScalingOption") + .HasColumnType("INTEGER"); + + b.Property("ShareReviews") + .HasColumnType("INTEGER"); + + b.Property("ShowScreenHints") + .HasColumnType("INTEGER"); + + b.Property("SwipeToPaginate") + .HasColumnType("INTEGER"); + + b.Property("ThemeId") + .HasColumnType("INTEGER"); + + b.Property("WantToReadSync") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + 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("CreatedUtc") + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastModifiedUtc") + .HasColumnType("TEXT"); + + b.Property("LibraryId") + .HasColumnType("INTEGER"); + + b.Property("PagesRead") + .HasColumnType("INTEGER"); + + b.Property("SeriesId") + .HasColumnType("INTEGER"); + + b.Property("VolumeId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("AppUserId"); + + b.HasIndex("ChapterId"); + + 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("HasBeenRated") + .HasColumnType("INTEGER"); + + b.Property("Rating") + .HasColumnType("REAL"); + + b.Property("Review") + .HasColumnType("TEXT"); + + b.Property("SeriesId") + .HasColumnType("INTEGER"); + + b.Property("Tagline") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("AppUserId"); + + b.HasIndex("SeriesId"); + + b.ToTable("AppUserRating"); + }); + + modelBuilder.Entity("API.Entities.AppUserReadingProfile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AllowAutomaticWebtoonReaderDetection") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("AppUserId") + .HasColumnType("INTEGER"); + + b.Property("AutoCloseMenu") + .HasColumnType("INTEGER"); + + b.Property("BackgroundColor") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT") + .HasDefaultValue("#000000"); + + 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("BookReaderWritingStyle") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(0); + + b.Property("BookThemeName") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT") + .HasDefaultValue("Dark"); + + b.Property("EmulateBook") + .HasColumnType("INTEGER"); + + b.Property("Kind") + .HasColumnType("INTEGER"); + + b.Property("LayoutMode") + .HasColumnType("INTEGER"); + + b.Property("LibraryIds") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("NormalizedName") + .HasColumnType("TEXT"); + + b.Property("PageSplitOption") + .HasColumnType("INTEGER"); + + b.Property("PdfScrollMode") + .HasColumnType("INTEGER"); + + b.Property("PdfSpreadMode") + .HasColumnType("INTEGER"); + + b.Property("PdfTheme") + .HasColumnType("INTEGER"); + + b.Property("ReaderMode") + .HasColumnType("INTEGER"); + + b.Property("ReadingDirection") + .HasColumnType("INTEGER"); + + b.Property("ScalingOption") + .HasColumnType("INTEGER"); + + b.PrimitiveCollection("SeriesIds") + .HasColumnType("TEXT"); + + b.Property("ShowScreenHints") + .HasColumnType("INTEGER"); + + b.Property("SwipeToPaginate") + .HasColumnType("INTEGER"); + + b.Property("WidthOverride") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("AppUserId"); + + b.ToTable("AppUserReadingProfiles"); + }); + + 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.AppUserSideNavStream", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AppUserId") + .HasColumnType("INTEGER"); + + b.Property("ExternalSourceId") + .HasColumnType("INTEGER"); + + b.Property("IsProvided") + .HasColumnType("INTEGER"); + + b.Property("LibraryId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Order") + .HasColumnType("INTEGER"); + + b.Property("SmartFilterId") + .HasColumnType("INTEGER"); + + b.Property("StreamType") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(5); + + b.Property("Visible") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("AppUserId"); + + b.HasIndex("SmartFilterId"); + + b.HasIndex("Visible"); + + b.ToTable("AppUserSideNavStream"); + }); + + modelBuilder.Entity("API.Entities.AppUserSmartFilter", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AppUserId") + .HasColumnType("INTEGER"); + + b.Property("Filter") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("AppUserId"); + + b.ToTable("AppUserSmartFilter"); + }); + + modelBuilder.Entity("API.Entities.AppUserTableOfContent", 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("CreatedUtc") + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastModifiedUtc") + .HasColumnType("TEXT"); + + b.Property("LibraryId") + .HasColumnType("INTEGER"); + + b.Property("PageNumber") + .HasColumnType("INTEGER"); + + b.Property("SeriesId") + .HasColumnType("INTEGER"); + + b.Property("Title") + .HasColumnType("TEXT"); + + b.Property("VolumeId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("AppUserId"); + + b.HasIndex("ChapterId"); + + b.HasIndex("SeriesId"); + + b.ToTable("AppUserTableOfContent"); + }); + + modelBuilder.Entity("API.Entities.AppUserWantToRead", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AppUserId") + .HasColumnType("INTEGER"); + + b.Property("SeriesId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("AppUserId"); + + b.HasIndex("SeriesId"); + + b.ToTable("AppUserWantToRead"); + }); + + modelBuilder.Entity("API.Entities.Chapter", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AgeRating") + .HasColumnType("INTEGER"); + + b.Property("AgeRatingLocked") + .HasColumnType("INTEGER"); + + b.Property("AlternateCount") + .HasColumnType("INTEGER"); + + b.Property("AlternateNumber") + .HasColumnType("TEXT"); + + b.Property("AlternateSeries") + .HasColumnType("TEXT"); + + b.Property("AverageExternalRating") + .HasColumnType("REAL"); + + b.Property("AvgHoursToRead") + .HasColumnType("REAL"); + + b.Property("CharacterLocked") + .HasColumnType("INTEGER"); + + b.Property("ColoristLocked") + .HasColumnType("INTEGER"); + + b.Property("Count") + .HasColumnType("INTEGER"); + + b.Property("CoverArtistLocked") + .HasColumnType("INTEGER"); + + b.Property("CoverImage") + .HasColumnType("TEXT"); + + b.Property("CoverImageLocked") + .HasColumnType("INTEGER"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("CreatedUtc") + .HasColumnType("TEXT"); + + b.Property("EditorLocked") + .HasColumnType("INTEGER"); + + b.Property("GenresLocked") + .HasColumnType("INTEGER"); + + b.Property("ISBN") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT") + .HasDefaultValue(""); + + b.Property("ISBNLocked") + .HasColumnType("INTEGER"); + + b.Property("ImprintLocked") + .HasColumnType("INTEGER"); + + b.Property("InkerLocked") + .HasColumnType("INTEGER"); + + b.Property("IsSpecial") + .HasColumnType("INTEGER"); + + b.Property("Language") + .HasColumnType("TEXT"); + + b.Property("LanguageLocked") + .HasColumnType("INTEGER"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastModifiedUtc") + .HasColumnType("TEXT"); + + b.Property("LettererLocked") + .HasColumnType("INTEGER"); + + b.Property("LocationLocked") + .HasColumnType("INTEGER"); + + b.Property("MaxHoursToRead") + .HasColumnType("INTEGER"); + + b.Property("MaxNumber") + .HasColumnType("REAL"); + + b.Property("MinHoursToRead") + .HasColumnType("INTEGER"); + + b.Property("MinNumber") + .HasColumnType("REAL"); + + b.Property("Number") + .HasColumnType("TEXT"); + + b.Property("Pages") + .HasColumnType("INTEGER"); + + b.Property("PencillerLocked") + .HasColumnType("INTEGER"); + + b.Property("PrimaryColor") + .HasColumnType("TEXT"); + + b.Property("PublisherLocked") + .HasColumnType("INTEGER"); + + b.Property("Range") + .HasColumnType("TEXT"); + + b.Property("ReleaseDate") + .HasColumnType("TEXT"); + + b.Property("ReleaseDateLocked") + .HasColumnType("INTEGER"); + + b.Property("SecondaryColor") + .HasColumnType("TEXT"); + + b.Property("SeriesGroup") + .HasColumnType("TEXT"); + + b.Property("SortOrder") + .HasColumnType("REAL"); + + b.Property("SortOrderLocked") + .HasColumnType("INTEGER"); + + b.Property("StoryArc") + .HasColumnType("TEXT"); + + b.Property("StoryArcNumber") + .HasColumnType("TEXT"); + + b.Property("Summary") + .HasColumnType("TEXT"); + + b.Property("SummaryLocked") + .HasColumnType("INTEGER"); + + b.Property("TagsLocked") + .HasColumnType("INTEGER"); + + b.Property("TeamLocked") + .HasColumnType("INTEGER"); + + b.Property("Title") + .HasColumnType("TEXT"); + + b.Property("TitleName") + .HasColumnType("TEXT"); + + b.Property("TitleNameLocked") + .HasColumnType("INTEGER"); + + b.Property("TotalCount") + .HasColumnType("INTEGER"); + + b.Property("TranslatorLocked") + .HasColumnType("INTEGER"); + + b.Property("VolumeId") + .HasColumnType("INTEGER"); + + b.Property("WebLinks") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT") + .HasDefaultValue(""); + + b.Property("WordCount") + .HasColumnType("INTEGER"); + + b.Property("WriterLocked") + .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("CreatedUtc") + .HasColumnType("TEXT"); + + b.Property("EmailAddress") + .HasColumnType("TEXT"); + + b.Property("IpAddress") + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastModifiedUtc") + .HasColumnType("TEXT"); + + b.Property("LastUsed") + .HasColumnType("TEXT"); + + b.Property("LastUsedUtc") + .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.EmailHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AppUserId") + .HasColumnType("INTEGER"); + + b.Property("Body") + .HasColumnType("TEXT"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("CreatedUtc") + .HasColumnType("TEXT"); + + b.Property("DeliveryStatus") + .HasColumnType("TEXT"); + + b.Property("EmailTemplate") + .HasColumnType("TEXT"); + + b.Property("ErrorMessage") + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastModifiedUtc") + .HasColumnType("TEXT"); + + b.Property("SendDate") + .HasColumnType("TEXT"); + + b.Property("Sent") + .HasColumnType("INTEGER"); + + b.Property("Subject") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("AppUserId"); + + b.HasIndex("Sent", "AppUserId", "EmailTemplate", "SendDate"); + + b.ToTable("EmailHistory"); + }); + + 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("NormalizedTitle") + .HasColumnType("TEXT"); + + b.Property("Title") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedTitle") + .IsUnique(); + + b.ToTable("Genre"); + }); + + modelBuilder.Entity("API.Entities.History.ManualMigrationHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("ProductVersion") + .HasColumnType("TEXT"); + + b.Property("RanAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("ManualMigrationHistory"); + }); + + modelBuilder.Entity("API.Entities.Library", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AllowMetadataMatching") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("AllowScrobbling") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("CoverImage") + .HasColumnType("TEXT"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("CreatedUtc") + .HasColumnType("TEXT"); + + b.Property("FolderWatching") + .HasColumnType("INTEGER"); + + b.Property("IncludeInDashboard") + .HasColumnType("INTEGER"); + + b.Property("IncludeInRecommended") + .HasColumnType("INTEGER"); + + b.Property("IncludeInSearch") + .HasColumnType("INTEGER"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastModifiedUtc") + .HasColumnType("TEXT"); + + b.Property("LastScanned") + .HasColumnType("TEXT"); + + b.Property("ManageCollections") + .HasColumnType("INTEGER"); + + b.Property("ManageReadingLists") + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("PrimaryColor") + .HasColumnType("TEXT"); + + b.Property("SecondaryColor") + .HasColumnType("TEXT"); + + b.Property("Type") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("Library"); + }); + + modelBuilder.Entity("API.Entities.LibraryExcludePattern", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("LibraryId") + .HasColumnType("INTEGER"); + + b.Property("Pattern") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("LibraryId"); + + b.ToTable("LibraryExcludePattern"); + }); + + modelBuilder.Entity("API.Entities.LibraryFileTypeGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("FileTypeGroup") + .HasColumnType("INTEGER"); + + b.Property("LibraryId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("LibraryId"); + + b.ToTable("LibraryFileTypeGroup"); + }); + + modelBuilder.Entity("API.Entities.MangaFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Bytes") + .HasColumnType("INTEGER"); + + b.Property("ChapterId") + .HasColumnType("INTEGER"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("CreatedUtc") + .HasColumnType("TEXT"); + + b.Property("Extension") + .HasColumnType("TEXT"); + + b.Property("FileName") + .HasColumnType("TEXT"); + + b.Property("FilePath") + .HasColumnType("TEXT"); + + b.Property("Format") + .HasColumnType("INTEGER"); + + b.Property("LastFileAnalysis") + .HasColumnType("TEXT"); + + b.Property("LastFileAnalysisUtc") + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastModifiedUtc") + .HasColumnType("TEXT"); + + b.Property("Pages") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ChapterId"); + + b.ToTable("MangaFile"); + }); + + modelBuilder.Entity("API.Entities.MediaError", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Comment") + .HasColumnType("TEXT"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("CreatedUtc") + .HasColumnType("TEXT"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("Extension") + .HasColumnType("TEXT"); + + b.Property("FilePath") + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastModifiedUtc") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("MediaError"); + }); + + modelBuilder.Entity("API.Entities.Metadata.ExternalRating", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Authority") + .HasColumnType("INTEGER"); + + b.Property("AverageScore") + .HasColumnType("INTEGER"); + + b.Property("ChapterId") + .HasColumnType("INTEGER"); + + b.Property("FavoriteCount") + .HasColumnType("INTEGER"); + + b.Property("Provider") + .HasColumnType("INTEGER"); + + b.Property("ProviderUrl") + .HasColumnType("TEXT"); + + b.Property("SeriesId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ChapterId"); + + b.ToTable("ExternalRating"); + }); + + modelBuilder.Entity("API.Entities.Metadata.ExternalRecommendation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AniListId") + .HasColumnType("INTEGER"); + + b.Property("CoverUrl") + .HasColumnType("TEXT"); + + b.Property("MalId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Provider") + .HasColumnType("INTEGER"); + + b.Property("SeriesId") + .HasColumnType("INTEGER"); + + b.Property("Summary") + .HasColumnType("TEXT"); + + b.Property("Url") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("SeriesId"); + + b.ToTable("ExternalRecommendation"); + }); + + modelBuilder.Entity("API.Entities.Metadata.ExternalReview", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Authority") + .HasColumnType("INTEGER"); + + b.Property("Body") + .HasColumnType("TEXT"); + + b.Property("BodyJustText") + .HasColumnType("TEXT"); + + b.Property("ChapterId") + .HasColumnType("INTEGER"); + + b.Property("Provider") + .HasColumnType("INTEGER"); + + b.Property("Rating") + .HasColumnType("INTEGER"); + + b.Property("RawBody") + .HasColumnType("TEXT"); + + b.Property("Score") + .HasColumnType("INTEGER"); + + b.Property("SeriesId") + .HasColumnType("INTEGER"); + + b.Property("SiteUrl") + .HasColumnType("TEXT"); + + b.Property("Tagline") + .HasColumnType("TEXT"); + + b.Property("TotalVotes") + .HasColumnType("INTEGER"); + + b.Property("Username") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ChapterId"); + + b.ToTable("ExternalReview"); + }); + + modelBuilder.Entity("API.Entities.Metadata.ExternalSeriesMetadata", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AniListId") + .HasColumnType("INTEGER"); + + b.Property("AverageExternalRating") + .HasColumnType("INTEGER"); + + b.Property("CbrId") + .HasColumnType("INTEGER"); + + b.Property("GoogleBooksId") + .HasColumnType("TEXT"); + + b.Property("MalId") + .HasColumnType("INTEGER"); + + b.Property("SeriesId") + .HasColumnType("INTEGER"); + + b.Property("ValidUntilUtc") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("SeriesId") + .IsUnique(); + + b.ToTable("ExternalSeriesMetadata"); + }); + + modelBuilder.Entity("API.Entities.Metadata.SeriesBlacklist", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("LastChecked") + .HasColumnType("TEXT"); + + b.Property("SeriesId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("SeriesId"); + + b.ToTable("SeriesBlacklist"); + }); + + 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("ImprintLocked") + .HasColumnType("INTEGER"); + + b.Property("InkerLocked") + .HasColumnType("INTEGER"); + + b.Property("Language") + .HasColumnType("TEXT"); + + b.Property("LanguageLocked") + .HasColumnType("INTEGER"); + + b.Property("LettererLocked") + .HasColumnType("INTEGER"); + + b.Property("LocationLocked") + .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("TeamLocked") + .HasColumnType("INTEGER"); + + b.Property("TotalCount") + .HasColumnType("INTEGER"); + + b.Property("TranslatorLocked") + .HasColumnType("INTEGER"); + + b.Property("WebLinks") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT") + .HasDefaultValue(""); + + 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.MetadataFieldMapping", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DestinationType") + .HasColumnType("INTEGER"); + + b.Property("DestinationValue") + .HasColumnType("TEXT"); + + b.Property("ExcludeFromSource") + .HasColumnType("INTEGER"); + + b.Property("MetadataSettingsId") + .HasColumnType("INTEGER"); + + b.Property("SourceType") + .HasColumnType("INTEGER"); + + b.Property("SourceValue") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("MetadataSettingsId"); + + b.ToTable("MetadataFieldMapping"); + }); + + modelBuilder.Entity("API.Entities.MetadataMatching.MetadataSettings", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AgeRatingMappings") + .HasColumnType("TEXT"); + + b.Property("Blacklist") + .HasColumnType("TEXT"); + + b.Property("EnableChapterCoverImage") + .HasColumnType("INTEGER"); + + b.Property("EnableChapterPublisher") + .HasColumnType("INTEGER"); + + b.Property("EnableChapterReleaseDate") + .HasColumnType("INTEGER"); + + b.Property("EnableChapterSummary") + .HasColumnType("INTEGER"); + + b.Property("EnableChapterTitle") + .HasColumnType("INTEGER"); + + b.Property("EnableCoverImage") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("EnableGenres") + .HasColumnType("INTEGER"); + + b.Property("EnableLocalizedName") + .HasColumnType("INTEGER"); + + b.Property("EnablePeople") + .HasColumnType("INTEGER"); + + b.Property("EnablePublicationStatus") + .HasColumnType("INTEGER"); + + b.Property("EnableRelationships") + .HasColumnType("INTEGER"); + + b.Property("EnableStartDate") + .HasColumnType("INTEGER"); + + b.Property("EnableSummary") + .HasColumnType("INTEGER"); + + b.Property("EnableTags") + .HasColumnType("INTEGER"); + + b.Property("Enabled") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("FirstLastPeopleNaming") + .HasColumnType("INTEGER"); + + b.Property("Overrides") + .HasColumnType("TEXT"); + + b.PrimitiveCollection("PersonRoles") + .HasColumnType("TEXT"); + + b.Property("Whitelist") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("MetadataSettings"); + }); + + modelBuilder.Entity("API.Entities.Person.ChapterPeople", b => + { + b.Property("ChapterId") + .HasColumnType("INTEGER"); + + b.Property("PersonId") + .HasColumnType("INTEGER"); + + b.Property("Role") + .HasColumnType("INTEGER"); + + b.Property("KavitaPlusConnection") + .HasColumnType("INTEGER"); + + b.Property("OrderWeight") + .HasColumnType("INTEGER"); + + b.HasKey("ChapterId", "PersonId", "Role"); + + b.HasIndex("PersonId"); + + b.ToTable("ChapterPeople"); + }); + + modelBuilder.Entity("API.Entities.Person.Person", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AniListId") + .HasColumnType("INTEGER"); + + b.Property("Asin") + .HasColumnType("TEXT"); + + b.Property("CoverImage") + .HasColumnType("TEXT"); + + b.Property("CoverImageLocked") + .HasColumnType("INTEGER"); + + b.Property("Description") + .HasColumnType("TEXT"); + + b.Property("HardcoverId") + .HasColumnType("TEXT"); + + b.Property("MalId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("NormalizedName") + .HasColumnType("TEXT"); + + b.Property("PrimaryColor") + .HasColumnType("TEXT"); + + b.Property("SecondaryColor") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Person"); + }); + + modelBuilder.Entity("API.Entities.Person.PersonAlias", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Alias") + .HasColumnType("TEXT"); + + b.Property("NormalizedAlias") + .HasColumnType("TEXT"); + + b.Property("PersonId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("PersonId"); + + b.ToTable("PersonAlias"); + }); + + modelBuilder.Entity("API.Entities.Person.SeriesMetadataPeople", b => + { + b.Property("SeriesMetadataId") + .HasColumnType("INTEGER"); + + b.Property("PersonId") + .HasColumnType("INTEGER"); + + b.Property("Role") + .HasColumnType("INTEGER"); + + b.Property("KavitaPlusConnection") + .HasColumnType("INTEGER"); + + b.Property("OrderWeight") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(0); + + b.HasKey("SeriesMetadataId", "PersonId", "Role"); + + b.HasIndex("PersonId"); + + b.ToTable("SeriesMetadataPeople"); + }); + + 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("CreatedUtc") + .HasColumnType("TEXT"); + + b.Property("EndingMonth") + .HasColumnType("INTEGER"); + + b.Property("EndingYear") + .HasColumnType("INTEGER"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastModifiedUtc") + .HasColumnType("TEXT"); + + b.Property("NormalizedTitle") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("PrimaryColor") + .HasColumnType("TEXT"); + + b.Property("Promoted") + .HasColumnType("INTEGER"); + + b.Property("SecondaryColor") + .HasColumnType("TEXT"); + + b.Property("StartingMonth") + .HasColumnType("INTEGER"); + + b.Property("StartingYear") + .HasColumnType("INTEGER"); + + b.Property("Summary") + .HasColumnType("TEXT"); + + b.Property("Title") + .IsRequired() + .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.Scrobble.ScrobbleError", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Comment") + .HasColumnType("TEXT"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("CreatedUtc") + .HasColumnType("TEXT"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastModifiedUtc") + .HasColumnType("TEXT"); + + b.Property("LibraryId") + .HasColumnType("INTEGER"); + + b.Property("ScrobbleEventId") + .HasColumnType("INTEGER"); + + b.Property("ScrobbleEventId1") + .HasColumnType("INTEGER"); + + b.Property("SeriesId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ScrobbleEventId1"); + + b.HasIndex("SeriesId"); + + b.ToTable("ScrobbleError"); + }); + + modelBuilder.Entity("API.Entities.Scrobble.ScrobbleEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AniListId") + .HasColumnType("INTEGER"); + + b.Property("AppUserId") + .HasColumnType("INTEGER"); + + b.Property("ChapterNumber") + .HasColumnType("INTEGER"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("CreatedUtc") + .HasColumnType("TEXT"); + + b.Property("ErrorDetails") + .HasColumnType("TEXT"); + + b.Property("Format") + .HasColumnType("INTEGER"); + + b.Property("IsErrored") + .HasColumnType("INTEGER"); + + b.Property("IsProcessed") + .HasColumnType("INTEGER"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastModifiedUtc") + .HasColumnType("TEXT"); + + b.Property("LibraryId") + .HasColumnType("INTEGER"); + + b.Property("MalId") + .HasColumnType("INTEGER"); + + b.Property("ProcessDateUtc") + .HasColumnType("TEXT"); + + b.Property("Rating") + .HasColumnType("REAL"); + + b.Property("ReviewBody") + .HasColumnType("TEXT"); + + b.Property("ReviewTitle") + .HasColumnType("TEXT"); + + b.Property("ScrobbleEventType") + .HasColumnType("INTEGER"); + + b.Property("SeriesId") + .HasColumnType("INTEGER"); + + b.Property("VolumeNumber") + .HasColumnType("REAL"); + + b.HasKey("Id"); + + b.HasIndex("AppUserId"); + + b.HasIndex("LibraryId"); + + b.HasIndex("SeriesId"); + + b.ToTable("ScrobbleEvent"); + }); + + modelBuilder.Entity("API.Entities.Scrobble.ScrobbleHold", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AppUserId") + .HasColumnType("INTEGER"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("CreatedUtc") + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastModifiedUtc") + .HasColumnType("TEXT"); + + b.Property("SeriesId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("AppUserId"); + + b.HasIndex("SeriesId"); + + b.ToTable("ScrobbleHold"); + }); + + modelBuilder.Entity("API.Entities.Series", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AvgHoursToRead") + .HasColumnType("REAL"); + + b.Property("CoverImage") + .HasColumnType("TEXT"); + + b.Property("CoverImageLocked") + .HasColumnType("INTEGER"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("CreatedUtc") + .HasColumnType("TEXT"); + + b.Property("DontMatch") + .HasColumnType("INTEGER"); + + b.Property("FolderPath") + .HasColumnType("TEXT"); + + b.Property("Format") + .HasColumnType("INTEGER"); + + b.Property("IsBlacklisted") + .HasColumnType("INTEGER"); + + b.Property("LastChapterAdded") + .HasColumnType("TEXT"); + + b.Property("LastChapterAddedUtc") + .HasColumnType("TEXT"); + + b.Property("LastFolderScanned") + .HasColumnType("TEXT"); + + b.Property("LastFolderScannedUtc") + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastModifiedUtc") + .HasColumnType("TEXT"); + + b.Property("LibraryId") + .HasColumnType("INTEGER"); + + b.Property("LocalizedName") + .HasColumnType("TEXT"); + + b.Property("LocalizedNameLocked") + .HasColumnType("INTEGER"); + + b.Property("LowestFolderPath") + .HasColumnType("TEXT"); + + b.Property("MaxHoursToRead") + .HasColumnType("INTEGER"); + + b.Property("MinHoursToRead") + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("NormalizedLocalizedName") + .HasColumnType("TEXT"); + + b.Property("NormalizedName") + .HasColumnType("TEXT"); + + b.Property("OriginalName") + .HasColumnType("TEXT"); + + b.Property("Pages") + .HasColumnType("INTEGER"); + + b.Property("PrimaryColor") + .HasColumnType("TEXT"); + + b.Property("SecondaryColor") + .HasColumnType("TEXT"); + + b.Property("SortName") + .HasColumnType("TEXT"); + + b.Property("SortNameLocked") + .HasColumnType("INTEGER"); + + b.Property("WordCount") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + 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.ServerStatistics", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChapterCount") + .HasColumnType("INTEGER"); + + b.Property("FileCount") + .HasColumnType("INTEGER"); + + b.Property("GenreCount") + .HasColumnType("INTEGER"); + + b.Property("PersonCount") + .HasColumnType("INTEGER"); + + b.Property("SeriesCount") + .HasColumnType("INTEGER"); + + b.Property("TagCount") + .HasColumnType("INTEGER"); + + b.Property("UserCount") + .HasColumnType("INTEGER"); + + b.Property("VolumeCount") + .HasColumnType("INTEGER"); + + b.Property("Year") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("ServerStatistics"); + }); + + modelBuilder.Entity("API.Entities.SiteTheme", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Author") + .HasColumnType("TEXT"); + + b.Property("CompatibleVersion") + .HasColumnType("TEXT"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("CreatedUtc") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasColumnType("TEXT"); + + b.Property("FileName") + .HasColumnType("TEXT"); + + b.Property("GitHubPath") + .HasColumnType("TEXT"); + + b.Property("IsDefault") + .HasColumnType("INTEGER"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastModifiedUtc") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("NormalizedName") + .HasColumnType("TEXT"); + + b.Property("PreviewUrls") + .HasColumnType("TEXT"); + + b.Property("Provider") + .HasColumnType("INTEGER"); + + b.Property("ShaHash") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("SiteTheme"); + }); + + modelBuilder.Entity("API.Entities.Tag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("NormalizedTitle") + .HasColumnType("TEXT"); + + b.Property("Title") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedTitle") + .IsUnique(); + + b.ToTable("Tag"); + }); + + modelBuilder.Entity("API.Entities.Volume", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AvgHoursToRead") + .HasColumnType("REAL"); + + b.Property("CoverImage") + .HasColumnType("TEXT"); + + b.Property("CoverImageLocked") + .HasColumnType("INTEGER"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("CreatedUtc") + .HasColumnType("TEXT"); + + b.Property("LastModified") + .HasColumnType("TEXT"); + + b.Property("LastModifiedUtc") + .HasColumnType("TEXT"); + + b.Property("LookupName") + .HasColumnType("TEXT"); + + b.Property("MaxHoursToRead") + .HasColumnType("INTEGER"); + + b.Property("MaxNumber") + .HasColumnType("REAL"); + + b.Property("MinHoursToRead") + .HasColumnType("INTEGER"); + + b.Property("MinNumber") + .HasColumnType("REAL"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Number") + .HasColumnType("INTEGER"); + + b.Property("Pages") + .HasColumnType("INTEGER"); + + b.Property("PrimaryColor") + .HasColumnType("TEXT"); + + b.Property("SecondaryColor") + .HasColumnType("TEXT"); + + b.Property("SeriesId") + .HasColumnType("INTEGER"); + + b.Property("WordCount") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("SeriesId"); + + b.ToTable("Volume"); + }); + + modelBuilder.Entity("AppUserCollectionSeries", b => + { + b.Property("CollectionsId") + .HasColumnType("INTEGER"); + + b.Property("ItemsId") + .HasColumnType("INTEGER"); + + b.HasKey("CollectionsId", "ItemsId"); + + b.HasIndex("ItemsId"); + + b.ToTable("AppUserCollectionSeries"); + }); + + 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("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("ExternalRatingExternalSeriesMetadata", b => + { + b.Property("ExternalRatingsId") + .HasColumnType("INTEGER"); + + b.Property("ExternalSeriesMetadatasId") + .HasColumnType("INTEGER"); + + b.HasKey("ExternalRatingsId", "ExternalSeriesMetadatasId"); + + b.HasIndex("ExternalSeriesMetadatasId"); + + b.ToTable("ExternalRatingExternalSeriesMetadata"); + }); + + modelBuilder.Entity("ExternalRecommendationExternalSeriesMetadata", b => + { + b.Property("ExternalRecommendationsId") + .HasColumnType("INTEGER"); + + b.Property("ExternalSeriesMetadatasId") + .HasColumnType("INTEGER"); + + b.HasKey("ExternalRecommendationsId", "ExternalSeriesMetadatasId"); + + b.HasIndex("ExternalSeriesMetadatasId"); + + b.ToTable("ExternalRecommendationExternalSeriesMetadata"); + }); + + modelBuilder.Entity("ExternalReviewExternalSeriesMetadata", b => + { + b.Property("ExternalReviewsId") + .HasColumnType("INTEGER"); + + b.Property("ExternalSeriesMetadatasId") + .HasColumnType("INTEGER"); + + b.HasKey("ExternalReviewsId", "ExternalSeriesMetadatasId"); + + b.HasIndex("ExternalSeriesMetadatasId"); + + b.ToTable("ExternalReviewExternalSeriesMetadata"); + }); + + 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("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.AppUserChapterRating", b => + { + b.HasOne("API.Entities.AppUser", "AppUser") + .WithMany("ChapterRatings") + .HasForeignKey("AppUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Chapter", "Chapter") + .WithMany("Ratings") + .HasForeignKey("ChapterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Series", "Series") + .WithMany() + .HasForeignKey("SeriesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AppUser"); + + b.Navigation("Chapter"); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("API.Entities.AppUserCollection", b => + { + b.HasOne("API.Entities.AppUser", "AppUser") + .WithMany("Collections") + .HasForeignKey("AppUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AppUser"); + }); + + modelBuilder.Entity("API.Entities.AppUserDashboardStream", b => + { + b.HasOne("API.Entities.AppUser", "AppUser") + .WithMany("DashboardStreams") + .HasForeignKey("AppUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.AppUserSmartFilter", "SmartFilter") + .WithMany() + .HasForeignKey("SmartFilterId"); + + b.Navigation("AppUser"); + + b.Navigation("SmartFilter"); + }); + + modelBuilder.Entity("API.Entities.AppUserExternalSource", b => + { + b.HasOne("API.Entities.AppUser", "AppUser") + .WithMany("ExternalSources") + .HasForeignKey("AppUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AppUser"); + }); + + modelBuilder.Entity("API.Entities.AppUserOnDeckRemoval", b => + { + b.HasOne("API.Entities.AppUser", "AppUser") + .WithMany() + .HasForeignKey("AppUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Series", "Series") + .WithMany() + .HasForeignKey("SeriesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AppUser"); + + b.Navigation("Series"); + }); + + 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.Chapter", null) + .WithMany("UserProgress") + .HasForeignKey("ChapterId") + .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", "Series") + .WithMany("Ratings") + .HasForeignKey("SeriesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AppUser"); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("API.Entities.AppUserReadingProfile", b => + { + b.HasOne("API.Entities.AppUser", "AppUser") + .WithMany("ReadingProfiles") + .HasForeignKey("AppUserId") + .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.AppUserSideNavStream", b => + { + b.HasOne("API.Entities.AppUser", "AppUser") + .WithMany("SideNavStreams") + .HasForeignKey("AppUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.AppUserSmartFilter", "SmartFilter") + .WithMany() + .HasForeignKey("SmartFilterId"); + + b.Navigation("AppUser"); + + b.Navigation("SmartFilter"); + }); + + modelBuilder.Entity("API.Entities.AppUserSmartFilter", b => + { + b.HasOne("API.Entities.AppUser", "AppUser") + .WithMany("SmartFilters") + .HasForeignKey("AppUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AppUser"); + }); + + modelBuilder.Entity("API.Entities.AppUserTableOfContent", b => + { + b.HasOne("API.Entities.AppUser", "AppUser") + .WithMany("TableOfContents") + .HasForeignKey("AppUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Chapter", "Chapter") + .WithMany() + .HasForeignKey("ChapterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Series", "Series") + .WithMany() + .HasForeignKey("SeriesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AppUser"); + + b.Navigation("Chapter"); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("API.Entities.AppUserWantToRead", b => + { + b.HasOne("API.Entities.AppUser", "AppUser") + .WithMany("WantToRead") + .HasForeignKey("AppUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Series", "Series") + .WithMany() + .HasForeignKey("SeriesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AppUser"); + + b.Navigation("Series"); + }); + + 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.EmailHistory", b => + { + b.HasOne("API.Entities.AppUser", "AppUser") + .WithMany() + .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.LibraryExcludePattern", b => + { + b.HasOne("API.Entities.Library", "Library") + .WithMany("LibraryExcludePatterns") + .HasForeignKey("LibraryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Library"); + }); + + modelBuilder.Entity("API.Entities.LibraryFileTypeGroup", b => + { + b.HasOne("API.Entities.Library", "Library") + .WithMany("LibraryFileTypes") + .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.ExternalRating", b => + { + b.HasOne("API.Entities.Chapter", null) + .WithMany("ExternalRatings") + .HasForeignKey("ChapterId"); + }); + + modelBuilder.Entity("API.Entities.Metadata.ExternalReview", b => + { + b.HasOne("API.Entities.Chapter", null) + .WithMany("ExternalReviews") + .HasForeignKey("ChapterId"); + }); + + modelBuilder.Entity("API.Entities.Metadata.ExternalSeriesMetadata", b => + { + b.HasOne("API.Entities.Series", "Series") + .WithOne("ExternalSeriesMetadata") + .HasForeignKey("API.Entities.Metadata.ExternalSeriesMetadata", "SeriesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("API.Entities.Metadata.SeriesBlacklist", b => + { + b.HasOne("API.Entities.Series", "Series") + .WithMany() + .HasForeignKey("SeriesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Series"); + }); + + 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.MetadataFieldMapping", b => + { + b.HasOne("API.Entities.MetadataMatching.MetadataSettings", "MetadataSettings") + .WithMany("FieldMappings") + .HasForeignKey("MetadataSettingsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MetadataSettings"); + }); + + modelBuilder.Entity("API.Entities.Person.ChapterPeople", b => + { + b.HasOne("API.Entities.Chapter", "Chapter") + .WithMany("People") + .HasForeignKey("ChapterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Person.Person", "Person") + .WithMany("ChapterPeople") + .HasForeignKey("PersonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Chapter"); + + b.Navigation("Person"); + }); + + modelBuilder.Entity("API.Entities.Person.PersonAlias", b => + { + b.HasOne("API.Entities.Person.Person", "Person") + .WithMany("Aliases") + .HasForeignKey("PersonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Person"); + }); + + modelBuilder.Entity("API.Entities.Person.SeriesMetadataPeople", b => + { + b.HasOne("API.Entities.Person.Person", "Person") + .WithMany("SeriesMetadataPeople") + .HasForeignKey("PersonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Metadata.SeriesMetadata", "SeriesMetadata") + .WithMany("People") + .HasForeignKey("SeriesMetadataId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Person"); + + b.Navigation("SeriesMetadata"); + }); + + 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.Scrobble.ScrobbleError", b => + { + b.HasOne("API.Entities.Scrobble.ScrobbleEvent", "ScrobbleEvent") + .WithMany() + .HasForeignKey("ScrobbleEventId1"); + + b.HasOne("API.Entities.Series", "Series") + .WithMany() + .HasForeignKey("SeriesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ScrobbleEvent"); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("API.Entities.Scrobble.ScrobbleEvent", b => + { + b.HasOne("API.Entities.AppUser", "AppUser") + .WithMany() + .HasForeignKey("AppUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Library", "Library") + .WithMany() + .HasForeignKey("LibraryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Series", "Series") + .WithMany() + .HasForeignKey("SeriesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AppUser"); + + b.Navigation("Library"); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("API.Entities.Scrobble.ScrobbleHold", b => + { + b.HasOne("API.Entities.AppUser", "AppUser") + .WithMany("ScrobbleHolds") + .HasForeignKey("AppUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Series", "Series") + .WithMany() + .HasForeignKey("SeriesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AppUser"); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("API.Entities.Series", b => + { + 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("AppUserCollectionSeries", b => + { + b.HasOne("API.Entities.AppUserCollection", null) + .WithMany() + .HasForeignKey("CollectionsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Series", null) + .WithMany() + .HasForeignKey("ItemsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + 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("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("ExternalRatingExternalSeriesMetadata", b => + { + b.HasOne("API.Entities.Metadata.ExternalRating", null) + .WithMany() + .HasForeignKey("ExternalRatingsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Metadata.ExternalSeriesMetadata", null) + .WithMany() + .HasForeignKey("ExternalSeriesMetadatasId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ExternalRecommendationExternalSeriesMetadata", b => + { + b.HasOne("API.Entities.Metadata.ExternalRecommendation", null) + .WithMany() + .HasForeignKey("ExternalRecommendationsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Metadata.ExternalSeriesMetadata", null) + .WithMany() + .HasForeignKey("ExternalSeriesMetadatasId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ExternalReviewExternalSeriesMetadata", b => + { + b.HasOne("API.Entities.Metadata.ExternalReview", null) + .WithMany() + .HasForeignKey("ExternalReviewsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("API.Entities.Metadata.ExternalSeriesMetadata", null) + .WithMany() + .HasForeignKey("ExternalSeriesMetadatasId") + .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("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("ChapterRatings"); + + b.Navigation("Collections"); + + b.Navigation("DashboardStreams"); + + b.Navigation("Devices"); + + b.Navigation("ExternalSources"); + + b.Navigation("Progresses"); + + b.Navigation("Ratings"); + + b.Navigation("ReadingLists"); + + b.Navigation("ReadingProfiles"); + + b.Navigation("ScrobbleHolds"); + + b.Navigation("SideNavStreams"); + + b.Navigation("SmartFilters"); + + b.Navigation("TableOfContents"); + + b.Navigation("UserPreferences"); + + b.Navigation("UserRoles"); + + b.Navigation("WantToRead"); + }); + + modelBuilder.Entity("API.Entities.Chapter", b => + { + b.Navigation("ExternalRatings"); + + b.Navigation("ExternalReviews"); + + b.Navigation("Files"); + + b.Navigation("People"); + + b.Navigation("Ratings"); + + b.Navigation("UserProgress"); + }); + + modelBuilder.Entity("API.Entities.Library", b => + { + b.Navigation("Folders"); + + b.Navigation("LibraryExcludePatterns"); + + b.Navigation("LibraryFileTypes"); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("API.Entities.Metadata.SeriesMetadata", b => + { + b.Navigation("People"); + }); + + modelBuilder.Entity("API.Entities.MetadataMatching.MetadataSettings", b => + { + b.Navigation("FieldMappings"); + }); + + modelBuilder.Entity("API.Entities.Person.Person", b => + { + b.Navigation("Aliases"); + + b.Navigation("ChapterPeople"); + + b.Navigation("SeriesMetadataPeople"); + }); + + modelBuilder.Entity("API.Entities.ReadingList", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("API.Entities.Series", b => + { + b.Navigation("ExternalSeriesMetadata"); + + 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/20250601200056_ReadingProfiles.cs b/API/Data/Migrations/20250601200056_ReadingProfiles.cs new file mode 100644 index 000000000..66b9e53e5 --- /dev/null +++ b/API/Data/Migrations/20250601200056_ReadingProfiles.cs @@ -0,0 +1,75 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace API.Data.Migrations +{ + /// + public partial class ReadingProfiles : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "AppUserReadingProfiles", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Name = table.Column(type: "TEXT", nullable: true), + NormalizedName = table.Column(type: "TEXT", nullable: true), + AppUserId = table.Column(type: "INTEGER", nullable: false), + Kind = table.Column(type: "INTEGER", nullable: false), + LibraryIds = table.Column(type: "TEXT", nullable: true), + SeriesIds = table.Column(type: "TEXT", nullable: true), + ReadingDirection = table.Column(type: "INTEGER", nullable: false), + ScalingOption = table.Column(type: "INTEGER", nullable: false), + PageSplitOption = table.Column(type: "INTEGER", nullable: false), + ReaderMode = table.Column(type: "INTEGER", nullable: false), + AutoCloseMenu = table.Column(type: "INTEGER", nullable: false), + ShowScreenHints = table.Column(type: "INTEGER", nullable: false), + EmulateBook = table.Column(type: "INTEGER", nullable: false), + LayoutMode = table.Column(type: "INTEGER", nullable: false), + BackgroundColor = table.Column(type: "TEXT", nullable: true, defaultValue: "#000000"), + SwipeToPaginate = table.Column(type: "INTEGER", nullable: false), + AllowAutomaticWebtoonReaderDetection = table.Column(type: "INTEGER", nullable: false, defaultValue: true), + WidthOverride = table.Column(type: "INTEGER", nullable: true), + BookReaderMargin = table.Column(type: "INTEGER", nullable: false), + BookReaderLineSpacing = table.Column(type: "INTEGER", nullable: false), + BookReaderFontSize = table.Column(type: "INTEGER", nullable: false), + BookReaderFontFamily = table.Column(type: "TEXT", nullable: true), + BookReaderTapToPaginate = table.Column(type: "INTEGER", nullable: false), + BookReaderReadingDirection = table.Column(type: "INTEGER", nullable: false), + BookReaderWritingStyle = table.Column(type: "INTEGER", nullable: false, defaultValue: 0), + BookThemeName = table.Column(type: "TEXT", nullable: true, defaultValue: "Dark"), + BookReaderLayoutMode = table.Column(type: "INTEGER", nullable: false), + BookReaderImmersiveMode = table.Column(type: "INTEGER", nullable: false), + PdfTheme = table.Column(type: "INTEGER", nullable: false), + PdfScrollMode = table.Column(type: "INTEGER", nullable: false), + PdfSpreadMode = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AppUserReadingProfiles", x => x.Id); + table.ForeignKey( + name: "FK_AppUserReadingProfiles_AspNetUsers_AppUserId", + column: x => x.AppUserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_AppUserReadingProfiles_AppUserId", + table: "AppUserReadingProfiles", + column: "AppUserId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AppUserReadingProfiles"); + } + } +} diff --git a/API/Data/Migrations/DataContextModelSnapshot.cs b/API/Data/Migrations/DataContextModelSnapshot.cs index bdeb3d7c4..25db64e2a 100644 --- a/API/Data/Migrations/DataContextModelSnapshot.cs +++ b/API/Data/Migrations/DataContextModelSnapshot.cs @@ -609,6 +609,120 @@ namespace API.Data.Migrations b.ToTable("AppUserRating"); }); + modelBuilder.Entity("API.Entities.AppUserReadingProfile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AllowAutomaticWebtoonReaderDetection") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("AppUserId") + .HasColumnType("INTEGER"); + + b.Property("AutoCloseMenu") + .HasColumnType("INTEGER"); + + b.Property("BackgroundColor") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT") + .HasDefaultValue("#000000"); + + 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("BookReaderWritingStyle") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(0); + + b.Property("BookThemeName") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT") + .HasDefaultValue("Dark"); + + b.Property("EmulateBook") + .HasColumnType("INTEGER"); + + b.Property("Kind") + .HasColumnType("INTEGER"); + + b.Property("LayoutMode") + .HasColumnType("INTEGER"); + + b.Property("LibraryIds") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("NormalizedName") + .HasColumnType("TEXT"); + + b.Property("PageSplitOption") + .HasColumnType("INTEGER"); + + b.Property("PdfScrollMode") + .HasColumnType("INTEGER"); + + b.Property("PdfSpreadMode") + .HasColumnType("INTEGER"); + + b.Property("PdfTheme") + .HasColumnType("INTEGER"); + + b.Property("ReaderMode") + .HasColumnType("INTEGER"); + + b.Property("ReadingDirection") + .HasColumnType("INTEGER"); + + b.Property("ScalingOption") + .HasColumnType("INTEGER"); + + b.PrimitiveCollection("SeriesIds") + .HasColumnType("TEXT"); + + b.Property("ShowScreenHints") + .HasColumnType("INTEGER"); + + b.Property("SwipeToPaginate") + .HasColumnType("INTEGER"); + + b.Property("WidthOverride") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("AppUserId"); + + b.ToTable("AppUserReadingProfiles"); + }); + modelBuilder.Entity("API.Entities.AppUserRole", b => { b.Property("UserId") @@ -2838,6 +2952,17 @@ namespace API.Data.Migrations b.Navigation("Series"); }); + modelBuilder.Entity("API.Entities.AppUserReadingProfile", b => + { + b.HasOne("API.Entities.AppUser", "AppUser") + .WithMany("ReadingProfiles") + .HasForeignKey("AppUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AppUser"); + }); + modelBuilder.Entity("API.Entities.AppUserRole", b => { b.HasOne("API.Entities.AppRole", "Role") @@ -3476,6 +3601,8 @@ namespace API.Data.Migrations b.Navigation("ReadingLists"); + b.Navigation("ReadingProfiles"); + b.Navigation("ScrobbleHolds"); b.Navigation("SideNavStreams"); diff --git a/API/Data/Repositories/AppUserReadingProfileRepository.cs b/API/Data/Repositories/AppUserReadingProfileRepository.cs new file mode 100644 index 000000000..11b97f21a --- /dev/null +++ b/API/Data/Repositories/AppUserReadingProfileRepository.cs @@ -0,0 +1,112 @@ +#nullable enable +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using API.DTOs; +using API.Entities; +using API.Entities.Enums; +using API.Extensions; +using API.Extensions.QueryExtensions; +using AutoMapper; +using AutoMapper.QueryableExtensions; +using Microsoft.EntityFrameworkCore; + +namespace API.Data.Repositories; + + +public interface IAppUserReadingProfileRepository +{ + + /// + /// Return the given profile if it belongs the user + /// + /// + /// + /// + Task GetUserProfile(int userId, int profileId); + /// + /// Returns all reading profiles for the user + /// + /// + /// + Task> GetProfilesForUser(int userId, bool skipImplicit = false); + /// + /// Returns all reading profiles for the user + /// + /// + /// + Task> GetProfilesDtoForUser(int userId, bool skipImplicit = false); + /// + /// Is there a user reading profile with this name (normalized) + /// + /// + /// + /// + Task IsProfileNameInUse(int userId, string name); + + void Add(AppUserReadingProfile readingProfile); + void Update(AppUserReadingProfile readingProfile); + void Remove(AppUserReadingProfile readingProfile); + void RemoveRange(IEnumerable readingProfiles); +} + +public class AppUserReadingProfileRepository(DataContext context, IMapper mapper): IAppUserReadingProfileRepository +{ + public async Task GetUserProfile(int userId, int profileId) + { + return await context.AppUserReadingProfiles + .Where(rp => rp.AppUserId == userId && rp.Id == profileId) + .FirstOrDefaultAsync(); + } + + public async Task> GetProfilesForUser(int userId, bool skipImplicit = false) + { + return await context.AppUserReadingProfiles + .Where(rp => rp.AppUserId == userId) + .WhereIf(skipImplicit, rp => rp.Kind != ReadingProfileKind.Implicit) + .ToListAsync(); + } + + /// + /// Returns all Reading Profiles for the User + /// + /// + /// + public async Task> GetProfilesDtoForUser(int userId, bool skipImplicit = false) + { + return await context.AppUserReadingProfiles + .Where(rp => rp.AppUserId == userId) + .WhereIf(skipImplicit, rp => rp.Kind != ReadingProfileKind.Implicit) + .ProjectTo(mapper.ConfigurationProvider) + .ToListAsync(); + } + + public async Task IsProfileNameInUse(int userId, string name) + { + var normalizedName = name.ToNormalized(); + + return await context.AppUserReadingProfiles + .Where(rp => rp.NormalizedName == normalizedName && rp.AppUserId == userId) + .AnyAsync(); + } + + public void Add(AppUserReadingProfile readingProfile) + { + context.AppUserReadingProfiles.Add(readingProfile); + } + + public void Update(AppUserReadingProfile readingProfile) + { + context.AppUserReadingProfiles.Update(readingProfile).State = EntityState.Modified; + } + + public void Remove(AppUserReadingProfile readingProfile) + { + context.AppUserReadingProfiles.Remove(readingProfile); + } + + public void RemoveRange(IEnumerable readingProfiles) + { + context.AppUserReadingProfiles.RemoveRange(readingProfiles); + } +} diff --git a/API/Data/Repositories/GenreRepository.cs b/API/Data/Repositories/GenreRepository.cs index ef9dfa7ec..d9bc20c99 100644 --- a/API/Data/Repositories/GenreRepository.cs +++ b/API/Data/Repositories/GenreRepository.cs @@ -111,7 +111,7 @@ public class GenreRepository : IGenreRepository /// /// Returns a set of Genre tags for a set of library Ids. - /// UserId will restrict returned Genres based on user's age restriction and library access. + /// AppUserId will restrict returned Genres based on user's age restriction and library access. /// /// /// diff --git a/API/Data/Repositories/UserRepository.cs b/API/Data/Repositories/UserRepository.cs index e55338c8b..6437cfcfe 100644 --- a/API/Data/Repositories/UserRepository.cs +++ b/API/Data/Repositories/UserRepository.cs @@ -757,7 +757,7 @@ public class UserRepository : IUserRepository /// - /// Fetches the UserId by API Key. This does not include any extra information + /// Fetches the AppUserId by API Key. This does not include any extra information /// /// /// diff --git a/API/Data/UnitOfWork.cs b/API/Data/UnitOfWork.cs index c4a07dee7..d72dd3bc7 100644 --- a/API/Data/UnitOfWork.cs +++ b/API/Data/UnitOfWork.cs @@ -33,6 +33,7 @@ public interface IUnitOfWork IAppUserExternalSourceRepository AppUserExternalSourceRepository { get; } IExternalSeriesMetadataRepository ExternalSeriesMetadataRepository { get; } IEmailHistoryRepository EmailHistoryRepository { get; } + IAppUserReadingProfileRepository AppUserReadingProfileRepository { get; } bool Commit(); Task CommitAsync(); bool HasChanges(); @@ -74,6 +75,7 @@ public class UnitOfWork : IUnitOfWork AppUserExternalSourceRepository = new AppUserExternalSourceRepository(_context, _mapper); ExternalSeriesMetadataRepository = new ExternalSeriesMetadataRepository(_context, _mapper); EmailHistoryRepository = new EmailHistoryRepository(_context, _mapper); + AppUserReadingProfileRepository = new AppUserReadingProfileRepository(_context, _mapper); } /// @@ -103,6 +105,7 @@ public class UnitOfWork : IUnitOfWork public IAppUserExternalSourceRepository AppUserExternalSourceRepository { get; } public IExternalSeriesMetadataRepository ExternalSeriesMetadataRepository { get; } public IEmailHistoryRepository EmailHistoryRepository { get; } + public IAppUserReadingProfileRepository AppUserReadingProfileRepository { get; } /// /// Commits changes to the DB. Completes the open transaction. diff --git a/API/Entities/AppUser.cs b/API/Entities/AppUser.cs index 50f795041..848636209 100644 --- a/API/Entities/AppUser.cs +++ b/API/Entities/AppUser.cs @@ -21,6 +21,7 @@ public class AppUser : IdentityUser, IHasConcurrencyToken public ICollection Ratings { get; set; } = null!; public ICollection ChapterRatings { get; set; } = null!; public AppUserPreferences UserPreferences { get; set; } = null!; + public ICollection ReadingProfiles { get; set; } = null!; /// /// Bookmarks associated with this User /// diff --git a/API/Entities/AppUserPreferences.cs b/API/Entities/AppUserPreferences.cs index b728e84e5..b0f21bcba 100644 --- a/API/Entities/AppUserPreferences.cs +++ b/API/Entities/AppUserPreferences.cs @@ -1,4 +1,5 @@ -using API.Data; +using System.Collections.Generic; +using API.Data; using API.Entities.Enums; using API.Entities.Enums.UserPreferences; diff --git a/API/Entities/AppUserReadingProfile.cs b/API/Entities/AppUserReadingProfile.cs new file mode 100644 index 000000000..ad2548661 --- /dev/null +++ b/API/Entities/AppUserReadingProfile.cs @@ -0,0 +1,143 @@ +using System.Collections.Generic; +using API.Entities.Enums; +using API.Entities.Enums.UserPreferences; + +namespace API.Entities; + +public class AppUserReadingProfile +{ + public int Id { get; set; } + + public string Name { get; set; } + public string NormalizedName { get; set; } + + public int AppUserId { get; set; } + public AppUser AppUser { get; set; } + + public ReadingProfileKind Kind { get; set; } + public List LibraryIds { get; set; } + public List SeriesIds { get; set; } + + #region MangaReader + + /// + /// Manga Reader Option: What direction should the next/prev page buttons go + /// + public ReadingDirection ReadingDirection { get; set; } = ReadingDirection.LeftToRight; + /// + /// Manga Reader Option: How should the image be scaled to screen + /// + public ScalingOption ScalingOption { get; set; } = ScalingOption.Automatic; + /// + /// Manga Reader Option: Which side of a split image should we show first + /// + public PageSplitOption PageSplitOption { get; set; } = PageSplitOption.FitSplit; + /// + /// Manga Reader Option: How the manga reader should perform paging or reading of the file + /// + /// Webtoon uses scrolling to page, MANGA_LR uses paging by clicking left/right side of reader, MANGA_UD uses paging + /// by clicking top/bottom sides of reader. + /// + /// + public ReaderMode ReaderMode { get; set; } + /// + /// Manga Reader Option: Allow the menu to close after 6 seconds without interaction + /// + public bool AutoCloseMenu { get; set; } = true; + /// + /// Manga Reader Option: Show screen hints to the user on some actions, ie) pagination direction change + /// + public bool ShowScreenHints { get; set; } = true; + /// + /// Manga Reader Option: Emulate a book by applying a shadow effect on the pages + /// + public bool EmulateBook { get; set; } = false; + /// + /// Manga Reader Option: How many pages to display in the reader at once + /// + public LayoutMode LayoutMode { get; set; } = LayoutMode.Single; + /// + /// Manga Reader Option: Background color of the reader + /// + public string BackgroundColor { get; set; } = "#000000"; + /// + /// Manga Reader Option: Should swiping trigger pagination + /// + public bool SwipeToPaginate { get; set; } + /// + /// Manga Reader Option: Allow Automatic Webtoon detection + /// + public bool AllowAutomaticWebtoonReaderDetection { get; set; } + /// + /// Manga Reader Option: Optional fixed width override + /// + public int? WidthOverride { get; set; } = null; + + #endregion + + #region EpubReader + + /// + /// Book Reader Option: Override extra Margin + /// + public int BookReaderMargin { get; set; } = 15; + /// + /// Book Reader Option: Override line-height + /// + public int BookReaderLineSpacing { get; set; } = 100; + /// + /// Book Reader Option: Override font size + /// + public int BookReaderFontSize { get; set; } = 100; + /// + /// Book Reader Option: Maps to the default Kavita font-family (inherit) or an override + /// + public string BookReaderFontFamily { get; set; } = "default"; + /// + /// Book Reader Option: Allows tapping on side of screens to paginate + /// + public bool BookReaderTapToPaginate { get; set; } = false; + /// + /// Book Reader Option: What direction should the next/prev page buttons go + /// + public ReadingDirection BookReaderReadingDirection { get; set; } = ReadingDirection.LeftToRight; + /// + /// Book Reader Option: Defines the writing styles vertical/horizontal + /// + public WritingStyle BookReaderWritingStyle { get; set; } = WritingStyle.Horizontal; + /// + /// Book Reader Option: The color theme to decorate the book contents + /// + /// Should default to Dark + public string BookThemeName { get; set; } = "Dark"; + /// + /// Book Reader Option: The way a page from a book is rendered. Default is as book dictates, 1 column is fit to height, + /// 2 column is fit to height, 2 columns + /// + /// Defaults to Default + public BookPageLayoutMode BookReaderLayoutMode { get; set; } = BookPageLayoutMode.Default; + /// + /// Book Reader Option: A flag that hides the menu-ing system behind a click on the screen. This should be used with tap to paginate, but the app doesn't enforce this. + /// + /// Defaults to false + public bool BookReaderImmersiveMode { get; set; } = false; + #endregion + + #region PdfReader + + /// + /// PDF Reader: Theme of the Reader + /// + public PdfTheme PdfTheme { get; set; } = PdfTheme.Dark; + /// + /// PDF Reader: Scroll mode of the reader + /// + public PdfScrollMode PdfScrollMode { get; set; } = PdfScrollMode.Vertical; + /// + /// PDF Reader: Spread Mode of the reader + /// + public PdfSpreadMode PdfSpreadMode { get; set; } = PdfSpreadMode.None; + + + #endregion +} diff --git a/API/Entities/Enums/ReadingProfileKind.cs b/API/Entities/Enums/ReadingProfileKind.cs new file mode 100644 index 000000000..0f9cfa20b --- /dev/null +++ b/API/Entities/Enums/ReadingProfileKind.cs @@ -0,0 +1,17 @@ +namespace API.Entities.Enums; + +public enum ReadingProfileKind +{ + /// + /// Generate by Kavita when registering a user, this is your default profile + /// + Default, + /// + /// Created by the user in the UI or via the API + /// + User, + /// + /// Automatically generated by Kavita to track changes made in the readers. Can be converted to a User Reading Profile. + /// + Implicit +} diff --git a/API/Extensions/ApplicationServiceExtensions.cs b/API/Extensions/ApplicationServiceExtensions.cs index e95c4f65e..10f285669 100644 --- a/API/Extensions/ApplicationServiceExtensions.cs +++ b/API/Extensions/ApplicationServiceExtensions.cs @@ -54,6 +54,7 @@ public static class ApplicationServiceExtensions services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); services.AddScoped(); services.AddScoped(); diff --git a/API/Helpers/AutoMapperProfiles.cs b/API/Helpers/AutoMapperProfiles.cs index 75183fdcd..d25444a51 100644 --- a/API/Helpers/AutoMapperProfiles.cs +++ b/API/Helpers/AutoMapperProfiles.cs @@ -275,13 +275,12 @@ public class AutoMapperProfiles : Profile CreateMap() .ForMember(dest => dest.Theme, opt => - opt.MapFrom(src => src.Theme)) + opt.MapFrom(src => src.Theme)); + + CreateMap() .ForMember(dest => dest.BookReaderThemeName, opt => - opt.MapFrom(src => src.BookThemeName)) - .ForMember(dest => dest.BookReaderLayoutMode, - opt => - opt.MapFrom(src => src.BookReaderLayoutMode)); + opt.MapFrom(src => src.BookThemeName)); CreateMap(); diff --git a/API/Helpers/Builders/AppUserBuilder.cs b/API/Helpers/Builders/AppUserBuilder.cs index 282361e41..7ffac355e 100644 --- a/API/Helpers/Builders/AppUserBuilder.cs +++ b/API/Helpers/Builders/AppUserBuilder.cs @@ -21,7 +21,7 @@ public class AppUserBuilder : IEntityBuilder ApiKey = HashUtil.ApiKey(), UserPreferences = new AppUserPreferences { - Theme = theme ?? Seed.DefaultThemes.First() + Theme = theme ?? Seed.DefaultThemes.First(), }, ReadingLists = new List(), Bookmarks = new List(), @@ -31,7 +31,8 @@ public class AppUserBuilder : IEntityBuilder Devices = new List(), Id = 0, DashboardStreams = new List(), - SideNavStreams = new List() + SideNavStreams = new List(), + ReadingProfiles = [], }; } diff --git a/API/Helpers/Builders/AppUserReadingProfileBuilder.cs b/API/Helpers/Builders/AppUserReadingProfileBuilder.cs new file mode 100644 index 000000000..26da5fd86 --- /dev/null +++ b/API/Helpers/Builders/AppUserReadingProfileBuilder.cs @@ -0,0 +1,54 @@ +using API.Entities; +using API.Entities.Enums; +using API.Extensions; + +namespace API.Helpers.Builders; + +public class AppUserReadingProfileBuilder +{ + private readonly AppUserReadingProfile _profile; + + public AppUserReadingProfile Build() => _profile; + + /// + /// The profile's kind will be unless overwritten with + /// + /// + public AppUserReadingProfileBuilder(int userId) + { + _profile = new AppUserReadingProfile + { + AppUserId = userId, + Kind = ReadingProfileKind.User, + SeriesIds = [], + LibraryIds = [] + }; + } + + public AppUserReadingProfileBuilder WithSeries(Series series) + { + _profile.SeriesIds.Add(series.Id); + return this; + } + + public AppUserReadingProfileBuilder WithLibrary(Library library) + { + _profile.LibraryIds.Add(library.Id); + return this; + } + + public AppUserReadingProfileBuilder WithKind(ReadingProfileKind kind) + { + _profile.Kind = kind; + return this; + } + + public AppUserReadingProfileBuilder WithName(string name) + { + _profile.Name = name; + _profile.NormalizedName = name.ToNormalized(); + return this; + } + + +} diff --git a/API/I18N/en.json b/API/I18N/en.json index 5916bc63e..d3cd1ecd3 100644 --- a/API/I18N/en.json +++ b/API/I18N/en.json @@ -230,6 +230,8 @@ "scan-libraries": "Scan Libraries", "kavita+-data-refresh": "Kavita+ Data Refresh", "backup": "Backup", - "update-yearly-stats": "Update Yearly Stats" + "update-yearly-stats": "Update Yearly Stats", + + "generated-reading-profile-name": "Generated from {0}" } diff --git a/API/Services/Plus/ScrobblingService.cs b/API/Services/Plus/ScrobblingService.cs index ef22736d2..85814dcd9 100644 --- a/API/Services/Plus/ScrobblingService.cs +++ b/API/Services/Plus/ScrobblingService.cs @@ -261,7 +261,7 @@ public class ScrobblingService : IScrobblingService var series = await _unitOfWork.SeriesRepository.GetSeriesByIdAsync(seriesId, SeriesIncludes.Metadata | SeriesIncludes.Library); if (series == null) throw new KavitaException(await _localizationService.Translate(userId, "series-doesnt-exist")); - _logger.LogInformation("Processing Scrobbling review event for {UserId} on {SeriesName}", userId, series.Name); + _logger.LogInformation("Processing Scrobbling review event for {AppUserId} on {SeriesName}", userId, series.Name); if (await CheckIfCannotScrobble(userId, seriesId, series)) return; if (IsAniListReviewValid(reviewTitle, reviewBody)) @@ -297,7 +297,7 @@ public class ScrobblingService : IScrobblingService }; _unitOfWork.ScrobbleRepository.Attach(evt); await _unitOfWork.CommitAsync(); - _logger.LogDebug("Added Scrobbling Review update on {SeriesName} with Userid {UserId} ", series.Name, userId); + _logger.LogDebug("Added Scrobbling Review update on {SeriesName} with Userid {AppUserId} ", series.Name, userId); } private static bool IsAniListReviewValid(string reviewTitle, string reviewBody) @@ -317,7 +317,7 @@ public class ScrobblingService : IScrobblingService var user = await _unitOfWork.UserRepository.GetUserByIdAsync(userId, AppUserIncludes.UserPreferences); if (user == null || !user.UserPreferences.AniListScrobblingEnabled) return; - _logger.LogInformation("Processing Scrobbling rating event for {UserId} on {SeriesName}", userId, series.Name); + _logger.LogInformation("Processing Scrobbling rating event for {AppUserId} on {SeriesName}", userId, series.Name); if (await CheckIfCannotScrobble(userId, seriesId, series)) return; var existingEvt = await _unitOfWork.ScrobbleRepository.GetEvent(userId, series.Id, @@ -346,7 +346,7 @@ public class ScrobblingService : IScrobblingService }; _unitOfWork.ScrobbleRepository.Attach(evt); await _unitOfWork.CommitAsync(); - _logger.LogDebug("Added Scrobbling Rating update on {SeriesName} with Userid {UserId}", series.Name, userId); + _logger.LogDebug("Added Scrobbling Rating update on {SeriesName} with Userid {AppUserId}", series.Name, userId); } public static long? GetMalId(Series series) @@ -371,7 +371,7 @@ public class ScrobblingService : IScrobblingService var user = await _unitOfWork.UserRepository.GetUserByIdAsync(userId, AppUserIncludes.UserPreferences); if (user == null || !user.UserPreferences.AniListScrobblingEnabled) return; - _logger.LogInformation("Processing Scrobbling reading event for {UserId} on {SeriesName}", userId, series.Name); + _logger.LogInformation("Processing Scrobbling reading event for {AppUserId} on {SeriesName}", userId, series.Name); if (await CheckIfCannotScrobble(userId, seriesId, series)) return; var existingEvt = await _unitOfWork.ScrobbleRepository.GetEvent(userId, series.Id, @@ -418,7 +418,7 @@ public class ScrobblingService : IScrobblingService _unitOfWork.ScrobbleRepository.Attach(evt); await _unitOfWork.CommitAsync(); - _logger.LogDebug("Added Scrobbling Read update on {SeriesName} - Volume: {VolumeNumber} Chapter: {ChapterNumber} for User: {UserId}", series.Name, evt.VolumeNumber, evt.ChapterNumber, userId); + _logger.LogDebug("Added Scrobbling Read update on {SeriesName} - Volume: {VolumeNumber} Chapter: {ChapterNumber} for User: {AppUserId}", series.Name, evt.VolumeNumber, evt.ChapterNumber, userId); } catch (Exception ex) { @@ -437,7 +437,7 @@ public class ScrobblingService : IScrobblingService if (user == null || !user.UserPreferences.AniListScrobblingEnabled) return; if (await CheckIfCannotScrobble(userId, seriesId, series)) return; - _logger.LogInformation("Processing Scrobbling want-to-read event for {UserId} on {SeriesName}", userId, series.Name); + _logger.LogInformation("Processing Scrobbling want-to-read event for {AppUserId} on {SeriesName}", userId, series.Name); // Get existing events for this series/user var existingEvents = (await _unitOfWork.ScrobbleRepository.GetUserEventsForSeries(userId, seriesId)) @@ -463,7 +463,7 @@ public class ScrobblingService : IScrobblingService _unitOfWork.ScrobbleRepository.Attach(evt); await _unitOfWork.CommitAsync(); - _logger.LogDebug("Added Scrobbling WantToRead update on {SeriesName} with Userid {UserId} ", series.Name, userId); + _logger.LogDebug("Added Scrobbling WantToRead update on {SeriesName} with Userid {AppUserId} ", series.Name, userId); } private async Task CheckIfCannotScrobble(int userId, int seriesId, Series series) @@ -471,7 +471,7 @@ public class ScrobblingService : IScrobblingService if (series.DontMatch) return true; if (await _unitOfWork.UserRepository.HasHoldOnSeries(userId, seriesId)) { - _logger.LogInformation("Series {SeriesName} is on UserId {UserId}'s hold list. Not scrobbling", series.Name, + _logger.LogInformation("Series {SeriesName} is on AppUserId {AppUserId}'s hold list. Not scrobbling", series.Name, userId); return true; } @@ -750,7 +750,7 @@ public class ScrobblingService : IScrobblingService /// public async Task ClearEventsForSeries(int userId, int seriesId) { - _logger.LogInformation("Clearing Pre-existing Scrobble events for Series {SeriesId} by User {UserId} as Series is now on hold list", seriesId, userId); + _logger.LogInformation("Clearing Pre-existing Scrobble events for Series {SeriesId} by User {AppUserId} as Series is now on hold list", seriesId, userId); var events = await _unitOfWork.ScrobbleRepository.GetUserEventsForSeries(userId, seriesId); foreach (var scrobble in events) { @@ -1109,7 +1109,7 @@ public class ScrobblingService : IScrobblingService { if (ex.Message.Contains("Access token is invalid")) { - _logger.LogCritical(ex, "Access Token for UserId: {UserId} needs to be regenerated/renewed to continue scrobbling", evt.AppUser.Id); + _logger.LogCritical(ex, "Access Token for AppUserId: {AppUserId} needs to be regenerated/renewed to continue scrobbling", evt.AppUser.Id); evt.IsErrored = true; evt.ErrorDetails = AccessTokenErrorMessage; _unitOfWork.ScrobbleRepository.Update(evt); diff --git a/API/Services/ReadingProfileService.cs b/API/Services/ReadingProfileService.cs new file mode 100644 index 000000000..fbfabad70 --- /dev/null +++ b/API/Services/ReadingProfileService.cs @@ -0,0 +1,453 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using API.Data; +using API.Data.Repositories; +using API.DTOs; +using API.Entities; +using API.Entities.Enums; +using API.Extensions; +using API.Helpers.Builders; +using AutoMapper; +using Kavita.Common; + +namespace API.Services; +#nullable enable + +public interface IReadingProfileService +{ + /// + /// Returns the ReadingProfile that should be applied to the given series, walks up the tree. + /// Series (Implicit) -> Series (User) -> Library (User) -> Default + /// + /// + /// + /// + /// + Task GetReadingProfileDtoForSeries(int userId, int seriesId, bool skipImplicit = false); + + /// + /// Creates a new reading profile for a user. Name must be unique per user + /// + /// + /// + /// + Task CreateReadingProfile(int userId, UserReadingProfileDto dto); + Task PromoteImplicitProfile(int userId, int profileId); + + /// + /// Updates the implicit reading profile for a series, creates one if none exists + /// + /// + /// + /// + /// + Task UpdateImplicitReadingProfile(int userId, int seriesId, UserReadingProfileDto dto); + + /// + /// Updates the non-implicit reading profile for the given series, and removes implicit profiles + /// + /// + /// + /// + /// + Task UpdateParent(int userId, int seriesId, UserReadingProfileDto dto); + + /// + /// Updates a given reading profile for a user + /// + /// + /// + /// + /// Does not update connected series and libraries + Task UpdateReadingProfile(int userId, UserReadingProfileDto dto); + + /// + /// Deletes a given profile for a user + /// + /// + /// + /// + /// + /// The default profile for the user cannot be deleted + Task DeleteReadingProfile(int userId, int profileId); + + /// + /// Binds the reading profile to the series, and remove the implicit RP from the series if it exists + /// + /// + /// + /// + /// + Task AddProfileToSeries(int userId, int profileId, int seriesId); + /// + /// Binds the reading profile to many series, and remove the implicit RP from the series if it exists + /// + /// + /// + /// + /// + Task BulkAddProfileToSeries(int userId, int profileId, IList seriesIds); + /// + /// Remove all reading profiles bound to the series + /// + /// + /// + /// + Task ClearSeriesProfile(int userId, int seriesId); + + /// + /// Bind the reading profile to the library + /// + /// + /// + /// + /// + Task AddProfileToLibrary(int userId, int profileId, int libraryId); + /// + /// Remove the reading profile bound to the library, if it exists + /// + /// + /// + /// + Task ClearLibraryProfile(int userId, int libraryId); + /// + /// Returns the bound Reading Profile to a Library + /// + /// + /// + /// + Task GetReadingProfileDtoForLibrary(int userId, int libraryId); +} + +public class ReadingProfileService(IUnitOfWork unitOfWork, ILocalizationService localizationService, IMapper mapper): IReadingProfileService +{ + /// + /// Tries to resolve the Reading Profile for a given Series. Will first check (optionally) Implicit profiles, then check for a bound Series profile, then a bound + /// Library profile, then default to the default profile. + /// + /// + /// + /// + /// + /// + public async Task GetReadingProfileForSeries(int userId, int seriesId, bool skipImplicit = false) + { + var profiles = await unitOfWork.AppUserReadingProfileRepository.GetProfilesForUser(userId, skipImplicit); + + // If there is an implicit, send back + var implicitProfile = + profiles.FirstOrDefault(p => p.SeriesIds.Contains(seriesId) && p.Kind == ReadingProfileKind.Implicit); + if (implicitProfile != null) return implicitProfile; + + // Next check for a bound Series profile + var seriesProfile = profiles + .FirstOrDefault(p => p.SeriesIds.Contains(seriesId) && p.Kind != ReadingProfileKind.Implicit); + if (seriesProfile != null) return seriesProfile; + + // Check for a library bound profile + var series = await unitOfWork.SeriesRepository.GetSeriesByIdAsync(seriesId); + if (series == null) throw new KavitaException(await localizationService.Translate(userId, "series-doesnt-exist")); + + var libraryProfile = profiles + .FirstOrDefault(p => p.LibraryIds.Contains(series.LibraryId) && p.Kind != ReadingProfileKind.Implicit); + if (libraryProfile != null) return libraryProfile; + + // Fallback to the default profile + return profiles.First(p => p.Kind == ReadingProfileKind.Default); + } + + public async Task GetReadingProfileDtoForSeries(int userId, int seriesId, bool skipImplicit = false) + { + return mapper.Map(await GetReadingProfileForSeries(userId, seriesId, skipImplicit)); + } + + public async Task UpdateParent(int userId, int seriesId, UserReadingProfileDto dto) + { + var parentProfile = await GetReadingProfileForSeries(userId, seriesId, true); + + UpdateReaderProfileFields(parentProfile, dto, false); + unitOfWork.AppUserReadingProfileRepository.Update(parentProfile); + + // Remove the implicit profile when we UpdateParent (from reader) as it is implied that we are already bound with a non-implicit profile + await DeleteImplicateReadingProfilesForSeries(userId, [seriesId]); + + await unitOfWork.CommitAsync(); + return mapper.Map(parentProfile); + } + + public async Task UpdateReadingProfile(int userId, UserReadingProfileDto dto) + { + var profile = await unitOfWork.AppUserReadingProfileRepository.GetUserProfile(userId, dto.Id); + if (profile == null) throw new KavitaException("profile-does-not-exist"); + + UpdateReaderProfileFields(profile, dto); + unitOfWork.AppUserReadingProfileRepository.Update(profile); + + await unitOfWork.CommitAsync(); + return mapper.Map(profile); + } + + public async Task CreateReadingProfile(int userId, UserReadingProfileDto dto) + { + var user = await unitOfWork.UserRepository.GetUserByIdAsync(userId, AppUserIncludes.UserPreferences); + if (user == null) throw new UnauthorizedAccessException(); + + if (await unitOfWork.AppUserReadingProfileRepository.IsProfileNameInUse(userId, dto.Name)) throw new KavitaException("name-already-in-use"); + + var newProfile = new AppUserReadingProfileBuilder(user.Id).Build(); + UpdateReaderProfileFields(newProfile, dto); + + unitOfWork.AppUserReadingProfileRepository.Add(newProfile); + user.ReadingProfiles.Add(newProfile); + + await unitOfWork.CommitAsync(); + + return mapper.Map(newProfile); + } + + /// + /// Promotes the implicit profile to a user profile. Removes the series from other profiles. + /// + /// + /// + /// + public async Task PromoteImplicitProfile(int userId, int profileId) + { + // Get all the user's profiles including the implicit + var allUserProfiles = await unitOfWork.AppUserReadingProfileRepository.GetProfilesForUser(userId, false); + var profileToPromote = allUserProfiles.First(r => r.Id == profileId); + var seriesId = profileToPromote.SeriesIds[0]; // An Implicit series can only be bound to 1 Series + + // Check if there are any reading profiles (Series) already bound to the series + var existingSeriesProfile = allUserProfiles.FirstOrDefault(r => r.SeriesIds.Contains(seriesId) && r.Kind == ReadingProfileKind.User); + if (existingSeriesProfile != null) + { + existingSeriesProfile.SeriesIds.Remove(seriesId); + unitOfWork.AppUserReadingProfileRepository.Update(existingSeriesProfile); + } + + // Convert the implicit profile into a proper Series + var series = await unitOfWork.SeriesRepository.GetSeriesByIdAsync(seriesId); + if (series == null) throw new KavitaException("series-doesnt-exist"); // Shouldn't happen + + profileToPromote.Kind = ReadingProfileKind.User; + profileToPromote.Name = await localizationService.Translate(userId, "generated-reading-profile-name", series.Name); + profileToPromote.Name = EnsureUniqueProfileName(allUserProfiles, profileToPromote.Name); + profileToPromote.NormalizedName = profileToPromote.Name.ToNormalized(); + unitOfWork.AppUserReadingProfileRepository.Update(profileToPromote); + + await unitOfWork.CommitAsync(); + + return mapper.Map(profileToPromote); + } + + private static string EnsureUniqueProfileName(IList allUserProfiles, string name) + { + var counter = 1; + var newName = name; + while (allUserProfiles.Any(p => p.Name == newName)) + { + newName = $"{name} ({counter})"; + counter++; + } + + return newName; + } + + public async Task UpdateImplicitReadingProfile(int userId, int seriesId, UserReadingProfileDto dto) + { + var user = await unitOfWork.UserRepository.GetUserByIdAsync(userId, AppUserIncludes.UserPreferences); + if (user == null) throw new UnauthorizedAccessException(); + + var profiles = await unitOfWork.AppUserReadingProfileRepository.GetProfilesForUser(userId); + var existingProfile = profiles.FirstOrDefault(rp => rp.Kind == ReadingProfileKind.Implicit && rp.SeriesIds.Contains(seriesId)); + + // Series already had an implicit profile, update it + if (existingProfile is {Kind: ReadingProfileKind.Implicit}) + { + UpdateReaderProfileFields(existingProfile, dto, false); + unitOfWork.AppUserReadingProfileRepository.Update(existingProfile); + await unitOfWork.CommitAsync(); + + return mapper.Map(existingProfile); + } + + var series = await unitOfWork.SeriesRepository.GetSeriesByIdAsync(seriesId) ?? throw new KeyNotFoundException(); + var newProfile = new AppUserReadingProfileBuilder(userId) + .WithSeries(series) + .WithKind(ReadingProfileKind.Implicit) + .Build(); + + // Set name to something fitting for debugging if needed + UpdateReaderProfileFields(newProfile, dto, false); + newProfile.Name = $"Implicit Profile for {seriesId}"; + newProfile.NormalizedName = newProfile.Name.ToNormalized(); + + user.ReadingProfiles.Add(newProfile); + await unitOfWork.CommitAsync(); + + return mapper.Map(newProfile); + } + + public async Task DeleteReadingProfile(int userId, int profileId) + { + var profile = await unitOfWork.AppUserReadingProfileRepository.GetUserProfile(userId, profileId); + if (profile == null) throw new KavitaException("profile-doesnt-exist"); + + if (profile.Kind == ReadingProfileKind.Default) throw new KavitaException("cant-delete-default-profile"); + + unitOfWork.AppUserReadingProfileRepository.Remove(profile); + await unitOfWork.CommitAsync(); + } + + public async Task AddProfileToSeries(int userId, int profileId, int seriesId) + { + var profile = await unitOfWork.AppUserReadingProfileRepository.GetUserProfile(userId, profileId); + if (profile == null) throw new KavitaException("profile-doesnt-exist"); + + await DeleteImplicitAndRemoveFromUserProfiles(userId, [seriesId], []); + + profile.SeriesIds.Add(seriesId); + unitOfWork.AppUserReadingProfileRepository.Update(profile); + + await unitOfWork.CommitAsync(); + } + + public async Task BulkAddProfileToSeries(int userId, int profileId, IList seriesIds) + { + var profile = await unitOfWork.AppUserReadingProfileRepository.GetUserProfile(userId, profileId); + if (profile == null) throw new KavitaException("profile-doesnt-exist"); + + await DeleteImplicitAndRemoveFromUserProfiles(userId, seriesIds, []); + + profile.SeriesIds.AddRange(seriesIds.Except(profile.SeriesIds)); + unitOfWork.AppUserReadingProfileRepository.Update(profile); + + await unitOfWork.CommitAsync(); + } + + public async Task ClearSeriesProfile(int userId, int seriesId) + { + await DeleteImplicitAndRemoveFromUserProfiles(userId, [seriesId], []); + await unitOfWork.CommitAsync(); + } + + public async Task AddProfileToLibrary(int userId, int profileId, int libraryId) + { + var profile = await unitOfWork.AppUserReadingProfileRepository.GetUserProfile(userId, profileId); + if (profile == null) throw new KavitaException("profile-doesnt-exist"); + + await DeleteImplicitAndRemoveFromUserProfiles(userId, [], [libraryId]); + + profile.LibraryIds.Add(libraryId); + unitOfWork.AppUserReadingProfileRepository.Update(profile); + await unitOfWork.CommitAsync(); + } + + public async Task ClearLibraryProfile(int userId, int libraryId) + { + var profiles = await unitOfWork.AppUserReadingProfileRepository.GetProfilesForUser(userId); + var libraryProfile = profiles.FirstOrDefault(p => p.LibraryIds.Contains(libraryId)); + if (libraryProfile != null) + { + libraryProfile.LibraryIds.Remove(libraryId); + unitOfWork.AppUserReadingProfileRepository.Update(libraryProfile); + } + + + if (unitOfWork.HasChanges()) + { + await unitOfWork.CommitAsync(); + } + } + + public async Task GetReadingProfileDtoForLibrary(int userId, int libraryId) + { + var profiles = await unitOfWork.AppUserReadingProfileRepository.GetProfilesForUser(userId, true); + return mapper.Map(profiles.FirstOrDefault(p => p.LibraryIds.Contains(libraryId))); + } + + private async Task DeleteImplicitAndRemoveFromUserProfiles(int userId, IList seriesIds, IList libraryIds) + { + var profiles = await unitOfWork.AppUserReadingProfileRepository.GetProfilesForUser(userId); + var implicitProfiles = profiles + .Where(rp => rp.SeriesIds.Intersect(seriesIds).Any()) + .Where(rp => rp.Kind == ReadingProfileKind.Implicit) + .ToList(); + unitOfWork.AppUserReadingProfileRepository.RemoveRange(implicitProfiles); + + var nonImplicitProfiles = profiles + .Where(rp => rp.SeriesIds.Intersect(seriesIds).Any() || rp.LibraryIds.Intersect(libraryIds).Any()) + .Where(rp => rp.Kind != ReadingProfileKind.Implicit); + + foreach (var profile in nonImplicitProfiles) + { + profile.SeriesIds.RemoveAll(seriesIds.Contains); + profile.LibraryIds.RemoveAll(libraryIds.Contains); + unitOfWork.AppUserReadingProfileRepository.Update(profile); + } + } + + private async Task DeleteImplicateReadingProfilesForSeries(int userId, IList seriesIds) + { + var profiles = await unitOfWork.AppUserReadingProfileRepository.GetProfilesForUser(userId); + var implicitProfiles = profiles + .Where(rp => rp.SeriesIds.Intersect(seriesIds).Any()) + .Where(rp => rp.Kind == ReadingProfileKind.Implicit) + .ToList(); + unitOfWork.AppUserReadingProfileRepository.RemoveRange(implicitProfiles); + } + + private async Task RemoveSeriesFromUserProfiles(int userId, IList seriesIds) + { + var profiles = await unitOfWork.AppUserReadingProfileRepository.GetProfilesForUser(userId); + var userProfiles = profiles + .Where(rp => rp.SeriesIds.Intersect(seriesIds).Any()) + .Where(rp => rp.Kind == ReadingProfileKind.User) + .ToList(); + + unitOfWork.AppUserReadingProfileRepository.RemoveRange(userProfiles); + } + + public static void UpdateReaderProfileFields(AppUserReadingProfile existingProfile, UserReadingProfileDto dto, bool updateName = true) + { + if (updateName && !string.IsNullOrEmpty(dto.Name) && existingProfile.NormalizedName != dto.Name.ToNormalized()) + { + existingProfile.Name = dto.Name; + existingProfile.NormalizedName = dto.Name.ToNormalized(); + } + + // Manga Reader + existingProfile.ReadingDirection = dto.ReadingDirection; + existingProfile.ScalingOption = dto.ScalingOption; + existingProfile.PageSplitOption = dto.PageSplitOption; + existingProfile.ReaderMode = dto.ReaderMode; + existingProfile.AutoCloseMenu = dto.AutoCloseMenu; + existingProfile.ShowScreenHints = dto.ShowScreenHints; + existingProfile.EmulateBook = dto.EmulateBook; + existingProfile.LayoutMode = dto.LayoutMode; + existingProfile.BackgroundColor = string.IsNullOrEmpty(dto.BackgroundColor) ? "#000000" : dto.BackgroundColor; + existingProfile.SwipeToPaginate = dto.SwipeToPaginate; + existingProfile.AllowAutomaticWebtoonReaderDetection = dto.AllowAutomaticWebtoonReaderDetection; + existingProfile.WidthOverride = dto.WidthOverride; + + // Book Reader + existingProfile.BookReaderMargin = dto.BookReaderMargin; + existingProfile.BookReaderLineSpacing = dto.BookReaderLineSpacing; + existingProfile.BookReaderFontSize = dto.BookReaderFontSize; + existingProfile.BookReaderFontFamily = dto.BookReaderFontFamily; + existingProfile.BookReaderTapToPaginate = dto.BookReaderTapToPaginate; + existingProfile.BookReaderReadingDirection = dto.BookReaderReadingDirection; + existingProfile.BookReaderWritingStyle = dto.BookReaderWritingStyle; + existingProfile.BookThemeName = dto.BookReaderThemeName; + existingProfile.BookReaderLayoutMode = dto.BookReaderLayoutMode; + existingProfile.BookReaderImmersiveMode = dto.BookReaderImmersiveMode; + + // PDF Reading + existingProfile.PdfTheme = dto.PdfTheme; + existingProfile.PdfScrollMode = dto.PdfScrollMode; + existingProfile.PdfSpreadMode = dto.PdfSpreadMode; + } +} diff --git a/API/Startup.cs b/API/Startup.cs index cb32d1742..f57cb7d01 100644 --- a/API/Startup.cs +++ b/API/Startup.cs @@ -293,6 +293,9 @@ public class Startup await ManualMigrateScrobbleSpecials.Migrate(dataContext, logger); await ManualMigrateScrobbleEventGen.Migrate(dataContext, logger); + // v0.8.7 + await ManualMigrateReadingProfiles.Migrate(dataContext, logger); + #endregion // Update the version in the DB after all migrations are run diff --git a/Kavita.Common/Configuration.cs b/Kavita.Common/Configuration.cs index f2d64cde6..3450cdce3 100644 --- a/Kavita.Common/Configuration.cs +++ b/Kavita.Common/Configuration.cs @@ -17,7 +17,7 @@ public static class Configuration private static readonly string AppSettingsFilename = Path.Join("config", GetAppSettingFilename()); public static readonly string KavitaPlusApiUrl = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == Environments.Development - ? "http://localhost:5020" : "https://plus.kavitareader.com"; + ? "https://plus.kavitareader.com" : "https://plus.kavitareader.com"; public static readonly string StatsApiUrl = "https://stats.kavitareader.com"; public static int Port diff --git a/UI/Web/src/app/_models/preferences/book-theme.ts b/UI/Web/src/app/_models/preferences/book-theme.ts index b6e37f6e4..cb321c110 100644 --- a/UI/Web/src/app/_models/preferences/book-theme.ts +++ b/UI/Web/src/app/_models/preferences/book-theme.ts @@ -1,7 +1,7 @@ -import { ThemeProvider } from "./site-theme"; +import {ThemeProvider} from "./site-theme"; /** - * Theme for the the book reader contents + * Theme for the book reader contents */ export interface BookTheme { name: string; diff --git a/UI/Web/src/app/_models/preferences/preferences.ts b/UI/Web/src/app/_models/preferences/preferences.ts index 1dd5731e5..886c570e2 100644 --- a/UI/Web/src/app/_models/preferences/preferences.ts +++ b/UI/Web/src/app/_models/preferences/preferences.ts @@ -1,47 +1,7 @@ -import {LayoutMode} from 'src/app/manga-reader/_models/layout-mode'; -import {BookPageLayoutMode} from '../readers/book-page-layout-mode'; import {PageLayoutMode} from '../page-layout-mode'; -import {PageSplitOption} from './page-split-option'; -import {ReaderMode} from './reader-mode'; -import {ReadingDirection} from './reading-direction'; -import {ScalingOption} from './scaling-option'; import {SiteTheme} from './site-theme'; -import {WritingStyle} from "./writing-style"; -import {PdfTheme} from "./pdf-theme"; -import {PdfScrollMode} from "./pdf-scroll-mode"; -import {PdfLayoutMode} from "./pdf-layout-mode"; -import {PdfSpreadMode} from "./pdf-spread-mode"; export interface Preferences { - // Manga Reader - readingDirection: ReadingDirection; - scalingOption: ScalingOption; - pageSplitOption: PageSplitOption; - readerMode: ReaderMode; - autoCloseMenu: boolean; - layoutMode: LayoutMode; - backgroundColor: string; - showScreenHints: boolean; - emulateBook: boolean; - swipeToPaginate: boolean; - allowAutomaticWebtoonReaderDetection: boolean; - - // Book Reader - bookReaderMargin: number; - bookReaderLineSpacing: number; - bookReaderFontSize: number; - bookReaderFontFamily: string; - bookReaderTapToPaginate: boolean; - bookReaderReadingDirection: ReadingDirection; - bookReaderWritingStyle: WritingStyle; - bookReaderThemeName: string; - bookReaderLayoutMode: BookPageLayoutMode; - bookReaderImmersiveMode: boolean; - - // PDF Reader - pdfTheme: PdfTheme; - pdfScrollMode: PdfScrollMode; - pdfSpreadMode: PdfSpreadMode; // Global theme: SiteTheme; @@ -58,15 +18,3 @@ export interface Preferences { wantToReadSync: boolean; } -export const readingDirections = [{text: 'left-to-right', value: ReadingDirection.LeftToRight}, {text: 'right-to-left', value: ReadingDirection.RightToLeft}]; -export const bookWritingStyles = [{text: 'horizontal', value: WritingStyle.Horizontal}, {text: 'vertical', value: WritingStyle.Vertical}]; -export const scalingOptions = [{text: 'automatic', value: ScalingOption.Automatic}, {text: 'fit-to-height', value: ScalingOption.FitToHeight}, {text: 'fit-to-width', value: ScalingOption.FitToWidth}, {text: 'original', value: ScalingOption.Original}]; -export const pageSplitOptions = [{text: 'fit-to-screen', value: PageSplitOption.FitSplit}, {text: 'right-to-left', value: PageSplitOption.SplitRightToLeft}, {text: 'left-to-right', value: PageSplitOption.SplitLeftToRight}, {text: 'no-split', value: PageSplitOption.NoSplit}]; -export const readingModes = [{text: 'left-to-right', value: ReaderMode.LeftRight}, {text: 'up-to-down', value: ReaderMode.UpDown}, {text: 'webtoon', value: ReaderMode.Webtoon}]; -export const layoutModes = [{text: 'single', value: LayoutMode.Single}, {text: 'double', value: LayoutMode.Double}, {text: 'double-manga', value: LayoutMode.DoubleReversed}]; // TODO: Build this, {text: 'Double (No Cover)', value: LayoutMode.DoubleNoCover} -export const bookLayoutModes = [{text: 'scroll', value: BookPageLayoutMode.Default}, {text: '1-column', value: BookPageLayoutMode.Column1}, {text: '2-column', value: BookPageLayoutMode.Column2}]; -export const pageLayoutModes = [{text: 'cards', value: PageLayoutMode.Cards}, {text: 'list', value: PageLayoutMode.List}]; -export const pdfLayoutModes = [{text: 'pdf-multiple', value: PdfLayoutMode.Multiple}, {text: 'pdf-book', value: PdfLayoutMode.Book}]; -export const pdfScrollModes = [{text: 'pdf-vertical', value: PdfScrollMode.Vertical}, {text: 'pdf-horizontal', value: PdfScrollMode.Horizontal}, {text: 'pdf-page', value: PdfScrollMode.Page}]; -export const pdfSpreadModes = [{text: 'pdf-none', value: PdfSpreadMode.None}, {text: 'pdf-odd', value: PdfSpreadMode.Odd}, {text: 'pdf-even', value: PdfSpreadMode.Even}]; -export const pdfThemes = [{text: 'pdf-light', value: PdfTheme.Light}, {text: 'pdf-dark', value: PdfTheme.Dark}]; diff --git a/UI/Web/src/app/_models/preferences/reading-profiles.ts b/UI/Web/src/app/_models/preferences/reading-profiles.ts new file mode 100644 index 000000000..d81b8cc88 --- /dev/null +++ b/UI/Web/src/app/_models/preferences/reading-profiles.ts @@ -0,0 +1,77 @@ +import {LayoutMode} from 'src/app/manga-reader/_models/layout-mode'; +import {BookPageLayoutMode} from '../readers/book-page-layout-mode'; +import {PageLayoutMode} from '../page-layout-mode'; +import {PageSplitOption} from './page-split-option'; +import {ReaderMode} from './reader-mode'; +import {ReadingDirection} from './reading-direction'; +import {ScalingOption} from './scaling-option'; +import {WritingStyle} from "./writing-style"; +import {PdfTheme} from "./pdf-theme"; +import {PdfScrollMode} from "./pdf-scroll-mode"; +import {PdfLayoutMode} from "./pdf-layout-mode"; +import {PdfSpreadMode} from "./pdf-spread-mode"; +import {Series} from "../series"; +import {Library} from "../library/library"; + +export enum ReadingProfileKind { + Default = 0, + User = 1, + Implicit = 2, +} + +export interface ReadingProfile { + + id: number; + name: string; + normalizedName: string; + kind: ReadingProfileKind; + + // Manga Reader + readingDirection: ReadingDirection; + scalingOption: ScalingOption; + pageSplitOption: PageSplitOption; + readerMode: ReaderMode; + autoCloseMenu: boolean; + layoutMode: LayoutMode; + backgroundColor: string; + showScreenHints: boolean; + emulateBook: boolean; + swipeToPaginate: boolean; + allowAutomaticWebtoonReaderDetection: boolean; + widthOverride?: number; + + // Book Reader + bookReaderMargin: number; + bookReaderLineSpacing: number; + bookReaderFontSize: number; + bookReaderFontFamily: string; + bookReaderTapToPaginate: boolean; + bookReaderReadingDirection: ReadingDirection; + bookReaderWritingStyle: WritingStyle; + bookReaderThemeName: string; + bookReaderLayoutMode: BookPageLayoutMode; + bookReaderImmersiveMode: boolean; + + // PDF Reader + pdfTheme: PdfTheme; + pdfScrollMode: PdfScrollMode; + pdfSpreadMode: PdfSpreadMode; + + // relations + seriesIds: number[]; + libraryIds: number[]; + +} + +export const readingDirections = [{text: 'left-to-right', value: ReadingDirection.LeftToRight}, {text: 'right-to-left', value: ReadingDirection.RightToLeft}]; +export const bookWritingStyles = [{text: 'horizontal', value: WritingStyle.Horizontal}, {text: 'vertical', value: WritingStyle.Vertical}]; +export const scalingOptions = [{text: 'automatic', value: ScalingOption.Automatic}, {text: 'fit-to-height', value: ScalingOption.FitToHeight}, {text: 'fit-to-width', value: ScalingOption.FitToWidth}, {text: 'original', value: ScalingOption.Original}]; +export const pageSplitOptions = [{text: 'fit-to-screen', value: PageSplitOption.FitSplit}, {text: 'right-to-left', value: PageSplitOption.SplitRightToLeft}, {text: 'left-to-right', value: PageSplitOption.SplitLeftToRight}, {text: 'no-split', value: PageSplitOption.NoSplit}]; +export const readingModes = [{text: 'left-to-right', value: ReaderMode.LeftRight}, {text: 'up-to-down', value: ReaderMode.UpDown}, {text: 'webtoon', value: ReaderMode.Webtoon}]; +export const layoutModes = [{text: 'single', value: LayoutMode.Single}, {text: 'double', value: LayoutMode.Double}, {text: 'double-manga', value: LayoutMode.DoubleReversed}]; // TODO: Build this, {text: 'Double (No Cover)', value: LayoutMode.DoubleNoCover} +export const bookLayoutModes = [{text: 'scroll', value: BookPageLayoutMode.Default}, {text: '1-column', value: BookPageLayoutMode.Column1}, {text: '2-column', value: BookPageLayoutMode.Column2}]; +export const pageLayoutModes = [{text: 'cards', value: PageLayoutMode.Cards}, {text: 'list', value: PageLayoutMode.List}]; +export const pdfLayoutModes = [{text: 'pdf-multiple', value: PdfLayoutMode.Multiple}, {text: 'pdf-book', value: PdfLayoutMode.Book}]; +export const pdfScrollModes = [{text: 'pdf-vertical', value: PdfScrollMode.Vertical}, {text: 'pdf-horizontal', value: PdfScrollMode.Horizontal}, {text: 'pdf-page', value: PdfScrollMode.Page}]; +export const pdfSpreadModes = [{text: 'pdf-none', value: PdfSpreadMode.None}, {text: 'pdf-odd', value: PdfSpreadMode.Odd}, {text: 'pdf-even', value: PdfSpreadMode.Even}]; +export const pdfThemes = [{text: 'pdf-light', value: PdfTheme.Light}, {text: 'pdf-dark', value: PdfTheme.Dark}]; diff --git a/UI/Web/src/app/_resolvers/reading-profile.resolver.ts b/UI/Web/src/app/_resolvers/reading-profile.resolver.ts new file mode 100644 index 000000000..1d28adf95 --- /dev/null +++ b/UI/Web/src/app/_resolvers/reading-profile.resolver.ts @@ -0,0 +1,18 @@ +import {Injectable} from '@angular/core'; +import {ActivatedRouteSnapshot, Resolve, RouterStateSnapshot} from '@angular/router'; +import {Observable} from 'rxjs'; +import {ReadingProfileService} from "../_services/reading-profile.service"; + +@Injectable({ + providedIn: 'root' +}) +export class ReadingProfileResolver implements Resolve { + + constructor(private readingProfileService: ReadingProfileService) {} + + resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { + // Extract seriesId from route params or parent route + const seriesId = route.params['seriesId'] || route.parent?.params['seriesId']; + return this.readingProfileService.getForSeries(seriesId); + } +} diff --git a/UI/Web/src/app/_routes/book-reader.router.module.ts b/UI/Web/src/app/_routes/book-reader.router.module.ts index 5083c2d4a..c9d6262ad 100644 --- a/UI/Web/src/app/_routes/book-reader.router.module.ts +++ b/UI/Web/src/app/_routes/book-reader.router.module.ts @@ -1,10 +1,14 @@ -import { Routes } from '@angular/router'; -import { BookReaderComponent } from '../book-reader/_components/book-reader/book-reader.component'; +import {Routes} from '@angular/router'; +import {BookReaderComponent} from '../book-reader/_components/book-reader/book-reader.component'; +import {ReadingProfileResolver} from "../_resolvers/reading-profile.resolver"; export const routes: Routes = [ { path: ':chapterId', component: BookReaderComponent, + resolve: { + readingProfile: ReadingProfileResolver + } } ]; diff --git a/UI/Web/src/app/_routes/manga-reader.router.module.ts b/UI/Web/src/app/_routes/manga-reader.router.module.ts index 04ff77b3c..e479e8ae6 100644 --- a/UI/Web/src/app/_routes/manga-reader.router.module.ts +++ b/UI/Web/src/app/_routes/manga-reader.router.module.ts @@ -1,15 +1,22 @@ -import { Routes } from '@angular/router'; -import { MangaReaderComponent } from '../manga-reader/_components/manga-reader/manga-reader.component'; +import {Routes} from '@angular/router'; +import {MangaReaderComponent} from '../manga-reader/_components/manga-reader/manga-reader.component'; +import {ReadingProfileResolver} from "../_resolvers/reading-profile.resolver"; export const routes: Routes = [ { path: ':chapterId', - component: MangaReaderComponent + component: MangaReaderComponent, + resolve: { + readingProfile: ReadingProfileResolver + } }, { // This will allow the MangaReader to have a list to use for next/prev chapters rather than natural sort order path: ':chapterId/list/:listId', - component: MangaReaderComponent + component: MangaReaderComponent, + resolve: { + readingProfile: ReadingProfileResolver + } } ]; diff --git a/UI/Web/src/app/_routes/pdf-reader.router.module.ts b/UI/Web/src/app/_routes/pdf-reader.router.module.ts index a55699280..7cb9f68e2 100644 --- a/UI/Web/src/app/_routes/pdf-reader.router.module.ts +++ b/UI/Web/src/app/_routes/pdf-reader.router.module.ts @@ -1,9 +1,13 @@ -import { Routes } from '@angular/router'; -import { PdfReaderComponent } from '../pdf-reader/_components/pdf-reader/pdf-reader.component'; +import {Routes} from '@angular/router'; +import {PdfReaderComponent} from '../pdf-reader/_components/pdf-reader/pdf-reader.component'; +import {ReadingProfileResolver} from "../_resolvers/reading-profile.resolver"; export const routes: Routes = [ { path: ':chapterId', component: PdfReaderComponent, + resolve: { + readingProfile: ReadingProfileResolver + } } ]; diff --git a/UI/Web/src/app/_services/action-factory.service.ts b/UI/Web/src/app/_services/action-factory.service.ts index 61fee39ec..e5967bf24 100644 --- a/UI/Web/src/app/_services/action-factory.service.ts +++ b/UI/Web/src/app/_services/action-factory.service.ts @@ -122,6 +122,14 @@ export enum Action { * Merge two (or more?) entities */ Merge = 29, + /** + * Add to a reading profile + */ + SetReadingProfile = 30, + /** + * Remove the reading profile from the entity + */ + ClearReadingProfile = 31, } /** @@ -342,6 +350,37 @@ export class ActionFactoryService { requiredRoles: [Role.Admin], children: [], }, + { + action: Action.Submenu, + title: 'reading-profiles', + description: '', + callback: this.dummyCallback, + shouldRender: this.dummyShouldRender, + requiresAdmin: false, + requiredRoles: [], + children: [ + { + action: Action.SetReadingProfile, + title: 'set-reading-profile', + description: 'set-reading-profile-tooltip', + callback: this.dummyCallback, + shouldRender: this.dummyShouldRender, + requiresAdmin: false, + requiredRoles: [], + children: [], + }, + { + action: Action.ClearReadingProfile, + title: 'clear-reading-profile', + description: 'clear-reading-profile-tooltip', + callback: this.dummyCallback, + shouldRender: this.dummyShouldRender, + requiresAdmin: false, + requiredRoles: [], + children: [], + }, + ], + }, { action: Action.Submenu, title: 'others', @@ -528,7 +567,7 @@ export class ActionFactoryService { requiresAdmin: false, requiredRoles: [], children: [], - }, + } ], }, { @@ -555,6 +594,37 @@ export class ActionFactoryService { } ], }, + { + action: Action.Submenu, + title: 'reading-profiles', + description: '', + callback: this.dummyCallback, + shouldRender: this.dummyShouldRender, + requiresAdmin: false, + requiredRoles: [], + children: [ + { + action: Action.SetReadingProfile, + title: 'set-reading-profile', + description: 'set-reading-profile-tooltip', + callback: this.dummyCallback, + shouldRender: this.dummyShouldRender, + requiresAdmin: false, + requiredRoles: [], + children: [], + }, + { + action: Action.ClearReadingProfile, + title: 'clear-reading-profile', + description: 'clear-reading-profile-tooltip', + callback: this.dummyCallback, + shouldRender: this.dummyShouldRender, + requiresAdmin: false, + requiredRoles: [], + children: [], + }, + ], + }, { action: Action.Submenu, title: 'others', @@ -1047,7 +1117,10 @@ export class ActionFactoryService { if (action.children === null || action.children?.length === 0) return; - action.children?.forEach((childAction) => { + // Ensure action children are a copy of the parent (since parent does a shallow mapping) + action.children = action.children.map(d => { return {...d}; }); + + action.children.forEach((childAction) => { this.applyCallback(childAction, callback, shouldRenderFunc); }); } @@ -1055,10 +1128,13 @@ export class ActionFactoryService { public applyCallbackToList(list: Array>, callback: ActionCallback, shouldRenderFunc: ActionShouldRenderFunc = this.dummyShouldRender): Array> { + // Create a clone of the list to ensure we aren't affecting the default state const actions = list.map((a) => { return { ...a }; }); + actions.forEach((action) => this.applyCallback(action, callback, shouldRenderFunc)); + return actions; } diff --git a/UI/Web/src/app/_services/action.service.ts b/UI/Web/src/app/_services/action.service.ts index 37826b0e2..2328bf72e 100644 --- a/UI/Web/src/app/_services/action.service.ts +++ b/UI/Web/src/app/_services/action.service.ts @@ -31,6 +31,9 @@ import {ChapterService} from "./chapter.service"; import {VolumeService} from "./volume.service"; import {DefaultModalOptions} from "../_models/default-modal-options"; import {MatchSeriesModalComponent} from "../_single-module/match-series-modal/match-series-modal.component"; +import { + BulkSetReadingProfileModalComponent +} from "../cards/_modals/bulk-set-reading-profile-modal/bulk-set-reading-profile-modal.component"; export type LibraryActionCallback = (library: Partial) => void; @@ -813,4 +816,56 @@ export class ActionService { }); } + /** + * Sets the reading profile for multiple series + * @param series + * @param callback + */ + setReadingProfileForMultiple(series: Array, callback?: BooleanActionCallback) { + if (this.readingListModalRef != null) { return; } + + this.readingListModalRef = this.modalService.open(BulkSetReadingProfileModalComponent, { scrollable: true, size: 'md', fullscreen: 'md' }); + this.readingListModalRef.componentInstance.seriesIds = series.map(s => s.id) + this.readingListModalRef.componentInstance.title = "" + + this.readingListModalRef.closed.pipe(take(1)).subscribe(() => { + this.readingListModalRef = null; + if (callback) { + callback(true); + } + }); + this.readingListModalRef.dismissed.pipe(take(1)).subscribe(() => { + this.readingListModalRef = null; + if (callback) { + callback(false); + } + }); + } + + /** + * Sets the reading profile for multiple series + * @param library + * @param callback + */ + setReadingProfileForLibrary(library: Library, callback?: BooleanActionCallback) { + if (this.readingListModalRef != null) { return; } + + this.readingListModalRef = this.modalService.open(BulkSetReadingProfileModalComponent, { scrollable: true, size: 'md', fullscreen: 'md' }); + this.readingListModalRef.componentInstance.libraryId = library.id; + this.readingListModalRef.componentInstance.title = "" + + this.readingListModalRef.closed.pipe(take(1)).subscribe(() => { + this.readingListModalRef = null; + if (callback) { + callback(true); + } + }); + this.readingListModalRef.dismissed.pipe(take(1)).subscribe(() => { + this.readingListModalRef = null; + if (callback) { + callback(false); + } + }); + } + } diff --git a/UI/Web/src/app/_services/reading-profile.service.ts b/UI/Web/src/app/_services/reading-profile.service.ts new file mode 100644 index 000000000..e8be8b6ab --- /dev/null +++ b/UI/Web/src/app/_services/reading-profile.service.ts @@ -0,0 +1,70 @@ +import {inject, Injectable} from '@angular/core'; +import {HttpClient} from "@angular/common/http"; +import {environment} from "../../environments/environment"; +import {ReadingProfile} from "../_models/preferences/reading-profiles"; + +@Injectable({ + providedIn: 'root' +}) +export class ReadingProfileService { + + private readonly httpClient = inject(HttpClient); + baseUrl = environment.apiUrl; + + getForSeries(seriesId: number, skipImplicit: boolean = false) { + return this.httpClient.get(this.baseUrl + `reading-profile/${seriesId}?skipImplicit=${skipImplicit}`); + } + + getForLibrary(libraryId: number) { + return this.httpClient.get(this.baseUrl + `reading-profile/library?libraryId=${libraryId}`); + } + + updateProfile(profile: ReadingProfile) { + return this.httpClient.post(this.baseUrl + 'reading-profile', profile); + } + + updateParentProfile(seriesId: number, profile: ReadingProfile) { + return this.httpClient.post(this.baseUrl + `reading-profile/update-parent?seriesId=${seriesId}`, profile); + } + + createProfile(profile: ReadingProfile) { + return this.httpClient.post(this.baseUrl + 'reading-profile/create', profile); + } + + promoteProfile(profileId: number) { + return this.httpClient.post(this.baseUrl + "reading-profile/promote?profileId=" + profileId, {}); + } + + updateImplicit(profile: ReadingProfile, seriesId: number) { + return this.httpClient.post(this.baseUrl + "reading-profile/series?seriesId="+seriesId, profile); + } + + getAllProfiles() { + return this.httpClient.get(this.baseUrl + 'reading-profile/all'); + } + + delete(id: number) { + return this.httpClient.delete(this.baseUrl + `reading-profile?profileId=${id}`); + } + + addToSeries(id: number, seriesId: number) { + return this.httpClient.post(this.baseUrl + `reading-profile/series/${seriesId}?profileId=${id}`, {}); + } + + clearSeriesProfiles(seriesId: number) { + return this.httpClient.delete(this.baseUrl + `reading-profile/series/${seriesId}`, {}); + } + + addToLibrary(id: number, libraryId: number) { + return this.httpClient.post(this.baseUrl + `reading-profile/library/${libraryId}?profileId=${id}`, {}); + } + + clearLibraryProfiles(libraryId: number) { + return this.httpClient.delete(this.baseUrl + `reading-profile/library/${libraryId}`, {}); + } + + bulkAddToSeries(id: number, seriesIds: number[]) { + return this.httpClient.post(this.baseUrl + `reading-profile/bulk?profileId=${id}`, seriesIds); + } + +} 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 ac62e2038..d4a7f36b0 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 @@ -9,12 +9,12 @@ import {NgbModal} from '@ng-bootstrap/ng-bootstrap'; import {allEncodeFormats} from '../_models/encode-format'; import {translate, TranslocoDirective, TranslocoService} from "@jsverse/transloco"; import {allCoverImageSizes, CoverImageSize} from '../_models/cover-image-size'; -import {pageLayoutModes} from "../../_models/preferences/preferences"; import {SettingItemComponent} from "../../settings/_components/setting-item/setting-item.component"; import {EncodeFormatPipe} from "../../_pipes/encode-format.pipe"; import {CoverImageSizePipe} from "../../_pipes/cover-image-size.pipe"; import {ConfirmService} from "../../shared/confirm.service"; import {takeUntilDestroyed} from "@angular/core/rxjs-interop"; +import {pageLayoutModes} from "../../_models/preferences/reading-profiles"; @Component({ selector: 'app-manage-media-settings', diff --git a/UI/Web/src/app/book-reader/_components/book-reader/book-reader.component.html b/UI/Web/src/app/book-reader/_components/book-reader/book-reader.component.html index fb741d4a1..69e4faf7b 100644 --- a/UI/Web/src/app/book-reader/_components/book-reader/book-reader.component.html +++ b/UI/Web/src/app/book-reader/_components/book-reader/book-reader.component.html @@ -61,6 +61,8 @@ {{t('settings-header')}} { + this.readingProfile = data['readingProfile']; + this.cdRef.markForCheck(); - this.memberService.hasReadingProgress(this.libraryId).pipe(take(1)).subscribe(hasProgress => { - if (!hasProgress) { - this.toggleDrawer(); - this.toastr.info(translate('toasts.book-settings-info')); + if (this.readingProfile == null) { + this.router.navigateByUrl('/home'); + return; } - }); - this.accountService.currentUser$.pipe(take(1)).subscribe(user => { - if (user) { - this.user = user; - this.init(); - } + this.memberService.hasReadingProgress(this.libraryId).pipe(take(1)).subscribe(hasProgress => { + if (!hasProgress) { + this.toggleDrawer(); + this.toastr.info(translate('toasts.book-settings-info')); + } + }); + + this.init(); }); } @@ -670,7 +671,10 @@ export class BookReaderComponent implements OnInit, AfterViewInit, OnDestroy { this.chapters = results.chapters; this.pageNum = results.progress.pageNum; this.cdRef.markForCheck(); - if (results.progress.bookScrollId) this.lastSeenScrollPartPath = results.progress.bookScrollId; + + if (results.progress.bookScrollId) { + this.lastSeenScrollPartPath = results.progress.bookScrollId; + } this.continuousChaptersStack.push(this.chapterId); @@ -771,6 +775,7 @@ export class BookReaderComponent implements OnInit, AfterViewInit, OnDestroy { this.readerService.closeReader(this.readingListMode, this.readingListId); } + sortElements(a: Element, b: Element) { const aTop = a.getBoundingClientRect().top; const bTop = b.getBoundingClientRect().top; @@ -1049,7 +1054,7 @@ export class BookReaderComponent implements OnInit, AfterViewInit, OnDestroy { // Virtual Paging stuff this.updateWidthAndHeightCalcs(); - this.updateLayoutMode(this.layoutMode || BookPageLayoutMode.Default); + this.updateLayoutMode(this.layoutMode); this.addEmptyPageIfRequired(); // Find all the part ids and their top offset diff --git a/UI/Web/src/app/book-reader/_components/reader-settings/reader-settings.component.html b/UI/Web/src/app/book-reader/_components/reader-settings/reader-settings.component.html index e2edb6a11..a4bc4cdfa 100644 --- a/UI/Web/src/app/book-reader/_components/reader-settings/reader-settings.component.html +++ b/UI/Web/src/app/book-reader/_components/reader-settings/reader-settings.component.html @@ -1,172 +1,190 @@ - - -
-
-
-

- -

-
-
- -
-
-
- - +@if (readingProfile !== null) { + + + +
+
+

+ +

+
+
+ +
+
+
+ + +
-
-
- - +
+ + -
+
-
- - - 1x - - 2.5x +
+ + + {{t('line-spacing-min-label')}} + + {{t('line-spacing-max-label')}} -
+
-
- - +
+ + -
+
-
- +
+ +
-
- + +
+
-
+
+

+ +

+
+
+ +
+ + +
+
+ + {{t('writing-style-tooltip')}} + + -
-

- -

-
-
- -
- - -
-
- - {{t('writing-style-tooltip')}} - - - -
-
- - {{t('tap-to-paginate-tooltip')}} - +
+
+ + {{t('tap-to-paginate-tooltip')}} + -
- - +
+ + +
-
-
- - {{t('immersive-mode-tooltip')}} - +
+ + {{t('immersive-mode-tooltip')}} + -
- - +
+ + +
-
-
- - {{t('fullscreen-tooltip')}} - +
+ + {{t('fullscreen-tooltip')}} + - -
+ +
-
- - - +
+ + + -
-
- - +
+
+ + - - + + - - + + +
-
- + +
-
-
-

- +

+
+
+ +
+ + + +
+
+
+
+
+ +
+ + - -
-
- -
- - - -
-
-
-
-
- - + +
+ + + +} diff --git a/UI/Web/src/app/book-reader/_components/reader-settings/reader-settings.component.ts b/UI/Web/src/app/book-reader/_components/reader-settings/reader-settings.component.ts index e28d44bbf..52c067a16 100644 --- a/UI/Web/src/app/book-reader/_components/reader-settings/reader-settings.component.ts +++ b/UI/Web/src/app/book-reader/_components/reader-settings/reader-settings.component.ts @@ -1,32 +1,46 @@ -import { DOCUMENT, NgFor, NgTemplateOutlet, NgIf, NgClass, NgStyle, TitleCasePipe } from '@angular/common'; +import {DOCUMENT, NgClass, NgFor, NgIf, NgStyle, NgTemplateOutlet, TitleCasePipe} from '@angular/common'; import { ChangeDetectionStrategy, ChangeDetectorRef, - Component, DestroyRef, + Component, + DestroyRef, EventEmitter, inject, Inject, + Input, OnInit, Output } from '@angular/core'; -import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms'; -import { take } from 'rxjs'; -import { BookPageLayoutMode } from 'src/app/_models/readers/book-page-layout-mode'; -import { BookTheme } from 'src/app/_models/preferences/book-theme'; -import { ReadingDirection } from 'src/app/_models/preferences/reading-direction'; -import { WritingStyle } from 'src/app/_models/preferences/writing-style'; -import { ThemeProvider } from 'src/app/_models/preferences/site-theme'; -import { User } from 'src/app/_models/user'; -import { AccountService } from 'src/app/_services/account.service'; -import { ThemeService } from 'src/app/_services/theme.service'; -import { FontFamily, BookService } from '../../_services/book.service'; -import { BookBlackTheme } from '../../_models/book-black-theme'; -import { BookDarkTheme } from '../../_models/book-dark-theme'; -import { BookWhiteTheme } from '../../_models/book-white-theme'; -import { BookPaperTheme } from '../../_models/book-paper-theme'; +import {FormControl, FormGroup, ReactiveFormsModule} from '@angular/forms'; +import {skip, take} from 'rxjs'; +import {BookPageLayoutMode} from 'src/app/_models/readers/book-page-layout-mode'; +import {BookTheme} from 'src/app/_models/preferences/book-theme'; +import {ReadingDirection} from 'src/app/_models/preferences/reading-direction'; +import {WritingStyle} from 'src/app/_models/preferences/writing-style'; +import {ThemeProvider} from 'src/app/_models/preferences/site-theme'; +import {User} from 'src/app/_models/user'; +import {AccountService} from 'src/app/_services/account.service'; +import {ThemeService} from 'src/app/_services/theme.service'; +import {BookService, FontFamily} from '../../_services/book.service'; +import {BookBlackTheme} from '../../_models/book-black-theme'; +import {BookDarkTheme} from '../../_models/book-dark-theme'; +import {BookWhiteTheme} from '../../_models/book-white-theme'; +import {BookPaperTheme} from '../../_models/book-paper-theme'; import {takeUntilDestroyed} from "@angular/core/rxjs-interop"; -import { NgbAccordionDirective, NgbAccordionItem, NgbAccordionHeader, NgbAccordionToggle, NgbAccordionButton, NgbCollapse, NgbAccordionCollapse, NgbAccordionBody, NgbTooltip } from '@ng-bootstrap/ng-bootstrap'; -import {TranslocoDirective} from "@jsverse/transloco"; +import { + NgbAccordionBody, + NgbAccordionButton, + NgbAccordionCollapse, + NgbAccordionDirective, + NgbAccordionHeader, + NgbAccordionItem, + NgbTooltip +} from '@ng-bootstrap/ng-bootstrap'; +import {translate, TranslocoDirective} from "@jsverse/transloco"; +import {ReadingProfileService} from "../../../_services/reading-profile.service"; +import {ReadingProfile, ReadingProfileKind} from "../../../_models/preferences/reading-profiles"; +import {debounceTime, distinctUntilChanged, tap} from "rxjs/operators"; +import {ToastrService} from "ngx-toastr"; /** * Used for book reader. Do not use for other components @@ -89,9 +103,13 @@ const mobileBreakpointMarginOverride = 700; templateUrl: './reader-settings.component.html', styleUrls: ['./reader-settings.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, - imports: [ReactiveFormsModule, NgbAccordionDirective, NgbAccordionItem, NgbAccordionHeader, NgbAccordionToggle, NgbAccordionButton, NgbCollapse, NgbAccordionCollapse, NgbAccordionBody, NgFor, NgbTooltip, NgTemplateOutlet, NgIf, NgClass, NgStyle, TitleCasePipe, TranslocoDirective] + imports: [ReactiveFormsModule, NgbAccordionDirective, NgbAccordionItem, NgbAccordionHeader, NgbAccordionButton, + NgbAccordionCollapse, NgbAccordionBody, NgFor, NgbTooltip, NgTemplateOutlet, NgIf, NgClass, NgStyle, + TitleCasePipe, TranslocoDirective] }) export class ReaderSettingsComponent implements OnInit { + @Input({required:true}) seriesId!: number; + @Input({required:true}) readingProfile!: ReadingProfile; /** * Outputs when clickToPaginate is changed */ @@ -147,6 +165,11 @@ export class ReaderSettingsComponent implements OnInit { settingsForm: FormGroup = new FormGroup({}); + /** + * The reading profile itself, unless readingProfile is implicit + */ + parentReadingProfile: ReadingProfile | null = null; + /** * System provided themes */ @@ -166,136 +189,169 @@ export class ReaderSettingsComponent implements OnInit { return WritingStyle; } - - constructor(private bookService: BookService, private accountService: AccountService, @Inject(DOCUMENT) private document: Document, private themeService: ThemeService, - private readonly cdRef: ChangeDetectorRef) {} + private readonly cdRef: ChangeDetectorRef, private readingProfileService: ReadingProfileService, + private toastr: ToastrService) {} ngOnInit(): void { + if (this.readingProfile.kind === ReadingProfileKind.Implicit) { + this.readingProfileService.getForSeries(this.seriesId, true).subscribe(parent => { + this.parentReadingProfile = parent; + this.cdRef.markForCheck(); + }) + } else { + this.parentReadingProfile = this.readingProfile; + this.cdRef.markForCheck(); + } this.fontFamilies = this.bookService.getFontFamilies(); this.fontOptions = this.fontFamilies.map(f => f.title); + + + this.cdRef.markForCheck(); + this.setupSettings(); + + this.setTheme(this.readingProfile.bookReaderThemeName || this.themeService.defaultBookTheme, false); + this.cdRef.markForCheck(); + + // Emit first time so book reader gets the setting + this.readingDirection.emit(this.readingDirectionModel); + this.bookReaderWritingStyle.emit(this.writingStyleModel); + this.clickToPaginateChanged.emit(this.readingProfile.bookReaderTapToPaginate); + this.layoutModeUpdate.emit(this.readingProfile.bookReaderLayoutMode); + this.immersiveMode.emit(this.readingProfile.bookReaderImmersiveMode); + this.accountService.currentUser$.pipe(take(1)).subscribe(user => { if (user) { this.user = user; - - if (this.user.preferences.bookReaderFontFamily === undefined) { - this.user.preferences.bookReaderFontFamily = 'default'; - } - if (this.user.preferences.bookReaderFontSize === undefined || this.user.preferences.bookReaderFontSize < 50) { - this.user.preferences.bookReaderFontSize = 100; - } - if (this.user.preferences.bookReaderLineSpacing === undefined || this.user.preferences.bookReaderLineSpacing < 100) { - this.user.preferences.bookReaderLineSpacing = 100; - } - if (this.user.preferences.bookReaderMargin === undefined) { - this.user.preferences.bookReaderMargin = 0; - } - if (this.user.preferences.bookReaderReadingDirection === undefined) { - this.user.preferences.bookReaderReadingDirection = ReadingDirection.LeftToRight; - } - if (this.user.preferences.bookReaderWritingStyle === undefined) { - this.user.preferences.bookReaderWritingStyle = WritingStyle.Horizontal; - } - this.readingDirectionModel = this.user.preferences.bookReaderReadingDirection; - this.writingStyleModel = this.user.preferences.bookReaderWritingStyle; - - - - this.settingsForm.addControl('bookReaderFontFamily', new FormControl(this.user.preferences.bookReaderFontFamily, [])); - this.settingsForm.get('bookReaderFontFamily')!.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(fontName => { - const familyName = this.fontFamilies.filter(f => f.title === fontName)[0].family; - if (familyName === 'default') { - this.pageStyles['font-family'] = 'inherit'; - } else { - this.pageStyles['font-family'] = "'" + familyName + "'"; - } - - this.styleUpdate.emit(this.pageStyles); - }); - - this.settingsForm.addControl('bookReaderFontSize', new FormControl(this.user.preferences.bookReaderFontSize, [])); - this.settingsForm.get('bookReaderFontSize')?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(value => { - this.pageStyles['font-size'] = value + '%'; - this.styleUpdate.emit(this.pageStyles); - }); - - this.settingsForm.addControl('bookReaderTapToPaginate', new FormControl(this.user.preferences.bookReaderTapToPaginate, [])); - this.settingsForm.get('bookReaderTapToPaginate')?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(value => { - this.clickToPaginateChanged.emit(value); - }); - - this.settingsForm.addControl('bookReaderLineSpacing', new FormControl(this.user.preferences.bookReaderLineSpacing, [])); - this.settingsForm.get('bookReaderLineSpacing')?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(value => { - this.pageStyles['line-height'] = value + '%'; - this.styleUpdate.emit(this.pageStyles); - }); - - this.settingsForm.addControl('bookReaderMargin', new FormControl(this.user.preferences.bookReaderMargin, [])); - this.settingsForm.get('bookReaderMargin')?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(value => { - this.pageStyles['margin-left'] = value + 'vw'; - this.pageStyles['margin-right'] = value + 'vw'; - this.styleUpdate.emit(this.pageStyles); - }); - - - - this.settingsForm.addControl('layoutMode', new FormControl(this.user.preferences.bookReaderLayoutMode || BookPageLayoutMode.Default, [])); - this.settingsForm.get('layoutMode')?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((layoutMode: BookPageLayoutMode) => { - this.layoutModeUpdate.emit(layoutMode); - }); - - this.settingsForm.addControl('bookReaderImmersiveMode', new FormControl(this.user.preferences.bookReaderImmersiveMode, [])); - this.settingsForm.get('bookReaderImmersiveMode')?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((immersiveMode: boolean) => { - if (immersiveMode) { - this.settingsForm.get('bookReaderTapToPaginate')?.setValue(true); - } - this.immersiveMode.emit(immersiveMode); - }); - - - this.setTheme(this.user.preferences.bookReaderThemeName || this.themeService.defaultBookTheme); - this.cdRef.markForCheck(); - - // Emit first time so book reader gets the setting - this.readingDirection.emit(this.readingDirectionModel); - this.bookReaderWritingStyle.emit(this.writingStyleModel); - this.clickToPaginateChanged.emit(this.user.preferences.bookReaderTapToPaginate); - this.layoutModeUpdate.emit(this.user.preferences.bookReaderLayoutMode); - this.immersiveMode.emit(this.user.preferences.bookReaderImmersiveMode); - - this.resetSettings(); - } else { - this.resetSettings(); } - + // User needs to be loaded before we call this + this.resetSettings(); }); } + setupSettings() { + if (!this.readingProfile) return; + + if (this.readingProfile.bookReaderFontFamily === undefined) { + this.readingProfile.bookReaderFontFamily = 'default'; + } + if (this.readingProfile.bookReaderFontSize === undefined || this.readingProfile.bookReaderFontSize < 50) { + this.readingProfile.bookReaderFontSize = 100; + } + if (this.readingProfile.bookReaderLineSpacing === undefined || this.readingProfile.bookReaderLineSpacing < 100) { + this.readingProfile.bookReaderLineSpacing = 100; + } + if (this.readingProfile.bookReaderMargin === undefined) { + this.readingProfile.bookReaderMargin = 0; + } + if (this.readingProfile.bookReaderReadingDirection === undefined) { + this.readingProfile.bookReaderReadingDirection = ReadingDirection.LeftToRight; + } + if (this.readingProfile.bookReaderWritingStyle === undefined) { + this.readingProfile.bookReaderWritingStyle = WritingStyle.Horizontal; + } + this.readingDirectionModel = this.readingProfile.bookReaderReadingDirection; + this.writingStyleModel = this.readingProfile.bookReaderWritingStyle; + + this.settingsForm.addControl('bookReaderFontFamily', new FormControl(this.readingProfile.bookReaderFontFamily, [])); + this.settingsForm.get('bookReaderFontFamily')!.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(fontName => { + const familyName = this.fontFamilies.filter(f => f.title === fontName)[0].family; + if (familyName === 'default') { + this.pageStyles['font-family'] = 'inherit'; + } else { + this.pageStyles['font-family'] = "'" + familyName + "'"; + } + + this.styleUpdate.emit(this.pageStyles); + }); + + this.settingsForm.addControl('bookReaderFontSize', new FormControl(this.readingProfile.bookReaderFontSize, [])); + this.settingsForm.get('bookReaderFontSize')?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(value => { + this.pageStyles['font-size'] = value + '%'; + this.styleUpdate.emit(this.pageStyles); + }); + + this.settingsForm.addControl('bookReaderTapToPaginate', new FormControl(this.readingProfile.bookReaderTapToPaginate, [])); + this.settingsForm.get('bookReaderTapToPaginate')?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(value => { + this.clickToPaginateChanged.emit(value); + }); + + this.settingsForm.addControl('bookReaderLineSpacing', new FormControl(this.readingProfile.bookReaderLineSpacing, [])); + this.settingsForm.get('bookReaderLineSpacing')?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(value => { + this.pageStyles['line-height'] = value + '%'; + this.styleUpdate.emit(this.pageStyles); + }); + + this.settingsForm.addControl('bookReaderMargin', new FormControl(this.readingProfile.bookReaderMargin, [])); + this.settingsForm.get('bookReaderMargin')?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(value => { + this.pageStyles['margin-left'] = value + 'vw'; + this.pageStyles['margin-right'] = value + 'vw'; + this.styleUpdate.emit(this.pageStyles); + }); + + this.settingsForm.addControl('layoutMode', new FormControl(this.readingProfile.bookReaderLayoutMode, [])); + this.settingsForm.get('layoutMode')?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((layoutMode: BookPageLayoutMode) => { + this.layoutModeUpdate.emit(layoutMode); + }); + + this.settingsForm.addControl('bookReaderImmersiveMode', new FormControl(this.readingProfile.bookReaderImmersiveMode, [])); + this.settingsForm.get('bookReaderImmersiveMode')?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((immersiveMode: boolean) => { + if (immersiveMode) { + this.settingsForm.get('bookReaderTapToPaginate')?.setValue(true); + } + this.immersiveMode.emit(immersiveMode); + }); + + // Update implicit reading profile while changing settings + this.settingsForm.valueChanges.pipe( + debounceTime(300), + distinctUntilChanged(), + skip(1), // Skip the initial creation of the form, we do not want an implicit profile of this snapshot + takeUntilDestroyed(this.destroyRef), + tap(_ => this.updateImplicit()) + ).subscribe(); + } + resetSettings() { + if (!this.readingProfile) return; + if (this.user) { - this.setPageStyles(this.user.preferences.bookReaderFontFamily, this.user.preferences.bookReaderFontSize + '%', this.user.preferences.bookReaderMargin + 'vw', this.user.preferences.bookReaderLineSpacing + '%'); + this.setPageStyles(this.readingProfile.bookReaderFontFamily, this.readingProfile.bookReaderFontSize + '%', this.readingProfile.bookReaderMargin + 'vw', this.readingProfile.bookReaderLineSpacing + '%'); } else { this.setPageStyles(); } - this.settingsForm.get('bookReaderFontFamily')?.setValue(this.user.preferences.bookReaderFontFamily); - this.settingsForm.get('bookReaderFontSize')?.setValue(this.user.preferences.bookReaderFontSize); - this.settingsForm.get('bookReaderLineSpacing')?.setValue(this.user.preferences.bookReaderLineSpacing); - this.settingsForm.get('bookReaderMargin')?.setValue(this.user.preferences.bookReaderMargin); - this.settingsForm.get('bookReaderReadingDirection')?.setValue(this.user.preferences.bookReaderReadingDirection); - this.settingsForm.get('bookReaderTapToPaginate')?.setValue(this.user.preferences.bookReaderTapToPaginate); - this.settingsForm.get('bookReaderLayoutMode')?.setValue(this.user.preferences.bookReaderLayoutMode); - this.settingsForm.get('bookReaderImmersiveMode')?.setValue(this.user.preferences.bookReaderImmersiveMode); - this.settingsForm.get('bookReaderWritingStyle')?.setValue(this.user.preferences.bookReaderWritingStyle); + this.settingsForm.get('bookReaderFontFamily')?.setValue(this.readingProfile.bookReaderFontFamily); + this.settingsForm.get('bookReaderFontSize')?.setValue(this.readingProfile.bookReaderFontSize); + this.settingsForm.get('bookReaderLineSpacing')?.setValue(this.readingProfile.bookReaderLineSpacing); + this.settingsForm.get('bookReaderMargin')?.setValue(this.readingProfile.bookReaderMargin); + this.settingsForm.get('bookReaderReadingDirection')?.setValue(this.readingProfile.bookReaderReadingDirection); + this.settingsForm.get('bookReaderTapToPaginate')?.setValue(this.readingProfile.bookReaderTapToPaginate); + this.settingsForm.get('bookReaderLayoutMode')?.setValue(this.readingProfile.bookReaderLayoutMode); + this.settingsForm.get('bookReaderImmersiveMode')?.setValue(this.readingProfile.bookReaderImmersiveMode); + this.settingsForm.get('bookReaderWritingStyle')?.setValue(this.readingProfile.bookReaderWritingStyle); + this.cdRef.detectChanges(); this.styleUpdate.emit(this.pageStyles); } + updateImplicit() { + this.readingProfileService.updateImplicit(this.packReadingProfile(), this.seriesId).subscribe({ + next: newProfile => { + this.readingProfile = newProfile; + this.cdRef.markForCheck(); + }, + error: err => { + console.error(err); + } + }) + } + /** * Internal method to be used by resetSettings. Pass items in with quantifiers */ @@ -318,11 +374,15 @@ export class ReaderSettingsComponent implements OnInit { }; } - setTheme(themeName: string) { + setTheme(themeName: string, update: boolean = true) { const theme = this.themes.find(t => t.name === themeName); this.activeTheme = theme; this.cdRef.markForCheck(); this.colorThemeUpdate.emit(theme); + + if (update) { + this.updateImplicit(); + } } toggleReadingDirection() { @@ -334,6 +394,7 @@ export class ReaderSettingsComponent implements OnInit { this.cdRef.markForCheck(); this.readingDirection.emit(this.readingDirectionModel); + this.updateImplicit(); } toggleWritingStyle() { @@ -345,6 +406,7 @@ export class ReaderSettingsComponent implements OnInit { this.cdRef.markForCheck(); this.bookReaderWritingStyle.emit(this.writingStyleModel); + this.updateImplicit(); } toggleFullscreen() { @@ -352,4 +414,53 @@ export class ReaderSettingsComponent implements OnInit { this.cdRef.markForCheck(); this.fullscreen.emit(); } + + // menu only code + updateParentPref() { + if (this.readingProfile.kind !== ReadingProfileKind.Implicit) { + return; + } + + this.readingProfileService.updateParentProfile(this.seriesId, this.packReadingProfile()).subscribe(newProfile => { + this.readingProfile = newProfile; + this.toastr.success(translate('manga-reader.reading-profile-updated')); + this.cdRef.markForCheck(); + }); + } + + createNewProfileFromImplicit() { + if (this.readingProfile.kind !== ReadingProfileKind.Implicit) { + return; + } + + this.readingProfileService.promoteProfile(this.readingProfile.id).subscribe(newProfile => { + this.readingProfile = newProfile; + this.parentReadingProfile = newProfile; // profile is no longer implicit + this.cdRef.markForCheck(); + + this.toastr.success(translate("manga-reader.reading-profile-promoted")); + }); + } + + private packReadingProfile(): ReadingProfile { + const modelSettings = this.settingsForm.getRawValue(); + const data = {...this.readingProfile!}; + data.bookReaderFontFamily = modelSettings.bookReaderFontFamily; + data.bookReaderFontSize = modelSettings.bookReaderFontSize + data.bookReaderLineSpacing = modelSettings.bookReaderLineSpacing; + data.bookReaderMargin = modelSettings.bookReaderMargin; + data.bookReaderTapToPaginate = modelSettings.bookReaderTapToPaginate; + data.bookReaderLayoutMode = modelSettings.layoutMode; + data.bookReaderImmersiveMode = modelSettings.bookReaderImmersiveMode; + + data.bookReaderReadingDirection = this.readingDirectionModel; + data.bookReaderWritingStyle = this.writingStyleModel; + if (this.activeTheme) { + data.bookReaderThemeName = this.activeTheme.name; + } + + return data; + } + + protected readonly ReadingProfileKind = ReadingProfileKind; } diff --git a/UI/Web/src/app/book-reader/_models/book-paper-theme.ts b/UI/Web/src/app/book-reader/_models/book-paper-theme.ts index 41c7958e1..9b6a5d461 100644 --- a/UI/Web/src/app/book-reader/_models/book-paper-theme.ts +++ b/UI/Web/src/app/book-reader/_models/book-paper-theme.ts @@ -48,6 +48,7 @@ export const BookPaperTheme = ` --btn-disabled-bg-color: #343a40; --btn-disabled-text-color: #efefef; --btn-disabled-border-color: #6c757d; + --btn-outline-primary-text-color: black; /* Inputs */ --input-bg-color: white; @@ -89,6 +90,8 @@ export const BookPaperTheme = ` /* Custom variables */ --theme-bg-color: #fff3c9; + + --bs-secondary-bg: darkgrey; } .reader-container { diff --git a/UI/Web/src/app/book-reader/_models/book-white-theme.ts b/UI/Web/src/app/book-reader/_models/book-white-theme.ts index 1b4bab274..a209b954f 100644 --- a/UI/Web/src/app/book-reader/_models/book-white-theme.ts +++ b/UI/Web/src/app/book-reader/_models/book-white-theme.ts @@ -51,6 +51,7 @@ export const BookWhiteTheme = ` --btn-disabled-bg-color: #343a40; --btn-disabled-text-color: #efefef; --btn-disabled-border-color: #6c757d; + --btn-outline-primary-text-color: black; /* Inputs */ --input-bg-color: white; diff --git a/UI/Web/src/app/cards/_modals/bulk-set-reading-profile-modal/bulk-set-reading-profile-modal.component.html b/UI/Web/src/app/cards/_modals/bulk-set-reading-profile-modal/bulk-set-reading-profile-modal.component.html new file mode 100644 index 000000000..d9dbb0715 --- /dev/null +++ b/UI/Web/src/app/cards/_modals/bulk-set-reading-profile-modal/bulk-set-reading-profile-modal.component.html @@ -0,0 +1,56 @@ + + + +
+ + + +
+ + + + + +
diff --git a/UI/Web/src/app/cards/_modals/bulk-set-reading-profile-modal/bulk-set-reading-profile-modal.component.scss b/UI/Web/src/app/cards/_modals/bulk-set-reading-profile-modal/bulk-set-reading-profile-modal.component.scss new file mode 100644 index 000000000..0974b1867 --- /dev/null +++ b/UI/Web/src/app/cards/_modals/bulk-set-reading-profile-modal/bulk-set-reading-profile-modal.component.scss @@ -0,0 +1,14 @@ +.clickable:hover, .clickable:focus { + background-color: var(--list-group-hover-bg-color, --primary-color); +} + +.pill { + font-size: .8rem; + background-color: var(--card-bg-color); + border-radius: 0.375rem; + color: var(--badge-text-color); + + &.active { + background-color : var(--primary-color); + } +} diff --git a/UI/Web/src/app/cards/_modals/bulk-set-reading-profile-modal/bulk-set-reading-profile-modal.component.ts b/UI/Web/src/app/cards/_modals/bulk-set-reading-profile-modal/bulk-set-reading-profile-modal.component.ts new file mode 100644 index 000000000..484fe7e75 --- /dev/null +++ b/UI/Web/src/app/cards/_modals/bulk-set-reading-profile-modal/bulk-set-reading-profile-modal.component.ts @@ -0,0 +1,120 @@ +import {AfterViewInit, ChangeDetectorRef, Component, ElementRef, inject, Input, OnInit, ViewChild} from '@angular/core'; +import {NgbActiveModal} from "@ng-bootstrap/ng-bootstrap"; +import {ToastrService} from "ngx-toastr"; +import {FormControl, FormGroup, ReactiveFormsModule} from "@angular/forms"; +import {translate, TranslocoDirective} from "@jsverse/transloco"; +import {ReadingProfileService} from "../../../_services/reading-profile.service"; +import {ReadingProfile, ReadingProfileKind} from "../../../_models/preferences/reading-profiles"; +import {FilterPipe} from "../../../_pipes/filter.pipe"; +import {SentenceCasePipe} from "../../../_pipes/sentence-case.pipe"; + +@Component({ + selector: 'app-bulk-set-reading-profile-modal', + imports: [ + ReactiveFormsModule, + FilterPipe, + TranslocoDirective, + SentenceCasePipe + ], + templateUrl: './bulk-set-reading-profile-modal.component.html', + styleUrl: './bulk-set-reading-profile-modal.component.scss' +}) +export class BulkSetReadingProfileModalComponent implements OnInit, AfterViewInit { + private readonly modal = inject(NgbActiveModal); + private readonly readingProfileService = inject(ReadingProfileService); + private readonly toastr = inject(ToastrService); + private readonly cdRef = inject(ChangeDetectorRef); + protected readonly MaxItems = 8; + + /** + * Modal Header - since this code is used for multiple flows + */ + @Input({required: true}) title!: string; + /** + * Series Ids to add to Reading Profile + */ + @Input() seriesIds: Array = []; + @Input() libraryId: number | undefined; + @ViewChild('title') inputElem!: ElementRef; + + currentProfile: ReadingProfile | null = null; + profiles: Array = []; + isLoading: boolean = false; + profileForm: FormGroup = new FormGroup({ + filterQuery: new FormControl('', []), // Used for inline filtering when too many RPs + }); + + ngOnInit(): void { + + this.profileForm.addControl('title', new FormControl(this.title, [])); + + this.isLoading = true; + this.cdRef.markForCheck(); + + if (this.libraryId !== undefined) { + this.readingProfileService.getForLibrary(this.libraryId).subscribe(profile => { + this.currentProfile = profile; + this.cdRef.markForCheck(); + }); + } else if (this.seriesIds.length === 1) { + this.readingProfileService.getForSeries(this.seriesIds[0], true).subscribe(profile => { + this.currentProfile = profile; + this.cdRef.markForCheck(); + }); + } + + + this.readingProfileService.getAllProfiles().subscribe(profiles => { + this.profiles = profiles; + this.isLoading = false; + this.cdRef.markForCheck(); + }); + } + + ngAfterViewInit() { + // Shift focus to input + if (this.inputElem) { + this.inputElem.nativeElement.select(); + this.cdRef.markForCheck(); + } + } + + close() { + this.modal.close(); + } + + addToProfile(profile: ReadingProfile) { + if (this.seriesIds.length == 1) { + this.readingProfileService.addToSeries(profile.id, this.seriesIds[0]).subscribe(() => { + this.toastr.success(translate('toasts.series-bound-to-reading-profile', {name: profile.name})); + this.modal.close(); + }); + return; + } + + if (this.seriesIds.length > 1) { + this.readingProfileService.bulkAddToSeries(profile.id, this.seriesIds).subscribe(() => { + this.toastr.success(translate('toasts.series-bound-to-reading-profile', {name: profile.name})); + this.modal.close(); + }); + return; + } + + if (this.libraryId) { + this.readingProfileService.addToLibrary(profile.id, this.libraryId).subscribe(() => { + this.toastr.success(translate('toasts.library-bound-to-reading-profile', {name: profile.name})); + this.modal.close(); + }); + } + } + + filterList = (listItem: ReadingProfile) => { + return listItem.name.toLowerCase().indexOf((this.profileForm.value.filterQuery || '').toLowerCase()) >= 0; + } + + clear() { + this.profileForm.get('filterQuery')?.setValue(''); + } + + protected readonly ReadingProfileKind = ReadingProfileKind; +} diff --git a/UI/Web/src/app/cards/bulk-selection.service.ts b/UI/Web/src/app/cards/bulk-selection.service.ts index ff80a0288..2fa84b50d 100644 --- a/UI/Web/src/app/cards/bulk-selection.service.ts +++ b/UI/Web/src/app/cards/bulk-selection.service.ts @@ -144,7 +144,7 @@ export class BulkSelectionService { */ getActions(callback: (action: ActionItem, data: any) => void) { const allowedActions = [Action.AddToReadingList, Action.MarkAsRead, Action.MarkAsUnread, Action.AddToCollection, - Action.Delete, Action.AddToWantToReadList, Action.RemoveFromWantToReadList]; + Action.Delete, Action.AddToWantToReadList, Action.RemoveFromWantToReadList, Action.SetReadingProfile]; if (Object.keys(this.selectedCards).filter(item => item === 'series').length > 0) { return this.applyFilterToList(this.actionFactory.getSeriesActions(callback), allowedActions); diff --git a/UI/Web/src/app/cards/series-card/series-card.component.ts b/UI/Web/src/app/cards/series-card/series-card.component.ts index c6cfa825f..052f71107 100644 --- a/UI/Web/src/app/cards/series-card/series-card.component.ts +++ b/UI/Web/src/app/cards/series-card/series-card.component.ts @@ -24,7 +24,7 @@ import {RelationKind} from 'src/app/_models/series-detail/relation-kind'; import {DecimalPipe} from "@angular/common"; import {RelationshipPipe} from "../../_pipes/relationship.pipe"; import {Device} from "../../_models/device/device"; -import {translate, TranslocoDirective} from "@jsverse/transloco"; +import {translate, TranslocoDirective, TranslocoService} from "@jsverse/transloco"; import {SeriesPreviewDrawerComponent} from "../../_single-module/series-preview-drawer/series-preview-drawer.component"; import {CardActionablesComponent} from "../../_single-module/card-actionables/card-actionables.component"; import {DefaultValuePipe} from "../../_pipes/default-value.pipe"; @@ -41,6 +41,7 @@ import {ScrollService} from "../../_services/scroll.service"; import {ReaderService} from "../../_services/reader.service"; import {SeriesFormatComponent} from "../../shared/series-format/series-format.component"; import {DefaultModalOptions} from "../../_models/default-modal-options"; +import {ReadingProfileService} from "../../_services/reading-profile.service"; function deepClone(obj: any): any { if (obj === null || typeof obj !== 'object') { @@ -92,6 +93,8 @@ export class SeriesCardComponent implements OnInit, OnChanges { private readonly downloadService = inject(DownloadService); private readonly scrollService = inject(ScrollService); private readonly readerService = inject(ReaderService); + private readonly readingProfilesService = inject(ReadingProfileService); + private readonly translocoService = inject(TranslocoService); @Input({required: true}) series!: Series; @Input() libraryId = 0; @@ -276,6 +279,14 @@ export class SeriesCardComponent implements OnInit, OnChanges { case Action.Download: this.downloadService.download('series', this.series); break; + case Action.SetReadingProfile: + this.actionService.setReadingProfileForMultiple([series]); + break; + case Action.ClearReadingProfile: + this.readingProfilesService.clearSeriesProfiles(series.id).subscribe(() => { + this.toastr.success(this.translocoService.translate('actionable.cleared-profile')); + }); + break; default: break; } diff --git a/UI/Web/src/app/library-detail/library-detail.component.ts b/UI/Web/src/app/library-detail/library-detail.component.ts index 8b816fc1c..b2563a1a6 100644 --- a/UI/Web/src/app/library-detail/library-detail.component.ts +++ b/UI/Web/src/app/library-detail/library-detail.component.ts @@ -149,6 +149,14 @@ export class LibraryDetailComponent implements OnInit { this.loadPage(); }); break; + case Action.SetReadingProfile: + this.actionService.setReadingProfileForMultiple(selectedSeries, (success) => { + this.bulkLoader = false; + this.cdRef.markForCheck(); + if (!success) return; + this.bulkSelectionService.deselectAll(); + this.loadPage(); + }) } } diff --git a/UI/Web/src/app/manga-reader/_components/manga-reader/manga-reader.component.html b/UI/Web/src/app/manga-reader/_components/manga-reader/manga-reader.component.html index 195b66b2b..069f52edd 100644 --- a/UI/Web/src/app/manga-reader/_components/manga-reader/manga-reader.component.html +++ b/UI/Web/src/app/manga-reader/_components/manga-reader/manga-reader.component.html @@ -53,7 +53,6 @@
- @if (readerMode !== ReaderMode.Webtoon) {
- + +
diff --git a/UI/Web/src/app/manga-reader/_components/manga-reader/manga-reader.component.ts b/UI/Web/src/app/manga-reader/_components/manga-reader/manga-reader.component.ts index a7bbe2d90..74bbca298 100644 --- a/UI/Web/src/app/manga-reader/_components/manga-reader/manga-reader.component.ts +++ b/UI/Web/src/app/manga-reader/_components/manga-reader/manga-reader.component.ts @@ -32,7 +32,7 @@ import { import {ChangeContext, LabelType, NgxSliderModule, Options} from '@angular-slider/ngx-slider'; import {animate, state, style, transition, trigger} from '@angular/animations'; import {FormBuilder, FormControl, FormGroup, ReactiveFormsModule} from '@angular/forms'; -import {NgbModal} from '@ng-bootstrap/ng-bootstrap'; +import {NgbModal, NgbTooltip} from '@ng-bootstrap/ng-bootstrap'; import {ToastrService} from 'ngx-toastr'; import {ShortcutsModalComponent} from 'src/app/reader-shared/_modals/shortcuts-modal/shortcuts-modal.component'; import {Stack} from 'src/app/shared/data-structures/stack'; @@ -40,7 +40,6 @@ import {Breakpoint, KEY_CODES, UtilityService} from 'src/app/shared/_services/ut import {LibraryType} from 'src/app/_models/library/library'; import {MangaFormat} from 'src/app/_models/manga-format'; import {PageSplitOption} from 'src/app/_models/preferences/page-split-option'; -import {layoutModes, pageSplitOptions} from 'src/app/_models/preferences/preferences'; import {ReaderMode} from 'src/app/_models/preferences/reader-mode'; import {ReadingDirection} from 'src/app/_models/preferences/reading-direction'; import {ScalingOption} from 'src/app/_models/preferences/scaling-option'; @@ -70,6 +69,13 @@ import {LoadingComponent} from '../../../shared/loading/loading.component'; import {translate, TranslocoDirective} from "@jsverse/transloco"; import {shareReplay} from "rxjs/operators"; import {DblClickDirective} from "../../../_directives/dbl-click.directive"; +import { + layoutModes, + pageSplitOptions, + ReadingProfile, + ReadingProfileKind +} from "../../../_models/preferences/reading-profiles"; +import {ReadingProfileService} from "../../../_services/reading-profile.service"; import {ConfirmService} from "../../../shared/confirm.service"; @@ -123,10 +129,10 @@ enum KeyDirection { ]) ]) ], - imports: [NgStyle, LoadingComponent, SwipeDirective, CanvasRendererComponent, SingleRendererComponent, - DoubleRendererComponent, DoubleReverseRendererComponent, DoubleNoCoverRendererComponent, InfiniteScrollerComponent, - NgxSliderModule, ReactiveFormsModule, FittingIconPipe, ReaderModeIconPipe, - FullscreenIconPipe, TranslocoDirective, PercentPipe, NgClass, AsyncPipe, DblClickDirective] + imports: [NgStyle, LoadingComponent, SwipeDirective, CanvasRendererComponent, SingleRendererComponent, + DoubleRendererComponent, DoubleReverseRendererComponent, DoubleNoCoverRendererComponent, InfiniteScrollerComponent, + NgxSliderModule, ReactiveFormsModule, FittingIconPipe, ReaderModeIconPipe, + FullscreenIconPipe, TranslocoDirective, PercentPipe, NgClass, AsyncPipe, DblClickDirective, NgbTooltip] }) export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy { @@ -151,6 +157,7 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy { private readonly modalService = inject(NgbModal); private readonly cdRef = inject(ChangeDetectorRef); private readonly toastr = inject(ToastrService); + private readonly readingProfileService = inject(ReadingProfileService); private readonly confirmService = inject(ConfirmService); protected readonly readerService = inject(ReaderService); protected readonly utilityService = inject(UtilityService); @@ -197,6 +204,11 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy { totalSeriesPages = 0; totalSeriesPagesRead = 0; user!: User; + readingProfile!: ReadingProfile; + /** + * The reading profile itself, unless readingProfile is implicit + */ + parentReadingProfile: ReadingProfile | null = null; generalSettingsForm!: FormGroup; readingDirection = ReadingDirection.LeftToRight; @@ -491,6 +503,17 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy { this.incognitoMode = this.route.snapshot.queryParamMap.get('incognitoMode') === 'true'; this.bookmarkMode = this.route.snapshot.queryParamMap.get('bookmarkMode') === 'true'; + this.route.data.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(data => { + this.readingProfile = data['readingProfile']; + if (this.readingProfile == null) { + this.router.navigateByUrl('/home'); + return; + } + // Requires seriesId to be set + this.setupReaderSettings(); + this.cdRef.markForCheck(); + }); + const readingListId = this.route.snapshot.queryParamMap.get('readingListId'); if (readingListId != null) { this.readingListMode = true; @@ -505,101 +528,9 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy { return; } + this.user = user; this.hasBookmarkRights = this.accountService.hasBookmarkRole(user) || this.accountService.hasAdminRole(user); - this.readingDirection = this.user.preferences.readingDirection; - this.scalingOption = this.user.preferences.scalingOption; - this.pageSplitOption = this.user.preferences.pageSplitOption; - this.autoCloseMenu = this.user.preferences.autoCloseMenu; - this.readerMode = this.user.preferences.readerMode; - this.layoutMode = this.user.preferences.layoutMode || LayoutMode.Single; - this.backgroundColor = this.user.preferences.backgroundColor || '#000000'; - this.readerService.setOverrideStyles(this.backgroundColor); - - this.generalSettingsForm = this.formBuilder.nonNullable.group({ - autoCloseMenu: new FormControl(this.autoCloseMenu), - pageSplitOption: new FormControl(this.pageSplitOption), - fittingOption: new FormControl(this.mangaReaderService.translateScalingOption(this.scalingOption)), - widthSlider: new FormControl('none'), - layoutMode: new FormControl(this.layoutMode), - darkness: new FormControl(100), - emulateBook: new FormControl(this.user.preferences.emulateBook), - swipeToPaginate: new FormControl(this.user.preferences.swipeToPaginate) - }); - - this.readerModeSubject.next(this.readerMode); - this.pagingDirectionSubject.next(this.pagingDirection); - - // We need a mergeMap when page changes - this.readerSettings$ = merge(this.generalSettingsForm.valueChanges, this.pagingDirection$, this.readerMode$).pipe( - map(_ => this.createReaderSettingsUpdate()), - takeUntilDestroyed(this.destroyRef), - ); - - this.updateForm(); - - this.pagingDirection$.pipe( - distinctUntilChanged(), - tap(dir => { - this.pagingDirection = dir; - this.cdRef.markForCheck(); - }), - takeUntilDestroyed(this.destroyRef) - ).subscribe(() => {}); - - this.readerMode$.pipe( - distinctUntilChanged(), - tap(mode => { - this.readerMode = mode; - this.disableDoubleRendererIfScreenTooSmall(); - this.cdRef.markForCheck(); - }), - takeUntilDestroyed(this.destroyRef) - ).subscribe(() => {}); - - this.setupWidthOverrideTriggers(); - - this.generalSettingsForm.get('layoutMode')?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(val => { - - const changeOccurred = parseInt(val, 10) !== this.layoutMode; - this.layoutMode = parseInt(val, 10); - - if (this.layoutMode === LayoutMode.Single) { - this.generalSettingsForm.get('pageSplitOption')?.setValue(this.user.preferences.pageSplitOption); - this.generalSettingsForm.get('pageSplitOption')?.enable(); - this.generalSettingsForm.get('widthSlider')?.enable(); - this.generalSettingsForm.get('fittingOption')?.enable(); - this.generalSettingsForm.get('emulateBook')?.enable(); - } else { - this.generalSettingsForm.get('pageSplitOption')?.setValue(PageSplitOption.NoSplit); - this.generalSettingsForm.get('pageSplitOption')?.disable(); - this.generalSettingsForm.get('widthSlider')?.disable(); - this.generalSettingsForm.get('fittingOption')?.setValue(this.mangaReaderService.translateScalingOption(ScalingOption.FitToHeight)); - this.generalSettingsForm.get('fittingOption')?.disable(); - this.generalSettingsForm.get('emulateBook')?.enable(); - } - this.cdRef.markForCheck(); - - // Re-render the current page when we switch layouts - if (changeOccurred) { - this.setPageNum(this.adjustPagesForDoubleRenderer(this.pageNum)); - this.loadPage(); - } - }); - - this.generalSettingsForm.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => { - this.autoCloseMenu = this.generalSettingsForm.get('autoCloseMenu')?.value; - this.pageSplitOption = parseInt(this.generalSettingsForm.get('pageSplitOption')?.value, 10); - - const needsSplitting = this.mangaReaderService.isWidePage(this.readerService.imageUrlToPageNum(this.canvasImage.src)); - // If we need to split on a menu change, then we need to re-render. - if (needsSplitting) { - // If we need to re-render, to ensure things layout properly, let's update paging direction & reset render - this.pagingDirectionSubject.next(PAGING_DIRECTION.FORWARD); - this.canvasRenderer.reset(); - this.loadPage(); - } - }); this.memberService.hasReadingProgress(this.libraryId).pipe(take(1)).subscribe(progress => { if (!progress) { @@ -607,9 +538,29 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy { this.toastr.info(translate('manga-reader.first-time-reading-manga')); } }); - }); - this.init(); + this.init(); + + // Update implicit reading profile while changing settings + this.generalSettingsForm.valueChanges.pipe( + debounceTime(300), + distinctUntilChanged(), + takeUntilDestroyed(this.destroyRef), + map(_ => this.packReadingProfile()), + distinctUntilChanged(), + tap(newProfile => { + this.readingProfileService.updateImplicit(newProfile, this.seriesId).subscribe({ + next: updatedProfile => { + this.readingProfile = updatedProfile; + this.cdRef.markForCheck(); + }, + error: err => { + console.error(err); + } + }) + }) + ).subscribe(); + }); } ngAfterViewInit() { @@ -697,6 +648,114 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy { } } + setupReaderSettings() { + + if (this.readingProfile.kind === ReadingProfileKind.Implicit) { + this.readingProfileService.getForSeries(this.seriesId, true).subscribe(parent => { + this.parentReadingProfile = parent; + this.cdRef.markForCheck(); + }) + } else { + this.parentReadingProfile = this.readingProfile; + } + + this.readingDirection = this.readingProfile.readingDirection; + this.scalingOption = this.readingProfile.scalingOption; + this.pageSplitOption = this.readingProfile.pageSplitOption; + this.autoCloseMenu = this.readingProfile.autoCloseMenu; + this.readerMode = this.readingProfile.readerMode; + this.layoutMode = this.readingProfile.layoutMode || LayoutMode.Single; + this.backgroundColor = this.readingProfile.backgroundColor || '#000000'; + this.readerService.setOverrideStyles(this.backgroundColor); + + this.generalSettingsForm = this.formBuilder.nonNullable.group({ + autoCloseMenu: new FormControl(this.autoCloseMenu), + pageSplitOption: new FormControl(this.pageSplitOption), + fittingOption: new FormControl(this.mangaReaderService.translateScalingOption(this.scalingOption)), + widthSlider: new FormControl(this.readingProfile.widthOverride ?? 'none'), + layoutMode: new FormControl(this.layoutMode), + darkness: new FormControl(100), + emulateBook: new FormControl(this.readingProfile.emulateBook), + swipeToPaginate: new FormControl(this.readingProfile.swipeToPaginate) + }); + + this.readerModeSubject.next(this.readerMode); + this.pagingDirectionSubject.next(this.pagingDirection); + + // We need a mergeMap when page changes + this.readerSettings$ = merge(this.generalSettingsForm.valueChanges, this.pagingDirection$, this.readerMode$).pipe( + map(_ => this.createReaderSettingsUpdate()), + takeUntilDestroyed(this.destroyRef), + ); + + this.updateForm(); + + this.pagingDirection$.pipe( + distinctUntilChanged(), + tap(dir => { + this.pagingDirection = dir; + this.cdRef.markForCheck(); + }), + takeUntilDestroyed(this.destroyRef) + ).subscribe(() => {}); + + this.readerMode$.pipe( + distinctUntilChanged(), + tap(mode => { + this.readerMode = mode; + this.disableDoubleRendererIfScreenTooSmall(); + this.cdRef.markForCheck(); + }), + takeUntilDestroyed(this.destroyRef) + ).subscribe(() => {}); + + this.setupWidthOverrideTriggers(); + + this.generalSettingsForm.get('layoutMode')?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(val => { + + const changeOccurred = parseInt(val, 10) !== this.layoutMode; + this.layoutMode = parseInt(val, 10); + + if (this.layoutMode === LayoutMode.Single) { + this.generalSettingsForm.get('pageSplitOption')?.setValue(this.readingProfile!.pageSplitOption); + this.generalSettingsForm.get('pageSplitOption')?.enable(); + this.generalSettingsForm.get('widthSlider')?.enable(); + this.generalSettingsForm.get('fittingOption')?.enable(); + this.generalSettingsForm.get('emulateBook')?.enable(); + } else { + this.generalSettingsForm.get('pageSplitOption')?.setValue(PageSplitOption.NoSplit); + this.generalSettingsForm.get('pageSplitOption')?.disable(); + this.generalSettingsForm.get('widthSlider')?.disable(); + this.generalSettingsForm.get('fittingOption')?.setValue(this.mangaReaderService.translateScalingOption(ScalingOption.FitToHeight)); + this.generalSettingsForm.get('fittingOption')?.disable(); + this.generalSettingsForm.get('emulateBook')?.enable(); + } + this.cdRef.markForCheck(); + + // Re-render the current page when we switch layouts + if (changeOccurred) { + this.setPageNum(this.adjustPagesForDoubleRenderer(this.pageNum)); + this.loadPage(); + } + }); + + this.generalSettingsForm.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => { + this.autoCloseMenu = this.generalSettingsForm.get('autoCloseMenu')?.value; + this.pageSplitOption = parseInt(this.generalSettingsForm.get('pageSplitOption')?.value, 10); + + const needsSplitting = this.mangaReaderService.isWidePage(this.readerService.imageUrlToPageNum(this.canvasImage.src)); + // If we need to split on a menu change, then we need to re-render. + if (needsSplitting) { + // If we need to re-render, to ensure things layout properly, let's update paging direction & reset render + this.pagingDirectionSubject.next(PAGING_DIRECTION.FORWARD); + this.canvasRenderer.reset(); + this.loadPage(); + } + }); + + this.cdRef.markForCheck(); + } + /** * Width override is only valid under the following conditions: * Image Scaling is Width @@ -750,7 +809,7 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy { ).subscribe(); // Set the default override to 0 - widthOverrideControl.setValue(0); + //widthOverrideControl.setValue(0); //send the current width override value to the label this.widthOverrideLabel$ = this.readerSettings$?.pipe( @@ -783,7 +842,7 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy { switchToWebtoonReaderIfPagesLikelyWebtoon() { if (this.readerMode === ReaderMode.Webtoon) return; - if (!this.user.preferences.allowAutomaticWebtoonReaderDetection) return; + if (!this.readingProfile!.allowAutomaticWebtoonReaderDetection) return; if (this.mangaReaderService.shouldBeWebtoonMode()) { this.readerMode = ReaderMode.Webtoon; @@ -795,7 +854,9 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy { disableDoubleRendererIfScreenTooSmall() { if (window.innerWidth > window.innerHeight) { - this.generalSettingsForm.get('layoutMode')?.enable(); + if (this.generalSettingsForm.get('layoutMode')?.disabled) { + this.generalSettingsForm.get('layoutMode')?.enable(); + } this.cdRef.markForCheck(); return; } @@ -1463,7 +1524,7 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy { this.readingDirection = ReadingDirection.LeftToRight; } - if (this.menuOpen && this.user.preferences.showScreenHints) { + if (this.menuOpen && this.readingProfile!.showScreenHints) { this.showClickOverlay = true; this.showClickOverlaySubject.next(true); setTimeout(() => { @@ -1740,28 +1801,28 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy { } // menu only code - savePref() { - const modelSettings = this.generalSettingsForm.getRawValue(); - // Get latest preferences from user, overwrite with what we manage in this UI, then save - this.accountService.currentUser$.pipe(take(1)).subscribe(user => { - if (!user) return; - const data = {...user.preferences}; - data.layoutMode = parseInt(modelSettings.layoutMode, 10); - data.readerMode = this.readerMode; - data.autoCloseMenu = this.autoCloseMenu; - data.readingDirection = this.readingDirection; - data.emulateBook = modelSettings.emulateBook; - data.swipeToPaginate = modelSettings.swipeToPaginate; - data.pageSplitOption = parseInt(modelSettings.pageSplitOption, 10); - data.locale = data.locale || 'en'; + updateParentPref() { + if (this.readingProfile.kind !== ReadingProfileKind.Implicit) { + return; + } - this.accountService.updatePreferences(data).subscribe(updatedPrefs => { - this.toastr.success(translate('manga-reader.user-preferences-updated')); - if (this.user) { - this.user.preferences = updatedPrefs; - this.cdRef.markForCheck(); - } - }) + this.readingProfileService.updateParentProfile(this.seriesId, this.packReadingProfile()).subscribe(newProfile => { + this.readingProfile = newProfile; + this.toastr.success(translate('manga-reader.reading-profile-updated')); + this.cdRef.markForCheck(); + }); + } + + createNewProfileFromImplicit() { + if (this.readingProfile.kind !== ReadingProfileKind.Implicit) { + return; + } + + this.readingProfileService.promoteProfile(this.readingProfile.id).subscribe(newProfile => { + this.readingProfile = newProfile; + this.parentReadingProfile = newProfile; // Profile is no longer implicit + this.toastr.success(translate("manga-reader.reading-profile-promoted")); + this.cdRef.markForCheck(); }); } @@ -1771,4 +1832,21 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy { return d; } + private packReadingProfile(): ReadingProfile { + const modelSettings = this.generalSettingsForm.getRawValue(); + const data = {...this.readingProfile!}; + + data.layoutMode = parseInt(modelSettings.layoutMode, 10); + data.readerMode = this.readerMode; + data.autoCloseMenu = this.autoCloseMenu; + data.readingDirection = this.readingDirection; + data.emulateBook = modelSettings.emulateBook; + data.swipeToPaginate = modelSettings.swipeToPaginate; + data.pageSplitOption = parseInt(modelSettings.pageSplitOption, 10); + data.widthOverride = modelSettings.widthSlider === 'none' ? null : modelSettings.widthSlider; + + return data; + } + + protected readonly ReadingProfileKind = ReadingProfileKind; } diff --git a/UI/Web/src/app/pdf-reader/_components/pdf-reader/pdf-reader.component.ts b/UI/Web/src/app/pdf-reader/_components/pdf-reader/pdf-reader.component.ts index b6e99b5ca..c6b7c0494 100644 --- a/UI/Web/src/app/pdf-reader/_components/pdf-reader/pdf-reader.component.ts +++ b/UI/Web/src/app/pdf-reader/_components/pdf-reader/pdf-reader.component.ts @@ -34,6 +34,9 @@ import {PdfSpreadMode} from "../../../_models/preferences/pdf-spread-mode"; import {SpreadType} from "ngx-extended-pdf-viewer/lib/options/spread-type"; import {PdfScrollModeTypePipe} from "../../_pipe/pdf-scroll-mode.pipe"; import {PdfSpreadTypePipe} from "../../_pipe/pdf-spread-mode.pipe"; +import {ReadingProfileService} from "../../../_services/reading-profile.service"; +import {ReadingProfile} from "../../../_models/preferences/reading-profiles"; +import {takeUntilDestroyed} from "@angular/core/rxjs-interop"; @Component({ selector: 'app-pdf-reader', @@ -54,6 +57,7 @@ export class PdfReaderComponent implements OnInit, OnDestroy { private readonly themeService = inject(ThemeService); private readonly cdRef = inject(ChangeDetectorRef); public readonly accountService = inject(AccountService); + private readonly readingProfileService = inject(ReadingProfileService); public readonly readerService = inject(ReaderService); public readonly utilityService = inject(UtilityService); public readonly destroyRef = inject(DestroyRef); @@ -69,6 +73,7 @@ export class PdfReaderComponent implements OnInit, OnDestroy { chapterId!: number; chapter!: Chapter; user!: User; + readingProfile!: ReadingProfile; /** * Reading List id. Defaults to -1. @@ -162,6 +167,16 @@ export class PdfReaderComponent implements OnInit, OnDestroy { this.chapterId = parseInt(chapterId, 10); this.incognitoMode = this.route.snapshot.queryParamMap.get('incognitoMode') === 'true'; + this.route.data.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(data => { + this.readingProfile = data['readingProfile']; + if (this.readingProfile == null) { + this.router.navigateByUrl('/home'); + return; + } + this.setupReaderSettings(); + this.cdRef.markForCheck(); + }); + const readingListId = this.route.snapshot.queryParamMap.get('readingListId'); if (readingListId != null) { @@ -234,12 +249,14 @@ export class PdfReaderComponent implements OnInit, OnDestroy { } } - init() { - + setupReaderSettings() { this.pageLayoutMode = this.convertPdfLayoutMode(PdfLayoutMode.Multiple); - this.scrollMode = this.convertPdfScrollMode(this.user.preferences.pdfScrollMode || PdfScrollMode.Vertical); - this.spreadMode = this.convertPdfSpreadMode(this.user.preferences.pdfSpreadMode || PdfSpreadMode.None); - this.theme = this.convertPdfTheme(this.user.preferences.pdfTheme || PdfTheme.Dark); + this.scrollMode = this.convertPdfScrollMode(this.readingProfile.pdfScrollMode || PdfScrollMode.Vertical); + this.spreadMode = this.convertPdfSpreadMode(this.readingProfile.pdfSpreadMode || PdfSpreadMode.None); + this.theme = this.convertPdfTheme(this.readingProfile.pdfTheme || PdfTheme.Dark); + } + + init() { this.backgroundColor = this.themeMap[this.theme].background; this.fontColor = this.themeMap[this.theme].font; // TODO: Move this to an observable or something diff --git a/UI/Web/src/app/series-detail/_components/series-detail/series-detail.component.ts b/UI/Web/src/app/series-detail/_components/series-detail/series-detail.component.ts index 6353664f3..5992df828 100644 --- a/UI/Web/src/app/series-detail/_components/series-detail/series-detail.component.ts +++ b/UI/Web/src/app/series-detail/_components/series-detail/series-detail.component.ts @@ -110,6 +110,7 @@ import {LicenseService} from "../../../_services/license.service"; import {PageBookmark} from "../../../_models/readers/page-bookmark"; import {VolumeRemovedEvent} from "../../../_models/events/volume-removed-event"; import {ReviewsComponent} from "../../../_single-module/reviews/reviews.component"; +import {ReadingProfileService} from "../../../_services/reading-profile.service"; enum TabID { @@ -175,6 +176,7 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked { private readonly cdRef = inject(ChangeDetectorRef); private readonly scrollService = inject(ScrollService); private readonly translocoService = inject(TranslocoService); + private readonly readingProfileService = inject(ReadingProfileService); protected readonly bulkSelectionService = inject(BulkSelectionService); protected readonly utilityService = inject(UtilityService); protected readonly imageService = inject(ImageService); @@ -609,6 +611,14 @@ export class SeriesDetailComponent implements OnInit, AfterContentChecked { this.actionService.sendToDevice(chapterIds, device); break; } + case Action.SetReadingProfile: + this.actionService.setReadingProfileForMultiple([this.series]); + break; + case Action.ClearReadingProfile: + this.readingProfileService.clearSeriesProfiles(this.seriesId).subscribe(() => { + this.toastr.success(this.translocoService.translate('actionable.cleared-profile')); + }); + break; default: break; } diff --git a/UI/Web/src/app/settings/_components/settings/settings.component.html b/UI/Web/src/app/settings/_components/settings/settings.component.html index 168c98a85..3e3d4f144 100644 --- a/UI/Web/src/app/settings/_components/settings/settings.component.html +++ b/UI/Web/src/app/settings/_components/settings/settings.component.html @@ -217,6 +217,15 @@
} } + + @defer (when fragment === SettingsTabId.ReadingProfiles; prefetch on idle) { + @if (fragment === SettingsTabId.ReadingProfiles) { +
+ +
+ } + } + }
diff --git a/UI/Web/src/app/settings/_components/settings/settings.component.ts b/UI/Web/src/app/settings/_components/settings/settings.component.ts index 84b1bfe0a..d470972d0 100644 --- a/UI/Web/src/app/settings/_components/settings/settings.component.ts +++ b/UI/Web/src/app/settings/_components/settings/settings.component.ts @@ -52,43 +52,47 @@ import {ScrobblingHoldsComponent} from "../../../user-settings/user-holds/scrobb import { ManageMetadataSettingsComponent } from "../../../admin/manage-metadata-settings/manage-metadata-settings.component"; +import { + ManageReadingProfilesComponent +} from "../../../user-settings/manage-reading-profiles/manage-reading-profiles.component"; @Component({ selector: 'app-settings', - imports: [ - ChangeAgeRestrictionComponent, - ChangeEmailComponent, - ChangePasswordComponent, - ManageDevicesComponent, - ManageOpdsComponent, - ManageScrobblingProvidersComponent, - ManageUserPreferencesComponent, - SideNavCompanionBarComponent, - ThemeManagerComponent, - TranslocoDirective, - UserStatsComponent, - AsyncPipe, - LicenseComponent, - ManageEmailSettingsComponent, - ManageLibraryComponent, - ManageMediaSettingsComponent, - ManageSettingsComponent, - ManageSystemComponent, - ManageTasksSettingsComponent, - ManageUsersComponent, - ServerStatsComponent, - SettingFragmentPipe, - ManageScrobblingComponent, - ManageMediaIssuesComponent, - ManageCustomizationComponent, - ImportMalCollectionComponent, - ImportCblComponent, - ManageMatchedMetadataComponent, - ManageUserTokensComponent, - EmailHistoryComponent, - ScrobblingHoldsComponent, - ManageMetadataSettingsComponent - ], + imports: [ + ChangeAgeRestrictionComponent, + ChangeEmailComponent, + ChangePasswordComponent, + ManageDevicesComponent, + ManageOpdsComponent, + ManageScrobblingProvidersComponent, + ManageUserPreferencesComponent, + SideNavCompanionBarComponent, + ThemeManagerComponent, + TranslocoDirective, + UserStatsComponent, + AsyncPipe, + LicenseComponent, + ManageEmailSettingsComponent, + ManageLibraryComponent, + ManageMediaSettingsComponent, + ManageSettingsComponent, + ManageSystemComponent, + ManageTasksSettingsComponent, + ManageUsersComponent, + ServerStatsComponent, + SettingFragmentPipe, + ManageScrobblingComponent, + ManageMediaIssuesComponent, + ManageCustomizationComponent, + ImportMalCollectionComponent, + ImportCblComponent, + ManageMatchedMetadataComponent, + ManageUserTokensComponent, + EmailHistoryComponent, + ScrobblingHoldsComponent, + ManageMetadataSettingsComponent, + ManageReadingProfilesComponent + ], templateUrl: './settings.component.html', styleUrl: './settings.component.scss', changeDetection: ChangeDetectionStrategy.OnPush diff --git a/UI/Web/src/app/sidenav/_components/side-nav/side-nav.component.ts b/UI/Web/src/app/sidenav/_components/side-nav/side-nav.component.ts index 547da378e..617db2500 100644 --- a/UI/Web/src/app/sidenav/_components/side-nav/side-nav.component.ts +++ b/UI/Web/src/app/sidenav/_components/side-nav/side-nav.component.ts @@ -16,7 +16,7 @@ import {AsyncPipe, NgClass} from "@angular/common"; import {SideNavItemComponent} from "../side-nav-item/side-nav-item.component"; import {FilterPipe} from "../../../_pipes/filter.pipe"; import {FormsModule} from "@angular/forms"; -import {translate, TranslocoDirective} from "@jsverse/transloco"; +import {translate, TranslocoDirective, TranslocoService} from "@jsverse/transloco"; import {CardActionablesComponent} from "../../../_single-module/card-actionables/card-actionables.component"; import {SideNavStream} from "../../../_models/sidenav/sidenav-stream"; import {SideNavStreamType} from "../../../_models/sidenav/sidenav-stream-type.enum"; @@ -25,6 +25,7 @@ import {SettingsTabId} from "../../preference-nav/preference-nav.component"; import {LicenseService} from "../../../_services/license.service"; import {CdkDrag, CdkDragDrop, CdkDropList} from "@angular/cdk/drag-drop"; import {ToastrService} from "ngx-toastr"; +import {ReadingProfileService} from "../../../_services/reading-profile.service"; @Component({ selector: 'app-side-nav', @@ -53,7 +54,9 @@ export class SideNavComponent implements OnInit { protected readonly licenseService = inject(LicenseService); private readonly destroyRef = inject(DestroyRef); private readonly actionFactoryService = inject(ActionFactoryService); - private readonly toastr = inject(ToastrService) + private readonly toastr = inject(ToastrService); + private readonly readingProfilesService = inject(ReadingProfileService); + private readonly translocoService = inject(TranslocoService); cachedData: SideNavStream[] | null = null; @@ -175,6 +178,14 @@ export class SideNavComponent implements OnInit { case (Action.Edit): this.actionService.editLibrary(lib, () => window.scrollTo(0, 0)); break; + case (Action.SetReadingProfile): + this.actionService.setReadingProfileForLibrary(lib); + break; + case (Action.ClearReadingProfile): + this.readingProfilesService.clearLibraryProfiles(lib.id).subscribe(() => { + this.toastr.success(this.translocoService.translate('actionable.cleared-profile')); + }); + break; default: break; } diff --git a/UI/Web/src/app/sidenav/preference-nav/preference-nav.component.ts b/UI/Web/src/app/sidenav/preference-nav/preference-nav.component.ts index 6574fe945..98ba48968 100644 --- a/UI/Web/src/app/sidenav/preference-nav/preference-nav.component.ts +++ b/UI/Web/src/app/sidenav/preference-nav/preference-nav.component.ts @@ -41,6 +41,7 @@ export enum SettingsTabId { // Non-Admin Account = 'account', Preferences = 'preferences', + ReadingProfiles = 'reading-profiles', Clients = 'clients', Theme = 'theme', Devices = 'devices', @@ -111,6 +112,7 @@ export class PreferenceNavComponent implements AfterViewInit { children: [ new SideNavItem(SettingsTabId.Account, []), new SideNavItem(SettingsTabId.Preferences), + new SideNavItem(SettingsTabId.ReadingProfiles), new SideNavItem(SettingsTabId.Customize, [], undefined, [Role.ReadOnly]), new SideNavItem(SettingsTabId.Clients), new SideNavItem(SettingsTabId.Theme), diff --git a/UI/Web/src/app/user-settings/manage-reading-profiles/manage-reading-profiles.component.html b/UI/Web/src/app/user-settings/manage-reading-profiles/manage-reading-profiles.component.html new file mode 100644 index 000000000..7acbe9196 --- /dev/null +++ b/UI/Web/src/app/user-settings/manage-reading-profiles/manage-reading-profiles.component.html @@ -0,0 +1,509 @@ + + + + + @if (!loading) { +
+ +
+ +

{{t('description')}}

+

{{t('extra-tip')}}

+ + +
+ +
+
+ + @if (readingProfiles.length < virtualScrollerBreakPoint) { + @for (readingProfile of readingProfiles; track readingProfile.id) { + + } + } @else { + + @for (readingProfile of scroll.viewPortItems; track readingProfile.id) { + + } + + } +
+
+ +
+
+ @if (selectedProfile === null) { +

{{t('no-selected')}}

+

{{t('selection-tip')}}

+ } + + @if (readingProfileForm !== null && selectedProfile !== null) { + +
+ +
+ + + {{readingProfileForm.get('name')!.value}} + + + + + + + @if (selectedProfile.id !== 0) { +
+ +
+ } + +
+ + +
+ +
+ } +
+
+ + + +
+ + + + +
+ +
{{profile.name | sentenceCase}}
+ + @if (profile.kind === ReadingProfileKind.Default) { + {{t('default-profile')}} + } +
+
+ } + +
diff --git a/UI/Web/src/app/user-settings/manage-reading-profiles/manage-reading-profiles.component.scss b/UI/Web/src/app/user-settings/manage-reading-profiles/manage-reading-profiles.component.scss new file mode 100644 index 000000000..13f341a32 --- /dev/null +++ b/UI/Web/src/app/user-settings/manage-reading-profiles/manage-reading-profiles.component.scss @@ -0,0 +1,38 @@ +@use '../../../series-detail-common'; + + + +.group-item { + background-color: transparent; + + &:hover { + background-color: var(--card-bg-color); + border-radius: 5px; + cursor: pointer; + } + + &:active, &.active { + background-color: var(--card-bg-color); + border-radius: 5px; + } +} + +.pill { + font-size: .8rem; + background-color: var(--card-bg-color); + border-radius: 0.375rem; + color: var(--badge-text-color); + + &.active { + background-color : var(--primary-color); + } +} + +.custom-position { + right: 15px; + top: -42px; +} + +a:hover { + cursor: pointer; +} diff --git a/UI/Web/src/app/user-settings/manage-reading-profiles/manage-reading-profiles.component.ts b/UI/Web/src/app/user-settings/manage-reading-profiles/manage-reading-profiles.component.ts new file mode 100644 index 000000000..2bc4ece7d --- /dev/null +++ b/UI/Web/src/app/user-settings/manage-reading-profiles/manage-reading-profiles.component.ts @@ -0,0 +1,319 @@ +import {ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, OnInit} from '@angular/core'; +import {ReadingProfileService} from "../../_services/reading-profile.service"; +import { + bookLayoutModes, + bookWritingStyles, + layoutModes, + pageSplitOptions, + pdfScrollModes, + pdfSpreadModes, + pdfThemes, + readingDirections, + readingModes, + ReadingProfile, + ReadingProfileKind, + scalingOptions +} from "../../_models/preferences/reading-profiles"; +import {translate, TranslocoDirective, TranslocoService} from "@jsverse/transloco"; +import {NgStyle, NgTemplateOutlet, TitleCasePipe} from "@angular/common"; +import {VirtualScrollerModule} from "@iharbeck/ngx-virtual-scroller"; +import {User} from "../../_models/user"; +import {AccountService} from "../../_services/account.service"; +import {debounceTime, distinctUntilChanged, take, tap} from "rxjs/operators"; +import {SentenceCasePipe} from "../../_pipes/sentence-case.pipe"; +import {FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators} from "@angular/forms"; +import {BookService} from "../../book-reader/_services/book.service"; +import {BookPageLayoutMode} from "../../_models/readers/book-page-layout-mode"; +import {PdfTheme} from "../../_models/preferences/pdf-theme"; +import {PdfScrollMode} from "../../_models/preferences/pdf-scroll-mode"; +import {PdfSpreadMode} from "../../_models/preferences/pdf-spread-mode"; +import {bookColorThemes} from "../../book-reader/_components/reader-settings/reader-settings.component"; +import {BookPageLayoutModePipe} from "../../_pipes/book-page-layout-mode.pipe"; +import {LayoutModePipe} from "../../_pipes/layout-mode.pipe"; +import {PageSplitOptionPipe} from "../../_pipes/page-split-option.pipe"; +import {PdfScrollModePipe} from "../../_pipes/pdf-scroll-mode.pipe"; +import {PdfSpreadModePipe} from "../../_pipes/pdf-spread-mode.pipe"; +import {PdfThemePipe} from "../../_pipes/pdf-theme.pipe"; +import {ReaderModePipe} from "../../_pipes/reading-mode.pipe"; +import {ReadingDirectionPipe} from "../../_pipes/reading-direction.pipe"; +import {ScalingOptionPipe} from "../../_pipes/scaling-option.pipe"; +import {SettingItemComponent} from "../../settings/_components/setting-item/setting-item.component"; +import {SettingSwitchComponent} from "../../settings/_components/setting-switch/setting-switch.component"; +import {WritingStylePipe} from "../../_pipes/writing-style.pipe"; +import {ColorPickerDirective} from "ngx-color-picker"; +import {NgbNav, NgbNavContent, NgbNavItem, NgbNavLinkBase, NgbNavOutlet, NgbTooltip} from "@ng-bootstrap/ng-bootstrap"; +import {filter} from "rxjs"; +import {takeUntilDestroyed} from "@angular/core/rxjs-interop"; +import {LoadingComponent} from "../../shared/loading/loading.component"; +import {ToastrService} from "ngx-toastr"; +import {ConfirmService} from "../../shared/confirm.service"; + +enum TabId { + ImageReader = "image-reader", + BookReader = "book-reader", + PdfReader = "pdf-reader", +} + +@Component({ + selector: 'app-manage-reading-profiles', + imports: [ + TranslocoDirective, + NgTemplateOutlet, + VirtualScrollerModule, + SentenceCasePipe, + BookPageLayoutModePipe, + FormsModule, + LayoutModePipe, + PageSplitOptionPipe, + PdfScrollModePipe, + PdfSpreadModePipe, + PdfThemePipe, + ReactiveFormsModule, + ReaderModePipe, + ReadingDirectionPipe, + ScalingOptionPipe, + SettingItemComponent, + SettingSwitchComponent, + TitleCasePipe, + WritingStylePipe, + NgStyle, + ColorPickerDirective, + NgbNav, + NgbNavItem, + NgbNavLinkBase, + NgbNavContent, + NgbNavOutlet, + LoadingComponent, + NgbTooltip, + ], + templateUrl: './manage-reading-profiles.component.html', + styleUrl: './manage-reading-profiles.component.scss', + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class ManageReadingProfilesComponent implements OnInit { + + virtualScrollerBreakPoint = 20; + + fontFamilies: Array = []; + readingProfiles: ReadingProfile[] = []; + user!: User; + activeTabId = TabId.ImageReader; + loading = true; + + selectedProfile: ReadingProfile | null = null; + readingProfileForm: FormGroup | null = null; + bookColorThemesTranslated = bookColorThemes.map(o => { + const d = {...o}; + d.name = translate('theme.' + d.translationKey); + return d; + }); + + constructor( + private readingProfileService: ReadingProfileService, + private cdRef: ChangeDetectorRef, + private accountService: AccountService, + private bookService: BookService, + private destroyRef: DestroyRef, + private toastr: ToastrService, + private confirmService: ConfirmService, + private transLoco: TranslocoService, + ) { + this.fontFamilies = this.bookService.getFontFamilies().map(f => f.title); + this.cdRef.markForCheck(); + } + + ngOnInit(): void { + this.accountService.currentUser$.pipe(take(1)).subscribe(user => { + if (user) { + this.user = user; + } + }); + + this.readingProfileService.getAllProfiles().subscribe(profiles => { + this.readingProfiles = profiles; + this.loading = false; + this.setupForm(); + + const defaultProfile = this.readingProfiles.find(rp => rp.kind === ReadingProfileKind.Default); + this.selectProfile(defaultProfile); + + this.cdRef.markForCheck(); + }); + + } + + async delete(readingProfile: ReadingProfile) { + if (!await this.confirmService.confirm(this.transLoco.translate("manage-reading-profiles.confirm", {name: readingProfile.name}))) { + return; + } + + + this.readingProfileService.delete(readingProfile.id).subscribe(() => { + this.selectProfile(undefined); + this.readingProfiles = this.readingProfiles.filter(o => o.id !== readingProfile.id); + this.cdRef.markForCheck(); + }); + } + + get widthOverrideLabel() { + const rawVal = this.readingProfileForm?.get('widthOverride')!.value; + if (!rawVal) { + return translate('reader-settings.off'); + } + + const val = parseInt(rawVal); + return (val <= 0) ? '' : val + '%' + } + + setupForm() { + if (this.selectedProfile == null) { + return; + } + + + this.readingProfileForm = new FormGroup({}) + + if (this.fontFamilies.indexOf(this.selectedProfile.bookReaderFontFamily) < 0) { + this.selectedProfile.bookReaderFontFamily = 'default'; + } + + this.readingProfileForm.addControl('name', new FormControl(this.selectedProfile.name, Validators.required)); + + + // Image reader + this.readingProfileForm.addControl('readingDirection', new FormControl(this.selectedProfile.readingDirection, [])); + this.readingProfileForm.addControl('scalingOption', new FormControl(this.selectedProfile.scalingOption, [])); + this.readingProfileForm.addControl('pageSplitOption', new FormControl(this.selectedProfile.pageSplitOption, [])); + this.readingProfileForm.addControl('autoCloseMenu', new FormControl(this.selectedProfile.autoCloseMenu, [])); + this.readingProfileForm.addControl('showScreenHints', new FormControl(this.selectedProfile.showScreenHints, [])); + this.readingProfileForm.addControl('readerMode', new FormControl(this.selectedProfile.readerMode, [])); + this.readingProfileForm.addControl('layoutMode', new FormControl(this.selectedProfile.layoutMode, [])); + this.readingProfileForm.addControl('emulateBook', new FormControl(this.selectedProfile.emulateBook, [])); + this.readingProfileForm.addControl('swipeToPaginate', new FormControl(this.selectedProfile.swipeToPaginate, [])); + this.readingProfileForm.addControl('backgroundColor', new FormControl(this.selectedProfile.backgroundColor, [])); + this.readingProfileForm.addControl('allowAutomaticWebtoonReaderDetection', new FormControl(this.selectedProfile.allowAutomaticWebtoonReaderDetection, [])); + this.readingProfileForm.addControl('widthOverride', new FormControl(this.selectedProfile.widthOverride, [Validators.min(0), Validators.max(100)])); + + // Epub reader + this.readingProfileForm.addControl('bookReaderFontFamily', new FormControl(this.selectedProfile.bookReaderFontFamily, [])); + this.readingProfileForm.addControl('bookReaderFontSize', new FormControl(this.selectedProfile.bookReaderFontSize, [])); + this.readingProfileForm.addControl('bookReaderLineSpacing', new FormControl(this.selectedProfile.bookReaderLineSpacing, [])); + this.readingProfileForm.addControl('bookReaderMargin', new FormControl(this.selectedProfile.bookReaderMargin, [])); + this.readingProfileForm.addControl('bookReaderReadingDirection', new FormControl(this.selectedProfile.bookReaderReadingDirection, [])); + this.readingProfileForm.addControl('bookReaderWritingStyle', new FormControl(this.selectedProfile.bookReaderWritingStyle, [])) + this.readingProfileForm.addControl('bookReaderTapToPaginate', new FormControl(this.selectedProfile.bookReaderTapToPaginate, [])); + this.readingProfileForm.addControl('bookReaderLayoutMode', new FormControl(this.selectedProfile.bookReaderLayoutMode || BookPageLayoutMode.Default, [])); + this.readingProfileForm.addControl('bookReaderThemeName', new FormControl(this.selectedProfile.bookReaderThemeName || bookColorThemes[0].name, [])); + this.readingProfileForm.addControl('bookReaderImmersiveMode', new FormControl(this.selectedProfile.bookReaderImmersiveMode, [])); + + // Pdf reader + this.readingProfileForm.addControl('pdfTheme', new FormControl(this.selectedProfile.pdfTheme || PdfTheme.Dark, [])); + this.readingProfileForm.addControl('pdfScrollMode', new FormControl(this.selectedProfile.pdfScrollMode || PdfScrollMode.Vertical, [])); + this.readingProfileForm.addControl('pdfSpreadMode', new FormControl(this.selectedProfile.pdfSpreadMode || PdfSpreadMode.None, [])); + + // Auto save + this.readingProfileForm.valueChanges.pipe( + debounceTime(500), + distinctUntilChanged(), + filter(_ => this.readingProfileForm!.valid), + takeUntilDestroyed(this.destroyRef), + tap(_ => this.autoSave()), + ).subscribe(); + } + + private autoSave() { + if (this.selectedProfile!.id == 0) { + this.readingProfileService.createProfile(this.packData()).subscribe({ + next: createdProfile => { + this.selectedProfile = createdProfile; + this.readingProfiles.push(createdProfile); + this.cdRef.markForCheck(); + }, + error: err => { + console.log(err); + this.toastr.error(err.message); + } + }) + } else { + const profile = this.packData(); + this.readingProfileService.updateProfile(profile).subscribe({ + next: _ => { + this.readingProfiles = this.readingProfiles.map(p => { + if (p.id !== profile.id) return p; + return profile; + }); + this.cdRef.markForCheck(); + }, + error: err => { + console.log(err); + this.toastr.error(err.message); + } + }) + } + } + + private packData(): ReadingProfile { + const data: ReadingProfile = this.readingProfileForm!.getRawValue(); + data.id = this.selectedProfile!.id; + data.readingDirection = parseInt(data.readingDirection as unknown as string); + data.scalingOption = parseInt(data.scalingOption as unknown as string); + data.pageSplitOption = parseInt(data.pageSplitOption as unknown as string); + data.readerMode = parseInt(data.readerMode as unknown as string); + data.layoutMode = parseInt(data.layoutMode as unknown as string); + + data.bookReaderReadingDirection = parseInt(data.bookReaderReadingDirection as unknown as string); + data.bookReaderWritingStyle = parseInt(data.bookReaderWritingStyle as unknown as string); + data.bookReaderLayoutMode = parseInt(data.bookReaderLayoutMode as unknown as string); + + data.pdfTheme = parseInt(data.pdfTheme as unknown as string); + data.pdfScrollMode = parseInt(data.pdfScrollMode as unknown as string); + data.pdfSpreadMode = parseInt(data.pdfSpreadMode as unknown as string); + + return data; + } + + handleBackgroundColorChange(color: string) { + if (!this.readingProfileForm || !this.selectedProfile) return; + + this.readingProfileForm.markAsDirty(); + this.readingProfileForm.markAsTouched(); + this.selectedProfile.backgroundColor = color; + this.readingProfileForm.get('backgroundColor')?.setValue(color); + this.cdRef.markForCheck(); + } + + selectProfile(profile: ReadingProfile | undefined | null) { + if (profile === undefined) { + this.selectedProfile = null; + this.cdRef.markForCheck(); + return; + } + + this.selectedProfile = profile; + this.setupForm(); + this.cdRef.markForCheck(); + } + + addNew() { + const defaultProfile = this.readingProfiles.find(f => f.kind === ReadingProfileKind.Default); + this.selectedProfile = {...defaultProfile!}; + this.selectedProfile.kind = ReadingProfileKind.User; + this.selectedProfile.id = 0; + this.selectedProfile.name = "New Profile #" + (this.readingProfiles.length + 1); + this.setupForm(); + this.cdRef.markForCheck(); + } + + protected readonly readingDirections = readingDirections; + protected readonly pdfSpreadModes = pdfSpreadModes; + protected readonly pageSplitOptions = pageSplitOptions; + protected readonly bookLayoutModes = bookLayoutModes; + protected readonly pdfThemes = pdfThemes; + protected readonly scalingOptions = scalingOptions; + protected readonly layoutModes = layoutModes; + protected readonly readerModes = readingModes; + protected readonly bookWritingStyles = bookWritingStyles; + protected readonly pdfScrollModes = pdfScrollModes; + protected readonly TabId = TabId; + protected readonly ReadingProfileKind = ReadingProfileKind; +} diff --git a/UI/Web/src/app/user-settings/manga-user-preferences/manage-user-preferences.component.html b/UI/Web/src/app/user-settings/manga-user-preferences/manage-user-preferences.component.html index 05cf7572e..d808ebd2d 100644 --- a/UI/Web/src/app/user-settings/manga-user-preferences/manage-user-preferences.component.html +++ b/UI/Web/src/app/user-settings/manga-user-preferences/manage-user-preferences.component.html @@ -115,383 +115,7 @@ }
-
} - - -

{{t('image-reader-settings-title')}}

- -
- - - {{settingsForm.get('readingDirection')!.value | readingDirection}} - - - - - -
- -
- - - {{settingsForm.get('scalingOption')!.value | scalingOption}} - - - - - -
- -
- - - {{settingsForm.get('pageSplitOption')!.value | pageSplitOption}} - - - - - -
- -
- - - {{settingsForm.get('readerMode')!.value | readerMode}} - - - - - -
- -
- - - {{settingsForm.get('layoutMode')!.value | layoutMode}} - - - - - -
- -
- - -
-
- {{ user.preferences!.backgroundColor.toUpperCase() }} -
-
- - - -
-
- -
- - -
- -
-
-
-
- -
- - -
- -
-
-
-
- -
- - -
- -
-
-
-
- -
- - -
- -
-
-
-
- -
- - -
- -
-
-
-
-
- -
- -

{{t('book-reader-settings-title')}}

- -
- - -
- -
-
-
-
- -
- - -
- -
-
-
-
- -
- - - {{settingsForm.get('bookReaderReadingDirection')!.value | readingDirection}} - - - - - -
- -
- - - {{settingsForm.get('bookReaderFontFamily')!.value | titlecase}} - - - - - -
- -
- - - {{settingsForm.get('bookReaderWritingStyle')!.value | writingStyle}} - - - - - -
- -
- - - {{settingsForm.get('bookReaderLayoutMode')!.value | bookPageLayoutMode}} - - - - - -
- -
- - - {{settingsForm.get('bookReaderThemeName')!.value}} - - - - - -
- -
- - - {{settingsForm.get('bookReaderFontSize')?.value + '%'}} - - -
-
- - -
- {{settingsForm.get('bookReaderFontSize')?.value + '%'}} -
-
-
-
- -
- - - {{settingsForm.get('bookReaderLineSpacing')?.value + '%'}} - - -
-
- -
- {{settingsForm.get('bookReaderLineSpacing')?.value + '%'}} -
-
-
-
- -
- - - {{settingsForm.get('bookReaderMargin')?.value + '%'}} - - -
-
- -
- {{settingsForm.get('bookReaderMargin')?.value + '%'}} -
-
-
-
-
- -
- -

{{t('pdf-reader-settings-title')}}

- -
- - - {{settingsForm.get('pdfSpreadMode')!.value | pdfSpreadMode}} - - - - - -
- -
- - - {{settingsForm.get('pdfTheme')!.value | pdfTheme}} - - - - - -
- -
- - - {{settingsForm.get('pdfScrollMode')!.value | pdfScrollMode}} - - - - - -
-
} diff --git a/UI/Web/src/app/user-settings/manga-user-preferences/manage-user-preferences.component.ts b/UI/Web/src/app/user-settings/manga-user-preferences/manage-user-preferences.component.ts index e91208a5e..15ed323c8 100644 --- a/UI/Web/src/app/user-settings/manga-user-preferences/manage-user-preferences.component.ts +++ b/UI/Web/src/app/user-settings/manga-user-preferences/manage-user-preferences.component.ts @@ -1,17 +1,7 @@ import {ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, inject, OnInit} from '@angular/core'; import {translate, TranslocoDirective} from "@jsverse/transloco"; import { - bookLayoutModes, - bookWritingStyles, - layoutModes, - pageSplitOptions, - pdfScrollModes, - pdfSpreadModes, - pdfThemes, - Preferences, - readingDirections, - readingModes, - scalingOptions + Preferences } from "../../_models/preferences/preferences"; import {AccountService} from "../../_services/account.service"; import {BookService} from "../../book-reader/_services/book.service"; @@ -44,6 +34,13 @@ import {PdfThemePipe} from "../../_pipes/pdf-theme.pipe"; import {PdfScrollModePipe} from "../../_pipes/pdf-scroll-mode.pipe"; import {LicenseService} from "../../_services/license.service"; import {ColorPickerDirective} from "ngx-color-picker"; +import { + bookLayoutModes, bookWritingStyles, + layoutModes, pageSplitOptions, + pdfScrollModes, + pdfSpreadModes, + pdfThemes, readingDirections, readingModes, scalingOptions +} from "../../_models/preferences/reading-profiles"; @Component({ selector: 'app-manga-user-preferences', @@ -83,23 +80,6 @@ export class ManageUserPreferencesComponent implements OnInit { private readonly localizationService = inject(LocalizationService); protected readonly licenseService = inject(LicenseService); - protected readonly readingDirections = readingDirections; - protected readonly scalingOptions = scalingOptions; - protected readonly pageSplitOptions = pageSplitOptions; - protected readonly readerModes = readingModes; - protected readonly layoutModes = layoutModes; - protected readonly bookWritingStyles = bookWritingStyles; - protected readonly bookLayoutModes = bookLayoutModes; - protected readonly pdfSpreadModes = pdfSpreadModes; - protected readonly pdfThemes = pdfThemes; - protected readonly pdfScrollModes = pdfScrollModes; - - bookColorThemesTranslated = bookColorThemes.map(o => { - const d = {...o}; - d.name = translate('theme.' + d.translationKey); - return d; - }); - fontFamilies: Array = []; locales: Array = []; @@ -145,37 +125,6 @@ export class ManageUserPreferencesComponent implements OnInit { this.user = results.user; this.user.preferences = results.pref; - if (this.fontFamilies.indexOf(this.user.preferences.bookReaderFontFamily) < 0) { - this.user.preferences.bookReaderFontFamily = 'default'; - } - - this.settingsForm.addControl('readingDirection', new FormControl(this.user.preferences.readingDirection, [])); - this.settingsForm.addControl('scalingOption', new FormControl(this.user.preferences.scalingOption, [])); - this.settingsForm.addControl('pageSplitOption', new FormControl(this.user.preferences.pageSplitOption, [])); - this.settingsForm.addControl('autoCloseMenu', new FormControl(this.user.preferences.autoCloseMenu, [])); - this.settingsForm.addControl('showScreenHints', new FormControl(this.user.preferences.showScreenHints, [])); - this.settingsForm.addControl('readerMode', new FormControl(this.user.preferences.readerMode, [])); - this.settingsForm.addControl('layoutMode', new FormControl(this.user.preferences.layoutMode, [])); - this.settingsForm.addControl('emulateBook', new FormControl(this.user.preferences.emulateBook, [])); - this.settingsForm.addControl('swipeToPaginate', new FormControl(this.user.preferences.swipeToPaginate, [])); - this.settingsForm.addControl('backgroundColor', new FormControl(this.user.preferences.backgroundColor, [])); - this.settingsForm.addControl('allowAutomaticWebtoonReaderDetection', new FormControl(this.user.preferences.allowAutomaticWebtoonReaderDetection, [])); - - this.settingsForm.addControl('bookReaderFontFamily', new FormControl(this.user.preferences.bookReaderFontFamily, [])); - this.settingsForm.addControl('bookReaderFontSize', new FormControl(this.user.preferences.bookReaderFontSize, [])); - this.settingsForm.addControl('bookReaderLineSpacing', new FormControl(this.user.preferences.bookReaderLineSpacing, [])); - this.settingsForm.addControl('bookReaderMargin', new FormControl(this.user.preferences.bookReaderMargin, [])); - this.settingsForm.addControl('bookReaderReadingDirection', new FormControl(this.user.preferences.bookReaderReadingDirection, [])); - this.settingsForm.addControl('bookReaderWritingStyle', new FormControl(this.user.preferences.bookReaderWritingStyle, [])) - this.settingsForm.addControl('bookReaderTapToPaginate', new FormControl(this.user.preferences.bookReaderTapToPaginate, [])); - this.settingsForm.addControl('bookReaderLayoutMode', new FormControl(this.user.preferences.bookReaderLayoutMode || BookPageLayoutMode.Default, [])); - this.settingsForm.addControl('bookReaderThemeName', new FormControl(this.user?.preferences.bookReaderThemeName || bookColorThemes[0].name, [])); - this.settingsForm.addControl('bookReaderImmersiveMode', new FormControl(this.user?.preferences.bookReaderImmersiveMode, [])); - - this.settingsForm.addControl('pdfTheme', new FormControl(this.user?.preferences.pdfTheme || PdfTheme.Dark, [])); - this.settingsForm.addControl('pdfScrollMode', new FormControl(this.user?.preferences.pdfScrollMode || PdfScrollMode.Vertical, [])); - this.settingsForm.addControl('pdfSpreadMode', new FormControl(this.user?.preferences.pdfSpreadMode || PdfSpreadMode.None, [])); - this.settingsForm.addControl('theme', new FormControl(this.user.preferences.theme, [])); this.settingsForm.addControl('globalPageLayoutMode', new FormControl(this.user.preferences.globalPageLayoutMode, [])); this.settingsForm.addControl('blurUnreadSummaries', new FormControl(this.user.preferences.blurUnreadSummaries, [])); @@ -222,7 +171,7 @@ export class ManageUserPreferencesComponent implements OnInit { reset() { if (!this.user) return; - this.settingsForm.get('readingDirection')?.setValue(this.user.preferences.readingDirection, {onlySelf: true, emitEvent: false}); + /*this.settingsForm.get('readingDirection')?.setValue(this.user.preferences.readingDirection, {onlySelf: true, emitEvent: false}); this.settingsForm.get('scalingOption')?.setValue(this.user.preferences.scalingOption, {onlySelf: true, emitEvent: false}); this.settingsForm.get('pageSplitOption')?.setValue(this.user.preferences.pageSplitOption, {onlySelf: true, emitEvent: false}); this.settingsForm.get('autoCloseMenu')?.setValue(this.user.preferences.autoCloseMenu, {onlySelf: true, emitEvent: false}); @@ -247,7 +196,7 @@ export class ManageUserPreferencesComponent implements OnInit { this.settingsForm.get('pdfTheme')?.setValue(this.user?.preferences.pdfTheme || PdfTheme.Dark, {onlySelf: true, emitEvent: false}); this.settingsForm.get('pdfScrollMode')?.setValue(this.user?.preferences.pdfScrollMode || PdfScrollMode.Vertical, {onlySelf: true, emitEvent: false}); - this.settingsForm.get('pdfSpreadMode')?.setValue(this.user?.preferences.pdfSpreadMode || PdfSpreadMode.None, {onlySelf: true, emitEvent: false}); + this.settingsForm.get('pdfSpreadMode')?.setValue(this.user?.preferences.pdfSpreadMode || PdfSpreadMode.None, {onlySelf: true, emitEvent: false});*/ this.settingsForm.get('theme')?.setValue(this.user.preferences.theme, {onlySelf: true, emitEvent: false}); this.settingsForm.get('globalPageLayoutMode')?.setValue(this.user.preferences.globalPageLayoutMode, {onlySelf: true, emitEvent: false}); @@ -265,7 +214,7 @@ export class ManageUserPreferencesComponent implements OnInit { packSettings(): Preferences { const modelSettings = this.settingsForm.value; return { - readingDirection: parseInt(modelSettings.readingDirection, 10), + /*readingDirection: parseInt(modelSettings.readingDirection, 10), scalingOption: parseInt(modelSettings.scalingOption, 10), pageSplitOption: parseInt(modelSettings.pageSplitOption, 10), autoCloseMenu: modelSettings.autoCloseMenu, @@ -282,34 +231,23 @@ export class ManageUserPreferencesComponent implements OnInit { bookReaderReadingDirection: parseInt(modelSettings.bookReaderReadingDirection, 10), bookReaderWritingStyle: parseInt(modelSettings.bookReaderWritingStyle, 10), bookReaderLayoutMode: parseInt(modelSettings.bookReaderLayoutMode, 10), - bookReaderThemeName: modelSettings.bookReaderThemeName, + bookReaderThemeName: modelSettings.bookReaderThemeName,*/ theme: modelSettings.theme, - bookReaderImmersiveMode: modelSettings.bookReaderImmersiveMode, + //bookReaderImmersiveMode: modelSettings.bookReaderImmersiveMode, globalPageLayoutMode: parseInt(modelSettings.globalPageLayoutMode, 10), blurUnreadSummaries: modelSettings.blurUnreadSummaries, promptForDownloadSize: modelSettings.promptForDownloadSize, noTransitions: modelSettings.noTransitions, - emulateBook: modelSettings.emulateBook, - swipeToPaginate: modelSettings.swipeToPaginate, + //emulateBook: modelSettings.emulateBook, + //swipeToPaginate: modelSettings.swipeToPaginate, collapseSeriesRelationships: modelSettings.collapseSeriesRelationships, shareReviews: modelSettings.shareReviews, locale: modelSettings.locale || 'en', - pdfTheme: parseInt(modelSettings.pdfTheme, 10), - pdfScrollMode: parseInt(modelSettings.pdfScrollMode, 10), - pdfSpreadMode: parseInt(modelSettings.pdfSpreadMode, 10), + //pdfTheme: parseInt(modelSettings.pdfTheme, 10), + //pdfScrollMode: parseInt(modelSettings.pdfScrollMode, 10), + //pdfSpreadMode: parseInt(modelSettings.pdfSpreadMode, 10), aniListScrobblingEnabled: modelSettings.aniListScrobblingEnabled, - wantToReadSync: modelSettings.wantToReadSync + wantToReadSync: modelSettings.wantToReadSync, }; } - - handleBackgroundColorChange(color: string) { - this.settingsForm.markAsDirty(); - this.settingsForm.markAsTouched(); - if (this.user?.preferences) { - this.user.preferences.backgroundColor = color; - } - - this.settingsForm.get('backgroundColor')?.setValue(color); - this.cdRef.markForCheck(); - } } diff --git a/UI/Web/src/assets/langs/en.json b/UI/Web/src/assets/langs/en.json index 3c53c4b56..b9ab24ae5 100644 --- a/UI/Web/src/assets/langs/en.json +++ b/UI/Web/src/assets/langs/en.json @@ -106,7 +106,7 @@ "user-preferences": { "title": "User Dashboard", - "pref-description": "These are global settings that are bound to your account.", + "pref-description": "These are global settings that are bound to your account. Reader settings are located in Reading Profiles.", "account-tab": "{{tabs.account-tab}}", "preferences-tab": "{{tabs.preferences-tab}}", @@ -140,60 +140,6 @@ "want-to-read-sync-label": "Want To Read Sync", "want-to-read-sync-tooltip": "Allow Kavita to add items to your Want to Read list based on AniList and MAL series in Pending readlist", - "image-reader-settings-title": "Image Reader", - "reading-direction-label": "Reading Direction", - "reading-direction-tooltip": "Direction to click to move to next page. Right to Left means you click on left side of screen to move to next page.", - "scaling-option-label": "Scaling Options", - "scaling-option-tooltip": "How to scale the image to your screen.", - "page-splitting-label": "Page Splitting", - "page-splitting-tooltip": "How to split a full width image (ie both left and right images are combined)", - "reading-mode-label": "Reading Mode", - "reading-mode-tooltip": "Change reader to paginate vertically, horizontally, or have an infinite scroll", - "layout-mode-label": "Layout Mode", - "layout-mode-tooltip": "Render a single image to the screen or two side-by-side images", - "background-color-label": "Background Color", - "background-color-tooltip": "Background Color of Image Reader", - "auto-close-menu-label": "Auto Close Menu", - "auto-close-menu-tooltip": "Should menu auto close", - "show-screen-hints-label": "Show Screen Hints", - "show-screen-hints-tooltip": "Show an overlay to help understand pagination area and direction", - "emulate-comic-book-label": "Emulate comic book", - "emulate-comic-book-tooltip": "Applies a shadow effect to emulate reading from a book", - "swipe-to-paginate-label": "Swipe to Paginate", - "swipe-to-paginate-tooltip": "Should swiping on the screen cause the next or previous page to be triggered", - "allow-auto-webtoon-reader-label": "Automatic Webtoon Reader Mode", - "allow-auto-webtoon-reader-tooltip": "Switch into Webtoon Reader mode if pages look like a webtoon. Some false positives may occur.", - - "book-reader-settings-title": "Book Reader", - "tap-to-paginate-label": "Tap to Paginate", - "tap-to-paginate-tooltip": "Should the sides of the book reader screen allow tapping on it to move to prev/next page", - "immersive-mode-label": "Immersive Mode", - "immersive-mode-tooltip": "This will hide the menu behind a click on the reader document and turn tap to paginate on", - "reading-direction-book-label": "Reading Direction", - "reading-direction-book-tooltip": "Direction to click to move to next page. Right to Left means you click on left side of screen to move to next page.", - "font-family-label": "Font Family", - "font-family-tooltip": "Font family to load up. Default will load the book's default font", - "writing-style-label": "Writing Style", - "writing-style-tooltip": "Changes the direction of the text. Horizontal is left to right, vertical is top to bottom.", - "layout-mode-book-label": "Layout Mode", - "layout-mode-book-tooltip": "How content should be laid out. Scroll is as the book packs it. 1 or 2 Column fits to the height of the device and fits 1 or 2 columns of text per page", - "color-theme-book-label": "Color Theme", - "color-theme-book-tooltip": "What color theme to apply to the book reader content and menu", - "font-size-book-label": "Font Size", - "font-size-book-tooltip": "Percent of scaling to apply to font in the book", - "line-height-book-label": "Line Spacing", - "line-height-book-tooltip": "How much spacing between the lines of the book", - "margin-book-label": "Margin", - "margin-book-tooltip": "How much spacing on each side of the screen. This will override to 0 on mobile devices regardless of this setting.", - - "pdf-reader-settings-title": "PDF Reader", - "pdf-scroll-mode-label": "Scroll Mode", - "pdf-scroll-mode-tooltip": "How you scroll through pages. Vertical/Horizontal and Tap to Paginate (no scroll)", - "pdf-spread-mode-label": "Spread Mode", - "pdf-spread-mode-tooltip": "How pages should be laid out. Single or double (odd/even)", - "pdf-theme-label": "Theme", - "pdf-theme-tooltip": "Color theme of the reader", - "clients-opds-alert": "OPDS is not enabled on this server. This will not affect Tachiyomi users.", "clients-opds-description": "All 3rd Party clients will either use the API key or the Connection Url below. These are like passwords, keep it private.", "clients-api-key-tooltip": "The API key is like a password. Resetting it will invalidate any existing clients.", @@ -941,7 +887,7 @@ "series-detail": { "page-settings-title": "Page Settings", "close": "{{common.close}}", - "layout-mode-label": "{{user-preferences.layout-mode-book-label}}", + "layout-mode-label": "{{manage-reading-profiles.layout-mode-book-label}}", "layout-mode-option-card": "Card", "layout-mode-option-list": "List", "continue-from": "Continue {{title}}", @@ -1181,36 +1127,45 @@ "reader-settings": { "general-settings-title": "General Settings", - "font-family-label": "{{user-preferences.font-family-label}}", - "font-size-label": "{{user-preferences.font-size-book-label}}", - "line-spacing-label": "{{user-preferences.line-height-book-label}}", - "margin-label": "{{user-preferences.margin-book-label}}", + "font-family-label": "{{manage-reading-profiles.font-family-label}}", + "font-size-label": "{{manage-reading-profiles.font-size-book-label}}", + "line-spacing-label": "{{manage-reading-profiles.line-height-book-label}}", + "margin-label": "{{manage-reading-profiles.margin-book-label}}", "reset-to-defaults": "Reset to Defaults", + "update-parent": "Save to {{name}}", + "loading": "loading", + "create-new": "New profile from implicit", + "create-new-tooltip": "Create a new manageable profile from your current implicit one", + "reading-profile-updated": "Reading profile updated", + "reading-profile-promoted": "Reading profile promoted", "reader-settings-title": "Reader Settings", - "reading-direction-label": "{{user-preferences.reading-direction-book-label}}", + "reading-direction-label": "{{manage-reading-profiles.reading-direction-book-label}}", "right-to-left": "Right to Left", "left-to-right": "Left to Right", "horizontal": "Horizontal", "vertical": "Vertical", - "writing-style-label": "{{user-preferences.writing-style-label}}", + "writing-style-label": "{{manage-reading-profiles.writing-style-label}}", "writing-style-tooltip": "Changes the direction of the text. Horizontal is left to right, vertical is top to bottom.", "tap-to-paginate-label": "Tap Pagination", "tap-to-paginate-tooltip": "Click the edges of the screen to paginate", "on": "On", "off": "Off", - "immersive-mode-label": "{{user-preferences.immersive-mode-label}}", + "immersive-mode-label": "{{manage-reading-profiles.immersive-mode-label}}", "immersive-mode-tooltip": "This will hide the menu behind a click on the reader document and turn tap to paginate on", "fullscreen-label": "Fullscreen", "fullscreen-tooltip": "Put reader in fullscreen mode", "exit": "Exit", "enter": "Enter", - "layout-mode-label": "{{user-preferences.layout-mode-book-label}}", + "layout-mode-label": "{{manage-reading-profiles.layout-mode-book-label}}", "layout-mode-tooltip": "Scroll: Mirrors epub file (usually one long scrolling page per chapter).
1 Column: Creates a single virtual page at a time.
2 Column: Creates two virtual pages at a time laid out side-by-side.", "layout-mode-option-scroll": "Scroll", "layout-mode-option-1col": "1 Column", "layout-mode-option-2col": "2 Column", "color-theme-title": "Color Theme", + "line-spacing-min-label": "1x", + "line-spacing-max-label": "2.5x", + "theme-dark": "Dark", "theme-black": "Black", "theme-white": "White", @@ -1324,6 +1279,17 @@ "create": "{{common.create}}" }, + "bulk-set-reading-profile-modal": { + "title": "Set Reading profile", + "close": "{{common.close}}", + "filter-label": "{{common.filter}}", + "clear": "{{common.clear}}", + "no-data": "No collections created yet", + "loading": "{{common.loading}}", + "create": "{{common.create}}", + "bound": "Bound" + }, + "entity-title": { "special": "Special", "issue-num": "{{common.issue-hash-num}}", @@ -1720,6 +1686,7 @@ "scrobble-holds": "Scrobble Holds", "account": "Account", "preferences": "Preferences", + "reading-profiles": "Reading Profiles", "clients": "API Key / OPDS", "devices": "Devices", "user-stats": "Stats", @@ -1990,7 +1957,10 @@ "manga-reader": { "back": "Back", - "save-globally": "Save Globally", + "update-parent": "{{reader-settings.update-parent}}", + "loading": "{{reader-settings.loading}}", + "create-new": "{{reader-settings.create-new}}", + "create-new-tooltip": "{{reader-settings.create-new-tooltip}}", "incognito-alt": "Incognito mode is on. Toggle to turn off.", "incognito-title": "Incognito Mode:", "shortcuts-menu-alt": "Keyboard Shortcuts Modal", @@ -2012,9 +1982,9 @@ "height": "Height", "width": "Width", "width-override-label": "Width Override", - "off": "Off", + "off": "{{reader-settings.off}}", "original": "Original", - "auto-close-menu-label": "{{user-preferences.auto-close-menu-label}}", + "auto-close-menu-label": "{{manage-reading-profiles.auto-close-menu-label}}", "swipe-enabled-label": "Swipe Enabled", "enable-comic-book-label": "Emulate comic book", "brightness-label": "Brightness", @@ -2026,8 +1996,9 @@ "layout-mode-switched": "Layout mode switched to Single due to insufficient space to render double layout", "no-next-chapter": "No Next Chapter", "no-prev-chapter": "No Previous Chapter", - "user-preferences-updated": "User preferences updated", - "emulate-comic-book-label": "{{user-preferences.emulate-comic-book-label}}", + "reading-profile-updated": "Reading profile updated", + "reading-profile-promoted": "Reading profile promoted", + "emulate-comic-book-label": "{{manage-reading-profiles.emulate-comic-book-label}}", "series-progress": "Series Progress: {{percentage}}" }, @@ -2708,7 +2679,9 @@ "bulk-delete-libraries": "Are you sure you want to delete {{count}} libraries?", "match-success": "Series matched correctly", "webtoon-override": "Switching to Webtoon mode due to images representing a webtoon.", - "scrobble-gen-init": "Enqueued a job to generate scrobble events from past reading history and ratings, syncing them with connected services." + "scrobble-gen-init": "Enqueued a job to generate scrobble events from past reading history and ratings, syncing them with connected services.", + "series-bound-to-reading-profile": "Series bound to Reading Profile {{name}}", + "library-bound-to-reading-profile": "Library bound to Reading Profile {{name}}" }, "read-time-pipe": { @@ -2762,6 +2735,13 @@ "remove-from-on-deck": "Remove From On Deck", "remove-from-on-deck-tooltip": "Remove series from showing from On Deck", + "reading-profiles": "Reading Profiles", + "set-reading-profile": "Set Reading Profile", + "set-reading-profile-tooltip": "Bind a Reading Profile to this Library", + "clear-reading-profile": "Clear Reading Profile", + "clear-reading-profile-tooltip": "Clear Reading Profile for this Library", + "cleared-profile": "Cleared Reading Profile", + "others": "Others", "add-to-reading-list": "Add to Reading List", "add-to-reading-list-tooltip": "Add to a Reading List", @@ -2843,6 +2823,80 @@ "pdf-dark": "Dark" }, + "manage-reading-profiles": { + "description": "Not all your series may be read in the same way, set up distinct reading profiles per library or series to make getting back in your series as seamless as possible.", + "extra-tip": "Assign reading profiles via the action menu on series and libraries, or in bulk. When changing settings in a reader, a hidden profile is created that remembers your choices for that series (not for pdfs). This profile is removed when you assign or update one of your own reading profiles to the series.", + "profiles-title": "Your reading profiles", + "default-profile": "Default", + "add": "{{common.add}}", + "add-tooltip": "Your new profile will be saved after making a change to it", + "make-default": "Set as default", + "no-selected": "No profile selected", + "confirm": "Are you sure you want to delete the reading profile {{name}}?", + "selection-tip": "Select a profile from the list, or create a new one at the top right", + + "image-reader-settings-title": "Image Reader", + "reading-direction-label": "Reading Direction", + "reading-direction-tooltip": "Direction to click to move to next page. Right to Left means you click on left side of screen to move to next page.", + "scaling-option-label": "Scaling Options", + "scaling-option-tooltip": "How to scale the image to your screen.", + "page-splitting-label": "Page Splitting", + "page-splitting-tooltip": "How to split a full width image (ie both left and right images are combined)", + "reading-mode-label": "Reading Mode", + "reading-mode-tooltip": "Change reader to paginate vertically, horizontally, or have an infinite scroll", + "layout-mode-label": "Layout Mode", + "layout-mode-tooltip": "Render a single image to the screen or two side-by-side images", + "background-color-label": "Background Color", + "background-color-tooltip": "Background Color of Image Reader", + "auto-close-menu-label": "Auto Close Menu", + "auto-close-menu-tooltip": "Should menu auto close", + "show-screen-hints-label": "Show Screen Hints", + "show-screen-hints-tooltip": "Show an overlay to help understand pagination area and direction", + "emulate-comic-book-label": "Emulate comic book", + "emulate-comic-book-tooltip": "Applies a shadow effect to emulate reading from a book", + "swipe-to-paginate-label": "Swipe to Paginate", + "swipe-to-paginate-tooltip": "Should swiping on the screen cause the next or previous page to be triggered", + "allow-auto-webtoon-reader-label": "Automatic Webtoon Reader Mode", + "allow-auto-webtoon-reader-tooltip": "Switch into Webtoon Reader mode if pages look like a webtoon. Some false positives may occur.", + "width-override-label": "{{manga-reader.width-override-label}}", + "width-override-tooltip": "Override width of images in the reader", + "reset": "{{common.reset}}", + + "book-reader-settings-title": "Book Reader", + "tap-to-paginate-label": "Tap to Paginate", + "tap-to-paginate-tooltip": "Should the sides of the book reader screen allow tapping on it to move to prev/next page", + "immersive-mode-label": "Immersive Mode", + "immersive-mode-tooltip": "This will hide the menu behind a click on the reader document and turn tap to paginate on", + "reading-direction-book-label": "Reading Direction", + "reading-direction-book-tooltip": "Direction to click to move to next page. Right to Left means you click on left side of screen to move to next page.", + "font-family-label": "Font Family", + "font-family-tooltip": "Font family to load up. Default will load the book's default font", + "writing-style-label": "Writing Style", + "writing-style-tooltip": "Changes the direction of the text. Horizontal is left to right, vertical is top to bottom.", + "layout-mode-book-label": "Layout Mode", + "layout-mode-book-tooltip": "How content should be laid out. Scroll is as the book packs it. 1 or 2 Column fits to the height of the device and fits 1 or 2 columns of text per page", + "color-theme-book-label": "Color Theme", + "color-theme-book-tooltip": "What color theme to apply to the book reader content and menu", + "font-size-book-label": "Font Size", + "font-size-book-tooltip": "Percent of scaling to apply to font in the book", + "line-height-book-label": "Line Spacing", + "line-height-book-tooltip": "How much spacing between the lines of the book", + "margin-book-label": "Margin", + "margin-book-tooltip": "How much spacing on each side of the screen. This will override to 0 on mobile devices regardless of this setting.", + + "pdf-reader-settings-title": "PDF Reader", + "pdf-scroll-mode-label": "Scroll Mode", + "pdf-scroll-mode-tooltip": "How you scroll through pages. Vertical/Horizontal and Tap to Paginate (no scroll)", + "pdf-spread-mode-label": "Spread Mode", + "pdf-spread-mode-tooltip": "How pages should be laid out. Single or double (odd/even)", + "pdf-theme-label": "Theme", + "pdf-theme-tooltip": "Color theme of the reader", + + "reading-profile-series-settings-title": "Series", + "reading-profile-library-settings-title": "Library", + "delete": "{{common.delete}}" + }, + "validation": { "required-field": "This field is required",