Entity & rough internal API outline
This commit is contained in:
parent
8ed2fa3829
commit
23c4a451b4
15 changed files with 4695 additions and 2 deletions
9
API/Controllers/ReadingProfileController.cs
Normal file
9
API/Controllers/ReadingProfileController.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
using API.Data;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace API.Controllers;
|
||||||
|
|
||||||
|
public class ReadingProfileController(ILogger<ReadingProfileController> logger, IUnitOfWork unitOfWork): BaseApiController
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
126
API/DTOs/UserReadingProfileDto.cs
Normal file
126
API/DTOs/UserReadingProfileDto.cs
Normal file
|
|
@ -0,0 +1,126 @@
|
||||||
|
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; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="AppUserReadingProfile.Implicit"/>
|
||||||
|
public bool Implicit { get; set; } = false;
|
||||||
|
|
||||||
|
#region MangaReader
|
||||||
|
|
||||||
|
/// <inheritdoc cref="API.Entities.AppUserReadingProfile.ReadingDirection"/>
|
||||||
|
[Required]
|
||||||
|
public ReadingDirection ReadingDirection { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="API.Entities.AppUserReadingProfile.ScalingOption"/>
|
||||||
|
[Required]
|
||||||
|
public ScalingOption ScalingOption { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="API.Entities.AppUserReadingProfile.PageSplitOption"/>
|
||||||
|
[Required]
|
||||||
|
public PageSplitOption PageSplitOption { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="API.Entities.AppUserReadingProfile.ReaderMode"/>
|
||||||
|
[Required]
|
||||||
|
public ReaderMode ReaderMode { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="API.Entities.AppUserReadingProfile.AutoCloseMenu"/>
|
||||||
|
[Required]
|
||||||
|
public bool AutoCloseMenu { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="API.Entities.AppUserReadingProfile.ShowScreenHints"/>
|
||||||
|
[Required]
|
||||||
|
public bool ShowScreenHints { get; set; } = true;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="API.Entities.AppUserReadingProfile.EmulateBook"/>
|
||||||
|
[Required]
|
||||||
|
public bool EmulateBook { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="API.Entities.AppUserReadingProfile.LayoutMode"/>
|
||||||
|
[Required]
|
||||||
|
public LayoutMode LayoutMode { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="API.Entities.AppUserReadingProfile.BackgroundColor"/>
|
||||||
|
[Required]
|
||||||
|
public string BackgroundColor { get; set; } = "#000000";
|
||||||
|
|
||||||
|
/// <inheritdoc cref="API.Entities.AppUserReadingProfile.SwipeToPaginate"/>
|
||||||
|
[Required]
|
||||||
|
public bool SwipeToPaginate { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="API.Entities.AppUserReadingProfile.AllowAutomaticWebtoonReaderDetection"/>
|
||||||
|
[Required]
|
||||||
|
public bool AllowAutomaticWebtoonReaderDetection { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region EpubReader
|
||||||
|
|
||||||
|
/// <inheritdoc cref="API.Entities.AppUserReadingProfile.BookReaderMargin"/>
|
||||||
|
[Required]
|
||||||
|
public int BookReaderMargin { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="API.Entities.AppUserReadingProfile.BookReaderLineSpacing"/>
|
||||||
|
[Required]
|
||||||
|
public int BookReaderLineSpacing { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="API.Entities.AppUserReadingProfile.BookReaderFontSize"/>
|
||||||
|
[Required]
|
||||||
|
public int BookReaderFontSize { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="API.Entities.AppUserReadingProfile.BookReaderFontFamily"/>
|
||||||
|
[Required]
|
||||||
|
public string BookReaderFontFamily { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="API.Entities.AppUserReadingProfile.BookReaderTapToPaginate"/>
|
||||||
|
[Required]
|
||||||
|
public bool BookReaderTapToPaginate { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="API.Entities.AppUserReadingProfile.BookReaderReadingDirection"/>
|
||||||
|
[Required]
|
||||||
|
public ReadingDirection BookReaderReadingDirection { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="API.Entities.AppUserReadingProfile.BookReaderWritingStyle"/>
|
||||||
|
[Required]
|
||||||
|
public WritingStyle BookReaderWritingStyle { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="AppUserReadingProfile.BookThemeName"/>
|
||||||
|
[Required]
|
||||||
|
public string BookReaderThemeName { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="API.Entities.AppUserReadingProfile.BookReaderLayoutMode"/>
|
||||||
|
[Required]
|
||||||
|
public BookPageLayoutMode BookReaderLayoutMode { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc cref="API.Entities.AppUserReadingProfile.BookReaderImmersiveMode"/>
|
||||||
|
[Required]
|
||||||
|
public bool BookReaderImmersiveMode { get; set; } = false;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region PdfReader
|
||||||
|
|
||||||
|
/// <inheritdoc cref="API.Entities.AppUserReadingProfile.PdfTheme"/>
|
||||||
|
[Required]
|
||||||
|
public PdfTheme PdfTheme { get; set; } = PdfTheme.Dark;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="API.Entities.AppUserReadingProfile.PdfScrollMode"/>
|
||||||
|
[Required]
|
||||||
|
public PdfScrollMode PdfScrollMode { get; set; } = PdfScrollMode.Vertical;
|
||||||
|
|
||||||
|
/// <inheritdoc cref="API.Entities.AppUserReadingProfile.PdfSpreadMode"/>
|
||||||
|
[Required]
|
||||||
|
public PdfSpreadMode PdfSpreadMode { get; set; } = PdfSpreadMode.None;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -81,6 +81,7 @@ public sealed class DataContext : IdentityDbContext<AppUser, AppRole, int,
|
||||||
public DbSet<MetadataSettings> MetadataSettings { get; set; } = null!;
|
public DbSet<MetadataSettings> MetadataSettings { get; set; } = null!;
|
||||||
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!;
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder builder)
|
protected override void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,90 @@
|
||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using API.Entities.History;
|
||||||
|
using Kavita.Common.EnvironmentInfo;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace API.Data.ManualMigrations.v0._8._7;
|
||||||
|
|
||||||
|
public class ManualMigrateReadingProfiles
|
||||||
|
{
|
||||||
|
public static async Task Migrate(DataContext context, ILogger<Program> 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");
|
||||||
|
|
||||||
|
await context.Database.ExecuteSqlRawAsync(@"
|
||||||
|
INSERT INTO AppUserReadingProfiles (
|
||||||
|
AppUserId,
|
||||||
|
ReadingDirection,
|
||||||
|
ScalingOption,
|
||||||
|
PageSplitOption,
|
||||||
|
ReaderMode,
|
||||||
|
AutoCloseMenu,
|
||||||
|
ShowScreenHints,
|
||||||
|
EmulateBook,
|
||||||
|
LayoutMode,
|
||||||
|
BackgroundColor,
|
||||||
|
SwipeToPaginate,
|
||||||
|
AllowAutomaticWebtoonReaderDetection,
|
||||||
|
BookReaderMargin,
|
||||||
|
BookReaderLineSpacing,
|
||||||
|
BookReaderFontSize,
|
||||||
|
BookReaderFontFamily,
|
||||||
|
BookReaderTapToPaginate,
|
||||||
|
BookReaderReadingDirection,
|
||||||
|
BookReaderWritingStyle,
|
||||||
|
BookThemeName,
|
||||||
|
BookReaderLayoutMode,
|
||||||
|
BookReaderImmersiveMode,
|
||||||
|
PdfTheme,
|
||||||
|
PdfScrollMode,
|
||||||
|
PdfSpreadMode
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
AppUserId,
|
||||||
|
ReadingDirection,
|
||||||
|
ScalingOption,
|
||||||
|
PageSplitOption,
|
||||||
|
ReaderMode,
|
||||||
|
AutoCloseMenu,
|
||||||
|
ShowScreenHints,
|
||||||
|
EmulateBook,
|
||||||
|
LayoutMode,
|
||||||
|
BackgroundColor,
|
||||||
|
SwipeToPaginate,
|
||||||
|
AllowAutomaticWebtoonReaderDetection,
|
||||||
|
BookReaderMargin,
|
||||||
|
BookReaderLineSpacing,
|
||||||
|
BookReaderFontSize,
|
||||||
|
BookReaderFontFamily,
|
||||||
|
BookReaderTapToPaginate,
|
||||||
|
BookReaderReadingDirection,
|
||||||
|
BookReaderWritingStyle,
|
||||||
|
BookThemeName,
|
||||||
|
BookReaderLayoutMode,
|
||||||
|
BookReaderImmersiveMode,
|
||||||
|
PdfTheme,
|
||||||
|
PdfScrollMode,
|
||||||
|
PdfSpreadMode
|
||||||
|
FROM AppUserPreferences
|
||||||
|
");
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
3753
API/Data/Migrations/20250514215429_AppUserReadingProfiles.Designer.cs
generated
Normal file
3753
API/Data/Migrations/20250514215429_AppUserReadingProfiles.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
157
API/Data/Migrations/20250514215429_AppUserReadingProfiles.cs
Normal file
157
API/Data/Migrations/20250514215429_AppUserReadingProfiles.cs
Normal file
|
|
@ -0,0 +1,157 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace API.Data.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AppUserReadingProfiles : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "DefaultReadingProfileId",
|
||||||
|
table: "AppUserPreferences",
|
||||||
|
type: "INTEGER",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "AppUserReadingProfile",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
UserId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
ReadingDirection = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
ScalingOption = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
PageSplitOption = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
ReaderMode = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
AutoCloseMenu = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||||
|
ShowScreenHints = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||||
|
EmulateBook = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||||
|
LayoutMode = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
BackgroundColor = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
SwipeToPaginate = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||||
|
AllowAutomaticWebtoonReaderDetection = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||||
|
WidthOverride = table.Column<int>(type: "INTEGER", nullable: true),
|
||||||
|
BookReaderMargin = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
BookReaderLineSpacing = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
BookReaderFontSize = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
BookReaderFontFamily = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
BookReaderTapToPaginate = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||||
|
BookReaderReadingDirection = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
BookReaderWritingStyle = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
BookThemeName = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
BookReaderLayoutMode = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
BookReaderImmersiveMode = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||||
|
PdfTheme = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
PdfScrollMode = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
PdfSpreadMode = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
Implicit = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||||
|
AppUserPreferencesId = table.Column<int>(type: "INTEGER", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_AppUserReadingProfile", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_AppUserReadingProfile_AppUserPreferences_AppUserPreferencesId",
|
||||||
|
column: x => x.AppUserPreferencesId,
|
||||||
|
principalTable: "AppUserPreferences",
|
||||||
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_AppUserReadingProfile_AspNetUsers_UserId",
|
||||||
|
column: x => x.UserId,
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "AppUserReadingProfileLibrary",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
LibrariesId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
ReadingProfilesId = table.Column<int>(type: "INTEGER", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_AppUserReadingProfileLibrary", x => new { x.LibrariesId, x.ReadingProfilesId });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_AppUserReadingProfileLibrary_AppUserReadingProfile_ReadingProfilesId",
|
||||||
|
column: x => x.ReadingProfilesId,
|
||||||
|
principalTable: "AppUserReadingProfile",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_AppUserReadingProfileLibrary_Library_LibrariesId",
|
||||||
|
column: x => x.LibrariesId,
|
||||||
|
principalTable: "Library",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "AppUserReadingProfileSeries",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
ReadingProfilesId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
|
SeriesId = table.Column<int>(type: "INTEGER", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_AppUserReadingProfileSeries", x => new { x.ReadingProfilesId, x.SeriesId });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_AppUserReadingProfileSeries_AppUserReadingProfile_ReadingProfilesId",
|
||||||
|
column: x => x.ReadingProfilesId,
|
||||||
|
principalTable: "AppUserReadingProfile",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_AppUserReadingProfileSeries_Series_SeriesId",
|
||||||
|
column: x => x.SeriesId,
|
||||||
|
principalTable: "Series",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_AppUserReadingProfile_AppUserPreferencesId",
|
||||||
|
table: "AppUserReadingProfile",
|
||||||
|
column: "AppUserPreferencesId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_AppUserReadingProfile_UserId",
|
||||||
|
table: "AppUserReadingProfile",
|
||||||
|
column: "UserId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_AppUserReadingProfileLibrary_ReadingProfilesId",
|
||||||
|
table: "AppUserReadingProfileLibrary",
|
||||||
|
column: "ReadingProfilesId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_AppUserReadingProfileSeries_SeriesId",
|
||||||
|
table: "AppUserReadingProfileSeries",
|
||||||
|
column: "SeriesId");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "AppUserReadingProfileLibrary");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "AppUserReadingProfileSeries");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "AppUserReadingProfile");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "DefaultReadingProfileId",
|
||||||
|
table: "AppUserPreferences");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -455,6 +455,9 @@ namespace API.Data.Migrations
|
||||||
b.Property<bool>("CollapseSeriesRelationships")
|
b.Property<bool>("CollapseSeriesRelationships")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("DefaultReadingProfileId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<bool>("EmulateBook")
|
b.Property<bool>("EmulateBook")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
|
@ -609,6 +612,105 @@ namespace API.Data.Migrations
|
||||||
b.ToTable("AppUserRating");
|
b.ToTable("AppUserRating");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("API.Entities.AppUserReadingProfile", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<bool>("AllowAutomaticWebtoonReaderDetection")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int?>("AppUserPreferencesId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<bool>("AutoCloseMenu")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("BackgroundColor")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("BookReaderFontFamily")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("BookReaderFontSize")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<bool>("BookReaderImmersiveMode")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("BookReaderLayoutMode")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("BookReaderLineSpacing")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("BookReaderMargin")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("BookReaderReadingDirection")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<bool>("BookReaderTapToPaginate")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("BookReaderWritingStyle")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("BookThemeName")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<bool>("EmulateBook")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<bool>("Implicit")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("LayoutMode")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("PageSplitOption")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("PdfScrollMode")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("PdfSpreadMode")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("PdfTheme")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("ReaderMode")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("ReadingDirection")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("ScalingOption")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<bool>("ShowScreenHints")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<bool>("SwipeToPaginate")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int>("UserId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<int?>("WidthOverride")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AppUserPreferencesId");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("AppUserReadingProfile");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Entities.AppUserRole", b =>
|
modelBuilder.Entity("API.Entities.AppUserRole", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("UserId")
|
b.Property<int>("UserId")
|
||||||
|
|
@ -2479,6 +2581,36 @@ 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")
|
||||||
|
|
@ -2838,6 +2970,21 @@ namespace API.Data.Migrations
|
||||||
b.Navigation("Series");
|
b.Navigation("Series");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("API.Entities.AppUserReadingProfile", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("API.Entities.AppUserPreferences", null)
|
||||||
|
.WithMany("ReadingProfiles")
|
||||||
|
.HasForeignKey("AppUserPreferencesId");
|
||||||
|
|
||||||
|
b.HasOne("API.Entities.AppUser", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Entities.AppUserRole", b =>
|
modelBuilder.Entity("API.Entities.AppUserRole", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("API.Entities.AppRole", "Role")
|
b.HasOne("API.Entities.AppRole", "Role")
|
||||||
|
|
@ -3295,6 +3442,36 @@ 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)
|
||||||
|
|
@ -3491,6 +3668,11 @@ namespace API.Data.Migrations
|
||||||
b.Navigation("WantToRead");
|
b.Navigation("WantToRead");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("API.Entities.AppUserPreferences", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("ReadingProfiles");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Entities.Chapter", b =>
|
modelBuilder.Entity("API.Entities.Chapter", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("ExternalRatings");
|
b.Navigation("ExternalRatings");
|
||||||
|
|
|
||||||
68
API/Data/Repositories/AppUserReadingProfileRepository.cs
Normal file
68
API/Data/Repositories/AppUserReadingProfileRepository.cs
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
#nullable enable
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using API.Entities;
|
||||||
|
using AutoMapper;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace API.Data.Repositories;
|
||||||
|
|
||||||
|
public interface IAppUserReadingProfileRepository
|
||||||
|
{
|
||||||
|
Task<IList<AppUserReadingProfile>> GetProfilesForUser(int userId);
|
||||||
|
Task<AppUserReadingProfile?> GetProfileForSeries(int userId, int seriesId);
|
||||||
|
Task<AppUserReadingProfile?> GetProfileForLibrary(int userId, int libraryId);
|
||||||
|
Task<AppUserReadingProfile?> GetProfile(int profileId);
|
||||||
|
|
||||||
|
void Add(AppUserReadingProfile readingProfile);
|
||||||
|
void Update(AppUserReadingProfile readingProfile);
|
||||||
|
void Remove(AppUserReadingProfile readingProfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AppUserReadingProfileRepository(DataContext context, IMapper mapper): IAppUserReadingProfileRepository
|
||||||
|
{
|
||||||
|
|
||||||
|
public async Task<IList<AppUserReadingProfile>> GetProfilesForUser(int userId)
|
||||||
|
{
|
||||||
|
return await context.AppUserReadingProfile
|
||||||
|
.Where(rp => rp.UserId == userId)
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<AppUserReadingProfile?> GetProfileForSeries(int userId, int seriesId)
|
||||||
|
{
|
||||||
|
return await context.AppUserReadingProfile
|
||||||
|
.Where(rp => rp.UserId == userId && rp.Series.Any(s => s.Id == seriesId))
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<AppUserReadingProfile?> GetProfileForLibrary(int userId, int libraryId)
|
||||||
|
{
|
||||||
|
return await context.AppUserReadingProfile
|
||||||
|
.Where(rp => rp.UserId == userId && rp.Libraries.Any(s => s.Id == libraryId))
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<AppUserReadingProfile?> GetProfile(int profileId)
|
||||||
|
{
|
||||||
|
return await context.AppUserReadingProfile
|
||||||
|
.Where(rp => rp.Id == profileId)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add(AppUserReadingProfile readingProfile)
|
||||||
|
{
|
||||||
|
context.AppUserReadingProfile.Add(readingProfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(AppUserReadingProfile readingProfile)
|
||||||
|
{
|
||||||
|
context.AppUserReadingProfile.Update(readingProfile).State = EntityState.Modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Remove(AppUserReadingProfile readingProfile)
|
||||||
|
{
|
||||||
|
context.AppUserReadingProfile.Remove(readingProfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -33,6 +33,7 @@ public interface IUnitOfWork
|
||||||
IAppUserExternalSourceRepository AppUserExternalSourceRepository { get; }
|
IAppUserExternalSourceRepository AppUserExternalSourceRepository { get; }
|
||||||
IExternalSeriesMetadataRepository ExternalSeriesMetadataRepository { get; }
|
IExternalSeriesMetadataRepository ExternalSeriesMetadataRepository { get; }
|
||||||
IEmailHistoryRepository EmailHistoryRepository { get; }
|
IEmailHistoryRepository EmailHistoryRepository { get; }
|
||||||
|
IAppUserReadingProfileRepository AppUserReadingProfileRepository { get; }
|
||||||
bool Commit();
|
bool Commit();
|
||||||
Task<bool> CommitAsync();
|
Task<bool> CommitAsync();
|
||||||
bool HasChanges();
|
bool HasChanges();
|
||||||
|
|
@ -74,6 +75,7 @@ public class UnitOfWork : IUnitOfWork
|
||||||
AppUserExternalSourceRepository = new AppUserExternalSourceRepository(_context, _mapper);
|
AppUserExternalSourceRepository = new AppUserExternalSourceRepository(_context, _mapper);
|
||||||
ExternalSeriesMetadataRepository = new ExternalSeriesMetadataRepository(_context, _mapper);
|
ExternalSeriesMetadataRepository = new ExternalSeriesMetadataRepository(_context, _mapper);
|
||||||
EmailHistoryRepository = new EmailHistoryRepository(_context, _mapper);
|
EmailHistoryRepository = new EmailHistoryRepository(_context, _mapper);
|
||||||
|
AppUserReadingProfileRepository = new AppUserReadingProfileRepository(_context, _mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -103,6 +105,7 @@ public class UnitOfWork : IUnitOfWork
|
||||||
public IAppUserExternalSourceRepository AppUserExternalSourceRepository { get; }
|
public IAppUserExternalSourceRepository AppUserExternalSourceRepository { get; }
|
||||||
public IExternalSeriesMetadataRepository ExternalSeriesMetadataRepository { get; }
|
public IExternalSeriesMetadataRepository ExternalSeriesMetadataRepository { get; }
|
||||||
public IEmailHistoryRepository EmailHistoryRepository { get; }
|
public IEmailHistoryRepository EmailHistoryRepository { get; }
|
||||||
|
public IAppUserReadingProfileRepository AppUserReadingProfileRepository { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Commits changes to the DB. Completes the open transaction.
|
/// Commits changes to the DB. Completes the open transaction.
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using API.Data;
|
using System.Collections.Generic;
|
||||||
|
using API.Data;
|
||||||
using API.Entities.Enums;
|
using API.Entities.Enums;
|
||||||
using API.Entities.Enums.UserPreferences;
|
using API.Entities.Enums.UserPreferences;
|
||||||
|
|
||||||
|
|
@ -8,6 +9,14 @@ public class AppUserPreferences
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
#region ReadingProfiles
|
||||||
|
|
||||||
|
public int DefaultReadingProfileId { get; set; }
|
||||||
|
|
||||||
|
public ICollection<AppUserReadingProfile> ReadingProfiles { get; set; } = null!;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region MangaReader
|
#region MangaReader
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
145
API/Entities/AppUserReadingProfile.cs
Normal file
145
API/Entities/AppUserReadingProfile.cs
Normal file
|
|
@ -0,0 +1,145 @@
|
||||||
|
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 int UserId { get; set; }
|
||||||
|
public AppUser User { get; set; }
|
||||||
|
|
||||||
|
public ICollection<Series> Series { get; set; }
|
||||||
|
public ICollection<Library> Libraries { get; set; }
|
||||||
|
|
||||||
|
#region MangaReader
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Manga Reader Option: What direction should the next/prev page buttons go
|
||||||
|
/// </summary>
|
||||||
|
public ReadingDirection ReadingDirection { get; set; } = ReadingDirection.LeftToRight;
|
||||||
|
/// <summary>
|
||||||
|
/// Manga Reader Option: How should the image be scaled to screen
|
||||||
|
/// </summary>
|
||||||
|
public ScalingOption ScalingOption { get; set; } = ScalingOption.Automatic;
|
||||||
|
/// <summary>
|
||||||
|
/// Manga Reader Option: Which side of a split image should we show first
|
||||||
|
/// </summary>
|
||||||
|
public PageSplitOption PageSplitOption { get; set; } = PageSplitOption.FitSplit;
|
||||||
|
/// <summary>
|
||||||
|
/// Manga Reader Option: How the manga reader should perform paging or reading of the file
|
||||||
|
/// <example>
|
||||||
|
/// 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.
|
||||||
|
/// </example>
|
||||||
|
/// </summary>
|
||||||
|
public ReaderMode ReaderMode { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Manga Reader Option: Allow the menu to close after 6 seconds without interaction
|
||||||
|
/// </summary>
|
||||||
|
public bool AutoCloseMenu { get; set; } = true;
|
||||||
|
/// <summary>
|
||||||
|
/// Manga Reader Option: Show screen hints to the user on some actions, ie) pagination direction change
|
||||||
|
/// </summary>
|
||||||
|
public bool ShowScreenHints { get; set; } = true;
|
||||||
|
/// <summary>
|
||||||
|
/// Manga Reader Option: Emulate a book by applying a shadow effect on the pages
|
||||||
|
/// </summary>
|
||||||
|
public bool EmulateBook { get; set; } = false;
|
||||||
|
/// <summary>
|
||||||
|
/// Manga Reader Option: How many pages to display in the reader at once
|
||||||
|
/// </summary>
|
||||||
|
public LayoutMode LayoutMode { get; set; } = LayoutMode.Single;
|
||||||
|
/// <summary>
|
||||||
|
/// Manga Reader Option: Background color of the reader
|
||||||
|
/// </summary>
|
||||||
|
public string BackgroundColor { get; set; } = "#000000";
|
||||||
|
/// <summary>
|
||||||
|
/// Manga Reader Option: Should swiping trigger pagination
|
||||||
|
/// </summary>
|
||||||
|
public bool SwipeToPaginate { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Manga Reader Option: Allow Automatic Webtoon detection
|
||||||
|
/// </summary>
|
||||||
|
public bool AllowAutomaticWebtoonReaderDetection { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Manga Reader Option: Optional fixed width override
|
||||||
|
/// </summary>
|
||||||
|
public int? WidthOverride { get; set; } = null;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region EpubReader
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Book Reader Option: Override extra Margin
|
||||||
|
/// </summary>
|
||||||
|
public int BookReaderMargin { get; set; } = 15;
|
||||||
|
/// <summary>
|
||||||
|
/// Book Reader Option: Override line-height
|
||||||
|
/// </summary>
|
||||||
|
public int BookReaderLineSpacing { get; set; } = 100;
|
||||||
|
/// <summary>
|
||||||
|
/// Book Reader Option: Override font size
|
||||||
|
/// </summary>
|
||||||
|
public int BookReaderFontSize { get; set; } = 100;
|
||||||
|
/// <summary>
|
||||||
|
/// Book Reader Option: Maps to the default Kavita font-family (inherit) or an override
|
||||||
|
/// </summary>
|
||||||
|
public string BookReaderFontFamily { get; set; } = "default";
|
||||||
|
/// <summary>
|
||||||
|
/// Book Reader Option: Allows tapping on side of screens to paginate
|
||||||
|
/// </summary>
|
||||||
|
public bool BookReaderTapToPaginate { get; set; } = false;
|
||||||
|
/// <summary>
|
||||||
|
/// Book Reader Option: What direction should the next/prev page buttons go
|
||||||
|
/// </summary>
|
||||||
|
public ReadingDirection BookReaderReadingDirection { get; set; } = ReadingDirection.LeftToRight;
|
||||||
|
/// <summary>
|
||||||
|
/// Book Reader Option: Defines the writing styles vertical/horizontal
|
||||||
|
/// </summary>
|
||||||
|
public WritingStyle BookReaderWritingStyle { get; set; } = WritingStyle.Horizontal;
|
||||||
|
/// <summary>
|
||||||
|
/// Book Reader Option: The color theme to decorate the book contents
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>Should default to Dark</remarks>
|
||||||
|
public string BookThemeName { get; set; } = "Dark";
|
||||||
|
/// <summary>
|
||||||
|
/// 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
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>Defaults to Default</remarks>
|
||||||
|
public BookPageLayoutMode BookReaderLayoutMode { get; set; } = BookPageLayoutMode.Default;
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>Defaults to false</remarks>
|
||||||
|
public bool BookReaderImmersiveMode { get; set; } = false;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region PdfReader
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PDF Reader: Theme of the Reader
|
||||||
|
/// </summary>
|
||||||
|
public PdfTheme PdfTheme { get; set; } = PdfTheme.Dark;
|
||||||
|
/// <summary>
|
||||||
|
/// PDF Reader: Scroll mode of the reader
|
||||||
|
/// </summary>
|
||||||
|
public PdfScrollMode PdfScrollMode { get; set; } = PdfScrollMode.Vertical;
|
||||||
|
/// <summary>
|
||||||
|
/// PDF Reader: Spread Mode of the reader
|
||||||
|
/// </summary>
|
||||||
|
public PdfSpreadMode PdfSpreadMode { get; set; } = PdfSpreadMode.None;
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If the profile has been created in the background after a user modified a series settings
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>A profile can be made non-implicit by a user, but not implicit</remarks>
|
||||||
|
public bool Implicit { get; set; } = false;
|
||||||
|
}
|
||||||
|
|
@ -65,6 +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 void UpdateLastModified()
|
public void UpdateLastModified()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -135,6 +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 void UpdateLastFolderScanned()
|
public void UpdateLastFolderScanned()
|
||||||
|
|
|
||||||
148
API/Services/ReadingProfileService.cs
Normal file
148
API/Services/ReadingProfileService.cs
Normal file
|
|
@ -0,0 +1,148 @@
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using API.Data;
|
||||||
|
using API.DTOs;
|
||||||
|
using API.Entities;
|
||||||
|
|
||||||
|
namespace API.Services;
|
||||||
|
|
||||||
|
public interface IReadingProfileService
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the ReadingProfile that should be applied to the given series, walks up the tree.
|
||||||
|
/// Series -> Library -> Default
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId"></param>
|
||||||
|
/// <param name="series"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<AppUserReadingProfile> GetReadingProfileForSeries(int userId, Series series);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates, or adds a specific reading profile for a user
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId"></param>
|
||||||
|
/// <param name="dto"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<bool> UpdateReadingProfile(int userId, UserReadingProfileDto dto);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates, or adds a specific reading profile for a user for a specific series.
|
||||||
|
/// If the reading profile is not assigned to the given series (Library, Default fallback),
|
||||||
|
/// a new implicit reading profile is created
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId"></param>
|
||||||
|
/// <param name="seriesId"></param>
|
||||||
|
/// <param name="dto"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<bool> UpdateReadingProfileForSeries(int userId, int seriesId, UserReadingProfileDto dto);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes the implicit reading profile for a given series, if it exists
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId"></param>
|
||||||
|
/// <param name="seriesId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task DeleteImplicitForSeries(int userId, int seriesId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ReadingProfileService(IUnitOfWork unitOfWork): IReadingProfileService
|
||||||
|
{
|
||||||
|
|
||||||
|
public async Task<AppUserReadingProfile> GetReadingProfileForSeries(int userId, Series series)
|
||||||
|
{
|
||||||
|
var seriesProfile = await unitOfWork.AppUserReadingProfileRepository.GetProfileForSeries(userId, series.Id);
|
||||||
|
if (seriesProfile != null) return seriesProfile;
|
||||||
|
|
||||||
|
var libraryProfile = await unitOfWork.AppUserReadingProfileRepository.GetProfileForLibrary(userId, series.Id);
|
||||||
|
if (libraryProfile != null) return libraryProfile;
|
||||||
|
|
||||||
|
var user = await unitOfWork.UserRepository.GetUserByIdAsync(userId);
|
||||||
|
if (user == null) throw new UnauthorizedAccessException();
|
||||||
|
|
||||||
|
return await unitOfWork.AppUserReadingProfileRepository.GetProfile(user.UserPreferences.DefaultReadingProfileId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> UpdateReadingProfile(int userId, UserReadingProfileDto dto)
|
||||||
|
{
|
||||||
|
var existingProfile = await unitOfWork.AppUserReadingProfileRepository.GetProfile(dto.Id);
|
||||||
|
if (existingProfile == null)
|
||||||
|
{
|
||||||
|
existingProfile = new AppUserReadingProfile
|
||||||
|
{
|
||||||
|
UserId = userId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (existingProfile.UserId != userId) return false;
|
||||||
|
|
||||||
|
UpdateReaderProfileFields(existingProfile, dto);
|
||||||
|
unitOfWork.AppUserReadingProfileRepository.Update(existingProfile);
|
||||||
|
return await unitOfWork.CommitAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> UpdateReadingProfileForSeries(int userId, int seriesId, UserReadingProfileDto dto)
|
||||||
|
{
|
||||||
|
var existingProfile = await unitOfWork.AppUserReadingProfileRepository.GetProfile(dto.Id);
|
||||||
|
|
||||||
|
if (existingProfile == null || existingProfile.Series.All(s => s.Id != seriesId))
|
||||||
|
{
|
||||||
|
existingProfile = new AppUserReadingProfile
|
||||||
|
{
|
||||||
|
Implicit = true,
|
||||||
|
UserId = userId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (existingProfile.UserId != userId) return false;
|
||||||
|
|
||||||
|
UpdateReaderProfileFields(existingProfile, dto);
|
||||||
|
unitOfWork.AppUserReadingProfileRepository.Update(existingProfile);
|
||||||
|
return await unitOfWork.CommitAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteImplicitForSeries(int userId, int seriesId)
|
||||||
|
{
|
||||||
|
var profile = await unitOfWork.AppUserReadingProfileRepository.GetProfileForSeries(userId, seriesId);
|
||||||
|
if (profile == null) return;
|
||||||
|
|
||||||
|
if (!profile.Implicit) return;
|
||||||
|
|
||||||
|
unitOfWork.AppUserReadingProfileRepository.Remove(profile);
|
||||||
|
await unitOfWork.CommitAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void UpdateReaderProfileFields(AppUserReadingProfile existingProfile, UserReadingProfileDto dto)
|
||||||
|
{
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
// EpubReading
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -17,7 +17,7 @@ public static class Configuration
|
||||||
private static readonly string AppSettingsFilename = Path.Join("config", GetAppSettingFilename());
|
private static readonly string AppSettingsFilename = Path.Join("config", GetAppSettingFilename());
|
||||||
|
|
||||||
public static readonly string KavitaPlusApiUrl = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == Environments.Development
|
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 readonly string StatsApiUrl = "https://stats.kavitareader.com";
|
||||||
|
|
||||||
public static int Port
|
public static int Port
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue