Slight changes to the entity, more UI work
This commit is contained in:
parent
5656fb2148
commit
9b4a4b8a50
24 changed files with 864 additions and 315 deletions
|
|
@ -157,7 +157,7 @@ public class ReadingProfileServiceTest: AbstractDbTest
|
||||||
|
|
||||||
var profile = await UnitOfWork.AppUserReadingProfileRepository.GetProfileForSeries(user.Id, series.Id);
|
var profile = await UnitOfWork.AppUserReadingProfileRepository.GetProfileForSeries(user.Id, series.Id);
|
||||||
Assert.NotNull(profile);
|
Assert.NotNull(profile);
|
||||||
Assert.Contains(profile.Series, s => s.Id == series.Id);
|
Assert.Contains(profile.Series, s => s.SeriesId == series.Id);
|
||||||
Assert.True(profile.Implicit);
|
Assert.True(profile.Implicit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -208,6 +208,55 @@ public class ReadingProfileServiceTest: AbstractDbTest
|
||||||
Assert.Equal("Global", p.Name);
|
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.AppUserReadingProfile.Add(profile1);
|
||||||
|
Context.AppUserReadingProfile.Add(profile2);
|
||||||
|
await UnitOfWork.CommitAsync();
|
||||||
|
|
||||||
|
var profile = await rps.GetReadingProfileForSeries(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.GetReadingProfileForSeries(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.AppUserReadingProfile.Add(profile1);
|
||||||
|
await UnitOfWork.CommitAsync();
|
||||||
|
|
||||||
|
await rps.RemoveProfileFromSeries(user.Id, profile1.Id, series.Id);
|
||||||
|
var profile = await rps.GetReadingProfileForSeries(user.Id, series.Id);
|
||||||
|
Assert.Null(profile);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected override async Task ResetDb()
|
protected override async Task ResetDb()
|
||||||
{
|
{
|
||||||
Context.AppUserReadingProfile.RemoveRange(Context.AppUserReadingProfile);
|
Context.AppUserReadingProfile.RemoveRange(Context.AppUserReadingProfile);
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,14 @@
|
||||||
#nullable enable
|
#nullable enable
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using API.Data;
|
using API.Data;
|
||||||
using API.Data.Repositories;
|
using API.Data.Repositories;
|
||||||
using API.DTOs;
|
using API.DTOs;
|
||||||
using API.Extensions;
|
using API.Extensions;
|
||||||
using API.Services;
|
using API.Services;
|
||||||
|
using AutoMapper;
|
||||||
using Kavita.Common;
|
using Kavita.Common;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
@ -24,7 +26,11 @@ public class ReadingProfileController(ILogger<ReadingProfileController> logger,
|
||||||
[HttpGet("all")]
|
[HttpGet("all")]
|
||||||
public async Task<ActionResult<IList<UserReadingProfileDto>>> GetAllReadingProfiles()
|
public async Task<ActionResult<IList<UserReadingProfileDto>>> GetAllReadingProfiles()
|
||||||
{
|
{
|
||||||
return Ok(await unitOfWork.AppUserReadingProfileRepository.GetProfilesForUser(User.GetUserId(), true));
|
var profiles = await unitOfWork.AppUserReadingProfileRepository
|
||||||
|
.GetProfilesDtoForUser(User.GetUserId(), true,
|
||||||
|
ReadingProfileIncludes.Series | ReadingProfileIncludes.Library);
|
||||||
|
|
||||||
|
return Ok(profiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -48,6 +54,10 @@ public class ReadingProfileController(ILogger<ReadingProfileController> logger,
|
||||||
/// If set, will delete the implicit reading profile if it exists
|
/// If set, will delete the implicit reading profile if it exists
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
/// <remarks>This does not update connected series, and libraries. Use
|
||||||
|
/// <see cref="DeleteProfileFromSeries"/>, <see cref="AddProfileToSeries"/>,
|
||||||
|
/// <see cref="DeleteProfileFromLibrary"/>, <see cref="AddProfileToLibrary"/>
|
||||||
|
/// </remarks>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<ActionResult> UpdateReadingProfile([FromBody] UserReadingProfileDto dto, [FromQuery] int? seriesCtx)
|
public async Task<ActionResult> UpdateReadingProfile([FromBody] UserReadingProfileDto dto, [FromQuery] int? seriesCtx)
|
||||||
{
|
{
|
||||||
|
|
@ -116,4 +126,56 @@ public class ReadingProfileController(ILogger<ReadingProfileController> logger,
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the reading profile for a given series, removes the old one
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="seriesId"></param>
|
||||||
|
/// <param name="profileId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("series/{seriesId}")]
|
||||||
|
public async Task<IActionResult> AddProfileToSeries(int seriesId, [FromQuery] int profileId)
|
||||||
|
{
|
||||||
|
await readingProfileService.AddProfileToSeries(User.GetUserId(), profileId, seriesId);
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes the reading profile from a series for the current logged-in user
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="seriesId"></param>
|
||||||
|
/// <param name="profileId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpDelete("series/{seriesId}")]
|
||||||
|
public async Task<IActionResult> DeleteProfileFromSeries(int seriesId, [FromQuery] int profileId)
|
||||||
|
{
|
||||||
|
await readingProfileService.RemoveProfileFromSeries(User.GetUserId(), profileId, seriesId);
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the reading profile for a given library, removes the old one
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="libraryId"></param>
|
||||||
|
/// <param name="profileId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("library/{libraryId}")]
|
||||||
|
public async Task<IActionResult> AddProfileToLibrary(int libraryId, [FromQuery] int profileId)
|
||||||
|
{
|
||||||
|
await readingProfileService.AddProfileToLibrary(User.GetUserId(), profileId, libraryId);
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove the reading profile from a library for the current logged-in user
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="libraryId"></param>
|
||||||
|
/// <param name="profileId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpDelete("library/{libraryId}")]
|
||||||
|
public async Task<IActionResult> DeleteProfileFromLibrary(int libraryId, [FromQuery] int profileId)
|
||||||
|
{
|
||||||
|
await readingProfileService.RemoveProfileFromLibrary(User.GetUserId(), profileId, libraryId);
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using API.Entities;
|
using API.Entities;
|
||||||
using API.Entities.Enums;
|
using API.Entities.Enums;
|
||||||
|
|
@ -128,4 +129,12 @@ public sealed record UserReadingProfileDto
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Relations
|
||||||
|
|
||||||
|
public IList<int> SeriesIds { get; set; } = [];
|
||||||
|
|
||||||
|
public IList<int> LibraryIds { get; set; } = [];
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,8 @@ public sealed class DataContext : IdentityDbContext<AppUser, AppRole, int,
|
||||||
public DbSet<MetadataFieldMapping> MetadataFieldMapping { get; set; } = null!;
|
public DbSet<MetadataFieldMapping> MetadataFieldMapping { get; set; } = null!;
|
||||||
public DbSet<AppUserChapterRating> AppUserChapterRating { get; set; } = null!;
|
public DbSet<AppUserChapterRating> AppUserChapterRating { get; set; } = null!;
|
||||||
public DbSet<AppUserReadingProfile> AppUserReadingProfile { get; set; } = null!;
|
public DbSet<AppUserReadingProfile> AppUserReadingProfile { get; set; } = null!;
|
||||||
|
public DbSet<SeriesReadingProfile> SeriesReadingProfile { get; set; } = null!;
|
||||||
|
public DbSet<LibraryReadingProfile> LibraryReadingProfile { get; set; } = null!;
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder builder)
|
protected override void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
namespace API.Data.Migrations
|
namespace API.Data.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(DataContext))]
|
[DbContext(typeof(DataContext))]
|
||||||
[Migration("20250517195000_AppUserReadingProfiles")]
|
[Migration("20250519113715_AppUserReadingProfiles")]
|
||||||
partial class AppUserReadingProfiles
|
partial class AppUserReadingProfiles
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|
@ -1380,6 +1380,33 @@ namespace API.Data.Migrations
|
||||||
b.ToTable("LibraryFileTypeGroup");
|
b.ToTable("LibraryFileTypeGroup");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("API.Entities.LibraryReadingProfile", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("AppUserId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("LibraryId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("ReadingProfileId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AppUserId");
|
||||||
|
|
||||||
|
b.HasIndex("ReadingProfileId");
|
||||||
|
|
||||||
|
b.HasIndex("LibraryId", "AppUserId")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("LibraryReadingProfile");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Entities.MangaFile", b =>
|
modelBuilder.Entity("API.Entities.MangaFile", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
|
|
@ -2367,6 +2394,32 @@ namespace API.Data.Migrations
|
||||||
b.ToTable("Series");
|
b.ToTable("Series");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("API.Entities.SeriesReadingProfile", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("AppUserId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("ReadingProfileId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("SeriesId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AppUserId");
|
||||||
|
|
||||||
|
b.HasIndex("ReadingProfileId");
|
||||||
|
|
||||||
|
b.HasIndex("SeriesId");
|
||||||
|
|
||||||
|
b.ToTable("SeriesReadingProfile");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Entities.ServerSetting", b =>
|
modelBuilder.Entity("API.Entities.ServerSetting", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Key")
|
b.Property<int>("Key")
|
||||||
|
|
@ -2598,36 +2651,6 @@ namespace API.Data.Migrations
|
||||||
b.ToTable("AppUserLibrary");
|
b.ToTable("AppUserLibrary");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("AppUserReadingProfileLibrary", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("LibrariesId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<int>("ReadingProfilesId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.HasKey("LibrariesId", "ReadingProfilesId");
|
|
||||||
|
|
||||||
b.HasIndex("ReadingProfilesId");
|
|
||||||
|
|
||||||
b.ToTable("AppUserReadingProfileLibrary");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("AppUserReadingProfileSeries", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("ReadingProfilesId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<int>("SeriesId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.HasKey("ReadingProfilesId", "SeriesId");
|
|
||||||
|
|
||||||
b.HasIndex("SeriesId");
|
|
||||||
|
|
||||||
b.ToTable("AppUserReadingProfileSeries");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("ChapterGenre", b =>
|
modelBuilder.Entity("ChapterGenre", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("ChaptersId")
|
b.Property<int>("ChaptersId")
|
||||||
|
|
@ -3161,6 +3184,33 @@ namespace API.Data.Migrations
|
||||||
b.Navigation("Library");
|
b.Navigation("Library");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("API.Entities.LibraryReadingProfile", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("API.Entities.AppUser", "AppUser")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("AppUserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("API.Entities.Library", "Library")
|
||||||
|
.WithMany("ReadingProfiles")
|
||||||
|
.HasForeignKey("LibraryId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("API.Entities.AppUserReadingProfile", "ReadingProfile")
|
||||||
|
.WithMany("Libraries")
|
||||||
|
.HasForeignKey("ReadingProfileId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("AppUser");
|
||||||
|
|
||||||
|
b.Navigation("Library");
|
||||||
|
|
||||||
|
b.Navigation("ReadingProfile");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Entities.MangaFile", b =>
|
modelBuilder.Entity("API.Entities.MangaFile", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("API.Entities.Chapter", "Chapter")
|
b.HasOne("API.Entities.Chapter", "Chapter")
|
||||||
|
|
@ -3418,6 +3468,33 @@ namespace API.Data.Migrations
|
||||||
b.Navigation("Library");
|
b.Navigation("Library");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("API.Entities.SeriesReadingProfile", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("API.Entities.AppUser", "AppUser")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("AppUserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("API.Entities.AppUserReadingProfile", "ReadingProfile")
|
||||||
|
.WithMany("Series")
|
||||||
|
.HasForeignKey("ReadingProfileId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("API.Entities.Series", "Series")
|
||||||
|
.WithMany("ReadingProfiles")
|
||||||
|
.HasForeignKey("SeriesId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("AppUser");
|
||||||
|
|
||||||
|
b.Navigation("ReadingProfile");
|
||||||
|
|
||||||
|
b.Navigation("Series");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Entities.Volume", b =>
|
modelBuilder.Entity("API.Entities.Volume", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("API.Entities.Series", "Series")
|
b.HasOne("API.Entities.Series", "Series")
|
||||||
|
|
@ -3459,36 +3536,6 @@ namespace API.Data.Migrations
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("AppUserReadingProfileLibrary", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("API.Entities.Library", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("LibrariesId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("API.Entities.AppUserReadingProfile", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("ReadingProfilesId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("AppUserReadingProfileSeries", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("API.Entities.AppUserReadingProfile", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("ReadingProfilesId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("API.Entities.Series", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("SeriesId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("ChapterGenre", b =>
|
modelBuilder.Entity("ChapterGenre", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("API.Entities.Chapter", null)
|
b.HasOne("API.Entities.Chapter", null)
|
||||||
|
|
@ -3690,6 +3737,13 @@ namespace API.Data.Migrations
|
||||||
b.Navigation("ReadingProfiles");
|
b.Navigation("ReadingProfiles");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("API.Entities.AppUserReadingProfile", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Libraries");
|
||||||
|
|
||||||
|
b.Navigation("Series");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Entities.Chapter", b =>
|
modelBuilder.Entity("API.Entities.Chapter", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("ExternalRatings");
|
b.Navigation("ExternalRatings");
|
||||||
|
|
@ -3713,6 +3767,8 @@ namespace API.Data.Migrations
|
||||||
|
|
||||||
b.Navigation("LibraryFileTypes");
|
b.Navigation("LibraryFileTypes");
|
||||||
|
|
||||||
|
b.Navigation("ReadingProfiles");
|
||||||
|
|
||||||
b.Navigation("Series");
|
b.Navigation("Series");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -3750,6 +3806,8 @@ namespace API.Data.Migrations
|
||||||
|
|
||||||
b.Navigation("Ratings");
|
b.Navigation("Ratings");
|
||||||
|
|
||||||
|
b.Navigation("ReadingProfiles");
|
||||||
|
|
||||||
b.Navigation("RelationOf");
|
b.Navigation("RelationOf");
|
||||||
|
|
||||||
b.Navigation("Relations");
|
b.Navigation("Relations");
|
||||||
|
|
@ -71,47 +71,65 @@ namespace API.Data.Migrations
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "AppUserReadingProfileLibrary",
|
name: "LibraryReadingProfile",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
LibrariesId = table.Column<int>(type: "INTEGER", nullable: false),
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||||
ReadingProfilesId = table.Column<int>(type: "INTEGER", nullable: false)
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
AppUserId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
LibraryId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
ReadingProfileId = table.Column<int>(type: "INTEGER", nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_AppUserReadingProfileLibrary", x => new { x.LibrariesId, x.ReadingProfilesId });
|
table.PrimaryKey("PK_LibraryReadingProfile", x => x.Id);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_AppUserReadingProfileLibrary_AppUserReadingProfile_ReadingProfilesId",
|
name: "FK_LibraryReadingProfile_AppUserReadingProfile_ReadingProfileId",
|
||||||
column: x => x.ReadingProfilesId,
|
column: x => x.ReadingProfileId,
|
||||||
principalTable: "AppUserReadingProfile",
|
principalTable: "AppUserReadingProfile",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_AppUserReadingProfileLibrary_Library_LibrariesId",
|
name: "FK_LibraryReadingProfile_AspNetUsers_AppUserId",
|
||||||
column: x => x.LibrariesId,
|
column: x => x.AppUserId,
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_LibraryReadingProfile_Library_LibraryId",
|
||||||
|
column: x => x.LibraryId,
|
||||||
principalTable: "Library",
|
principalTable: "Library",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "AppUserReadingProfileSeries",
|
name: "SeriesReadingProfile",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
ReadingProfilesId = table.Column<int>(type: "INTEGER", nullable: false),
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||||
SeriesId = table.Column<int>(type: "INTEGER", nullable: false)
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
AppUserId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
SeriesId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
ReadingProfileId = table.Column<int>(type: "INTEGER", nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_AppUserReadingProfileSeries", x => new { x.ReadingProfilesId, x.SeriesId });
|
table.PrimaryKey("PK_SeriesReadingProfile", x => x.Id);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_AppUserReadingProfileSeries_AppUserReadingProfile_ReadingProfilesId",
|
name: "FK_SeriesReadingProfile_AppUserReadingProfile_ReadingProfileId",
|
||||||
column: x => x.ReadingProfilesId,
|
column: x => x.ReadingProfileId,
|
||||||
principalTable: "AppUserReadingProfile",
|
principalTable: "AppUserReadingProfile",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_AppUserReadingProfileSeries_Series_SeriesId",
|
name: "FK_SeriesReadingProfile_AspNetUsers_AppUserId",
|
||||||
|
column: x => x.AppUserId,
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_SeriesReadingProfile_Series_SeriesId",
|
||||||
column: x => x.SeriesId,
|
column: x => x.SeriesId,
|
||||||
principalTable: "Series",
|
principalTable: "Series",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
|
|
@ -129,13 +147,34 @@ namespace API.Data.Migrations
|
||||||
column: "UserId");
|
column: "UserId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_AppUserReadingProfileLibrary_ReadingProfilesId",
|
name: "IX_LibraryReadingProfile_AppUserId",
|
||||||
table: "AppUserReadingProfileLibrary",
|
table: "LibraryReadingProfile",
|
||||||
column: "ReadingProfilesId");
|
column: "AppUserId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_AppUserReadingProfileSeries_SeriesId",
|
name: "IX_LibraryReadingProfile_LibraryId_AppUserId",
|
||||||
table: "AppUserReadingProfileSeries",
|
table: "LibraryReadingProfile",
|
||||||
|
columns: new[] { "LibraryId", "AppUserId" },
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_LibraryReadingProfile_ReadingProfileId",
|
||||||
|
table: "LibraryReadingProfile",
|
||||||
|
column: "ReadingProfileId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_SeriesReadingProfile_AppUserId",
|
||||||
|
table: "SeriesReadingProfile",
|
||||||
|
column: "AppUserId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_SeriesReadingProfile_ReadingProfileId",
|
||||||
|
table: "SeriesReadingProfile",
|
||||||
|
column: "ReadingProfileId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_SeriesReadingProfile_SeriesId",
|
||||||
|
table: "SeriesReadingProfile",
|
||||||
column: "SeriesId");
|
column: "SeriesId");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -143,10 +182,10 @@ namespace API.Data.Migrations
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "AppUserReadingProfileLibrary");
|
name: "LibraryReadingProfile");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "AppUserReadingProfileSeries");
|
name: "SeriesReadingProfile");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "AppUserReadingProfile");
|
name: "AppUserReadingProfile");
|
||||||
|
|
@ -1377,6 +1377,33 @@ namespace API.Data.Migrations
|
||||||
b.ToTable("LibraryFileTypeGroup");
|
b.ToTable("LibraryFileTypeGroup");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("API.Entities.LibraryReadingProfile", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("AppUserId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("LibraryId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("ReadingProfileId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AppUserId");
|
||||||
|
|
||||||
|
b.HasIndex("ReadingProfileId");
|
||||||
|
|
||||||
|
b.HasIndex("LibraryId", "AppUserId")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("LibraryReadingProfile");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Entities.MangaFile", b =>
|
modelBuilder.Entity("API.Entities.MangaFile", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
|
|
@ -2364,6 +2391,32 @@ namespace API.Data.Migrations
|
||||||
b.ToTable("Series");
|
b.ToTable("Series");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("API.Entities.SeriesReadingProfile", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("AppUserId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("ReadingProfileId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("SeriesId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AppUserId");
|
||||||
|
|
||||||
|
b.HasIndex("ReadingProfileId");
|
||||||
|
|
||||||
|
b.HasIndex("SeriesId");
|
||||||
|
|
||||||
|
b.ToTable("SeriesReadingProfile");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Entities.ServerSetting", b =>
|
modelBuilder.Entity("API.Entities.ServerSetting", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Key")
|
b.Property<int>("Key")
|
||||||
|
|
@ -2595,36 +2648,6 @@ namespace API.Data.Migrations
|
||||||
b.ToTable("AppUserLibrary");
|
b.ToTable("AppUserLibrary");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("AppUserReadingProfileLibrary", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("LibrariesId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<int>("ReadingProfilesId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.HasKey("LibrariesId", "ReadingProfilesId");
|
|
||||||
|
|
||||||
b.HasIndex("ReadingProfilesId");
|
|
||||||
|
|
||||||
b.ToTable("AppUserReadingProfileLibrary");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("AppUserReadingProfileSeries", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("ReadingProfilesId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<int>("SeriesId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.HasKey("ReadingProfilesId", "SeriesId");
|
|
||||||
|
|
||||||
b.HasIndex("SeriesId");
|
|
||||||
|
|
||||||
b.ToTable("AppUserReadingProfileSeries");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("ChapterGenre", b =>
|
modelBuilder.Entity("ChapterGenre", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("ChaptersId")
|
b.Property<int>("ChaptersId")
|
||||||
|
|
@ -3158,6 +3181,33 @@ namespace API.Data.Migrations
|
||||||
b.Navigation("Library");
|
b.Navigation("Library");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("API.Entities.LibraryReadingProfile", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("API.Entities.AppUser", "AppUser")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("AppUserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("API.Entities.Library", "Library")
|
||||||
|
.WithMany("ReadingProfiles")
|
||||||
|
.HasForeignKey("LibraryId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("API.Entities.AppUserReadingProfile", "ReadingProfile")
|
||||||
|
.WithMany("Libraries")
|
||||||
|
.HasForeignKey("ReadingProfileId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("AppUser");
|
||||||
|
|
||||||
|
b.Navigation("Library");
|
||||||
|
|
||||||
|
b.Navigation("ReadingProfile");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Entities.MangaFile", b =>
|
modelBuilder.Entity("API.Entities.MangaFile", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("API.Entities.Chapter", "Chapter")
|
b.HasOne("API.Entities.Chapter", "Chapter")
|
||||||
|
|
@ -3415,6 +3465,33 @@ namespace API.Data.Migrations
|
||||||
b.Navigation("Library");
|
b.Navigation("Library");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("API.Entities.SeriesReadingProfile", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("API.Entities.AppUser", "AppUser")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("AppUserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("API.Entities.AppUserReadingProfile", "ReadingProfile")
|
||||||
|
.WithMany("Series")
|
||||||
|
.HasForeignKey("ReadingProfileId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("API.Entities.Series", "Series")
|
||||||
|
.WithMany("ReadingProfiles")
|
||||||
|
.HasForeignKey("SeriesId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("AppUser");
|
||||||
|
|
||||||
|
b.Navigation("ReadingProfile");
|
||||||
|
|
||||||
|
b.Navigation("Series");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Entities.Volume", b =>
|
modelBuilder.Entity("API.Entities.Volume", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("API.Entities.Series", "Series")
|
b.HasOne("API.Entities.Series", "Series")
|
||||||
|
|
@ -3456,36 +3533,6 @@ namespace API.Data.Migrations
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("AppUserReadingProfileLibrary", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("API.Entities.Library", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("LibrariesId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("API.Entities.AppUserReadingProfile", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("ReadingProfilesId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("AppUserReadingProfileSeries", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("API.Entities.AppUserReadingProfile", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("ReadingProfilesId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("API.Entities.Series", null)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("SeriesId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("ChapterGenre", b =>
|
modelBuilder.Entity("ChapterGenre", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("API.Entities.Chapter", null)
|
b.HasOne("API.Entities.Chapter", null)
|
||||||
|
|
@ -3687,6 +3734,13 @@ namespace API.Data.Migrations
|
||||||
b.Navigation("ReadingProfiles");
|
b.Navigation("ReadingProfiles");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("API.Entities.AppUserReadingProfile", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Libraries");
|
||||||
|
|
||||||
|
b.Navigation("Series");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Entities.Chapter", b =>
|
modelBuilder.Entity("API.Entities.Chapter", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("ExternalRatings");
|
b.Navigation("ExternalRatings");
|
||||||
|
|
@ -3710,6 +3764,8 @@ namespace API.Data.Migrations
|
||||||
|
|
||||||
b.Navigation("LibraryFileTypes");
|
b.Navigation("LibraryFileTypes");
|
||||||
|
|
||||||
|
b.Navigation("ReadingProfiles");
|
||||||
|
|
||||||
b.Navigation("Series");
|
b.Navigation("Series");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -3747,6 +3803,8 @@ namespace API.Data.Migrations
|
||||||
|
|
||||||
b.Navigation("Ratings");
|
b.Navigation("Ratings");
|
||||||
|
|
||||||
|
b.Navigation("ReadingProfiles");
|
||||||
|
|
||||||
b.Navigation("RelationOf");
|
b.Navigation("RelationOf");
|
||||||
|
|
||||||
b.Navigation("Relations");
|
b.Navigation("Relations");
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ public enum ReadingProfileIncludes
|
||||||
public interface IAppUserReadingProfileRepository
|
public interface IAppUserReadingProfileRepository
|
||||||
{
|
{
|
||||||
Task<IList<AppUserReadingProfile>> GetProfilesForUser(int userId, bool nonImplicitOnly, ReadingProfileIncludes includes = ReadingProfileIncludes.None);
|
Task<IList<AppUserReadingProfile>> GetProfilesForUser(int userId, bool nonImplicitOnly, ReadingProfileIncludes includes = ReadingProfileIncludes.None);
|
||||||
|
Task<IList<UserReadingProfileDto>> GetProfilesDtoForUser(int userId, bool nonImplicitOnly, ReadingProfileIncludes includes = ReadingProfileIncludes.None);
|
||||||
Task<AppUserReadingProfile?> GetProfileForSeries(int userId, int seriesId, ReadingProfileIncludes includes = ReadingProfileIncludes.None);
|
Task<AppUserReadingProfile?> GetProfileForSeries(int userId, int seriesId, ReadingProfileIncludes includes = ReadingProfileIncludes.None);
|
||||||
Task<UserReadingProfileDto?> GetProfileDtoForSeries(int userId, int seriesId);
|
Task<UserReadingProfileDto?> GetProfileDtoForSeries(int userId, int seriesId);
|
||||||
Task<AppUserReadingProfile?> GetProfileForLibrary(int userId, int libraryId, ReadingProfileIncludes includes = ReadingProfileIncludes.None);
|
Task<AppUserReadingProfile?> GetProfileForLibrary(int userId, int libraryId, ReadingProfileIncludes includes = ReadingProfileIncludes.None);
|
||||||
|
|
@ -31,6 +32,8 @@ public interface IAppUserReadingProfileRepository
|
||||||
Task<AppUserReadingProfile?> GetProfile(int profileId, ReadingProfileIncludes includes = ReadingProfileIncludes.None);
|
Task<AppUserReadingProfile?> GetProfile(int profileId, ReadingProfileIncludes includes = ReadingProfileIncludes.None);
|
||||||
Task<UserReadingProfileDto?> GetProfileDto(int profileId);
|
Task<UserReadingProfileDto?> GetProfileDto(int profileId);
|
||||||
Task<AppUserReadingProfile?> GetProfileByName(int userId, string name);
|
Task<AppUserReadingProfile?> GetProfileByName(int userId, string name);
|
||||||
|
Task<SeriesReadingProfile?> GetSeriesProfile(int userId, int seriesId);
|
||||||
|
Task<LibraryReadingProfile?> GetLibraryProfile(int userId, int libraryId);
|
||||||
|
|
||||||
void Add(AppUserReadingProfile readingProfile);
|
void Add(AppUserReadingProfile readingProfile);
|
||||||
void Update(AppUserReadingProfile readingProfile);
|
void Update(AppUserReadingProfile readingProfile);
|
||||||
|
|
@ -48,10 +51,20 @@ public class AppUserReadingProfileRepository(DataContext context, IMapper mapper
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IList<UserReadingProfileDto>> GetProfilesDtoForUser(int userId, bool nonImplicitOnly,
|
||||||
|
ReadingProfileIncludes includes = ReadingProfileIncludes.None)
|
||||||
|
{
|
||||||
|
return await context.AppUserReadingProfile
|
||||||
|
.Where(rp => rp.UserId == userId && !(nonImplicitOnly && rp.Implicit))
|
||||||
|
.Includes(includes)
|
||||||
|
.ProjectTo<UserReadingProfileDto>(mapper.ConfigurationProvider)
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<AppUserReadingProfile?> GetProfileForSeries(int userId, int seriesId, ReadingProfileIncludes includes = ReadingProfileIncludes.None)
|
public async Task<AppUserReadingProfile?> GetProfileForSeries(int userId, int seriesId, ReadingProfileIncludes includes = ReadingProfileIncludes.None)
|
||||||
{
|
{
|
||||||
return await context.AppUserReadingProfile
|
return await context.AppUserReadingProfile
|
||||||
.Where(rp => rp.UserId == userId && rp.Series.Any(s => s.Id == seriesId))
|
.Where(rp => rp.UserId == userId && rp.Series.Any(s => s.SeriesId == seriesId))
|
||||||
.Includes(includes)
|
.Includes(includes)
|
||||||
.OrderByDescending(rp => rp.Implicit) // Get implicit profiles first
|
.OrderByDescending(rp => rp.Implicit) // Get implicit profiles first
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
@ -60,7 +73,7 @@ public class AppUserReadingProfileRepository(DataContext context, IMapper mapper
|
||||||
public async Task<UserReadingProfileDto?> GetProfileDtoForSeries(int userId, int seriesId)
|
public async Task<UserReadingProfileDto?> GetProfileDtoForSeries(int userId, int seriesId)
|
||||||
{
|
{
|
||||||
return await context.AppUserReadingProfile
|
return await context.AppUserReadingProfile
|
||||||
.Where(rp => rp.UserId == userId && rp.Series.Any(s => s.Id == seriesId))
|
.Where(rp => rp.UserId == userId && rp.Series.Any(s => s.SeriesId == seriesId))
|
||||||
.OrderByDescending(rp => rp.Implicit) // Get implicit profiles first
|
.OrderByDescending(rp => rp.Implicit) // Get implicit profiles first
|
||||||
.ProjectTo<UserReadingProfileDto>(mapper.ConfigurationProvider)
|
.ProjectTo<UserReadingProfileDto>(mapper.ConfigurationProvider)
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
@ -69,7 +82,7 @@ public class AppUserReadingProfileRepository(DataContext context, IMapper mapper
|
||||||
public async Task<AppUserReadingProfile?> GetProfileForLibrary(int userId, int libraryId, ReadingProfileIncludes includes = ReadingProfileIncludes.None)
|
public async Task<AppUserReadingProfile?> GetProfileForLibrary(int userId, int libraryId, ReadingProfileIncludes includes = ReadingProfileIncludes.None)
|
||||||
{
|
{
|
||||||
return await context.AppUserReadingProfile
|
return await context.AppUserReadingProfile
|
||||||
.Where(rp => rp.UserId == userId && rp.Libraries.Any(s => s.Id == libraryId))
|
.Where(rp => rp.UserId == userId && rp.Libraries.Any(s => s.LibraryId == libraryId))
|
||||||
.Includes(includes)
|
.Includes(includes)
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
}
|
}
|
||||||
|
|
@ -77,7 +90,7 @@ public class AppUserReadingProfileRepository(DataContext context, IMapper mapper
|
||||||
public async Task<UserReadingProfileDto?> GetProfileDtoForLibrary(int userId, int libraryId)
|
public async Task<UserReadingProfileDto?> GetProfileDtoForLibrary(int userId, int libraryId)
|
||||||
{
|
{
|
||||||
return await context.AppUserReadingProfile
|
return await context.AppUserReadingProfile
|
||||||
.Where(rp => rp.UserId == userId && rp.Libraries.Any(s => s.Id == libraryId))
|
.Where(rp => rp.UserId == userId && rp.Libraries.Any(s => s.LibraryId == libraryId))
|
||||||
.ProjectTo<UserReadingProfileDto>(mapper.ConfigurationProvider)
|
.ProjectTo<UserReadingProfileDto>(mapper.ConfigurationProvider)
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
}
|
}
|
||||||
|
|
@ -106,6 +119,20 @@ public class AppUserReadingProfileRepository(DataContext context, IMapper mapper
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<SeriesReadingProfile?> GetSeriesProfile(int userId, int seriesId)
|
||||||
|
{
|
||||||
|
return await context.SeriesReadingProfile
|
||||||
|
.Where(rp => rp.SeriesId == seriesId && rp.AppUserId == userId)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<LibraryReadingProfile?> GetLibraryProfile(int userId, int libraryId)
|
||||||
|
{
|
||||||
|
return await context.LibraryReadingProfile
|
||||||
|
.Where(rp => rp.LibraryId == libraryId && rp.AppUserId == userId)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
}
|
||||||
|
|
||||||
public void Add(AppUserReadingProfile readingProfile)
|
public void Add(AppUserReadingProfile readingProfile)
|
||||||
{
|
{
|
||||||
context.AppUserReadingProfile.Add(readingProfile);
|
context.AppUserReadingProfile.Add(readingProfile);
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ public class Library : IEntityDate, IHasCoverImage
|
||||||
public ICollection<Series> Series { get; set; } = null!;
|
public ICollection<Series> Series { get; set; } = null!;
|
||||||
public ICollection<LibraryFileTypeGroup> LibraryFileTypes { get; set; } = new List<LibraryFileTypeGroup>();
|
public ICollection<LibraryFileTypeGroup> LibraryFileTypes { get; set; } = new List<LibraryFileTypeGroup>();
|
||||||
public ICollection<LibraryExcludePattern> LibraryExcludePatterns { get; set; } = new List<LibraryExcludePattern>();
|
public ICollection<LibraryExcludePattern> LibraryExcludePatterns { get; set; } = new List<LibraryExcludePattern>();
|
||||||
public ICollection<AppUserReadingProfile> ReadingProfiles { get; set; } = null!;
|
public ICollection<LibraryReadingProfile> ReadingProfiles { get; set; } = null!;
|
||||||
|
|
||||||
public void UpdateLastModified()
|
public void UpdateLastModified()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ public class AppUserReadingProfile
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
public AppUser User { get; set; }
|
public AppUser User { get; set; }
|
||||||
|
|
||||||
public ICollection<Series> Series { get; set; }
|
public ICollection<SeriesReadingProfile> Series { get; set; }
|
||||||
public ICollection<Library> Libraries { get; set; }
|
public ICollection<LibraryReadingProfile> Libraries { get; set; }
|
||||||
|
|
||||||
#region MangaReader
|
#region MangaReader
|
||||||
|
|
||||||
20
API/Entities/ReadingProfile/LibraryReadingProfile.cs
Normal file
20
API/Entities/ReadingProfile/LibraryReadingProfile.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace API.Entities;
|
||||||
|
|
||||||
|
[Index(nameof(LibraryId), nameof(AppUserId), IsUnique = true)]
|
||||||
|
public class LibraryReadingProfile
|
||||||
|
{
|
||||||
|
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public int AppUserId { get; set; }
|
||||||
|
public AppUser AppUser { get; set; }
|
||||||
|
|
||||||
|
public int LibraryId { get; set; }
|
||||||
|
public Library Library { get; set; }
|
||||||
|
|
||||||
|
public int ReadingProfileId { get; set; }
|
||||||
|
public AppUserReadingProfile ReadingProfile { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
17
API/Entities/ReadingProfile/SeriesReadingProfile.cs
Normal file
17
API/Entities/ReadingProfile/SeriesReadingProfile.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
namespace API.Entities;
|
||||||
|
|
||||||
|
public class SeriesReadingProfile
|
||||||
|
{
|
||||||
|
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public int AppUserId { get; set; }
|
||||||
|
public AppUser AppUser { get; set; }
|
||||||
|
|
||||||
|
public int SeriesId { get; set; }
|
||||||
|
public Series Series { get; set; }
|
||||||
|
|
||||||
|
public int ReadingProfileId { get; set; }
|
||||||
|
public AppUserReadingProfile ReadingProfile { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -135,7 +135,7 @@ public class Series : IEntityDate, IHasReadTimeEstimate, IHasCoverImage
|
||||||
public List<Volume> Volumes { get; set; } = null!;
|
public List<Volume> Volumes { get; set; } = null!;
|
||||||
public Library Library { get; set; } = null!;
|
public Library Library { get; set; } = null!;
|
||||||
public int LibraryId { get; set; }
|
public int LibraryId { get; set; }
|
||||||
public ICollection<AppUserReadingProfile> ReadingProfiles { get; set; } = null!;
|
public ICollection<SeriesReadingProfile> ReadingProfiles { get; set; } = null!;
|
||||||
|
|
||||||
|
|
||||||
public void UpdateLastFolderScanned()
|
public void UpdateLastFolderScanned()
|
||||||
|
|
|
||||||
|
|
@ -283,7 +283,13 @@ public class AutoMapperProfiles : Profile
|
||||||
opt.MapFrom(src => src.BookThemeName))
|
opt.MapFrom(src => src.BookThemeName))
|
||||||
.ForMember(dest => dest.BookReaderLayoutMode,
|
.ForMember(dest => dest.BookReaderLayoutMode,
|
||||||
opt =>
|
opt =>
|
||||||
opt.MapFrom(src => src.BookReaderLayoutMode));
|
opt.MapFrom(src => src.BookReaderLayoutMode))
|
||||||
|
.ForMember(dest => dest.SeriesIds,
|
||||||
|
opt =>
|
||||||
|
opt.MapFrom(src => src.Series.Select(s => s.SeriesId).ToList()))
|
||||||
|
.ForMember(dest => dest.LibraryIds,
|
||||||
|
opt =>
|
||||||
|
opt.MapFrom(src => src.Libraries.Select(s => s.LibraryId).ToList()));
|
||||||
|
|
||||||
|
|
||||||
CreateMap<AppUserBookmark, BookmarkDto>();
|
CreateMap<AppUserBookmark, BookmarkDto>();
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,21 @@ public class AppUserReadingProfileBuilder
|
||||||
|
|
||||||
public AppUserReadingProfileBuilder WithSeries(Series series)
|
public AppUserReadingProfileBuilder WithSeries(Series series)
|
||||||
{
|
{
|
||||||
_profile.Series.Add(series);
|
_profile.Series.Add(new SeriesReadingProfile
|
||||||
|
{
|
||||||
|
Series = series,
|
||||||
|
AppUserId = _profile.UserId,
|
||||||
|
});
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AppUserReadingProfileBuilder WithLibrary(Library library)
|
public AppUserReadingProfileBuilder WithLibrary(Library library)
|
||||||
{
|
{
|
||||||
_profile.Libraries.Add(library);
|
_profile.Libraries.Add(new LibraryReadingProfile
|
||||||
|
{
|
||||||
|
Library = library,
|
||||||
|
AppUserId = _profile.UserId,
|
||||||
|
});
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ public interface IReadingProfileService
|
||||||
/// <param name="userId"></param>
|
/// <param name="userId"></param>
|
||||||
/// <param name="dto"></param>
|
/// <param name="dto"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
/// <remarks>Does not update connected series and libraries</remarks>
|
||||||
Task<bool> UpdateReadingProfile(int userId, UserReadingProfileDto dto);
|
Task<bool> UpdateReadingProfile(int userId, UserReadingProfileDto dto);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -74,6 +75,12 @@ public interface IReadingProfileService
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task SetDefaultReadingProfile(int userId, int profileId);
|
Task SetDefaultReadingProfile(int userId, int profileId);
|
||||||
|
|
||||||
|
Task AddProfileToSeries(int userId, int profileId, int seriesId);
|
||||||
|
Task RemoveProfileFromSeries(int userId, int profileId, int seriesId);
|
||||||
|
|
||||||
|
Task AddProfileToLibrary(int userId, int profileId, int libraryId);
|
||||||
|
Task RemoveProfileFromLibrary(int userId, int profileId, int libraryId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ReadingProfileService(IUnitOfWork unitOfWork, ILocalizationService localizationService): IReadingProfileService
|
public class ReadingProfileService(IUnitOfWork unitOfWork, ILocalizationService localizationService): IReadingProfileService
|
||||||
|
|
@ -164,7 +171,7 @@ public class ReadingProfileService(IUnitOfWork unitOfWork, ILocalizationService
|
||||||
|
|
||||||
if (!profile.Implicit) return;
|
if (!profile.Implicit) return;
|
||||||
|
|
||||||
profile.Series = profile.Series.Where(s => s.Id != seriesId).ToList();
|
profile.Series = profile.Series.Where(s => s.SeriesId != seriesId).ToList();
|
||||||
|
|
||||||
await unitOfWork.CommitAsync();
|
await unitOfWork.CommitAsync();
|
||||||
}
|
}
|
||||||
|
|
@ -197,6 +204,70 @@ public class ReadingProfileService(IUnitOfWork unitOfWork, ILocalizationService
|
||||||
await unitOfWork.CommitAsync();
|
await unitOfWork.CommitAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task AddProfileToSeries(int userId, int profileId, int seriesId)
|
||||||
|
{
|
||||||
|
var profile = await unitOfWork.AppUserReadingProfileRepository.GetProfile(profileId);
|
||||||
|
if (profile == null) throw new KavitaException("profile-not-found");
|
||||||
|
|
||||||
|
if (profile.UserId != userId) throw new UnauthorizedAccessException();
|
||||||
|
|
||||||
|
var seriesProfile = await unitOfWork.AppUserReadingProfileRepository.GetSeriesProfile(userId, seriesId);
|
||||||
|
if (seriesProfile == null)
|
||||||
|
{
|
||||||
|
seriesProfile = new SeriesReadingProfile
|
||||||
|
{
|
||||||
|
AppUserId = userId,
|
||||||
|
SeriesId = seriesId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
seriesProfile.ReadingProfile = profile;
|
||||||
|
await unitOfWork.CommitAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task RemoveProfileFromSeries(int userId, int profileId, int seriesId)
|
||||||
|
{
|
||||||
|
var profile = await unitOfWork.AppUserReadingProfileRepository.GetProfile(profileId);
|
||||||
|
if (profile == null) throw new KavitaException("profile-not-found");
|
||||||
|
|
||||||
|
if (profile.UserId != userId) throw new UnauthorizedAccessException();
|
||||||
|
|
||||||
|
profile.Series = profile.Series.Where(s => s.SeriesId != seriesId).ToList();
|
||||||
|
await unitOfWork.CommitAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task AddProfileToLibrary(int userId, int profileId, int libraryId)
|
||||||
|
{
|
||||||
|
var profile = await unitOfWork.AppUserReadingProfileRepository.GetProfile(profileId);
|
||||||
|
if (profile == null) throw new KavitaException("profile-not-found");
|
||||||
|
|
||||||
|
if (profile.UserId != userId) throw new UnauthorizedAccessException();
|
||||||
|
|
||||||
|
var libraryProfile = await unitOfWork.AppUserReadingProfileRepository.GetLibraryProfile(userId, libraryId);
|
||||||
|
if (libraryProfile == null)
|
||||||
|
{
|
||||||
|
libraryProfile = new LibraryReadingProfile
|
||||||
|
{
|
||||||
|
AppUserId = userId,
|
||||||
|
LibraryId = libraryId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
libraryProfile.ReadingProfile = profile;
|
||||||
|
await unitOfWork.CommitAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task RemoveProfileFromLibrary(int userId, int profileId, int libraryId)
|
||||||
|
{
|
||||||
|
var profile = await unitOfWork.AppUserReadingProfileRepository.GetProfile(profileId);
|
||||||
|
if (profile == null) throw new KavitaException("profile-not-found");
|
||||||
|
|
||||||
|
if (profile.UserId != userId) throw new UnauthorizedAccessException();
|
||||||
|
|
||||||
|
profile.Libraries = profile.Libraries.Where(s => s.LibraryId != libraryId).ToList();
|
||||||
|
await unitOfWork.CommitAsync();
|
||||||
|
}
|
||||||
|
|
||||||
private static void UpdateReaderProfileFields(AppUserReadingProfile existingProfile, UserReadingProfileDto dto, bool updateName = true)
|
private static void UpdateReaderProfileFields(AppUserReadingProfile existingProfile, UserReadingProfileDto dto, bool updateName = true)
|
||||||
{
|
{
|
||||||
if (updateName && !string.IsNullOrEmpty(dto.Name) && existingProfile.NormalizedName != dto.Name.ToNormalized())
|
if (updateName && !string.IsNullOrEmpty(dto.Name) && existingProfile.NormalizedName != dto.Name.ToNormalized())
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ import {PdfTheme} from "./pdf-theme";
|
||||||
import {PdfScrollMode} from "./pdf-scroll-mode";
|
import {PdfScrollMode} from "./pdf-scroll-mode";
|
||||||
import {PdfLayoutMode} from "./pdf-layout-mode";
|
import {PdfLayoutMode} from "./pdf-layout-mode";
|
||||||
import {PdfSpreadMode} from "./pdf-spread-mode";
|
import {PdfSpreadMode} from "./pdf-spread-mode";
|
||||||
|
import {Series} from "../series";
|
||||||
|
import {Library} from "../library/library";
|
||||||
|
|
||||||
export interface ReadingProfile {
|
export interface ReadingProfile {
|
||||||
|
|
||||||
|
|
@ -48,6 +50,10 @@ export interface ReadingProfile {
|
||||||
pdfScrollMode: PdfScrollMode;
|
pdfScrollMode: PdfScrollMode;
|
||||||
pdfSpreadMode: PdfSpreadMode;
|
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 readingDirections = [{text: 'left-to-right', value: ReadingDirection.LeftToRight}, {text: 'right-to-left', value: ReadingDirection.RightToLeft}];
|
||||||
|
|
|
||||||
|
|
@ -43,4 +43,20 @@ export class ReadingProfileService {
|
||||||
return this.httpClient.post(this.baseUrl + "ReadingProfile/set-default?profileId=" + id, {});
|
return this.httpClient.post(this.baseUrl + "ReadingProfile/set-default?profileId=" + id, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addToSeries(id: number, seriesId: number) {
|
||||||
|
return this.httpClient.post(this.baseUrl + `ReadingProfile/series/${seriesId}?profileId=${id}`, {});
|
||||||
|
}
|
||||||
|
|
||||||
|
removeFromSeries(id: number, seriesId: number) {
|
||||||
|
return this.httpClient.delete(this.baseUrl + `ReadingProfile/series/${seriesId}?profileId=${id}`, {});
|
||||||
|
}
|
||||||
|
|
||||||
|
addToLibrary(id: number, libraryId: number) {
|
||||||
|
return this.httpClient.post(this.baseUrl + `ReadingProfile/library/${libraryId}?profileId=${id}`, {});
|
||||||
|
}
|
||||||
|
|
||||||
|
removeFromLibrary(id: number, libraryId: number) {
|
||||||
|
return this.httpClient.delete(this.baseUrl + `ReadingProfile/library/${libraryId}?profileId=${id}`, {});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<ng-container *transloco="let t;prefix:'manage-reading-profiles'">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</ng-container>
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
import {Component, Input, OnInit} from '@angular/core';
|
||||||
|
import {FormGroup} from "@angular/forms";
|
||||||
|
import {ReadingProfile} from "../../../../_models/preferences/reading-profiles";
|
||||||
|
import {Library} from "../../../../_models/library/library";
|
||||||
|
import {LibraryService} from "../../../../_services/library.service";
|
||||||
|
import {ReadingProfileService} from "../../../../_services/reading-profile.service";
|
||||||
|
import {TranslocoDirective} from "@jsverse/transloco";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-reading-profile-library-selection',
|
||||||
|
imports: [
|
||||||
|
TranslocoDirective
|
||||||
|
],
|
||||||
|
templateUrl: './reading-profile-library-selection.component.html',
|
||||||
|
styleUrl: './reading-profile-library-selection.component.scss'
|
||||||
|
})
|
||||||
|
export class ReadingProfileLibrarySelectionComponent implements OnInit{
|
||||||
|
|
||||||
|
@Input({required: true}) readingProfileForm!: FormGroup;
|
||||||
|
@Input({required: true}) selectedProfile!: ReadingProfile;
|
||||||
|
|
||||||
|
allLibraries: Library[] = []
|
||||||
|
|
||||||
|
constructor(private libraryService: LibraryService, private readingProfileService: ReadingProfileService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.libraryService.getLibraries().subscribe(libs => this.allLibraries = libs);
|
||||||
|
}
|
||||||
|
|
||||||
|
addToProfile(library: Library) {
|
||||||
|
this.readingProfileService.addToLibrary(this.selectedProfile.id, library.id).subscribe()
|
||||||
|
}
|
||||||
|
|
||||||
|
removeFromProfile(library: Library) {
|
||||||
|
this.readingProfileService.removeFromLibrary(this.selectedProfile.id, library.id).subscribe()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -53,12 +53,12 @@
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</app-setting-item>
|
</app-setting-item>
|
||||||
|
|
||||||
@if (this.selectedProfile?.id !== 0) {
|
@if (selectedProfile.id !== 0) {
|
||||||
<div class="d-flex justify-content-between">
|
<div class="d-flex justify-content-between">
|
||||||
<button class="me-2 btn btn-primary" (click)="setDefault(this.selectedProfile!.id)">
|
<button class="me-2 btn btn-primary" [disabled]="selectedProfile.id === user.preferences.defaultReadingProfileId" (click)="setDefault(selectedProfile.id)">
|
||||||
<span>{{t('make-default')}}</span>
|
<span>{{t('make-default')}}</span>
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-danger" (click)="delete(this.selectedProfile!.id)">
|
<button class="btn btn-danger" (click)="delete(selectedProfile.id)">
|
||||||
<i class="fa fa-trash" aria-hidden="true"></i>
|
<i class="fa fa-trash" aria-hidden="true"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -230,6 +230,28 @@
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</app-setting-switch>
|
</app-setting-switch>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@if (readingProfileForm.get("widthOverride"); as widthOverride) {
|
||||||
|
<div class="row g-0 mt-4 mb-4">
|
||||||
|
<app-setting-item [title]="t('width-overwrite')">
|
||||||
|
<ng-template #view>
|
||||||
|
<label for="width-override-slider" class="form-label">
|
||||||
|
{{ widthOverwriteLabel }}
|
||||||
|
</label>
|
||||||
|
</ng-template>
|
||||||
|
<ng-template #edit>
|
||||||
|
<div class="d-flex justify-content-between align-items-center">
|
||||||
|
<span>{{ widthOverwriteLabel }}</span>
|
||||||
|
<button class="btn btn-secondary" (click)="widthOverride.setValue(null)">
|
||||||
|
{{t('reset')}}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<input id="width-override-slider" type="range" min="0" max="100" class="form-range" formControlName="widthOverride">
|
||||||
|
</ng-template>
|
||||||
|
</app-setting-item>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
@ -239,6 +261,7 @@
|
||||||
<a ngbNavLink (click)="activeTabId = TabId.BookReader">{{t('book-reader-settings-title')}}</a>
|
<a ngbNavLink (click)="activeTabId = TabId.BookReader">{{t('book-reader-settings-title')}}</a>
|
||||||
<ng-template ngbNavContent>
|
<ng-template ngbNavContent>
|
||||||
@defer (when activeTabId === TabId.BookReader; prefetch on idle) {
|
@defer (when activeTabId === TabId.BookReader; prefetch on idle) {
|
||||||
|
@if (selectedProfile !== null && readingProfileForm !== null) {
|
||||||
<div>
|
<div>
|
||||||
<div class="row g-0 mt-4 mb-4">
|
<div class="row g-0 mt-4 mb-4">
|
||||||
<app-setting-switch [title]="t('tap-to-paginate-label')" [subtitle]="t('tap-to-paginate-tooltip')">
|
<app-setting-switch [title]="t('tap-to-paginate-label')" [subtitle]="t('tap-to-paginate-tooltip')">
|
||||||
|
|
@ -397,6 +420,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
@ -459,12 +483,23 @@
|
||||||
|
|
||||||
<li [ngbNavItem]="TabId.Series">
|
<li [ngbNavItem]="TabId.Series">
|
||||||
<a ngbNavLink (click)="activeTabId = TabId.Series">{{t('reading-profile-series-settings-title')}}</a>
|
<a ngbNavLink (click)="activeTabId = TabId.Series">{{t('reading-profile-series-settings-title')}}</a>
|
||||||
<ng-template ngbNavContent></ng-template>
|
<ng-template ngbNavContent>
|
||||||
|
@defer (when activeTabId === TabId.Series; prefetch on idle) {
|
||||||
|
@if (readingProfileForm !== null && selectedProfile !== null) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</ng-template>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li [ngbNavItem]="TabId.Libraries">
|
<li [ngbNavItem]="TabId.Libraries">
|
||||||
<a ngbNavLink (click)="activeTabId = TabId.Libraries">{{t('reading-profile-library-settings-title')}}</a>
|
<a ngbNavLink (click)="activeTabId = TabId.Libraries">{{t('reading-profile-library-settings-title')}}</a>
|
||||||
<ng-template ngbNavContent></ng-template>
|
<ng-template ngbNavContent>
|
||||||
|
@defer (when activeTabId === TabId.Libraries; prefetch on idle) {
|
||||||
|
@if (readingProfileForm !== null && selectedProfile !== null) {
|
||||||
|
<app-reading-profile-library-selection [readingProfileForm]="readingProfileForm" [selectedProfile]="selectedProfile" />
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</ng-template>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import {
|
||||||
ReadingProfile, scalingOptions
|
ReadingProfile, scalingOptions
|
||||||
} from "../../_models/preferences/reading-profiles";
|
} from "../../_models/preferences/reading-profiles";
|
||||||
import {translate, TranslocoDirective} from "@jsverse/transloco";
|
import {translate, TranslocoDirective} from "@jsverse/transloco";
|
||||||
import {Location, NgStyle, NgTemplateOutlet, TitleCasePipe} from "@angular/common";
|
import {NgStyle, NgTemplateOutlet, TitleCasePipe} from "@angular/common";
|
||||||
import {VirtualScrollerModule} from "@iharbeck/ngx-virtual-scroller";
|
import {VirtualScrollerModule} from "@iharbeck/ngx-virtual-scroller";
|
||||||
import {User} from "../../_models/user";
|
import {User} from "../../_models/user";
|
||||||
import {AccountService} from "../../_services/account.service";
|
import {AccountService} from "../../_services/account.service";
|
||||||
|
|
@ -44,6 +44,7 @@ import {
|
||||||
import {filter} from "rxjs";
|
import {filter} from "rxjs";
|
||||||
import {takeUntilDestroyed} from "@angular/core/rxjs-interop";
|
import {takeUntilDestroyed} from "@angular/core/rxjs-interop";
|
||||||
import {LoadingComponent} from "../../shared/loading/loading.component";
|
import {LoadingComponent} from "../../shared/loading/loading.component";
|
||||||
|
import {ReadingProfileLibrarySelectionComponent} from "./_components/library-selection/reading-profile-library-selection.component";
|
||||||
|
|
||||||
enum TabId {
|
enum TabId {
|
||||||
ImageReader = "image-reader",
|
ImageReader = "image-reader",
|
||||||
|
|
@ -82,7 +83,8 @@ enum TabId {
|
||||||
NgbNavLinkBase,
|
NgbNavLinkBase,
|
||||||
NgbNavContent,
|
NgbNavContent,
|
||||||
NgbNavOutlet,
|
NgbNavOutlet,
|
||||||
LoadingComponent
|
LoadingComponent,
|
||||||
|
ReadingProfileLibrarySelectionComponent
|
||||||
],
|
],
|
||||||
templateUrl: './manage-reading-profiles.component.html',
|
templateUrl: './manage-reading-profiles.component.html',
|
||||||
styleUrl: './manage-reading-profiles.component.scss',
|
styleUrl: './manage-reading-profiles.component.scss',
|
||||||
|
|
@ -149,6 +151,16 @@ export class ManageReadingProfilesComponent implements OnInit {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get widthOverwriteLabel() {
|
||||||
|
const rawVal = this.readingProfileForm?.get('widthOverride')!.value;
|
||||||
|
if (!rawVal) {
|
||||||
|
return translate('off');
|
||||||
|
}
|
||||||
|
|
||||||
|
const val = parseInt(rawVal);
|
||||||
|
return (val <= 0) ? '' : val + '%'
|
||||||
|
}
|
||||||
|
|
||||||
setupForm() {
|
setupForm() {
|
||||||
if (this.selectedProfile == null) {
|
if (this.selectedProfile == null) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -162,6 +174,9 @@ export class ManageReadingProfilesComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.readingProfileForm.addControl('name', new FormControl(this.selectedProfile.name, Validators.required));
|
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('readingDirection', new FormControl(this.selectedProfile.readingDirection, []));
|
||||||
this.readingProfileForm.addControl('scalingOption', new FormControl(this.selectedProfile.scalingOption, []));
|
this.readingProfileForm.addControl('scalingOption', new FormControl(this.selectedProfile.scalingOption, []));
|
||||||
this.readingProfileForm.addControl('pageSplitOption', new FormControl(this.selectedProfile.pageSplitOption, []));
|
this.readingProfileForm.addControl('pageSplitOption', new FormControl(this.selectedProfile.pageSplitOption, []));
|
||||||
|
|
@ -173,7 +188,9 @@ export class ManageReadingProfilesComponent implements OnInit {
|
||||||
this.readingProfileForm.addControl('swipeToPaginate', new FormControl(this.selectedProfile.swipeToPaginate, []));
|
this.readingProfileForm.addControl('swipeToPaginate', new FormControl(this.selectedProfile.swipeToPaginate, []));
|
||||||
this.readingProfileForm.addControl('backgroundColor', new FormControl(this.selectedProfile.backgroundColor, []));
|
this.readingProfileForm.addControl('backgroundColor', new FormControl(this.selectedProfile.backgroundColor, []));
|
||||||
this.readingProfileForm.addControl('allowAutomaticWebtoonReaderDetection', new FormControl(this.selectedProfile.allowAutomaticWebtoonReaderDetection, []));
|
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('bookReaderFontFamily', new FormControl(this.selectedProfile.bookReaderFontFamily, []));
|
||||||
this.readingProfileForm.addControl('bookReaderFontSize', new FormControl(this.selectedProfile.bookReaderFontSize, []));
|
this.readingProfileForm.addControl('bookReaderFontSize', new FormControl(this.selectedProfile.bookReaderFontSize, []));
|
||||||
this.readingProfileForm.addControl('bookReaderLineSpacing', new FormControl(this.selectedProfile.bookReaderLineSpacing, []));
|
this.readingProfileForm.addControl('bookReaderLineSpacing', new FormControl(this.selectedProfile.bookReaderLineSpacing, []));
|
||||||
|
|
@ -185,10 +202,12 @@ export class ManageReadingProfilesComponent implements OnInit {
|
||||||
this.readingProfileForm.addControl('bookReaderThemeName', new FormControl(this.selectedProfile.bookReaderThemeName || bookColorThemes[0].name, []));
|
this.readingProfileForm.addControl('bookReaderThemeName', new FormControl(this.selectedProfile.bookReaderThemeName || bookColorThemes[0].name, []));
|
||||||
this.readingProfileForm.addControl('bookReaderImmersiveMode', new FormControl(this.selectedProfile.bookReaderImmersiveMode, []));
|
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('pdfTheme', new FormControl(this.selectedProfile.pdfTheme || PdfTheme.Dark, []));
|
||||||
this.readingProfileForm.addControl('pdfScrollMode', new FormControl(this.selectedProfile.pdfScrollMode || PdfScrollMode.Vertical, []));
|
this.readingProfileForm.addControl('pdfScrollMode', new FormControl(this.selectedProfile.pdfScrollMode || PdfScrollMode.Vertical, []));
|
||||||
this.readingProfileForm.addControl('pdfSpreadMode', new FormControl(this.selectedProfile.pdfSpreadMode || PdfSpreadMode.None, []));
|
this.readingProfileForm.addControl('pdfSpreadMode', new FormControl(this.selectedProfile.pdfSpreadMode || PdfSpreadMode.None, []));
|
||||||
|
|
||||||
|
// Auto save
|
||||||
this.readingProfileForm.valueChanges.pipe(
|
this.readingProfileForm.valueChanges.pipe(
|
||||||
debounceTime(500),
|
debounceTime(500),
|
||||||
distinctUntilChanged(),
|
distinctUntilChanged(),
|
||||||
|
|
|
||||||
|
|
@ -2818,6 +2818,9 @@
|
||||||
"swipe-to-paginate-tooltip": "Should swiping on the screen cause the next or previous page to be triggered",
|
"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-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.",
|
"allow-auto-webtoon-reader-tooltip": "Switch into Webtoon Reader mode if pages look like a webtoon. Some false positives may occur.",
|
||||||
|
"width-overwrite": "Width overwrite",
|
||||||
|
"width-override-label": "Width overwrite",
|
||||||
|
"reset": "{{common.reset}}",
|
||||||
|
|
||||||
"book-reader-settings-title": "Book Reader",
|
"book-reader-settings-title": "Book Reader",
|
||||||
"tap-to-paginate-label": "Tap to Paginate",
|
"tap-to-paginate-label": "Tap to Paginate",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue