Skip to content

Kavita is a fast, feature rich, cross platform reading server. Built with the goal of being a full solution for all your reading needs. Setup your own server and share your reading collection with your friends and family.

Automatic Collection Creation (#1768)

Joe Milazzo1da27f085c64
diff --git a/API.Tests/AbstractDbTest.cs b/API.Tests/AbstractDbTest.cs
index 6f59b55e9..1a9926345 100644
--- a/API.Tests/AbstractDbTest.cs
+++ b/API.Tests/AbstractDbTest.cs
@@ -56,7 +56,7 @@ public abstract class AbstractDbTest
return connection;
}
- protected async Task<bool> SeedDb()
+ private async Task<bool> SeedDb()
{
await _context.Database.MigrateAsync();
var filesystem = CreateFileSystem();
@@ -86,7 +86,8 @@ public abstract class AbstractDbTest
{
Path = "C:/data/"
}
- }
+ },
+ Series = new List<Series>()
});
return await _context.SaveChangesAsync() > 0;
}
diff --git a/API.Tests/Helpers/EntityFactory.cs b/API.Tests/Helpers/EntityFactory.cs
index 2f46cc1f4..06fbc35bd 100644
--- a/API.Tests/Helpers/EntityFactory.cs
+++ b/API.Tests/Helpers/EntityFactory.cs
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
+using API.Data;
using API.Entities;
using API.Entities.Enums;
using API.Entities.Metadata;
@@ -70,13 +71,6 @@ public static class EntityFactory
public static CollectionTag CreateCollectionTag(int id, string title, string summary, bool promoted)
{
- return new CollectionTag()
- {
- Id = id,
- NormalizedTitle = API.Services.Tasks.Scanner.Parser.Parser.Normalize(title).ToUpper(),
- Title = title,
- Summary = summary,
- Promoted = promoted
- };
+ return DbFactory.CollectionTag(id, title, summary, promoted);
}
}
diff --git a/API.Tests/Services/CollectionTagServiceTests.cs b/API.Tests/Services/CollectionTagServiceTests.cs
new file mode 100644
index 000000000..150e8d02b
--- /dev/null
+++ b/API.Tests/Services/CollectionTagServiceTests.cs
@@ -0,0 +1,113 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using API.Data;
+using API.DTOs.CollectionTags;
+using API.Entities;
+using API.Entities.Enums;
+using API.Services;
+using API.Services.Tasks.Metadata;
+using API.SignalR;
+using API.Tests.Helpers;
+using Microsoft.Extensions.Logging;
+using NSubstitute;
+using Xunit;
+
+namespace API.Tests.Services;
+
+public class CollectionTagServiceTests : AbstractDbTest
+{
+ private readonly ICollectionTagService _service;
+ public CollectionTagServiceTests()
+ {
+ _service = new CollectionTagService(_unitOfWork, Substitute.For<IEventHub>());
+ }
+
+ protected override async Task ResetDb()
+ {
+ _context.CollectionTag.RemoveRange(_context.CollectionTag.ToList());
+ _context.Library.RemoveRange(_context.Library.ToList());
+
+ await _unitOfWork.CommitAsync();
+ }
+
+ private async Task SeedSeries()
+ {
+ if (_context.CollectionTag.Any()) return;
+ _context.Library.Add(new Library()
+ {
+ Name = "Library 2",
+ Type = LibraryType.Manga,
+ Series = new List<Series>()
+ {
+ EntityFactory.CreateSeries("Series 1"),
+ EntityFactory.CreateSeries("Series 2"),
+ }
+ });
+
+ _context.CollectionTag.Add(DbFactory.CollectionTag(0, "Tag 1", string.Empty, false));
+ _context.CollectionTag.Add(DbFactory.CollectionTag(0, "Tag 2", string.Empty, true));
+ await _unitOfWork.CommitAsync();
+ }
+
+
+ [Fact]
+ public async Task TagExistsByName_ShouldFindTag()
+ {
+ await SeedSeries();
+ Assert.True(await _service.TagExistsByName("Tag 1"));
+ Assert.True(await _service.TagExistsByName("tag 1"));
+ Assert.False(await _service.TagExistsByName("tag5"));
+ }
+
+ [Fact]
+ public async Task UpdateTag_ShouldUpdateFields()
+ {
+ await SeedSeries();
+ _context.CollectionTag.Add(EntityFactory.CreateCollectionTag(3, "UpdateTag_ShouldUpdateFields",
+ string.Empty, true));
+ await _unitOfWork.CommitAsync();
+
+ await _service.UpdateTag(new CollectionTagDto()
+ {
+ Title = "UpdateTag_ShouldUpdateFields",
+ Id = 3,
+ Promoted = true,
+ Summary = "Test Summary",
+ });
+
+ var tag = await _unitOfWork.CollectionTagRepository.GetTagAsync(3);
+ Assert.NotNull(tag);
+ Assert.True(tag.Promoted);
+ Assert.True(!string.IsNullOrEmpty(tag.Summary));
+ }
+
+ [Fact]
+ public async Task AddTagToSeries_ShouldAddTagToAllSeries()
+ {
+ await SeedSeries();
+ var ids = new[] {1, 2};
+ await _service.AddTagToSeries(await _unitOfWork.CollectionTagRepository.GetFullTagAsync(1), ids);
+
+ var metadatas = await _unitOfWork.SeriesRepository.GetSeriesMetadataForIdsAsync(ids);
+ Assert.True(metadatas.ElementAt(0).CollectionTags.Any(t => t.Title.Equals("Tag 1")));
+ Assert.True(metadatas.ElementAt(1).CollectionTags.Any(t => t.Title.Equals("Tag 1")));
+ }
+
+ [Fact]
+ public async Task RemoveTagFromSeries_ShouldRemoveMultiple()
+ {
+ await SeedSeries();
+ var ids = new[] {1, 2};
+ var tag = await _unitOfWork.CollectionTagRepository.GetFullTagAsync(2);
+ await _service.AddTagToSeries(tag, ids);
+
+ await _service.RemoveTagFromSeries(tag, new[] {1});
+
+ var metadatas = await _unitOfWork.SeriesRepository.GetSeriesMetadataForIdsAsync(new[] {1});
+
+ Assert.Single(metadatas);
+ Assert.Empty(metadatas.First().CollectionTags);
+ Assert.NotEmpty(await _unitOfWork.SeriesRepository.GetSeriesMetadataForIdsAsync(new[] {2}));
+ }
+}
diff --git a/API.Tests/Services/DeviceServiceTests.cs b/API.Tests/Services/DeviceServiceTests.cs
index 5e3b65522..78ec8cfd2 100644
--- a/API.Tests/Services/DeviceServiceTests.cs
+++ b/API.Tests/Services/DeviceServiceTests.cs
@@ -51,7 +51,6 @@ public class DeviceServiceDbTests : AbstractDbTest
}, user);
Assert.NotNull(device);
-
}
[Fact]
diff --git a/API/Controllers/CollectionController.cs b/API/Controllers/CollectionController.cs
index eaec15b0f..cd9402fe7 100644
--- a/API/Controllers/CollectionController.cs
+++ b/API/Controllers/CollectionController.cs
@@ -6,7 +6,10 @@ using API.Data;
using API.DTOs.CollectionTags;
using API.Entities.Metadata;
using API.Extensions;
+using API.Services;
+using API.Services.Tasks.Metadata;
using API.SignalR;
+using Kavita.Common;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -18,13 +21,13 @@ namespace API.Controllers;
public class CollectionController : BaseApiController
{
private readonly IUnitOfWork _unitOfWork;
- private readonly IEventHub _eventHub;
+ private readonly ICollectionTagService _collectionService;
/// <inheritdoc />
- public CollectionController(IUnitOfWork unitOfWork, IEventHub eventHub)
+ public CollectionController(IUnitOfWork unitOfWork, ICollectionTagService collectionService)
{
_unitOfWork = unitOfWork;
- _eventHub = eventHub;
+ _collectionService = collectionService;
}
/// <summary>
@@ -71,8 +74,7 @@ public class CollectionController : BaseApiController
[HttpGet("name-exists")]
public async Task<ActionResult<bool>> DoesNameExists(string name)
{
- if (string.IsNullOrEmpty(name.Trim())) return Ok(true);
- return Ok(await _unitOfWork.CollectionTagRepository.TagExists(name));
+ return Ok(await _collectionService.TagExistsByName(name));
}
/// <summary>
@@ -85,28 +87,13 @@ public class CollectionController : BaseApiController
[HttpPost("update")]
public async Task<ActionResult> UpdateTag(CollectionTagDto updatedTag)
{
- var existingTag = await _unitOfWork.CollectionTagRepository.GetTagAsync(updatedTag.Id);
- if (existingTag == null) return BadRequest("This tag does not exist");
- var title = updatedTag.Title.Trim();
- if (string.IsNullOrEmpty(title)) return BadRequest("Title cannot be empty");
- if (!title.Equals(existingTag.Title) && await _unitOfWork.CollectionTagRepository.TagExists(updatedTag.Title))
- return BadRequest("A tag with this name already exists");
-
- existingTag.Title = title;
- existingTag.Promoted = updatedTag.Promoted;
- existingTag.NormalizedTitle = Services.Tasks.Scanner.Parser.Parser.Normalize(updatedTag.Title);
- existingTag.Summary = updatedTag.Summary.Trim();
-
- if (_unitOfWork.HasChanges())
+ try
{
- if (await _unitOfWork.CommitAsync())
- {
- return Ok("Tag updated successfully");
- }
+ if (await _collectionService.UpdateTag(updatedTag)) return Ok("Tag updated successfully");
}
- else
+ catch (KavitaException ex)
{
- return Ok("Tag updated successfully");
+ return BadRequest(ex.Message);
}
return BadRequest("Something went wrong, please try again");
@@ -121,29 +108,11 @@ public class CollectionController : BaseApiController
[HttpPost("update-for-series")]
public async Task<ActionResult> AddToMultipleSeries(CollectionTagBulkAddDto dto)
{
- var tag = await _unitOfWork.CollectionTagRepository.GetFullTagAsync(dto.CollectionTagId);
- if (tag == null)
- {
- tag = DbFactory.CollectionTag(0, dto.CollectionTagTitle, String.Empty, false);
- _unitOfWork.CollectionTagRepository.Add(tag);
- }
-
+ // Create a new tag and save
+ var tag = await _collectionService.GetTagOrCreate(dto.CollectionTagId, dto.CollectionTagTitle);
- var seriesMetadatas = await _unitOfWork.SeriesRepository.GetSeriesMetadataForIdsAsync(dto.SeriesIds);
- foreach (var metadata in seriesMetadatas)
- {
- if (!metadata.CollectionTags.Any(t => t.Title.Equals(tag.Title, StringComparison.InvariantCulture)))
- {
- metadata.CollectionTags.Add(tag);
- _unitOfWork.SeriesMetadataRepository.Update(metadata);
- }
- }
+ if (await _collectionService.AddTagToSeries(tag, dto.SeriesIds)) return Ok();
- if (!_unitOfWork.HasChanges()) return Ok();
- if (await _unitOfWork.CommitAsync())
- {
- return Ok();
- }
return BadRequest("There was an issue updating series with collection tag");
}
@@ -154,7 +123,7 @@ public class CollectionController : BaseApiController
/// <returns></returns>
[Authorize(Policy = "RequireAdminRole")]
[HttpPost("update-series")]
- public async Task<ActionResult> UpdateSeriesForTag(UpdateSeriesForTagDto updateSeriesForTagDto)
+ public async Task<ActionResult> RemoveTagFromMultipleSeries(UpdateSeriesForTagDto updateSeriesForTagDto)
{
try
{
@@ -162,41 +131,8 @@ public class CollectionController : BaseApiController
if (tag == null) return BadRequest("Not a valid Tag");
tag.SeriesMetadatas ??= new List<SeriesMetadata>();
- // Check if Tag has updated (Summary)
- if (tag.Summary == null || !tag.Summary.Equals(updateSeriesForTagDto.Tag.Summary))
- {
- tag.Summary = updateSeriesForTagDto.Tag.Summary;
- _unitOfWork.CollectionTagRepository.Update(tag);
- }
-
- tag.CoverImageLocked = updateSeriesForTagDto.Tag.CoverImageLocked;
-
- if (!updateSeriesForTagDto.Tag.CoverImageLocked)
- {
- tag.CoverImageLocked = false;
- tag.CoverImage = string.Empty;
- await _eventHub.SendMessageAsync(MessageFactory.CoverUpdate,
- MessageFactory.CoverUpdateEvent(tag.Id, MessageFactoryEntityTypes.CollectionTag), false);
- _unitOfWork.CollectionTagRepository.Update(tag);
- }
-
- foreach (var seriesIdToRemove in updateSeriesForTagDto.SeriesIdsToRemove)
- {
- tag.SeriesMetadatas.Remove(tag.SeriesMetadatas.Single(sm => sm.SeriesId == seriesIdToRemove));
- }
-
-
- if (tag.SeriesMetadatas.Count == 0)
- {
- _unitOfWork.CollectionTagRepository.Remove(tag);
- }
-
- if (!_unitOfWork.HasChanges()) return Ok("No updates");
-
- if (await _unitOfWork.CommitAsync())
- {
+ if (await _collectionService.RemoveTagFromSeries(tag, updateSeriesForTagDto.SeriesIdsToRemove))
return Ok("Tag updated");
- }
}
catch (Exception)
{
diff --git a/API/Controllers/LibraryController.cs b/API/Controllers/LibraryController.cs
index b8655322f..316431c6d 100644
--- a/API/Controllers/LibraryController.cs
+++ b/API/Controllers/LibraryController.cs
@@ -247,11 +247,9 @@ public class LibraryController : BaseApiController
var library = await _unitOfWork.LibraryRepository.GetLibraryForIdAsync(libraryId, LibraryIncludes.None);
if (TaskScheduler.HasScanTaskRunningForLibrary(libraryId))
{
- // TODO: Figure out how to cancel a job
-
_logger.LogInformation("User is attempting to delete a library while a scan is in progress");
return BadRequest(
- "You cannot delete a library while a scan is in progress. Please wait for scan to continue then try to delete");
+ "You cannot delete a library while a scan is in progress. Please wait for scan to complete or restart Kavita then try to delete");
}
// Due to a bad schema that I can't figure out how to fix, we need to erase all RelatedSeries before we delete the library
@@ -336,6 +334,7 @@ public class LibraryController : BaseApiController
library.IncludeInDashboard = dto.IncludeInDashboard;
library.IncludeInRecommended = dto.IncludeInRecommended;
library.IncludeInSearch = dto.IncludeInSearch;
+ library.ManageCollections = dto.CreateCollections;
_unitOfWork.LibraryRepository.Update(library);
diff --git a/API/DTOs/LibraryDto.cs b/API/DTOs/LibraryDto.cs
index 4a451c52a..6d25409e6 100644
--- a/API/DTOs/LibraryDto.cs
+++ b/API/DTOs/LibraryDto.cs
@@ -30,6 +30,10 @@ public class LibraryDto
/// </summary>
public bool IncludeInRecommended { get; set; } = true;
/// <summary>
+ /// Should this library create and manage collections from Metadata
+ /// </summary>
+ public bool ManageCollections { get; set; } = true;
+ /// <summary>
/// Include library series in Search
/// </summary>
public bool IncludeInSearch { get; set; } = true;
diff --git a/API/DTOs/UpdateLibraryDto.cs b/API/DTOs/UpdateLibraryDto.cs
index 602351328..6a9b7c72d 100644
--- a/API/DTOs/UpdateLibraryDto.cs
+++ b/API/DTOs/UpdateLibraryDto.cs
@@ -1,17 +1,28 @@
using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
using API.Entities.Enums;
namespace API.DTOs;
public class UpdateLibraryDto
{
+ [Required]
public int Id { get; init; }
+ [Required]
public string Name { get; init; }
+ [Required]
public LibraryType Type { get; set; }
+ [Required]
public IEnumerable<string> Folders { get; init; }
+ [Required]
public bool FolderWatching { get; init; }
+ [Required]
public bool IncludeInDashboard { get; init; }
+ [Required]
public bool IncludeInRecommended { get; init; }
+ [Required]
public bool IncludeInSearch { get; init; }
+ [Required]
+ public bool CreateCollections { get; init; }
}
diff --git a/API/Data/DataContext.cs b/API/Data/DataContext.cs
index e39b09a45..1606f9c71 100644
--- a/API/Data/DataContext.cs
+++ b/API/Data/DataContext.cs
@@ -104,6 +104,9 @@ public sealed class DataContext : IdentityDbContext<AppUser, AppRole, int,
builder.Entity<Library>()
.Property(b => b.IncludeInSearch)
.HasDefaultValue(true);
+ builder.Entity<Library>()
+ .Property(b => b.ManageCollections)
+ .HasDefaultValue(true);
}
diff --git a/API/Data/DbFactory.cs b/API/Data/DbFactory.cs
index 891c10843..08fcc2e9a 100644
--- a/API/Data/DbFactory.cs
+++ b/API/Data/DbFactory.cs
@@ -95,7 +95,7 @@ public static class DbFactory
return new CollectionTag()
{
Id = id,
- NormalizedTitle = Services.Tasks.Scanner.Parser.Parser.Normalize(title?.Trim()).ToUpper(),
+ NormalizedTitle = Services.Tasks.Scanner.Parser.Parser.Normalize(title?.Trim()),
Title = title?.Trim(),
Summary = summary?.Trim(),
Promoted = promoted
@@ -106,7 +106,7 @@ public static class DbFactory
{
return new ReadingList()
{
- NormalizedTitle = Services.Tasks.Scanner.Parser.Parser.Normalize(title?.Trim()).ToUpper(),
+ NormalizedTitle = Services.Tasks.Scanner.Parser.Parser.Normalize(title?.Trim()),
Title = title?.Trim(),
Summary = summary?.Trim(),
Promoted = promoted,
diff --git a/API/Data/Migrations/20230130210252_AutoCollections.Designer.cs b/API/Data/Migrations/20230130210252_AutoCollections.Designer.cs
new file mode 100644
index 000000000..6406e7335
--- /dev/null
+++ b/API/Data/Migrations/20230130210252_AutoCollections.Designer.cs
@@ -0,0 +1,1754 @@
+// <auto-generated />
+using System;
+using API.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace API.Data.Migrations
+{
+ [DbContext(typeof(DataContext))]
+ [Migration("20230130210252_AutoCollections")]
+ partial class AutoCollections
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "6.0.10");
+
+ modelBuilder.Entity("API.Entities.AppRole", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Name")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property<string>("NormalizedName")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedName")
+ .IsUnique()
+ .HasDatabaseName("RoleNameIndex");
+
+ b.ToTable("AspNetRoles", (string)null);
+ });
+
+ modelBuilder.Entity("API.Entities.AppUser", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AccessFailedCount")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AgeRestriction")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("AgeRestrictionIncludeUnknowns")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("ApiKey")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("TEXT");
+
+ b.Property<string>("ConfirmationToken")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Email")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("EmailConfirmed")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("LastActive")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("LockoutEnabled")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTimeOffset?>("LockoutEnd")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("NormalizedEmail")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property<string>("NormalizedUserName")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property<string>("PasswordHash")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("PhoneNumber")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("PhoneNumberConfirmed")
+ .HasColumnType("INTEGER");
+
+ b.Property<uint>("RowVersion")
+ .IsConcurrencyToken()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("SecurityStamp")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("TwoFactorEnabled")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("UserName")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedEmail")
+ .HasDatabaseName("EmailIndex");
+
+ b.HasIndex("NormalizedUserName")
+ .IsUnique()
+ .HasDatabaseName("UserNameIndex");
+
+ b.ToTable("AspNetUsers", (string)null);
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserBookmark", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AppUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("ChapterId")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("FileName")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Page")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("VolumeId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppUserId");
+
+ b.ToTable("AppUserBookmark");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserPreferences", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AppUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("AutoCloseMenu")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("BackgroundColor")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT")
+ .HasDefaultValue("#000000");
+
+ b.Property<bool>("BlurUnreadSummaries")
+ .HasColumnType("INTEGER");
+
+ 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<string>("BookThemeName")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT")
+ .HasDefaultValue("Dark");
+
+ b.Property<bool>("EmulateBook")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("GlobalPageLayoutMode")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER")
+ .HasDefaultValue(0);
+
+ b.Property<int>("LayoutMode")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("NoTransitions")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("PageSplitOption")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("PromptForDownloadSize")
+ .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?>("ThemeId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppUserId")
+ .IsUnique();
+
+ b.HasIndex("ThemeId");
+
+ b.ToTable("AppUserPreferences");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserProgress", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AppUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("BookScrollId")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("ChapterId")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("LibraryId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("PagesRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("VolumeId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppUserId");
+
+ b.HasIndex("SeriesId");
+
+ b.ToTable("AppUserProgresses");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserRating", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AppUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("Rating")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Review")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppUserId");
+
+ b.HasIndex("SeriesId");
+
+ b.ToTable("AppUserRating");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserRole", b =>
+ {
+ b.Property<int>("UserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("RoleId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("UserId", "RoleId");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("AspNetUserRoles", (string)null);
+ });
+
+ modelBuilder.Entity("API.Entities.Chapter", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AgeRating")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AvgHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("Count")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("CoverImage")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("CoverImageLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("IsSpecial")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Language")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("MaxHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("MinHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Number")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Pages")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Range")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("ReleaseDate")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("SeriesGroup")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Summary")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Title")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("TitleName")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("TotalCount")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("VolumeId")
+ .HasColumnType("INTEGER");
+
+ b.Property<long>("WordCount")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("VolumeId");
+
+ b.ToTable("Chapter");
+ });
+
+ modelBuilder.Entity("API.Entities.CollectionTag", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("CoverImage")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("CoverImageLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("NormalizedTitle")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("Promoted")
+ .HasColumnType("INTEGER");
+
+ b.Property<uint>("RowVersion")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Summary")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Title")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Id", "Promoted")
+ .IsUnique();
+
+ b.ToTable("CollectionTag");
+ });
+
+ modelBuilder.Entity("API.Entities.Device", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AppUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("EmailAddress")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("IpAddress")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastUsed")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Name")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Platform")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppUserId");
+
+ b.ToTable("Device");
+ });
+
+ modelBuilder.Entity("API.Entities.FolderPath", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("LastScanned")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("LibraryId")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Path")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("LibraryId");
+
+ b.ToTable("FolderPath");
+ });
+
+ modelBuilder.Entity("API.Entities.Genre", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("ExternalTag")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("NormalizedTitle")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Title")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedTitle", "ExternalTag")
+ .IsUnique();
+
+ b.ToTable("Genre");
+ });
+
+ modelBuilder.Entity("API.Entities.Library", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("CoverImage")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("FolderWatching")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER")
+ .HasDefaultValue(true);
+
+ b.Property<bool>("IncludeInDashboard")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER")
+ .HasDefaultValue(true);
+
+ b.Property<bool>("IncludeInRecommended")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER")
+ .HasDefaultValue(true);
+
+ b.Property<bool>("IncludeInSearch")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER")
+ .HasDefaultValue(true);
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastScanned")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("ManageCollections")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER")
+ .HasDefaultValue(true);
+
+ b.Property<string>("Name")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Type")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.ToTable("Library");
+ });
+
+ modelBuilder.Entity("API.Entities.MangaFile", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<long>("Bytes")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("ChapterId")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Extension")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("FilePath")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Format")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("LastFileAnalysis")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Pages")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ChapterId");
+
+ b.ToTable("MangaFile");
+ });
+
+ modelBuilder.Entity("API.Entities.Metadata.SeriesMetadata", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AgeRating")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("AgeRatingLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("CharacterLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("ColoristLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("CoverArtistLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("EditorLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("GenresLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("InkerLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Language")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("LanguageLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("LettererLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("MaxCount")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("PencillerLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("PublicationStatus")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("PublicationStatusLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("PublisherLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("ReleaseYear")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("ReleaseYearLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<uint>("RowVersion")
+ .IsConcurrencyToken()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Summary")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("SummaryLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("TagsLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("TotalCount")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("TranslatorLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("WriterLocked")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("SeriesId")
+ .IsUnique();
+
+ b.HasIndex("Id", "SeriesId")
+ .IsUnique();
+
+ b.ToTable("SeriesMetadata");
+ });
+
+ modelBuilder.Entity("API.Entities.Metadata.SeriesRelation", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("RelationKind")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("TargetSeriesId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("SeriesId");
+
+ b.HasIndex("TargetSeriesId");
+
+ b.ToTable("SeriesRelation");
+ });
+
+ modelBuilder.Entity("API.Entities.Person", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Name")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("NormalizedName")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Role")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.ToTable("Person");
+ });
+
+ modelBuilder.Entity("API.Entities.ReadingList", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AgeRating")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AppUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("CoverImage")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("CoverImageLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("NormalizedTitle")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("Promoted")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Summary")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Title")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppUserId");
+
+ b.ToTable("ReadingList");
+ });
+
+ modelBuilder.Entity("API.Entities.ReadingListItem", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("ChapterId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("Order")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("ReadingListId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("VolumeId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ChapterId");
+
+ b.HasIndex("ReadingListId");
+
+ b.HasIndex("SeriesId");
+
+ b.HasIndex("VolumeId");
+
+ b.ToTable("ReadingListItem");
+ });
+
+ modelBuilder.Entity("API.Entities.Series", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int?>("AppUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AvgHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("CoverImage")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("CoverImageLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("FolderPath")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Format")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("LastChapterAdded")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastFolderScanned")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("LibraryId")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("LocalizedName")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("LocalizedNameLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("MaxHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("MinHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Name")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("NameLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("NormalizedLocalizedName")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("NormalizedName")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("OriginalName")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Pages")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("SortName")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("SortNameLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<long>("WordCount")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppUserId");
+
+ b.HasIndex("LibraryId");
+
+ b.ToTable("Series");
+ });
+
+ modelBuilder.Entity("API.Entities.ServerSetting", b =>
+ {
+ b.Property<int>("Key")
+ .HasColumnType("INTEGER");
+
+ b.Property<uint>("RowVersion")
+ .IsConcurrencyToken()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Value")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Key");
+
+ b.ToTable("ServerSetting");
+ });
+
+ modelBuilder.Entity("API.Entities.ServerStatistics", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<long>("ChapterCount")
+ .HasColumnType("INTEGER");
+
+ b.Property<long>("FileCount")
+ .HasColumnType("INTEGER");
+
+ b.Property<long>("GenreCount")
+ .HasColumnType("INTEGER");
+
+ b.Property<long>("PersonCount")
+ .HasColumnType("INTEGER");
+
+ b.Property<long>("SeriesCount")
+ .HasColumnType("INTEGER");
+
+ b.Property<long>("TagCount")
+ .HasColumnType("INTEGER");
+
+ b.Property<long>("UserCount")
+ .HasColumnType("INTEGER");
+
+ b.Property<long>("VolumeCount")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("Year")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.ToTable("ServerStatistics");
+ });
+
+ modelBuilder.Entity("API.Entities.SiteTheme", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("FileName")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("IsDefault")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Name")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("NormalizedName")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Provider")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.ToTable("SiteTheme");
+ });
+
+ modelBuilder.Entity("API.Entities.Tag", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("ExternalTag")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("NormalizedTitle")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Title")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedTitle", "ExternalTag")
+ .IsUnique();
+
+ b.ToTable("Tag");
+ });
+
+ modelBuilder.Entity("API.Entities.Volume", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AvgHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("CoverImage")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("MaxHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("MinHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Name")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Number")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("Pages")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.Property<long>("WordCount")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("SeriesId");
+
+ b.ToTable("Volume");
+ });
+
+ modelBuilder.Entity("AppUserLibrary", b =>
+ {
+ b.Property<int>("AppUsersId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("LibrariesId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("AppUsersId", "LibrariesId");
+
+ b.HasIndex("LibrariesId");
+
+ b.ToTable("AppUserLibrary");
+ });
+
+ modelBuilder.Entity("ChapterGenre", b =>
+ {
+ b.Property<int>("ChaptersId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("GenresId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("ChaptersId", "GenresId");
+
+ b.HasIndex("GenresId");
+
+ b.ToTable("ChapterGenre");
+ });
+
+ modelBuilder.Entity("ChapterPerson", b =>
+ {
+ b.Property<int>("ChapterMetadatasId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("PeopleId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("ChapterMetadatasId", "PeopleId");
+
+ b.HasIndex("PeopleId");
+
+ b.ToTable("ChapterPerson");
+ });
+
+ modelBuilder.Entity("ChapterTag", b =>
+ {
+ b.Property<int>("ChaptersId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("TagsId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("ChaptersId", "TagsId");
+
+ b.HasIndex("TagsId");
+
+ b.ToTable("ChapterTag");
+ });
+
+ modelBuilder.Entity("CollectionTagSeriesMetadata", b =>
+ {
+ b.Property<int>("CollectionTagsId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesMetadatasId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("CollectionTagsId", "SeriesMetadatasId");
+
+ b.HasIndex("SeriesMetadatasId");
+
+ b.ToTable("CollectionTagSeriesMetadata");
+ });
+
+ modelBuilder.Entity("GenreSeriesMetadata", b =>
+ {
+ b.Property<int>("GenresId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesMetadatasId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("GenresId", "SeriesMetadatasId");
+
+ b.HasIndex("SeriesMetadatasId");
+
+ b.ToTable("GenreSeriesMetadata");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("ClaimType")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("ClaimValue")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("RoleId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("AspNetRoleClaims", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("ClaimType")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("ClaimValue")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("UserId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("AspNetUserClaims", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
+ {
+ b.Property<string>("LoginProvider")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("ProviderKey")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("ProviderDisplayName")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("UserId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("LoginProvider", "ProviderKey");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("AspNetUserLogins", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
+ {
+ b.Property<int>("UserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("LoginProvider")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Name")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Value")
+ .HasColumnType("TEXT");
+
+ b.HasKey("UserId", "LoginProvider", "Name");
+
+ b.ToTable("AspNetUserTokens", (string)null);
+ });
+
+ modelBuilder.Entity("PersonSeriesMetadata", b =>
+ {
+ b.Property<int>("PeopleId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesMetadatasId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("PeopleId", "SeriesMetadatasId");
+
+ b.HasIndex("SeriesMetadatasId");
+
+ b.ToTable("PersonSeriesMetadata");
+ });
+
+ modelBuilder.Entity("SeriesMetadataTag", b =>
+ {
+ b.Property<int>("SeriesMetadatasId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("TagsId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("SeriesMetadatasId", "TagsId");
+
+ b.HasIndex("TagsId");
+
+ b.ToTable("SeriesMetadataTag");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserBookmark", b =>
+ {
+ b.HasOne("API.Entities.AppUser", "AppUser")
+ .WithMany("Bookmarks")
+ .HasForeignKey("AppUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("AppUser");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserPreferences", b =>
+ {
+ b.HasOne("API.Entities.AppUser", "AppUser")
+ .WithOne("UserPreferences")
+ .HasForeignKey("API.Entities.AppUserPreferences", "AppUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.SiteTheme", "Theme")
+ .WithMany()
+ .HasForeignKey("ThemeId");
+
+ b.Navigation("AppUser");
+
+ b.Navigation("Theme");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserProgress", b =>
+ {
+ b.HasOne("API.Entities.AppUser", "AppUser")
+ .WithMany("Progresses")
+ .HasForeignKey("AppUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Series", null)
+ .WithMany("Progress")
+ .HasForeignKey("SeriesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("AppUser");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserRating", b =>
+ {
+ b.HasOne("API.Entities.AppUser", "AppUser")
+ .WithMany("Ratings")
+ .HasForeignKey("AppUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Series", null)
+ .WithMany("Ratings")
+ .HasForeignKey("SeriesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("AppUser");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserRole", b =>
+ {
+ b.HasOne("API.Entities.AppRole", "Role")
+ .WithMany("UserRoles")
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.AppUser", "User")
+ .WithMany("UserRoles")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Role");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("API.Entities.Chapter", b =>
+ {
+ b.HasOne("API.Entities.Volume", "Volume")
+ .WithMany("Chapters")
+ .HasForeignKey("VolumeId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Volume");
+ });
+
+ modelBuilder.Entity("API.Entities.Device", b =>
+ {
+ b.HasOne("API.Entities.AppUser", "AppUser")
+ .WithMany("Devices")
+ .HasForeignKey("AppUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("AppUser");
+ });
+
+ modelBuilder.Entity("API.Entities.FolderPath", b =>
+ {
+ b.HasOne("API.Entities.Library", "Library")
+ .WithMany("Folders")
+ .HasForeignKey("LibraryId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Library");
+ });
+
+ modelBuilder.Entity("API.Entities.MangaFile", b =>
+ {
+ b.HasOne("API.Entities.Chapter", "Chapter")
+ .WithMany("Files")
+ .HasForeignKey("ChapterId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Chapter");
+ });
+
+ modelBuilder.Entity("API.Entities.Metadata.SeriesMetadata", b =>
+ {
+ b.HasOne("API.Entities.Series", "Series")
+ .WithOne("Metadata")
+ .HasForeignKey("API.Entities.Metadata.SeriesMetadata", "SeriesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Series");
+ });
+
+ modelBuilder.Entity("API.Entities.Metadata.SeriesRelation", b =>
+ {
+ b.HasOne("API.Entities.Series", "Series")
+ .WithMany("Relations")
+ .HasForeignKey("SeriesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Series", "TargetSeries")
+ .WithMany("RelationOf")
+ .HasForeignKey("TargetSeriesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Series");
+
+ b.Navigation("TargetSeries");
+ });
+
+ modelBuilder.Entity("API.Entities.ReadingList", b =>
+ {
+ b.HasOne("API.Entities.AppUser", "AppUser")
+ .WithMany("ReadingLists")
+ .HasForeignKey("AppUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("AppUser");
+ });
+
+ modelBuilder.Entity("API.Entities.ReadingListItem", b =>
+ {
+ b.HasOne("API.Entities.Chapter", "Chapter")
+ .WithMany()
+ .HasForeignKey("ChapterId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.ReadingList", "ReadingList")
+ .WithMany("Items")
+ .HasForeignKey("ReadingListId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Series", "Series")
+ .WithMany()
+ .HasForeignKey("SeriesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Volume", "Volume")
+ .WithMany()
+ .HasForeignKey("VolumeId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Chapter");
+
+ b.Navigation("ReadingList");
+
+ b.Navigation("Series");
+
+ b.Navigation("Volume");
+ });
+
+ modelBuilder.Entity("API.Entities.Series", b =>
+ {
+ b.HasOne("API.Entities.AppUser", null)
+ .WithMany("WantToRead")
+ .HasForeignKey("AppUserId");
+
+ b.HasOne("API.Entities.Library", "Library")
+ .WithMany("Series")
+ .HasForeignKey("LibraryId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Library");
+ });
+
+ modelBuilder.Entity("API.Entities.Volume", b =>
+ {
+ b.HasOne("API.Entities.Series", "Series")
+ .WithMany("Volumes")
+ .HasForeignKey("SeriesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Series");
+ });
+
+ modelBuilder.Entity("AppUserLibrary", b =>
+ {
+ b.HasOne("API.Entities.AppUser", null)
+ .WithMany()
+ .HasForeignKey("AppUsersId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Library", null)
+ .WithMany()
+ .HasForeignKey("LibrariesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("ChapterGenre", b =>
+ {
+ b.HasOne("API.Entities.Chapter", null)
+ .WithMany()
+ .HasForeignKey("ChaptersId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Genre", null)
+ .WithMany()
+ .HasForeignKey("GenresId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("ChapterPerson", b =>
+ {
+ b.HasOne("API.Entities.Chapter", null)
+ .WithMany()
+ .HasForeignKey("ChapterMetadatasId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Person", null)
+ .WithMany()
+ .HasForeignKey("PeopleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("ChapterTag", b =>
+ {
+ b.HasOne("API.Entities.Chapter", null)
+ .WithMany()
+ .HasForeignKey("ChaptersId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Tag", null)
+ .WithMany()
+ .HasForeignKey("TagsId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("CollectionTagSeriesMetadata", b =>
+ {
+ b.HasOne("API.Entities.CollectionTag", null)
+ .WithMany()
+ .HasForeignKey("CollectionTagsId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Metadata.SeriesMetadata", null)
+ .WithMany()
+ .HasForeignKey("SeriesMetadatasId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("GenreSeriesMetadata", b =>
+ {
+ b.HasOne("API.Entities.Genre", null)
+ .WithMany()
+ .HasForeignKey("GenresId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Metadata.SeriesMetadata", null)
+ .WithMany()
+ .HasForeignKey("SeriesMetadatasId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
+ {
+ b.HasOne("API.Entities.AppRole", null)
+ .WithMany()
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
+ {
+ b.HasOne("API.Entities.AppUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
+ {
+ b.HasOne("API.Entities.AppUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
+ {
+ b.HasOne("API.Entities.AppUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("PersonSeriesMetadata", b =>
+ {
+ b.HasOne("API.Entities.Person", null)
+ .WithMany()
+ .HasForeignKey("PeopleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Metadata.SeriesMetadata", null)
+ .WithMany()
+ .HasForeignKey("SeriesMetadatasId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("SeriesMetadataTag", b =>
+ {
+ b.HasOne("API.Entities.Metadata.SeriesMetadata", null)
+ .WithMany()
+ .HasForeignKey("SeriesMetadatasId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Tag", null)
+ .WithMany()
+ .HasForeignKey("TagsId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("API.Entities.AppRole", b =>
+ {
+ b.Navigation("UserRoles");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUser", b =>
+ {
+ b.Navigation("Bookmarks");
+
+ b.Navigation("Devices");
+
+ b.Navigation("Progresses");
+
+ b.Navigation("Ratings");
+
+ b.Navigation("ReadingLists");
+
+ b.Navigation("UserPreferences");
+
+ b.Navigation("UserRoles");
+
+ b.Navigation("WantToRead");
+ });
+
+ modelBuilder.Entity("API.Entities.Chapter", b =>
+ {
+ b.Navigation("Files");
+ });
+
+ modelBuilder.Entity("API.Entities.Library", b =>
+ {
+ b.Navigation("Folders");
+
+ b.Navigation("Series");
+ });
+
+ modelBuilder.Entity("API.Entities.ReadingList", b =>
+ {
+ b.Navigation("Items");
+ });
+
+ modelBuilder.Entity("API.Entities.Series", b =>
+ {
+ b.Navigation("Metadata");
+
+ b.Navigation("Progress");
+
+ b.Navigation("Ratings");
+
+ b.Navigation("RelationOf");
+
+ b.Navigation("Relations");
+
+ b.Navigation("Volumes");
+ });
+
+ modelBuilder.Entity("API.Entities.Volume", b =>
+ {
+ b.Navigation("Chapters");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/API/Data/Migrations/20230130210252_AutoCollections.cs b/API/Data/Migrations/20230130210252_AutoCollections.cs
new file mode 100644
index 000000000..86d2dd3c1
--- /dev/null
+++ b/API/Data/Migrations/20230130210252_AutoCollections.cs
@@ -0,0 +1,36 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace API.Data.Migrations
+{
+ public partial class AutoCollections : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn<bool>(
+ name: "ManageCollections",
+ table: "Library",
+ type: "INTEGER",
+ nullable: false,
+ defaultValue: true);
+
+ migrationBuilder.AddColumn<string>(
+ name: "SeriesGroup",
+ table: "Chapter",
+ type: "TEXT",
+ nullable: true);
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "ManageCollections",
+ table: "Library");
+
+ migrationBuilder.DropColumn(
+ name: "SeriesGroup",
+ table: "Chapter");
+ }
+ }
+}
diff --git a/API/Data/Migrations/DataContextModelSnapshot.cs b/API/Data/Migrations/DataContextModelSnapshot.cs
index e38aac7fb..d5bda4ef4 100644
--- a/API/Data/Migrations/DataContextModelSnapshot.cs
+++ b/API/Data/Migrations/DataContextModelSnapshot.cs
@@ -400,6 +400,9 @@ namespace API.Data.Migrations
b.Property<DateTime>("ReleaseDate")
.HasColumnType("TEXT");
+ b.Property<string>("SeriesGroup")
+ .HasColumnType("TEXT");
+
b.Property<string>("Summary")
.HasColumnType("TEXT");
@@ -580,6 +583,11 @@ namespace API.Data.Migrations
b.Property<DateTime>("LastScanned")
.HasColumnType("TEXT");
+ b.Property<bool>("ManageCollections")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER")
+ .HasDefaultValue(true);
+
b.Property<string>("Name")
.HasColumnType("TEXT");
diff --git a/API/Entities/Chapter.cs b/API/Entities/Chapter.cs
index cc0db195c..311f769dc 100644
--- a/API/Entities/Chapter.cs
+++ b/API/Entities/Chapter.cs
@@ -73,6 +73,10 @@ public class Chapter : IEntityDate, IHasReadTimeEstimate
/// Number of the Total Count (progress the Series is complete)
/// </summary>
public int Count { get; set; } = 0;
+ /// <summary>
+ /// SeriesGroup tag in ComicInfo
+ /// </summary>
+ public string SeriesGroup { get; set; }
/// <summary>
/// Total Word count of all chapters in this chapter.
diff --git a/API/Entities/Library.cs b/API/Entities/Library.cs
index 84b4fa403..18eb69b0f 100644
--- a/API/Entities/Library.cs
+++ b/API/Entities/Library.cs
@@ -27,6 +27,10 @@ public class Library : IEntityDate
/// Include library series in Search
/// </summary>
public bool IncludeInSearch { get; set; } = true;
+ /// <summary>
+ /// Should this library create and manage collections from Metadata
+ /// </summary>
+ public bool ManageCollections { get; set; } = true;
public DateTime Created { get; set; }
public DateTime LastModified { get; set; }
/// <summary>
diff --git a/API/Extensions/ApplicationServiceExtensions.cs b/API/Extensions/ApplicationServiceExtensions.cs
index 327290b33..164b58751 100644
--- a/API/Extensions/ApplicationServiceExtensions.cs
+++ b/API/Extensions/ApplicationServiceExtensions.cs
@@ -55,6 +55,7 @@ public static class ApplicationServiceExtensions
services.AddScoped<IWordCountAnalyzerService, WordCountAnalyzerService>();
services.AddScoped<ILibraryWatcher, LibraryWatcher>();
services.AddScoped<ITachiyomiService, TachiyomiService>();
+ services.AddScoped<ICollectionTagService, CollectionTagService>();
services.AddScoped<IPresenceTracker, PresenceTracker>();
services.AddScoped<IEventHub, EventHub>();
diff --git a/API/Services/CollectionTagService.cs b/API/Services/CollectionTagService.cs
new file mode 100644
index 000000000..986e2e4a8
--- /dev/null
+++ b/API/Services/CollectionTagService.cs
@@ -0,0 +1,157 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using API.Data;
+using API.DTOs.CollectionTags;
+using API.Entities;
+using API.Entities.Metadata;
+using API.SignalR;
+using Kavita.Common;
+using Microsoft.Extensions.Logging;
+
+namespace API.Services;
+
+
+public interface ICollectionTagService
+{
+ Task<bool> TagExistsByName(string name);
+ Task<bool> UpdateTag(CollectionTagDto dto);
+ Task<bool> AddTagToSeries(CollectionTag tag, IEnumerable<int> seriesIds);
+ Task<bool> RemoveTagFromSeries(CollectionTag tag, IEnumerable<int> seriesIds);
+ Task<CollectionTag> GetTagOrCreate(int tagId, string title);
+ void AddTagToSeriesMetadata(CollectionTag tag, SeriesMetadata metadata);
+}
+
+
+public class CollectionTagService : ICollectionTagService
+{
+ private readonly IUnitOfWork _unitOfWork;
+ private readonly IEventHub _eventHub;
+
+ public CollectionTagService(IUnitOfWork unitOfWork, IEventHub eventHub)
+ {
+ _unitOfWork = unitOfWork;
+ _eventHub = eventHub;
+ }
+
+ /// <summary>
+ /// Checks if a collection exists with the name
+ /// </summary>
+ /// <param name="name">If empty or null, will return true as that is invalid</param>
+ /// <returns></returns>
+ public async Task<bool> TagExistsByName(string name)
+ {
+ if (string.IsNullOrEmpty(name.Trim())) return true;
+ return await _unitOfWork.CollectionTagRepository.TagExists(name);
+ }
+
+ public async Task<bool> UpdateTag(CollectionTagDto dto)
+ {
+ var existingTag = await _unitOfWork.CollectionTagRepository.GetTagAsync(dto.Id);
+ if (existingTag == null) throw new KavitaException("This tag does not exist");
+
+ var title = dto.Title.Trim();
+ if (string.IsNullOrEmpty(title)) throw new KavitaException("Title cannot be empty");
+ if (!title.Equals(existingTag.Title) && await TagExistsByName(dto.Title))
+ throw new KavitaException("A tag with this name already exists");
+
+ existingTag.SeriesMetadatas ??= new List<SeriesMetadata>();
+ existingTag.Title = title;
+ existingTag.NormalizedTitle = Tasks.Scanner.Parser.Parser.Normalize(dto.Title);
+ existingTag.Promoted = dto.Promoted;
+ existingTag.CoverImageLocked = dto.CoverImageLocked;
+ _unitOfWork.CollectionTagRepository.Update(existingTag);
+
+ // Check if Tag has updated (Summary)
+ var summary = dto.Summary.Trim();
+ if (existingTag.Summary == null || !existingTag.Summary.Equals(summary))
+ {
+ existingTag.Summary = summary;
+ _unitOfWork.CollectionTagRepository.Update(existingTag);
+ }
+
+ // If we unlock the cover image it means reset
+ if (!dto.CoverImageLocked)
+ {
+ existingTag.CoverImageLocked = false;
+ existingTag.CoverImage = string.Empty;
+ await _eventHub.SendMessageAsync(MessageFactory.CoverUpdate,
+ MessageFactory.CoverUpdateEvent(existingTag.Id, MessageFactoryEntityTypes.CollectionTag), false);
+ _unitOfWork.CollectionTagRepository.Update(existingTag);
+ }
+
+ if (!_unitOfWork.HasChanges()) return true;
+ return await _unitOfWork.CommitAsync();
+ }
+
+ /// <summary>
+ /// Adds a set of Series to a Collection
+ /// </summary>
+ /// <param name="tag">A full Tag</param>
+ /// <param name="seriesIds"></param>
+ /// <returns></returns>
+ public async Task<bool> AddTagToSeries(CollectionTag tag, IEnumerable<int> seriesIds)
+ {
+ var metadatas = await _unitOfWork.SeriesRepository.GetSeriesMetadataForIdsAsync(seriesIds);
+ foreach (var metadata in metadatas)
+ {
+ AddTagToSeriesMetadata(tag, metadata);
+ }
+
+ if (!_unitOfWork.HasChanges()) return true;
+ return await _unitOfWork.CommitAsync();
+ }
+
+ /// <summary>
+ /// Adds a collection tag to a SeriesMetadata
+ /// </summary>
+ /// <remarks>Does not commit</remarks>
+ /// <param name="tag"></param>
+ /// <param name="metadata"></param>
+ /// <returns></returns>
+ public void AddTagToSeriesMetadata(CollectionTag tag, SeriesMetadata metadata)
+ {
+ metadata.CollectionTags ??= new List<CollectionTag>();
+ if (metadata.CollectionTags.Any(t => t.Title.Equals(tag.Title, StringComparison.InvariantCulture))) return;
+
+ metadata.CollectionTags.Add(tag);
+ _unitOfWork.SeriesMetadataRepository.Update(metadata);
+ }
+
+ public async Task<bool> RemoveTagFromSeries(CollectionTag tag, IEnumerable<int> seriesIds)
+ {
+ foreach (var seriesIdToRemove in seriesIds)
+ {
+ tag.SeriesMetadatas.Remove(tag.SeriesMetadatas.Single(sm => sm.SeriesId == seriesIdToRemove));
+ }
+
+
+ if (tag.SeriesMetadatas.Count == 0)
+ {
+ _unitOfWork.CollectionTagRepository.Remove(tag);
+ }
+
+ if (!_unitOfWork.HasChanges()) return true;
+
+ return await _unitOfWork.CommitAsync();
+ }
+
+ /// <summary>
+ /// Tries to fetch the full tag, else returns a new tag. Adds to tracking but does not commit
+ /// </summary>
+ /// <param name="tagId"></param>
+ /// <param name="title"></param>
+ /// <returns></returns>
+ public async Task<CollectionTag> GetTagOrCreate(int tagId, string title)
+ {
+ var tag = await _unitOfWork.CollectionTagRepository.GetFullTagAsync(tagId);
+ if (tag == null)
+ {
+ tag = DbFactory.CollectionTag(0, title, string.Empty, false);
+ _unitOfWork.CollectionTagRepository.Add(tag);
+ }
+
+ return tag;
+ }
+}
diff --git a/API/Services/Tasks/Scanner/ProcessSeries.cs b/API/Services/Tasks/Scanner/ProcessSeries.cs
index d47520084..5c1b97604 100644
--- a/API/Services/Tasks/Scanner/ProcessSeries.cs
+++ b/API/Services/Tasks/Scanner/ProcessSeries.cs
@@ -45,6 +45,7 @@ public class ProcessSeries : IProcessSeries
private readonly IFileService _fileService;
private readonly IMetadataService _metadataService;
private readonly IWordCountAnalyzerService _wordCountAnalyzerService;
+ private readonly ICollectionTagService _collectionTagService;
private IList<Genre> _genres;
private IList<Person> _people;
@@ -52,7 +53,8 @@ public class ProcessSeries : IProcessSeries
public ProcessSeries(IUnitOfWork unitOfWork, ILogger<ProcessSeries> logger, IEventHub eventHub,
IDirectoryService directoryService, ICacheHelper cacheHelper, IReadingItemService readingItemService,
- IFileService fileService, IMetadataService metadataService, IWordCountAnalyzerService wordCountAnalyzerService)
+ IFileService fileService, IMetadataService metadataService, IWordCountAnalyzerService wordCountAnalyzerService,
+ ICollectionTagService collectionTagService)
{
_unitOfWork = unitOfWork;
_logger = logger;
@@ -63,6 +65,7 @@ public class ProcessSeries : IProcessSeries
_fileService = fileService;
_metadataService = metadataService;
_wordCountAnalyzerService = wordCountAnalyzerService;
+ _collectionTagService = collectionTagService;
}
/// <summary>
@@ -151,7 +154,7 @@ public class ProcessSeries : IProcessSeries
series.NormalizedLocalizedName = Parser.Parser.Normalize(series.LocalizedName);
}
- UpdateSeriesMetadata(series, library.Type);
+ await UpdateSeriesMetadata(series, library);
// Update series FolderPath here
await UpdateSeriesFolderPath(parsedInfos, library, series);
@@ -223,10 +226,10 @@ public class ProcessSeries : IProcessSeries
BackgroundJob.Enqueue(() => _wordCountAnalyzerService.ScanSeries(libraryId, seriesId, forceUpdate));
}
- private static void UpdateSeriesMetadata(Series series, LibraryType libraryType)
+ private async Task UpdateSeriesMetadata(Series series, Library library)
{
series.Metadata ??= DbFactory.SeriesMetadata(new List<CollectionTag>());
- var isBook = libraryType == LibraryType.Book;
+ var isBook = library.Type == LibraryType.Book;
var firstChapter = SeriesService.GetFirstChapterForMetadata(series, isBook);
var firstFile = firstChapter?.Files.FirstOrDefault();
@@ -278,6 +281,14 @@ public class ProcessSeries : IProcessSeries
series.Metadata.Language = firstChapter.Language;
}
+ if (!string.IsNullOrEmpty(firstChapter.SeriesGroup) && library.ManageCollections)
+ {
+ _logger.LogDebug("Collection tag found for {SeriesName}", series.Name);
+
+ var tag = await _collectionTagService.GetTagOrCreate(0, firstChapter.SeriesGroup);
+ _collectionTagService.AddTagToSeriesMetadata(tag, series.Metadata);
+ }
+
// Handle People
foreach (var chapter in chapters)
{
@@ -629,6 +640,11 @@ public class ProcessSeries : IProcessSeries
chapter.Language = comicInfo.LanguageISO;
}
+ if (!string.IsNullOrEmpty(comicInfo.SeriesGroup))
+ {
+ chapter.SeriesGroup = comicInfo.SeriesGroup;
+ }
+
if (comicInfo.Count > 0)
{
chapter.TotalCount = comicInfo.Count;
diff --git a/UI/Web/src/app/_models/library.ts b/UI/Web/src/app/_models/library.ts
index f15fbab8c..665911be3 100644
--- a/UI/Web/src/app/_models/library.ts
+++ b/UI/Web/src/app/_models/library.ts
@@ -15,4 +15,5 @@ export interface Library {
includeInDashboard: boolean;
includeInRecommended: boolean;
includeInSearch: boolean;
+ manageCollections: boolean;
}
\ No newline at end of file
diff --git a/UI/Web/src/app/cards/_modals/edit-collection-tags/edit-collection-tags.component.ts b/UI/Web/src/app/cards/_modals/edit-collection-tags/edit-collection-tags.component.ts
index 7d0b9ee6a..8522c02c6 100644
--- a/UI/Web/src/app/cards/_modals/edit-collection-tags/edit-collection-tags.component.ts
+++ b/UI/Web/src/app/cards/_modals/edit-collection-tags/edit-collection-tags.component.ts
@@ -151,16 +151,15 @@ export class EditCollectionTagsComponent implements OnInit, OnDestroy {
async save() {
const selectedIndex = this.collectionTagForm.get('coverImageIndex')?.value || 0;
const unselectedIds = this.selections.unselected().map(s => s.id);
- const tag: CollectionTag = {...this.tag};
- tag.summary = this.collectionTagForm.get('summary')?.value;
- tag.coverImageLocked = this.collectionTagForm.get('coverImageLocked')?.value;
- tag.promoted = this.collectionTagForm.get('promoted')?.value;
+ const tag = this.collectionTagForm.value;
+ tag.id = this.tag.id;
if (unselectedIds.length == this.series.length && !await this.confirmSerivce.confirm('Warning! No series are selected, saving will delete the tag. Are you sure you want to continue?')) {
return;
}
- const apis = [this.collectionService.updateTag(tag),
+ const apis = [
+ this.collectionService.updateTag(tag),
this.collectionService.updateSeriesForTag(tag, this.selections.unselected().map(s => s.id))
];
diff --git a/UI/Web/src/app/cards/card-item/card-item.component.html b/UI/Web/src/app/cards/card-item/card-item.component.html
index 2b48436b3..f04b5abab 100644
--- a/UI/Web/src/app/cards/card-item/card-item.component.html
+++ b/UI/Web/src/app/cards/card-item/card-item.component.html
@@ -17,7 +17,12 @@
Cannot Read
</div>
- <div class="not-read-badge" *ngIf="read === 0 && total > 0"></div>
+ <ng-container *ngIf="read === 0 && total > 0">
+ <div class="badge-container">
+ <div class="not-read-badge" ></div>
+ </div>
+ </ng-container>
+
<div class="bulk-mode {{bulkSelectionService.hasSelections() ? 'always-show' : ''}}" (click)="handleSelection($event)" *ngIf="allowSelection">
<input type="checkbox" class="form-check-input" attr.aria-labelledby="{{title}}_{{entity.id}}" [ngModel]="selected" [ngModelOptions]="{standalone: true}">
</div>
diff --git a/UI/Web/src/app/cards/card-item/card-item.component.scss b/UI/Web/src/app/cards/card-item/card-item.component.scss
index cd3b100cf..88d0038a5 100644
--- a/UI/Web/src/app/cards/card-item/card-item.component.scss
+++ b/UI/Web/src/app/cards/card-item/card-item.component.scss
@@ -67,15 +67,28 @@ $image-width: 160px;
right: 30%;
}
+.badge-container {
+ border-radius: 4px;
+ display: block;
+ height: $image-height;
+ left: 0;
+ overflow: hidden;
+ pointer-events: none;
+ position: absolute;
+ top: 0;
+ width: 158px;
+
+}
+
.not-read-badge {
position: absolute;
- top: 0px;
- right: 0px;
- width: 0;
- height: 0;
- border-style: solid;
- border-width: 0 var(--card-progress-triangle-size) var(--card-progress-triangle-size) 0;
- border-color: transparent var(--primary-color) transparent transparent;
+ top: calc(-1 * (var(--card-progress-triangle-size) / 2));
+ right: -14px;
+ z-index: 1000;
+ height: var(--card-progress-triangle-size);
+ width: var(--card-progress-triangle-size);
+ background-color: var(--primary-color);
+ transform: rotate(45deg);
}
@@ -109,8 +122,8 @@ $image-width: 160px;
.overlay {
height: $image-height;
-
-
+ border-top-left-radius: 4px;
+ border-top-right-radius: 4px;
&:hover {
visibility: visible;
@@ -169,4 +182,6 @@ $image-width: 160px;
height: $image-height;
z-index: 10;
transition: all 0.2s;
+ border-top-left-radius: 4px;
+ border-top-right-radius: 4px;
}
diff --git a/UI/Web/src/app/sidenav/_modals/library-settings-modal/library-settings-modal.component.html b/UI/Web/src/app/sidenav/_modals/library-settings-modal/library-settings-modal.component.html
index cb16cf113..79adc4623 100644
--- a/UI/Web/src/app/sidenav/_modals/library-settings-modal/library-settings-modal.component.html
+++ b/UI/Web/src/app/sidenav/_modals/library-settings-modal/library-settings-modal.component.html
@@ -92,6 +92,19 @@
<li [ngbNavItem]="TabID.Advanced" [disabled]="isAddLibrary && setupStep < 3">
<a ngbNavLink>{{TabID.Advanced}}</a>
<ng-template ngbNavContent>
+ <div class="row">
+ <div class="col-md-12 col-sm-12 pe-2 mb-2">
+ <div class="mb-3 mt-1">
+ <div class="form-check form-switch">
+ <input type="checkbox" id="manage-collections" role="switch" formControlName="manageCollections" class="form-check-input" aria-labelledby="auto-close-label">
+ <label class="form-check-label" for="manage-collections">Manage Collections</label>
+ </div>
+ </div>
+ <p class="accent">
+ Should Kavita create and update Collections from SeriesGroup tags found within ComicInfo.xml files
+ </p>
+ </div>
+ </div>
<div class="row">
<div class="col-md-12 col-sm-12 pe-2 mb-2">
diff --git a/UI/Web/src/app/sidenav/_modals/library-settings-modal/library-settings-modal.component.ts b/UI/Web/src/app/sidenav/_modals/library-settings-modal/library-settings-modal.component.ts
index 7aea4c7eb..24ddb7fad 100644
--- a/UI/Web/src/app/sidenav/_modals/library-settings-modal/library-settings-modal.component.ts
+++ b/UI/Web/src/app/sidenav/_modals/library-settings-modal/library-settings-modal.component.ts
@@ -46,6 +46,7 @@ export class LibrarySettingsModalComponent implements OnInit, OnDestroy {
includeInDashboard: new FormControl<boolean>(true, { nonNullable: true, validators: [Validators.required] }),
includeInRecommended: new FormControl<boolean>(true, { nonNullable: true, validators: [Validators.required] }),
includeInSearch: new FormControl<boolean>(true, { nonNullable: true, validators: [Validators.required] }),
+ manageCollections: new FormControl<boolean>(true, { nonNullable: true, validators: [Validators.required] }),
});
selectedFolders: string[] = [];
@@ -117,6 +118,7 @@ export class LibrarySettingsModalComponent implements OnInit, OnDestroy {
this.libraryForm.get('includeInDashboard')?.setValue(this.library.includeInDashboard);
this.libraryForm.get('includeInRecommended')?.setValue(this.library.includeInRecommended);
this.libraryForm.get('includeInSearch')?.setValue(this.library.includeInSearch);
+ this.libraryForm.get('manageCollections')?.setValue(this.library.manageCollections);
this.selectedFolders = this.library.folders;
this.madeChanges = false;
this.cdRef.markForCheck();
diff --git a/UI/Web/src/theme/themes/dark.scss b/UI/Web/src/theme/themes/dark.scss
index a3a4505fc..2b325f0ba 100644
--- a/UI/Web/src/theme/themes/dark.scss
+++ b/UI/Web/src/theme/themes/dark.scss
@@ -201,7 +201,7 @@
--card-progress-bar-color: var(--primary-color);
--card-overlay-bg-color: rgba(0, 0, 0, 0);
--card-overlay-hover-bg-color: rgba(0, 0, 0, 0.2);
- --card-progress-triangle-size: 20px;
+ --card-progress-triangle-size: 28px;
/* Slider */
--slider-text-color: white;
diff --git a/openapi.json b/openapi.json
index 0a355a7e8..c3289d528 100644
--- a/openapi.json
+++ b/openapi.json
@@ -7,7 +7,7 @@
"name": "GPL-3.0",
"url": "https://github.com/Kareadita/Kavita/blob/develop/LICENSE"
},
- "version": "0.6.1.31"
+ "version": "0.6.1.32"
},
"servers": [
{
@@ -9943,6 +9943,11 @@
"description": "Number of the Total Count (progress the Series is complete)",
"format": "int32"
},
+ "seriesGroup": {
+ "type": "string",
+ "description": "SeriesGroup tag in ComicInfo",
+ "nullable": true
+ },
"wordCount": {
"type": "integer",
"description": "Total Word count of all chapters in this chapter.",
@@ -11159,6 +11164,10 @@
"type": "boolean",
"description": "Include library series in Search"
},
+ "manageCollections": {
+ "type": "boolean",
+ "description": "Should this library create and manage collections from Metadata"
+ },
"created": {
"type": "string",
"format": "date-time"
@@ -11232,6 +11241,10 @@
"type": "boolean",
"description": "Include Library series on Recommended Streams"
},
+ "manageCollections": {
+ "type": "boolean",
+ "description": "Should this library create and manage collections from Metadata"
+ },
"includeInSearch": {
"type": "boolean",
"description": "Include library series in Search"
@@ -13711,6 +13724,17 @@
"additionalProperties": false
},
"UpdateLibraryDto": {
+ "required": [
+ "createCollections",
+ "folders",
+ "folderWatching",
+ "id",
+ "includeInDashboard",
+ "includeInRecommended",
+ "includeInSearch",
+ "name",
+ "type"
+ ],
"type": "object",
"properties": {
"id": {
@@ -13718,8 +13742,8 @@
"format": "int32"
},
"name": {
- "type": "string",
- "nullable": true
+ "minLength": 1,
+ "type": "string"
},
"type": {
"$ref": "#/components/schemas/LibraryType"
@@ -13728,8 +13752,7 @@
"type": "array",
"items": {
"type": "string"
- },
- "nullable": true
+ }
},
"folderWatching": {
"type": "boolean"
@@ -13742,6 +13765,9 @@
},
"includeInSearch": {
"type": "boolean"
+ },
+ "createCollections": {
+ "type": "boolean"
}
},
"additionalProperties": false