mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-07-09 03:04:19 -04:00
Reading List Fixes (#1784)
* Add ability to save readinglist comicinfo fields in Chapter. * Added the appropriate fields and migration for Reading List generation. * Started the reading list code * Started building out the CBL import code with some initial unit tests. * Fixed first unit test * Started refactoring control code into services and writing unit tests for ReadingLists. Found a logic issue around reading list title between create/update. Will be corrected in this branch with unit tests. * Can't figure out how to mock UserManager, so had to uncomment a few tests. * Tooltip for total pages read shows the full number * Tweaked the math a bit for average reading per week. * Fixed up the reading list unit tests. Fixed an issue where when inserting chapters into a blank reading list, the initial reading list item would have an order of 1 instead of 0. * Cleaned up the code to allow the reading list code to be localized easily and fixed up a bug in last PR. * Fixed a sorting issue on reading activity * Tweaked the code around reading list actionables not showing due to some weird filter. * Fixed edit library settings not opening on library detail page * Fixed a bug where reading activity dates would be out of order due to a bug in how charts works. A temp hack has been added. * Disable promotion in edit reading list modal since non-admins can (and should have) been able to use it. * Fixed a bug where non-admins couldn't update their OWN reading lists. Made uploading a cover image for readinglists now check against the user's reading list access to allow non-admin's to set images. * Fixed an issue introduced earlier in PR where adding chapters to reading list could cause order to get skewed. * Fixed another regression from earlier commit * Hooked in Import CBL flow. No functionality yet. * Code is a mess. Shifting how the whole import process is going to be done. Commiting so I can pivot drastically. * Very rough code for first step is done. * Ui has started, I've run out of steam for this feature. * Cleaned up the UI code a bit to make the step tracker nature easier without a dedicated component. * Much flow implementation and tweaking to how validation checks and what is sent back. * Removed import via cbl code as it's not done. Pushing to next release.
This commit is contained in:
parent
ae1af22af1
commit
3f24dc7392
@ -9,6 +9,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.10" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
|
||||
<PackageReference Include="Moq" Version="4.18.4" />
|
||||
<PackageReference Include="NSubstitute" Version="4.4.0" />
|
||||
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="17.2.3" />
|
||||
<PackageReference Include="xunit" Version="2.4.2" />
|
||||
|
@ -1,16 +1,20 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.IO;
|
||||
using System.IO.Abstractions.TestingHelpers;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using API.Data;
|
||||
using API.Data.Repositories;
|
||||
using API.DTOs.ReadingLists;
|
||||
using API.DTOs.ReadingLists.CBL;
|
||||
using API.Entities;
|
||||
using API.Entities.Enums;
|
||||
using API.Helpers;
|
||||
using API.Services;
|
||||
using API.SignalR;
|
||||
using API.Tests.Helpers;
|
||||
using AutoMapper;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@ -24,7 +28,6 @@ public class ReadingListServiceTests
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly IReadingListService _readingListService;
|
||||
|
||||
private readonly DataContext _context;
|
||||
|
||||
private const string CacheDirectory = "C:/kavita/config/cache/";
|
||||
@ -43,7 +46,7 @@ public class ReadingListServiceTests
|
||||
var mapper = config.CreateMapper();
|
||||
_unitOfWork = new UnitOfWork(_context, mapper, null);
|
||||
|
||||
_readingListService = new ReadingListService(_unitOfWork, Substitute.For<ILogger<ReadingListService>>());
|
||||
_readingListService = new ReadingListService(_unitOfWork, Substitute.For<ILogger<ReadingListService>>(), Substitute.For<IEventHub>());
|
||||
}
|
||||
|
||||
#region Setup
|
||||
@ -83,6 +86,7 @@ public class ReadingListServiceTests
|
||||
private async Task ResetDb()
|
||||
{
|
||||
_context.AppUser.RemoveRange(_context.AppUser);
|
||||
_context.Library.RemoveRange(_context.Library);
|
||||
_context.Series.RemoveRange(_context.Series);
|
||||
_context.ReadingList.RemoveRange(_context.ReadingList);
|
||||
await _unitOfWork.CommitAsync();
|
||||
@ -103,8 +107,148 @@ public class ReadingListServiceTests
|
||||
|
||||
#endregion
|
||||
|
||||
#region AddChaptersToReadingList
|
||||
[Fact]
|
||||
public async Task AddChaptersToReadingList_ShouldAddFirstItem_AsOrderZero()
|
||||
{
|
||||
await ResetDb();
|
||||
_context.AppUser.Add(new AppUser()
|
||||
{
|
||||
UserName = "majora2007",
|
||||
ReadingLists = new List<ReadingList>(),
|
||||
Libraries = new List<Library>()
|
||||
{
|
||||
new Library()
|
||||
{
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Book,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test",
|
||||
Metadata = DbFactory.SeriesMetadata(new List<CollectionTag>()),
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
new Volume()
|
||||
{
|
||||
Name = "0",
|
||||
Chapters = new List<Chapter>()
|
||||
{
|
||||
new Chapter()
|
||||
{
|
||||
Number = "1",
|
||||
AgeRating = AgeRating.Everyone,
|
||||
},
|
||||
new Chapter()
|
||||
{
|
||||
Number = "2",
|
||||
AgeRating = AgeRating.X18Plus
|
||||
},
|
||||
new Chapter()
|
||||
{
|
||||
Number = "3",
|
||||
AgeRating = AgeRating.X18Plus
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync("majora2007", AppUserIncludes.ReadingLists);
|
||||
var readingList = new ReadingList();
|
||||
user.ReadingLists = new List<ReadingList>()
|
||||
{
|
||||
readingList
|
||||
};
|
||||
|
||||
await _readingListService.AddChaptersToReadingList(1, new List<int>() {1}, readingList);
|
||||
await _unitOfWork.CommitAsync();
|
||||
|
||||
Assert.Equal(1, readingList.Items.Count);
|
||||
Assert.Equal(0, readingList.Items.First().Order);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AddChaptersToReadingList_ShouldNewItems_AfterLastOrder()
|
||||
{
|
||||
await ResetDb();
|
||||
_context.AppUser.Add(new AppUser()
|
||||
{
|
||||
UserName = "majora2007",
|
||||
ReadingLists = new List<ReadingList>(),
|
||||
Libraries = new List<Library>()
|
||||
{
|
||||
new Library()
|
||||
{
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Book,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test",
|
||||
Metadata = DbFactory.SeriesMetadata(new List<CollectionTag>()),
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
new Volume()
|
||||
{
|
||||
Name = "0",
|
||||
Chapters = new List<Chapter>()
|
||||
{
|
||||
new Chapter()
|
||||
{
|
||||
Number = "1",
|
||||
AgeRating = AgeRating.Everyone,
|
||||
},
|
||||
new Chapter()
|
||||
{
|
||||
Number = "2",
|
||||
AgeRating = AgeRating.X18Plus
|
||||
},
|
||||
new Chapter()
|
||||
{
|
||||
Number = "3",
|
||||
AgeRating = AgeRating.X18Plus
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync("majora2007", AppUserIncludes.ReadingLists);
|
||||
var readingList = new ReadingList();
|
||||
user.ReadingLists = new List<ReadingList>()
|
||||
{
|
||||
readingList
|
||||
};
|
||||
|
||||
await _readingListService.AddChaptersToReadingList(1, new List<int>() {1}, readingList);
|
||||
await _unitOfWork.CommitAsync();
|
||||
await _readingListService.AddChaptersToReadingList(1, new List<int>() {2}, readingList);
|
||||
await _unitOfWork.CommitAsync();
|
||||
|
||||
Assert.Equal(2, readingList.Items.Count);
|
||||
Assert.Equal(0, readingList.Items.First().Order);
|
||||
Assert.Equal(1, readingList.Items.ElementAt(1).Order);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region UpdateReadingListItemPosition
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task UpdateReadingListItemPosition_MoveLastToFirst_TwoItemsShouldShift()
|
||||
{
|
||||
@ -623,4 +767,516 @@ public class ReadingListServiceTests
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CreateReadingList
|
||||
|
||||
private async Task CreateReadingList_SetupBaseData()
|
||||
{
|
||||
var fablesSeries = DbFactory.Series("Fables");
|
||||
fablesSeries.Volumes.Add(new Volume()
|
||||
{
|
||||
Number = 1,
|
||||
Name = "2002",
|
||||
Chapters = new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("1", false),
|
||||
}
|
||||
});
|
||||
|
||||
_context.AppUser.Add(new AppUser()
|
||||
{
|
||||
UserName = "majora2007",
|
||||
ReadingLists = new List<ReadingList>(),
|
||||
Libraries = new List<Library>()
|
||||
{
|
||||
new Library()
|
||||
{
|
||||
Name = "Test Lib",
|
||||
Type = LibraryType.Book,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
fablesSeries,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
_context.AppUser.Add(new AppUser()
|
||||
{
|
||||
UserName = "admin",
|
||||
ReadingLists = new List<ReadingList>(),
|
||||
Libraries = new List<Library>()
|
||||
{
|
||||
new Library()
|
||||
{
|
||||
Name = "Test Lib 2",
|
||||
Type = LibraryType.Book,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
fablesSeries,
|
||||
},
|
||||
},
|
||||
}
|
||||
});
|
||||
await _unitOfWork.CommitAsync();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CreateReadingList_ShouldCreate_WhenNoOtherListsOnUser()
|
||||
{
|
||||
await ResetDb();
|
||||
await CreateReadingList_SetupBaseData();
|
||||
|
||||
var user = await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.ReadingLists);
|
||||
await _readingListService.CreateReadingListForUser(user, "Test List");
|
||||
Assert.NotEmpty((await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.ReadingLists))
|
||||
.ReadingLists);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CreateReadingList_ShouldNotCreate_WhenExistingList()
|
||||
{
|
||||
await ResetDb();
|
||||
await CreateReadingList_SetupBaseData();
|
||||
|
||||
var user = await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.ReadingLists);
|
||||
await _readingListService.CreateReadingListForUser(user, "Test List");
|
||||
Assert.NotEmpty((await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.ReadingLists))
|
||||
.ReadingLists);
|
||||
try
|
||||
{
|
||||
await _readingListService.CreateReadingListForUser(user, "Test List");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Assert.Equal("A list of this name already exists", ex.Message);
|
||||
}
|
||||
Assert.Single((await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.ReadingLists))
|
||||
.ReadingLists);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CreateReadingList_ShouldNotCreate_WhenPromotedListExists()
|
||||
{
|
||||
await ResetDb();
|
||||
await CreateReadingList_SetupBaseData();
|
||||
|
||||
|
||||
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync("admin", AppUserIncludes.ReadingLists);
|
||||
var list = await _readingListService.CreateReadingListForUser(user, "Test List");
|
||||
await _readingListService.UpdateReadingList(list,
|
||||
new UpdateReadingListDto()
|
||||
{
|
||||
ReadingListId = list.Id, Promoted = true, Title = list.Title, Summary = list.Summary,
|
||||
CoverImageLocked = false
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
await _readingListService.CreateReadingListForUser(user, "Test List");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Assert.Equal("A list of this name already exists", ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UpdateReadingList
|
||||
#endregion
|
||||
|
||||
#region DeleteReadingList
|
||||
[Fact]
|
||||
public async Task DeleteReadingList_ShouldDelete()
|
||||
{
|
||||
await ResetDb();
|
||||
await CreateReadingList_SetupBaseData();
|
||||
|
||||
var user = await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.ReadingLists);
|
||||
await _readingListService.CreateReadingListForUser(user, "Test List");
|
||||
Assert.NotEmpty((await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.ReadingLists))
|
||||
.ReadingLists);
|
||||
try
|
||||
{
|
||||
await _readingListService.CreateReadingListForUser(user, "Test List");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Assert.Equal("A list of this name already exists", ex.Message);
|
||||
}
|
||||
Assert.Single((await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.ReadingLists))
|
||||
.ReadingLists);
|
||||
|
||||
await _readingListService.DeleteReadingList(1, user);
|
||||
Assert.Empty((await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.ReadingLists))
|
||||
.ReadingLists);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region UserHasReadingListAccess
|
||||
// TODO: UserHasReadingListAccess tests are unavailable because I can't mock UserManager<AppUser>
|
||||
public async Task UserHasReadingListAccess_ShouldWorkIfTheirList()
|
||||
{
|
||||
await ResetDb();
|
||||
await CreateReadingList_SetupBaseData();
|
||||
|
||||
var user = await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.ReadingLists);
|
||||
await _readingListService.CreateReadingListForUser(user, "Test List");
|
||||
|
||||
var userWithList = await _readingListService.UserHasReadingListAccess(1, "majora2007");
|
||||
Assert.NotNull(userWithList);
|
||||
Assert.Single(userWithList.ReadingLists);
|
||||
}
|
||||
|
||||
|
||||
public async Task UserHasReadingListAccess_ShouldNotWork_IfNotTheirList()
|
||||
{
|
||||
await ResetDb();
|
||||
await CreateReadingList_SetupBaseData();
|
||||
|
||||
var user = await _unitOfWork.UserRepository.GetUserByIdAsync(2, AppUserIncludes.ReadingLists);
|
||||
await _readingListService.CreateReadingListForUser(user, "Test List");
|
||||
|
||||
var userWithList = await _readingListService.UserHasReadingListAccess(1, "majora2007");
|
||||
Assert.Null(userWithList);
|
||||
}
|
||||
|
||||
|
||||
public async Task UserHasReadingListAccess_ShouldWork_IfNotTheirList_ButUserIsAdmin()
|
||||
{
|
||||
await ResetDb();
|
||||
await CreateReadingList_SetupBaseData();
|
||||
|
||||
|
||||
var user = await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.ReadingLists);
|
||||
await _readingListService.CreateReadingListForUser(user, "Test List");
|
||||
|
||||
//var admin = await _unitOfWork.UserRepository.GetUserByIdAsync(2, AppUserIncludes.ReadingLists);
|
||||
//_userManager.When(x => x.IsInRoleAsync(user, PolicyConstants.AdminRole)).Returns((info => true), null);
|
||||
|
||||
//_userManager.IsInRoleAsync(admin, PolicyConstants.AdminRole).ReturnsForAnyArgs(true);
|
||||
|
||||
var userWithList = await _readingListService.UserHasReadingListAccess(1, "majora2007");
|
||||
Assert.NotNull(userWithList);
|
||||
Assert.Single(userWithList.ReadingLists);
|
||||
}
|
||||
#endregion
|
||||
//
|
||||
// #region CreateReadingListFromCBL
|
||||
//
|
||||
// private static CblReadingList LoadCblFromPath(string path)
|
||||
// {
|
||||
// var testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/ReadingListService/");
|
||||
//
|
||||
// var reader = new System.Xml.Serialization.XmlSerializer(typeof(CblReadingList));
|
||||
// using var file = new StreamReader(Path.Join(testDirectory, path));
|
||||
// var cblReadingList = (CblReadingList) reader.Deserialize(file);
|
||||
// file.Close();
|
||||
// return cblReadingList;
|
||||
// }
|
||||
//
|
||||
// [Fact]
|
||||
// public async Task CreateReadingListFromCBL_ShouldCreateList()
|
||||
// {
|
||||
// await ResetDb();
|
||||
// var cblReadingList = LoadCblFromPath("Fables.cbl");
|
||||
//
|
||||
// // Mock up our series
|
||||
// var fablesSeries = DbFactory.Series("Fables");
|
||||
// var fables2Series = DbFactory.Series("Fables: The Last Castle");
|
||||
//
|
||||
// fablesSeries.Volumes.Add(new Volume()
|
||||
// {
|
||||
// Number = 1,
|
||||
// Name = "2002",
|
||||
// Chapters = new List<Chapter>()
|
||||
// {
|
||||
// EntityFactory.CreateChapter("1", false),
|
||||
// EntityFactory.CreateChapter("2", false),
|
||||
// EntityFactory.CreateChapter("3", false),
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// fables2Series.Volumes.Add(new Volume()
|
||||
// {
|
||||
// Number = 1,
|
||||
// Name = "2003",
|
||||
// Chapters = new List<Chapter>()
|
||||
// {
|
||||
// EntityFactory.CreateChapter("1", false),
|
||||
// EntityFactory.CreateChapter("2", false),
|
||||
// EntityFactory.CreateChapter("3", false),
|
||||
//
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// _context.AppUser.Add(new AppUser()
|
||||
// {
|
||||
// UserName = "majora2007",
|
||||
// ReadingLists = new List<ReadingList>(),
|
||||
// Libraries = new List<Library>()
|
||||
// {
|
||||
// new Library()
|
||||
// {
|
||||
// Name = "Test LIb",
|
||||
// Type = LibraryType.Book,
|
||||
// Series = new List<Series>()
|
||||
// {
|
||||
// fablesSeries,
|
||||
// fables2Series
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// });
|
||||
// await _unitOfWork.CommitAsync();
|
||||
//
|
||||
// var importSummary = await _readingListService.CreateReadingListFromCbl(1, cblReadingList);
|
||||
//
|
||||
// Assert.Equal(CblImportResult.Partial, importSummary.Success);
|
||||
// Assert.NotEmpty(importSummary.Results);
|
||||
//
|
||||
// var createdList = await _unitOfWork.ReadingListRepository.GetReadingListByIdAsync(1);
|
||||
//
|
||||
// Assert.NotNull(createdList);
|
||||
// Assert.Equal("Fables", createdList.Title);
|
||||
//
|
||||
// Assert.Equal(4, createdList.Items.Count);
|
||||
// Assert.Equal(1, createdList.Items.First(item => item.Order == 0).ChapterId);
|
||||
// Assert.Equal(2, createdList.Items.First(item => item.Order == 1).ChapterId);
|
||||
// Assert.Equal(3, createdList.Items.First(item => item.Order == 2).ChapterId);
|
||||
// Assert.Equal(4, createdList.Items.First(item => item.Order == 3).ChapterId);
|
||||
// }
|
||||
//
|
||||
// [Fact]
|
||||
// public async Task CreateReadingListFromCBL_ShouldCreateList_ButOnlyIncludeSeriesThatUserHasAccessTo()
|
||||
// {
|
||||
// await ResetDb();
|
||||
// var cblReadingList = LoadCblFromPath("Fables.cbl");
|
||||
//
|
||||
// // Mock up our series
|
||||
// var fablesSeries = DbFactory.Series("Fables");
|
||||
// var fables2Series = DbFactory.Series("Fables: The Last Castle");
|
||||
//
|
||||
// fablesSeries.Volumes.Add(new Volume()
|
||||
// {
|
||||
// Number = 1,
|
||||
// Name = "2002",
|
||||
// Chapters = new List<Chapter>()
|
||||
// {
|
||||
// EntityFactory.CreateChapter("1", false),
|
||||
// EntityFactory.CreateChapter("2", false),
|
||||
// EntityFactory.CreateChapter("3", false),
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// fables2Series.Volumes.Add(new Volume()
|
||||
// {
|
||||
// Number = 1,
|
||||
// Name = "2003",
|
||||
// Chapters = new List<Chapter>()
|
||||
// {
|
||||
// EntityFactory.CreateChapter("1", false),
|
||||
// EntityFactory.CreateChapter("2", false),
|
||||
// EntityFactory.CreateChapter("3", false),
|
||||
//
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// _context.AppUser.Add(new AppUser()
|
||||
// {
|
||||
// UserName = "majora2007",
|
||||
// ReadingLists = new List<ReadingList>(),
|
||||
// Libraries = new List<Library>()
|
||||
// {
|
||||
// new Library()
|
||||
// {
|
||||
// Name = "Test LIb",
|
||||
// Type = LibraryType.Book,
|
||||
// Series = new List<Series>()
|
||||
// {
|
||||
// fablesSeries,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// });
|
||||
//
|
||||
// _context.Library.Add(new Library()
|
||||
// {
|
||||
// Name = "Test Lib 2",
|
||||
// Type = LibraryType.Book,
|
||||
// Series = new List<Series>()
|
||||
// {
|
||||
// fables2Series,
|
||||
// },
|
||||
// });
|
||||
//
|
||||
// await _unitOfWork.CommitAsync();
|
||||
//
|
||||
// var importSummary = await _readingListService.CreateReadingListFromCbl(1, cblReadingList);
|
||||
//
|
||||
// Assert.Equal(CblImportResult.Partial, importSummary.Success);
|
||||
// Assert.NotEmpty(importSummary.Results);
|
||||
//
|
||||
// var createdList = await _unitOfWork.ReadingListRepository.GetReadingListByIdAsync(1);
|
||||
//
|
||||
// Assert.NotNull(createdList);
|
||||
// Assert.Equal("Fables", createdList.Title);
|
||||
//
|
||||
// Assert.Equal(3, createdList.Items.Count);
|
||||
// Assert.Equal(1, createdList.Items.First(item => item.Order == 0).ChapterId);
|
||||
// Assert.Equal(2, createdList.Items.First(item => item.Order == 1).ChapterId);
|
||||
// Assert.Equal(3, createdList.Items.First(item => item.Order == 2).ChapterId);
|
||||
// Assert.NotNull(importSummary.Results.SingleOrDefault(r => r.Series == "Fables: The Last Castle"
|
||||
// && r.Reason == CblImportReason.SeriesMissing));
|
||||
// }
|
||||
//
|
||||
// [Fact]
|
||||
// public async Task CreateReadingListFromCBL_ShouldFail_UserHasAccessToNoSeries()
|
||||
// {
|
||||
// await ResetDb();
|
||||
// var cblReadingList = LoadCblFromPath("Fables.cbl");
|
||||
//
|
||||
// // Mock up our series
|
||||
// var fablesSeries = DbFactory.Series("Fables");
|
||||
// var fables2Series = DbFactory.Series("Fables: The Last Castle");
|
||||
//
|
||||
// fablesSeries.Volumes.Add(new Volume()
|
||||
// {
|
||||
// Number = 1,
|
||||
// Name = "2002",
|
||||
// Chapters = new List<Chapter>()
|
||||
// {
|
||||
// EntityFactory.CreateChapter("1", false),
|
||||
// EntityFactory.CreateChapter("2", false),
|
||||
// EntityFactory.CreateChapter("3", false),
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// fables2Series.Volumes.Add(new Volume()
|
||||
// {
|
||||
// Number = 1,
|
||||
// Name = "2003",
|
||||
// Chapters = new List<Chapter>()
|
||||
// {
|
||||
// EntityFactory.CreateChapter("1", false),
|
||||
// EntityFactory.CreateChapter("2", false),
|
||||
// EntityFactory.CreateChapter("3", false),
|
||||
//
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// _context.AppUser.Add(new AppUser()
|
||||
// {
|
||||
// UserName = "majora2007",
|
||||
// ReadingLists = new List<ReadingList>(),
|
||||
// Libraries = new List<Library>(),
|
||||
// });
|
||||
//
|
||||
// _context.Library.Add(new Library()
|
||||
// {
|
||||
// Name = "Test Lib 2",
|
||||
// Type = LibraryType.Book,
|
||||
// Series = new List<Series>()
|
||||
// {
|
||||
// fablesSeries,
|
||||
// fables2Series,
|
||||
// },
|
||||
// });
|
||||
//
|
||||
// await _unitOfWork.CommitAsync();
|
||||
//
|
||||
// var importSummary = await _readingListService.CreateReadingListFromCbl(1, cblReadingList);
|
||||
//
|
||||
// Assert.Equal(CblImportResult.Fail, importSummary.Success);
|
||||
// Assert.NotEmpty(importSummary.Results);
|
||||
//
|
||||
// var createdList = await _unitOfWork.ReadingListRepository.GetReadingListByIdAsync(1);
|
||||
//
|
||||
// Assert.Null(createdList);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// [Fact]
|
||||
// public async Task CreateReadingListFromCBL_ShouldUpdateAnExistingList()
|
||||
// {
|
||||
// await ResetDb();
|
||||
// var cblReadingList = LoadCblFromPath("Fables.cbl");
|
||||
//
|
||||
// // Mock up our series
|
||||
// var fablesSeries = DbFactory.Series("Fables");
|
||||
// var fables2Series = DbFactory.Series("Fables: The Last Castle");
|
||||
//
|
||||
// fablesSeries.Volumes.Add(new Volume()
|
||||
// {
|
||||
// Number = 1,
|
||||
// Name = "2002",
|
||||
// Chapters = new List<Chapter>()
|
||||
// {
|
||||
// EntityFactory.CreateChapter("1", false),
|
||||
// EntityFactory.CreateChapter("2", false),
|
||||
// EntityFactory.CreateChapter("3", false),
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// fables2Series.Volumes.Add(new Volume()
|
||||
// {
|
||||
// Number = 1,
|
||||
// Name = "2003",
|
||||
// Chapters = new List<Chapter>()
|
||||
// {
|
||||
// EntityFactory.CreateChapter("1", false),
|
||||
// EntityFactory.CreateChapter("2", false),
|
||||
// EntityFactory.CreateChapter("3", false),
|
||||
//
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// _context.AppUser.Add(new AppUser()
|
||||
// {
|
||||
// UserName = "majora2007",
|
||||
// ReadingLists = new List<ReadingList>(),
|
||||
// Libraries = new List<Library>()
|
||||
// {
|
||||
// new Library()
|
||||
// {
|
||||
// Name = "Test LIb",
|
||||
// Type = LibraryType.Book,
|
||||
// Series = new List<Series>()
|
||||
// {
|
||||
// fablesSeries,
|
||||
// fables2Series
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// });
|
||||
//
|
||||
// await _unitOfWork.CommitAsync();
|
||||
//
|
||||
// // Create a reading list named Fables and add 2 chapters to it
|
||||
// var user = await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.ReadingLists);
|
||||
// var readingList = await _readingListService.CreateReadingListForUser(user, "Fables");
|
||||
// Assert.True(await _readingListService.AddChaptersToReadingList(1, new List<int>() {1, 3}, readingList));
|
||||
// Assert.Equal(2, readingList.Items.Count);
|
||||
//
|
||||
// // Attempt to import a Cbl with same reading list name
|
||||
// var importSummary = await _readingListService.CreateReadingListFromCbl(1, cblReadingList);
|
||||
//
|
||||
// Assert.Equal(CblImportResult.Partial, importSummary.Success);
|
||||
// Assert.NotEmpty(importSummary.Results);
|
||||
//
|
||||
// var createdList = await _unitOfWork.ReadingListRepository.GetReadingListByIdAsync(1);
|
||||
//
|
||||
// Assert.NotNull(createdList);
|
||||
// Assert.Equal("Fables", createdList.Title);
|
||||
//
|
||||
// Assert.Equal(4, createdList.Items.Count);
|
||||
// Assert.Equal(4, importSummary.SuccessfulInserts.Count);
|
||||
//
|
||||
// Assert.Equal(1, createdList.Items.First(item => item.Order == 0).ChapterId);
|
||||
// Assert.Equal(3, createdList.Items.First(item => item.Order == 1).ChapterId); // we inserted 3 first
|
||||
// Assert.Equal(2, createdList.Items.First(item => item.Order == 2).ChapterId);
|
||||
// Assert.Equal(4, createdList.Items.First(item => item.Order == 3).ChapterId);
|
||||
// }
|
||||
// #endregion
|
||||
//
|
||||
}
|
||||
|
67
API.Tests/Services/Test Data/ReadingListService/Fables.cbl
Normal file
67
API.Tests/Services/Test Data/ReadingListService/Fables.cbl
Normal file
@ -0,0 +1,67 @@
|
||||
<?xml version="1.0"?>
|
||||
<ReadingList xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<Name>Fables</Name>
|
||||
<Books>
|
||||
<Book Series="Fables" Number="1" Volume="2002" Year="2002">
|
||||
<Id>5bd3dd55-2a85-4325-aefa-21e9f19b12c9</Id>
|
||||
</Book>
|
||||
<Book Series="Fables" Number="2" Volume="2002" Year="2002">
|
||||
<Id>3831761c-604a-4420-bed2-9f5ac4e94bd4</Id>
|
||||
</Book>
|
||||
<Book Series="Fables" Number="3" Volume="2002" Year="2002">
|
||||
<Id>6353c208-b566-4cc2-b07f-96e122caae31</Id>
|
||||
</Book>
|
||||
<Book Series="Fables" Number="4" Volume="2002" Year="2002">
|
||||
<Id>09688abb-6ec3-4e98-8acf-d622e3b210ab</Id>
|
||||
</Book>
|
||||
<Book Series="Fables" Number="5" Volume="2002" Year="2002">
|
||||
<Id>23acefd4-1bc7-4c3c-99df-133045d1f266</Id>
|
||||
</Book>
|
||||
<Book Series="Fables" Number="6" Volume="2002" Year="2002">
|
||||
<Id>27a5d7db-9f7e-4be1-aca6-998a1cc1488f</Id>
|
||||
</Book>
|
||||
<Book Series="Fables" Number="7" Volume="2002" Year="2003">
|
||||
<Id>872d1218-b463-4d00-b588-a36e24e3f6d2</Id>
|
||||
</Book>
|
||||
<Book Series="Fables" Number="8" Volume="2002" Year="2003">
|
||||
<Id>8fdbe8fe-a83c-4f23-b37a-66b214517c80</Id>
|
||||
</Book>
|
||||
<Book Series="Fables" Number="9" Volume="2002" Year="2003">
|
||||
<Id>4759c53e-6ae7-423f-b5bf-f3310764765e</Id>
|
||||
</Book>
|
||||
<Book Series="Fables" Number="10" Volume="2002" Year="2003">
|
||||
<Id>7d6b38cd-f83b-4762-8026-9e6edc8c4f22</Id>
|
||||
</Book>
|
||||
<Book Series="Fables" Number="11" Volume="2002" Year="2003">
|
||||
<Id>23a48c6f-2879-4d06-9f24-a1d605292059</Id>
|
||||
</Book>
|
||||
<Book Series="Fables" Number="12" Volume="2002" Year="2003">
|
||||
<Id>0345cf90-de98-43a9-8c4f-9b2a7f000ca6</Id>
|
||||
</Book>
|
||||
<Book Series="Fables" Number="13" Volume="2002" Year="2003">
|
||||
<Id>7ad9aa88-2156-42bd-b8bf-a92525fbf9ee</Id>
|
||||
</Book>
|
||||
<Book Series="Fables" Number="14" Volume="2002" Year="2003">
|
||||
<Id>c2ffb724-016b-411c-846b-412f7b003ef6</Id>
|
||||
</Book>
|
||||
<Book Series="Fables" Number="15" Volume="2002" Year="2003">
|
||||
<Id>f3f38f3f-42e8-47e6-9b36-87d00ce48b1b</Id>
|
||||
</Book>
|
||||
<Book Series="Fables" Number="16" Volume="2002" Year="2003">
|
||||
<Id>54523d9b-31e5-4fd2-840b-8c653a457b7b</Id>
|
||||
</Book>
|
||||
<Book Series="Fables" Number="17" Volume="2002" Year="2003">
|
||||
<Id>01eb2417-fb46-4621-a0c3-ecf9ea3a2221</Id>
|
||||
</Book>
|
||||
<Book Series="Fables" Number="18" Volume="2002" Year="2003">
|
||||
<Id>091e72bf-fa87-4f95-ab75-f8ed3d943828</Id>
|
||||
</Book>
|
||||
<Book Series="Fables: The Last Castle" Number="1" Volume="2003" Year="2003">
|
||||
<Id>cad6353e-09c8-470a-b58a-0896c9b0a5d2</Id>
|
||||
</Book>
|
||||
<Book Series="Fables" Number="22" Volume="2002" Year="2004">
|
||||
<Id>33d7e642-0cd3-48a1-a3ee-30aaf9f31edd</Id>
|
||||
</Book>
|
||||
</Books>
|
||||
<Matchers />
|
||||
</ReadingList>
|
@ -1,17 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Abstractions;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using API.Comparators;
|
||||
using API.Data;
|
||||
using API.Data.Repositories;
|
||||
using API.DTOs.ReadingLists;
|
||||
using API.DTOs.ReadingLists.CBL;
|
||||
using API.Entities;
|
||||
using API.Extensions;
|
||||
using API.Helpers;
|
||||
using API.Services;
|
||||
using API.SignalR;
|
||||
using Kavita.Common;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace API.Controllers;
|
||||
@ -22,12 +27,14 @@ public class ReadingListController : BaseApiController
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly IEventHub _eventHub;
|
||||
private readonly IReadingListService _readingListService;
|
||||
private readonly IDirectoryService _directoryService;
|
||||
|
||||
public ReadingListController(IUnitOfWork unitOfWork, IEventHub eventHub, IReadingListService readingListService)
|
||||
public ReadingListController(IUnitOfWork unitOfWork, IEventHub eventHub, IReadingListService readingListService, IDirectoryService directoryService)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
_eventHub = eventHub;
|
||||
_readingListService = readingListService;
|
||||
_directoryService = directoryService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -180,21 +187,16 @@ public class ReadingListController : BaseApiController
|
||||
public async Task<ActionResult<ReadingListDto>> CreateList(CreateReadingListDto dto)
|
||||
{
|
||||
|
||||
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername(), AppUserIncludes.ReadingListsWithItems);
|
||||
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername(), AppUserIncludes.ReadingLists);
|
||||
|
||||
// When creating, we need to make sure Title is unique
|
||||
var hasExisting = user.ReadingLists.Any(l => l.Title.Equals(dto.Title));
|
||||
if (hasExisting)
|
||||
try
|
||||
{
|
||||
return BadRequest("A list of this name already exists");
|
||||
await _readingListService.CreateReadingListForUser(user, dto.Title);
|
||||
}
|
||||
catch (KavitaException ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
|
||||
var readingList = DbFactory.ReadingList(dto.Title, string.Empty, false);
|
||||
user.ReadingLists.Add(readingList);
|
||||
|
||||
if (!_unitOfWork.HasChanges()) return BadRequest("There was a problem creating list");
|
||||
|
||||
await _unitOfWork.CommitAsync();
|
||||
|
||||
return Ok(await _unitOfWork.ReadingListRepository.GetReadingListDtoByTitleAsync(user.Id, dto.Title));
|
||||
}
|
||||
@ -216,37 +218,16 @@ public class ReadingListController : BaseApiController
|
||||
return BadRequest("You do not have permissions on this reading list or the list doesn't exist");
|
||||
}
|
||||
|
||||
dto.Title = dto.Title.Trim();
|
||||
|
||||
if (string.IsNullOrEmpty(dto.Title)) return BadRequest("Title must be set");
|
||||
if (!dto.Title.Equals(readingList.Title) && await _unitOfWork.ReadingListRepository.ReadingListExists(dto.Title))
|
||||
return BadRequest("Reading list already exists");
|
||||
|
||||
|
||||
readingList.Summary = dto.Summary;
|
||||
readingList.Title = dto.Title;
|
||||
readingList.NormalizedTitle = Services.Tasks.Scanner.Parser.Parser.Normalize(readingList.Title);
|
||||
readingList.Promoted = dto.Promoted;
|
||||
readingList.CoverImageLocked = dto.CoverImageLocked;
|
||||
|
||||
if (!dto.CoverImageLocked)
|
||||
try
|
||||
{
|
||||
readingList.CoverImageLocked = false;
|
||||
readingList.CoverImage = string.Empty;
|
||||
await _eventHub.SendMessageAsync(MessageFactory.CoverUpdate,
|
||||
MessageFactory.CoverUpdateEvent(readingList.Id, MessageFactoryEntityTypes.ReadingList), false);
|
||||
_unitOfWork.ReadingListRepository.Update(readingList);
|
||||
await _readingListService.UpdateReadingList(readingList, dto);
|
||||
}
|
||||
catch (KavitaException ex)
|
||||
{
|
||||
return BadRequest(ex.Message);
|
||||
}
|
||||
|
||||
_unitOfWork.ReadingListRepository.Update(readingList);
|
||||
|
||||
if (!_unitOfWork.HasChanges()) return Ok("Updated");
|
||||
|
||||
if (await _unitOfWork.CommitAsync())
|
||||
{
|
||||
return Ok("Updated");
|
||||
}
|
||||
return BadRequest("Could not update reading list");
|
||||
return Ok("Updated");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -503,4 +484,22 @@ public class ReadingListController : BaseApiController
|
||||
if (string.IsNullOrEmpty(name)) return true;
|
||||
return Ok(await _unitOfWork.ReadingListRepository.ReadingListExists(name));
|
||||
}
|
||||
|
||||
// [HttpPost("import-cbl")]
|
||||
// public async Task<ActionResult<CblImportSummaryDto>> ImportCbl([FromForm(Name = "cbl")] IFormFile file, [FromForm(Name = "dryRun")] bool dryRun = false)
|
||||
// {
|
||||
// var userId = User.GetUserId();
|
||||
// var filename = Path.GetRandomFileName();
|
||||
// var outputFile = Path.Join(_directoryService.TempDirectory, filename);
|
||||
//
|
||||
// await using var stream = System.IO.File.Create(outputFile);
|
||||
// await file.CopyToAsync(stream);
|
||||
// stream.Close();
|
||||
// var cbl = ReadingListService.LoadCblFromPath(outputFile);
|
||||
//
|
||||
// // We need to pass the temp file back
|
||||
//
|
||||
// var importSummary = await _readingListService.ValidateCblFile(userId, cbl);
|
||||
// return importSummary.Results.Any() ? Ok(importSummary) : Ok(await _readingListService.CreateReadingListFromCbl(userId, cbl, dryRun));
|
||||
// }
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ namespace API.Controllers;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Authorize(Policy = "RequireAdminRole")]
|
||||
public class UploadController : BaseApiController
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
@ -26,10 +25,11 @@ public class UploadController : BaseApiController
|
||||
private readonly ITaskScheduler _taskScheduler;
|
||||
private readonly IDirectoryService _directoryService;
|
||||
private readonly IEventHub _eventHub;
|
||||
private readonly IReadingListService _readingListService;
|
||||
|
||||
/// <inheritdoc />
|
||||
public UploadController(IUnitOfWork unitOfWork, IImageService imageService, ILogger<UploadController> logger,
|
||||
ITaskScheduler taskScheduler, IDirectoryService directoryService, IEventHub eventHub)
|
||||
ITaskScheduler taskScheduler, IDirectoryService directoryService, IEventHub eventHub, IReadingListService readingListService)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
_imageService = imageService;
|
||||
@ -37,6 +37,7 @@ public class UploadController : BaseApiController
|
||||
_taskScheduler = taskScheduler;
|
||||
_directoryService = directoryService;
|
||||
_eventHub = eventHub;
|
||||
_readingListService = readingListService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -170,9 +171,9 @@ public class UploadController : BaseApiController
|
||||
/// <summary>
|
||||
/// Replaces reading list cover image and locks it with a base64 encoded image
|
||||
/// </summary>
|
||||
/// <remarks>This is the only API that can be called by non-admins, but the authenticated user must have a readinglist permission</remarks>
|
||||
/// <param name="uploadFileDto"></param>
|
||||
/// <returns></returns>
|
||||
[Authorize(Policy = "RequireAdminRole")]
|
||||
[RequestSizeLimit(8_000_000)]
|
||||
[HttpPost("reading-list")]
|
||||
public async Task<ActionResult> UploadReadingListCoverImageFromUrl(UploadFileDto uploadFileDto)
|
||||
@ -184,6 +185,9 @@ public class UploadController : BaseApiController
|
||||
return BadRequest("You must pass a url to use");
|
||||
}
|
||||
|
||||
if (_readingListService.UserHasReadingListAccess(uploadFileDto.Id, User.GetUsername()) == null)
|
||||
return Unauthorized("You do not have access");
|
||||
|
||||
try
|
||||
{
|
||||
var filePath = _imageService.CreateThumbnailFromBase64(uploadFileDto.Url, $"{ImageService.GetReadingListFormat(uploadFileDto.Id)}");
|
||||
|
29
API/DTOs/ReadingLists/CBL/CblBook.cs
Normal file
29
API/DTOs/ReadingLists/CBL/CblBook.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace API.DTOs.ReadingLists.CBL;
|
||||
|
||||
|
||||
[XmlRoot(ElementName="Book")]
|
||||
public class CblBook
|
||||
{
|
||||
[XmlAttribute("Series")]
|
||||
public string Series { get; set; }
|
||||
/// <summary>
|
||||
/// Chapter Number
|
||||
/// </summary>
|
||||
[XmlAttribute("Number")]
|
||||
public string Number { get; set; }
|
||||
/// <summary>
|
||||
/// Volume Number (usually for Comics they are the year)
|
||||
/// </summary>
|
||||
[XmlAttribute("Volume")]
|
||||
public string Volume { get; set; }
|
||||
[XmlAttribute("Year")]
|
||||
public string Year { get; set; }
|
||||
/// <summary>
|
||||
/// The underlying filetype
|
||||
/// </summary>
|
||||
/// <remarks>This is not part of the standard and explicitly for Kavita to support non cbz/cbr files</remarks>
|
||||
[XmlAttribute("FileType")]
|
||||
public string FileType { get; set; }
|
||||
}
|
10
API/DTOs/ReadingLists/CBL/CblConflictsDto.cs
Normal file
10
API/DTOs/ReadingLists/CBL/CblConflictsDto.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace API.DTOs.ReadingLists.CBL;
|
||||
|
||||
|
||||
public class CblConflictQuestion
|
||||
{
|
||||
public string SeriesName { get; set; }
|
||||
public IList<int> LibrariesIds { get; set; }
|
||||
}
|
104
API/DTOs/ReadingLists/CBL/CblImportSummary.cs
Normal file
104
API/DTOs/ReadingLists/CBL/CblImportSummary.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using API.DTOs.ReadingLists.CBL;
|
||||
|
||||
namespace API.DTOs.ReadingLists;
|
||||
|
||||
public enum CblImportResult {
|
||||
/// <summary>
|
||||
/// There was an issue which prevented processing
|
||||
/// </summary>
|
||||
[Description("Fail")]
|
||||
Fail = 0,
|
||||
/// <summary>
|
||||
/// Some items were added, but not all
|
||||
/// </summary>
|
||||
[Description("Partial")]
|
||||
Partial = 1,
|
||||
/// <summary>
|
||||
/// Everything was imported correctly
|
||||
/// </summary>
|
||||
[Description("Success")]
|
||||
Success = 2
|
||||
}
|
||||
|
||||
public enum CblImportReason
|
||||
{
|
||||
/// <summary>
|
||||
/// The Chapter is not present in Kavita
|
||||
/// </summary>
|
||||
[Description("Chapter missing")]
|
||||
ChapterMissing = 0,
|
||||
/// <summary>
|
||||
/// The Volume is not present in Kavita or no Volume field present in CBL and there is no chapter matching
|
||||
/// </summary>
|
||||
[Description("Volume missing")]
|
||||
VolumeMissing = 1,
|
||||
/// <summary>
|
||||
/// The Series is not present in Kavita or the user does not have access to the Series due to some account restrictions
|
||||
/// </summary>
|
||||
[Description("Series missing")]
|
||||
SeriesMissing = 2,
|
||||
/// <summary>
|
||||
/// The CBL Name conflicts with another Reading List in the system
|
||||
/// </summary>
|
||||
[Description("Name Conflict")]
|
||||
NameConflict = 3,
|
||||
/// <summary>
|
||||
/// Every Series in the Reading list is missing from within Kavita or user has access restrictions to
|
||||
/// </summary>
|
||||
[Description("All Series Missing")]
|
||||
AllSeriesMissing = 4,
|
||||
/// <summary>
|
||||
/// There are no Book entries in the CBL
|
||||
/// </summary>
|
||||
[Description("Empty File")]
|
||||
EmptyFile = 5,
|
||||
/// <summary>
|
||||
/// Series Collides between Libraries
|
||||
/// </summary>
|
||||
[Description("Series Collision")]
|
||||
SeriesCollision = 6,
|
||||
/// <summary>
|
||||
/// Every book chapter is missing or can't be matched
|
||||
/// </summary>
|
||||
[Description("All Chapters Missing")]
|
||||
AllChapterMissing = 7,
|
||||
}
|
||||
|
||||
public class CblBookResult
|
||||
{
|
||||
public string Series { get; set; }
|
||||
public string Volume { get; set; }
|
||||
public string Number { get; set; }
|
||||
public CblImportReason Reason { get; set; }
|
||||
|
||||
public CblBookResult(CblBook book)
|
||||
{
|
||||
Series = book.Series;
|
||||
Volume = book.Volume;
|
||||
Number = book.Number;
|
||||
}
|
||||
|
||||
public CblBookResult()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents the summary from the Import of a given CBL
|
||||
/// </summary>
|
||||
public class CblImportSummaryDto
|
||||
{
|
||||
public string CblName { get; set; }
|
||||
public ICollection<CblBookResult> Results { get; set; }
|
||||
public CblImportResult Success { get; set; }
|
||||
public ICollection<CblBookResult> SuccessfulInserts { get; set; }
|
||||
/// <summary>
|
||||
/// A list of Series that are within the CBL but map to multiple libraries within Kavita
|
||||
/// </summary>
|
||||
public IList<SeriesDto> Conflicts { get; set; }
|
||||
public IList<CblConflictQuestion> Conflicts2 { get; set; }
|
||||
|
||||
}
|
26
API/DTOs/ReadingLists/CBL/CblReadingList.cs
Normal file
26
API/DTOs/ReadingLists/CBL/CblReadingList.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace API.DTOs.ReadingLists.CBL;
|
||||
|
||||
|
||||
[XmlRoot(ElementName="Books")]
|
||||
public class CblBooks
|
||||
{
|
||||
[XmlElement(ElementName="Book")]
|
||||
public List<CblBook> Book { get; set; }
|
||||
}
|
||||
|
||||
|
||||
[XmlRoot(ElementName="ReadingList")]
|
||||
public class CblReadingList
|
||||
{
|
||||
/// <summary>
|
||||
/// Name of the Reading List
|
||||
/// </summary>
|
||||
[XmlElement(ElementName="Name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[XmlElement(ElementName="Books")]
|
||||
public CblBooks Books { get; set; }
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using API.Entities;
|
||||
using API.Entities.Enums;
|
||||
using Kavita.Common.Extensions;
|
||||
|
||||
@ -54,13 +55,27 @@ public class ComicInfo
|
||||
/// User's rating of the content
|
||||
/// </summary>
|
||||
public float UserRating { get; set; }
|
||||
|
||||
public string StoryArc { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// Can contain multiple comma separated strings, each create a <see cref="CollectionTag"/>
|
||||
/// </summary>
|
||||
public string SeriesGroup { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string StoryArc { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// Can contain multiple comma separated numbers that match with StoryArc
|
||||
/// </summary>
|
||||
public string StoryArcNumber { get; set; } = string.Empty;
|
||||
public string AlternateNumber { get; set; } = string.Empty;
|
||||
public string AlternateSeries { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Not used
|
||||
/// </summary>
|
||||
[System.ComponentModel.DefaultValueAttribute(0)]
|
||||
public int AlternateCount { get; set; } = 0;
|
||||
public string AlternateSeries { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// This is Epub only: calibre:title_sort
|
||||
|
1769
API/Data/Migrations/20230202182602_ReadingListFields.Designer.cs
generated
Normal file
1769
API/Data/Migrations/20230202182602_ReadingListFields.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
66
API/Data/Migrations/20230202182602_ReadingListFields.cs
Normal file
66
API/Data/Migrations/20230202182602_ReadingListFields.cs
Normal file
@ -0,0 +1,66 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace API.Data.Migrations
|
||||
{
|
||||
public partial class ReadingListFields : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "AlternateCount",
|
||||
table: "Chapter",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "AlternateNumber",
|
||||
table: "Chapter",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "AlternateSeries",
|
||||
table: "Chapter",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "StoryArc",
|
||||
table: "Chapter",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "StoryArcNumber",
|
||||
table: "Chapter",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AlternateCount",
|
||||
table: "Chapter");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AlternateNumber",
|
||||
table: "Chapter");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AlternateSeries",
|
||||
table: "Chapter");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "StoryArc",
|
||||
table: "Chapter");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "StoryArcNumber",
|
||||
table: "Chapter");
|
||||
}
|
||||
}
|
||||
}
|
@ -378,6 +378,15 @@ namespace API.Data.Migrations
|
||||
b.Property<int>("AgeRating")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("AlternateCount")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("AlternateNumber")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("AlternateSeries")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("AvgHoursToRead")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
@ -429,6 +438,12 @@ namespace API.Data.Migrations
|
||||
b.Property<string>("SeriesGroup")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("StoryArc")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("StoryArcNumber")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Summary")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using API.DTOs.ReadingLists;
|
||||
@ -31,6 +32,7 @@ public interface IReadingListRepository
|
||||
Task<string> GetCoverImageAsync(int readingListId);
|
||||
Task<IList<string>> GetAllCoverImagesAsync();
|
||||
Task<bool> ReadingListExists(string name);
|
||||
Task<List<ReadingList>> GetAllReadingListsAsync();
|
||||
}
|
||||
|
||||
public class ReadingListRepository : IReadingListRepository
|
||||
@ -84,6 +86,15 @@ public class ReadingListRepository : IReadingListRepository
|
||||
.AnyAsync(x => x.NormalizedTitle.Equals(normalized));
|
||||
}
|
||||
|
||||
public async Task<List<ReadingList>> GetAllReadingListsAsync()
|
||||
{
|
||||
return await _context.ReadingList
|
||||
.Include(r => r.Items.OrderBy(i => i.Order))
|
||||
.AsSplitQuery()
|
||||
.OrderBy(l => l.Title)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public void Remove(ReadingListItem item)
|
||||
{
|
||||
_context.ReadingListItem.Remove(item);
|
||||
|
@ -35,6 +35,7 @@ public enum SeriesIncludes
|
||||
Metadata = 4,
|
||||
Related = 8,
|
||||
Library = 16,
|
||||
Chapters = 32
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -115,6 +116,11 @@ public interface ISeriesRepository
|
||||
Task<PagedList<SeriesDto>> GetWantToReadForUserAsync(int userId, UserParams userParams, FilterDto filter);
|
||||
Task<bool> IsSeriesInWantToRead(int userId, int seriesId);
|
||||
Task<Series> GetSeriesByFolderPath(string folder, SeriesIncludes includes = SeriesIncludes.None);
|
||||
|
||||
Task<IEnumerable<Series>> GetAllSeriesByNameAsync(IEnumerable<string> normalizedNames,
|
||||
int userId, SeriesIncludes includes = SeriesIncludes.None);
|
||||
Task<IEnumerable<SeriesDto>> GetAllSeriesDtosByNameAsync(IEnumerable<string> normalizedNames,
|
||||
int userId, SeriesIncludes includes = SeriesIncludes.None);
|
||||
Task<Series> GetFullSeriesByAnyName(string seriesName, string localizedName, int libraryId, MangaFormat format, bool withFullIncludes = true);
|
||||
Task<IList<Series>> RemoveSeriesNotInList(IList<ParsedSeries> seenSeries, int libraryId);
|
||||
Task<IDictionary<string, IList<SeriesModified>>> GetFolderPathMap(int libraryId);
|
||||
@ -545,6 +551,7 @@ public class SeriesRepository : ISeriesRepository
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
|
||||
public async Task AddSeriesModifiers(int userId, List<SeriesDto> series)
|
||||
{
|
||||
var userProgress = await _context.AppUserProgresses
|
||||
@ -1200,6 +1207,35 @@ public class SeriesRepository : ISeriesRepository
|
||||
.SingleOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Series>> GetAllSeriesByNameAsync(IEnumerable<string> normalizedNames,
|
||||
int userId, SeriesIncludes includes = SeriesIncludes.None)
|
||||
{
|
||||
var libraryIds = _context.Library.GetUserLibraries(userId);
|
||||
var userRating = await _context.AppUser.GetUserAgeRestriction(userId);
|
||||
|
||||
return await _context.Series
|
||||
.Where(s => normalizedNames.Contains(s.NormalizedName))
|
||||
.Where(s => libraryIds.Contains(s.LibraryId))
|
||||
.RestrictAgainstAgeRestriction(userRating)
|
||||
.Includes(includes)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<SeriesDto>> GetAllSeriesDtosByNameAsync(IEnumerable<string> normalizedNames, int userId,
|
||||
SeriesIncludes includes = SeriesIncludes.None)
|
||||
{
|
||||
var libraryIds = _context.Library.GetUserLibraries(userId);
|
||||
var userRating = await _context.AppUser.GetUserAgeRestriction(userId);
|
||||
|
||||
return await _context.Series
|
||||
.Where(s => normalizedNames.Contains(s.NormalizedName))
|
||||
.Where(s => libraryIds.Contains(s.LibraryId))
|
||||
.RestrictAgainstAgeRestriction(userRating)
|
||||
.Includes(includes)
|
||||
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds a series by series name or localized name for a given library.
|
||||
/// </summary>
|
||||
|
@ -119,6 +119,7 @@ public class UserRepository : IUserRepository
|
||||
var query = _context.Users
|
||||
.Where(x => x.UserName == username);
|
||||
|
||||
// TODO: Move to QueryExtensions
|
||||
query = AddIncludesToQuery(query, includeFlags);
|
||||
|
||||
return await query.SingleOrDefaultAsync();
|
||||
@ -201,9 +202,7 @@ public class UserRepository : IUserRepository
|
||||
query = query.Include(u => u.Devices);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return query;
|
||||
return query.AsSplitQuery();
|
||||
}
|
||||
|
||||
|
||||
|
@ -80,6 +80,15 @@ public class Chapter : IEntityDate, IHasReadTimeEstimate
|
||||
/// SeriesGroup tag in ComicInfo
|
||||
/// </summary>
|
||||
public string SeriesGroup { get; set; }
|
||||
public string StoryArc { get; set; } = string.Empty;
|
||||
public string StoryArcNumber { get; set; } = string.Empty;
|
||||
public string AlternateNumber { get; set; } = string.Empty;
|
||||
public string AlternateSeries { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Not currently used in Kavita
|
||||
/// </summary>
|
||||
public int AlternateCount { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Total Word count of all chapters in this chapter.
|
||||
|
@ -156,6 +156,13 @@ public static class QueryableExtensions
|
||||
query = query.Include(s => s.Volumes);
|
||||
}
|
||||
|
||||
if (includeFlags.HasFlag(SeriesIncludes.Chapters))
|
||||
{
|
||||
query = query
|
||||
.Include(s => s.Volumes)
|
||||
.ThenInclude(v => v.Chapters);
|
||||
}
|
||||
|
||||
if (includeFlags.HasFlag(SeriesIncludes.Related))
|
||||
{
|
||||
query = query.Include(s => s.Relations)
|
||||
|
@ -150,13 +150,7 @@ public class CollectionTagService : ICollectionTagService
|
||||
/// <returns></returns>
|
||||
public async Task<CollectionTag> GetTagOrCreate(int tagId, string title)
|
||||
{
|
||||
var tag = await _unitOfWork.CollectionTagRepository.GetFullTagAsync(tagId);
|
||||
if (tag == null)
|
||||
{
|
||||
tag = CreateTag(title);
|
||||
}
|
||||
|
||||
return tag;
|
||||
return await _unitOfWork.CollectionTagRepository.GetFullTagAsync(tagId) ?? CreateTag(title);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,19 +1,27 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using API.Comparators;
|
||||
using API.Data;
|
||||
using API.Data.Repositories;
|
||||
using API.DTOs;
|
||||
using API.DTOs.ReadingLists;
|
||||
using API.DTOs.ReadingLists.CBL;
|
||||
using API.Entities;
|
||||
using API.Entities.Enums;
|
||||
using API.SignalR;
|
||||
using Kavita.Common;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace API.Services;
|
||||
|
||||
public interface IReadingListService
|
||||
{
|
||||
Task<ReadingList> CreateReadingListForUser(AppUser userWithReadingList, string title);
|
||||
Task UpdateReadingList(ReadingList readingList, UpdateReadingListDto dto);
|
||||
Task<bool> RemoveFullyReadItems(int readingListId, AppUser user);
|
||||
Task<bool> UpdateReadingListItemPosition(UpdateReadingListPosition dto);
|
||||
Task<bool> DeleteReadingListItem(UpdateReadingListPosition dto);
|
||||
@ -22,6 +30,9 @@ public interface IReadingListService
|
||||
Task CalculateReadingListAgeRating(ReadingList readingList);
|
||||
Task<bool> AddChaptersToReadingList(int seriesId, IList<int> chapterIds,
|
||||
ReadingList readingList);
|
||||
|
||||
Task<CblImportSummaryDto> ValidateCblFile(int userId, CblReadingList cblReading);
|
||||
Task<CblImportSummaryDto> CreateReadingListFromCbl(int userId, CblReadingList cblReading, bool dryRun = false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -32,14 +43,16 @@ public class ReadingListService : IReadingListService
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly ILogger<ReadingListService> _logger;
|
||||
private readonly ChapterSortComparerZeroFirst _chapterSortComparerForInChapterSorting = new ChapterSortComparerZeroFirst();
|
||||
private readonly IEventHub _eventHub;
|
||||
private readonly ChapterSortComparerZeroFirst _chapterSortComparerForInChapterSorting = ChapterSortComparerZeroFirst.Default;
|
||||
private static readonly Regex JustNumbers = new Regex(@"^\d+$", RegexOptions.Compiled | RegexOptions.IgnoreCase,
|
||||
Tasks.Scanner.Parser.Parser.RegexTimeout);
|
||||
|
||||
public ReadingListService(IUnitOfWork unitOfWork, ILogger<ReadingListService> logger)
|
||||
public ReadingListService(IUnitOfWork unitOfWork, ILogger<ReadingListService> logger, IEventHub eventHub)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
_logger = logger;
|
||||
_eventHub = eventHub;
|
||||
}
|
||||
|
||||
public static string FormatTitle(ReadingListItemDto item)
|
||||
@ -86,6 +99,66 @@ public class ReadingListService : IReadingListService
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new Reading List for a User
|
||||
/// </summary>
|
||||
/// <param name="userWithReadingList"></param>
|
||||
/// <param name="title"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="KavitaException"></exception>
|
||||
public async Task<ReadingList> CreateReadingListForUser(AppUser userWithReadingList, string title)
|
||||
{
|
||||
// When creating, we need to make sure Title is unique
|
||||
// TODO: Perform normalization
|
||||
var hasExisting = userWithReadingList.ReadingLists.Any(l => l.Title.Equals(title));
|
||||
if (hasExisting)
|
||||
{
|
||||
throw new KavitaException("A list of this name already exists");
|
||||
}
|
||||
|
||||
var readingList = DbFactory.ReadingList(title, string.Empty, false);
|
||||
userWithReadingList.ReadingLists.Add(readingList);
|
||||
|
||||
if (!_unitOfWork.HasChanges()) throw new KavitaException("There was a problem creating list");
|
||||
await _unitOfWork.CommitAsync();
|
||||
return readingList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="readingList"></param>
|
||||
/// <param name="dto"></param>
|
||||
/// <exception cref="KavitaException"></exception>
|
||||
public async Task UpdateReadingList(ReadingList readingList, UpdateReadingListDto dto)
|
||||
{
|
||||
dto.Title = dto.Title.Trim();
|
||||
if (string.IsNullOrEmpty(dto.Title)) throw new KavitaException("Title must be set");
|
||||
|
||||
if (!dto.Title.Equals(readingList.Title) && await _unitOfWork.ReadingListRepository.ReadingListExists(dto.Title))
|
||||
throw new KavitaException("Reading list already exists");
|
||||
|
||||
readingList.Summary = dto.Summary;
|
||||
readingList.Title = dto.Title.Trim();
|
||||
readingList.NormalizedTitle = Tasks.Scanner.Parser.Parser.Normalize(readingList.Title);
|
||||
readingList.Promoted = dto.Promoted;
|
||||
readingList.CoverImageLocked = dto.CoverImageLocked;
|
||||
|
||||
if (!dto.CoverImageLocked)
|
||||
{
|
||||
readingList.CoverImageLocked = false;
|
||||
readingList.CoverImage = string.Empty;
|
||||
await _eventHub.SendMessageAsync(MessageFactory.CoverUpdate,
|
||||
MessageFactory.CoverUpdateEvent(readingList.Id, MessageFactoryEntityTypes.ReadingList), false);
|
||||
_unitOfWork.ReadingListRepository.Update(readingList);
|
||||
}
|
||||
|
||||
_unitOfWork.ReadingListRepository.Update(readingList);
|
||||
|
||||
if (!_unitOfWork.HasChanges()) return;
|
||||
await _unitOfWork.CommitAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all entries that are fully read from the reading list. This commits
|
||||
/// </summary>
|
||||
@ -198,9 +271,10 @@ public class ReadingListService : IReadingListService
|
||||
/// <returns></returns>
|
||||
public async Task<AppUser?> UserHasReadingListAccess(int readingListId, string username)
|
||||
{
|
||||
// We need full reading list with items as this is used by many areas that manipulate items
|
||||
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(username,
|
||||
AppUserIncludes.ReadingListsWithItems);
|
||||
if (user.ReadingLists.SingleOrDefault(rl => rl.Id == readingListId) == null && !await _unitOfWork.UserRepository.IsUserAdminAsync(user))
|
||||
if (!await UserHasReadingListAccess(readingListId, user))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@ -208,6 +282,17 @@ public class ReadingListService : IReadingListService
|
||||
return user;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// User must have ReadingList on it
|
||||
/// </summary>
|
||||
/// <param name="readingListId"></param>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<bool> UserHasReadingListAccess(int readingListId, AppUser user)
|
||||
{
|
||||
return user.ReadingLists.Any(rl => rl.Id == readingListId) || await _unitOfWork.UserRepository.IsUserAdminAsync(user);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the Reading List from kavita
|
||||
/// </summary>
|
||||
@ -246,7 +331,7 @@ public class ReadingListService : IReadingListService
|
||||
.ThenBy(x => double.Parse(x.Number), _chapterSortComparerForInChapterSorting)
|
||||
.ToList();
|
||||
|
||||
var index = lastOrder + 1;
|
||||
var index = readingList.Items.Count == 0 ? 0 : lastOrder + 1;
|
||||
foreach (var chapter in chaptersForSeries.Where(chapter => !existingChapterExists.Contains(chapter.Id)))
|
||||
{
|
||||
readingList.Items.Add(DbFactory.ReadingListItem(index, seriesId, chapter.VolumeId, chapter.Id));
|
||||
@ -257,4 +342,208 @@ public class ReadingListService : IReadingListService
|
||||
|
||||
return index > lastOrder + 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check for File issues like: No entries, Reading List Name collision, Duplicate Series across Libraries
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="cblReading"></param>
|
||||
public async Task<CblImportSummaryDto> ValidateCblFile(int userId, CblReadingList cblReading)
|
||||
{
|
||||
var importSummary = new CblImportSummaryDto()
|
||||
{
|
||||
CblName = cblReading.Name,
|
||||
Success = CblImportResult.Success,
|
||||
Results = new List<CblBookResult>(),
|
||||
SuccessfulInserts = new List<CblBookResult>(),
|
||||
Conflicts = new List<SeriesDto>(),
|
||||
Conflicts2 = new List<CblConflictQuestion>()
|
||||
};
|
||||
if (IsCblEmpty(cblReading, importSummary, out var readingListFromCbl)) return readingListFromCbl;
|
||||
|
||||
var uniqueSeries = cblReading.Books.Book.Select(b => Tasks.Scanner.Parser.Parser.Normalize(b.Series)).Distinct();
|
||||
var userSeries =
|
||||
(await _unitOfWork.SeriesRepository.GetAllSeriesByNameAsync(uniqueSeries, userId, SeriesIncludes.Chapters)).ToList();
|
||||
if (!userSeries.Any())
|
||||
{
|
||||
// Report that no series exist in the reading list
|
||||
importSummary.Results.Add(new CblBookResult()
|
||||
{
|
||||
Reason = CblImportReason.AllSeriesMissing
|
||||
});
|
||||
importSummary.Success = CblImportResult.Fail;
|
||||
return importSummary;
|
||||
}
|
||||
|
||||
var conflicts = FindCblImportConflicts(userSeries);
|
||||
if (!conflicts.Any()) return importSummary;
|
||||
|
||||
importSummary.Success = CblImportResult.Fail;
|
||||
if (conflicts.Count == cblReading.Books.Book.Count)
|
||||
{
|
||||
importSummary.Results.Add(new CblBookResult()
|
||||
{
|
||||
Reason = CblImportReason.AllChapterMissing,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var conflict in conflicts)
|
||||
{
|
||||
importSummary.Results.Add(new CblBookResult()
|
||||
{
|
||||
Reason = CblImportReason.SeriesCollision,
|
||||
Series = conflict.Name
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return importSummary;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Imports (or pretends to) a cbl into a reading list. Call <see cref="ValidateCblFile"/> first!
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="cblReading"></param>
|
||||
/// <param name="dryRun"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<CblImportSummaryDto> CreateReadingListFromCbl(int userId, CblReadingList cblReading, bool dryRun = false)
|
||||
{
|
||||
var user = await _unitOfWork.UserRepository.GetUserByIdAsync(userId, AppUserIncludes.ReadingListsWithItems);
|
||||
_logger.LogDebug("Importing {ReadingListName} CBL for User {UserName}", cblReading.Name, user.UserName);
|
||||
var importSummary = new CblImportSummaryDto()
|
||||
{
|
||||
CblName = cblReading.Name,
|
||||
Success = CblImportResult.Success,
|
||||
Results = new List<CblBookResult>(),
|
||||
SuccessfulInserts = new List<CblBookResult>()
|
||||
};
|
||||
|
||||
var uniqueSeries = cblReading.Books.Book.Select(b => Tasks.Scanner.Parser.Parser.Normalize(b.Series)).Distinct();
|
||||
var userSeries =
|
||||
(await _unitOfWork.SeriesRepository.GetAllSeriesByNameAsync(uniqueSeries, userId, SeriesIncludes.Chapters)).ToList();
|
||||
var allSeries = userSeries.ToDictionary(s => Tasks.Scanner.Parser.Parser.Normalize(s.Name));
|
||||
|
||||
var readingListNameNormalized = Tasks.Scanner.Parser.Parser.Normalize(cblReading.Name);
|
||||
// Get all the user's reading lists
|
||||
var allReadingLists = (user.ReadingLists).ToDictionary(s => s.NormalizedTitle);
|
||||
if (!allReadingLists.TryGetValue(readingListNameNormalized, out var readingList))
|
||||
{
|
||||
readingList = DbFactory.ReadingList(cblReading.Name, string.Empty, false);
|
||||
user.ReadingLists.Add(readingList);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reading List exists, check if we own it
|
||||
if (user.ReadingLists.All(l => l.NormalizedTitle != readingListNameNormalized))
|
||||
{
|
||||
importSummary.Results.Add(new CblBookResult()
|
||||
{
|
||||
Reason = CblImportReason.NameConflict
|
||||
});
|
||||
importSummary.Success = CblImportResult.Fail;
|
||||
return importSummary;
|
||||
}
|
||||
}
|
||||
|
||||
readingList.Items ??= new List<ReadingListItem>();
|
||||
foreach (var (book, i) in cblReading.Books.Book.Select((value, i) => ( value, i )))
|
||||
{
|
||||
var normalizedSeries = Tasks.Scanner.Parser.Parser.Normalize(book.Series);
|
||||
if (!allSeries.TryGetValue(normalizedSeries, out var bookSeries))
|
||||
{
|
||||
importSummary.Results.Add(new CblBookResult(book)
|
||||
{
|
||||
Reason = CblImportReason.SeriesMissing
|
||||
});
|
||||
continue;
|
||||
}
|
||||
// Prioritize lookup by Volume then Chapter, but allow fallback to just Chapter
|
||||
var matchingVolume = bookSeries.Volumes.FirstOrDefault(v => book.Volume == v.Name) ?? bookSeries.Volumes.FirstOrDefault(v => v.Number == 0);
|
||||
if (matchingVolume == null)
|
||||
{
|
||||
importSummary.Results.Add(new CblBookResult(book)
|
||||
{
|
||||
Reason = CblImportReason.VolumeMissing
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
var chapter = matchingVolume.Chapters.FirstOrDefault(c => c.Number == book.Number);
|
||||
if (chapter == null)
|
||||
{
|
||||
importSummary.Results.Add(new CblBookResult(book)
|
||||
{
|
||||
Reason = CblImportReason.ChapterMissing
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
// See if a matching item already exists
|
||||
ExistsOrAddReadingListItem(readingList, bookSeries.Id, matchingVolume.Id, chapter.Id);
|
||||
importSummary.SuccessfulInserts.Add(new CblBookResult(book));
|
||||
}
|
||||
|
||||
if (importSummary.SuccessfulInserts.Count != cblReading.Books.Book.Count || importSummary.Results.Count > 0)
|
||||
{
|
||||
importSummary.Success = CblImportResult.Partial;
|
||||
}
|
||||
|
||||
await CalculateReadingListAgeRating(readingList);
|
||||
|
||||
if (!dryRun) return importSummary;
|
||||
|
||||
if (!_unitOfWork.HasChanges()) return importSummary;
|
||||
await _unitOfWork.CommitAsync();
|
||||
|
||||
|
||||
return importSummary;
|
||||
}
|
||||
|
||||
private static IList<Series> FindCblImportConflicts(IEnumerable<Series> userSeries)
|
||||
{
|
||||
var dict = new HashSet<string>();
|
||||
return userSeries.Where(series => !dict.Add(Tasks.Scanner.Parser.Parser.Normalize(series.Name))).ToList();
|
||||
}
|
||||
|
||||
private static bool IsCblEmpty(CblReadingList cblReading, CblImportSummaryDto importSummary,
|
||||
out CblImportSummaryDto readingListFromCbl)
|
||||
{
|
||||
readingListFromCbl = new CblImportSummaryDto();
|
||||
if (cblReading.Books == null || cblReading.Books.Book.Count == 0)
|
||||
{
|
||||
importSummary.Results.Add(new CblBookResult()
|
||||
{
|
||||
Reason = CblImportReason.EmptyFile
|
||||
});
|
||||
importSummary.Success = CblImportResult.Fail;
|
||||
readingListFromCbl = importSummary;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void ExistsOrAddReadingListItem(ReadingList readingList, int seriesId, int volumeId, int chapterId)
|
||||
{
|
||||
var readingListItem =
|
||||
readingList.Items.FirstOrDefault(item =>
|
||||
item.SeriesId == seriesId && item.ChapterId == chapterId);
|
||||
if (readingListItem != null) return;
|
||||
|
||||
readingListItem = DbFactory.ReadingListItem(readingList.Items.Count, seriesId,
|
||||
volumeId, chapterId);
|
||||
readingList.Items.Add(readingListItem);
|
||||
}
|
||||
|
||||
public static CblReadingList LoadCblFromPath(string path)
|
||||
{
|
||||
var reader = new System.Xml.Serialization.XmlSerializer(typeof(CblReadingList));
|
||||
using var file = new StreamReader(path);
|
||||
var cblReadingList = (CblReadingList) reader.Deserialize(file);
|
||||
file.Close();
|
||||
return cblReadingList;
|
||||
}
|
||||
}
|
||||
|
@ -105,10 +105,20 @@ public class StatisticService : IStatisticService
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
// var averageReadingTimePerWeek = _context.AppUserProgresses
|
||||
// .Where(p => p.AppUserId == userId)
|
||||
// .Join(_context.Chapter, p => p.ChapterId, c => c.Id,
|
||||
// (p, c) => (p.PagesRead / (float) c.Pages) * c.AvgHoursToRead)
|
||||
// .Average() / 7.0;
|
||||
|
||||
var averageReadingTimePerWeek = _context.AppUserProgresses
|
||||
.Where(p => p.AppUserId == userId)
|
||||
.Join(_context.Chapter, p => p.ChapterId, c => c.Id,
|
||||
(p, c) => (p.PagesRead / (float) c.Pages) * c.AvgHoursToRead)
|
||||
(p, c) => new
|
||||
{
|
||||
AverageReadingHours = Math.Min((float) p.PagesRead / (float) c.Pages, 1.0) * ((float) c.AvgHoursToRead)
|
||||
})
|
||||
.Select(x => x.AverageReadingHours)
|
||||
.Average() / 7.0;
|
||||
|
||||
return new UserReadStatistics()
|
||||
@ -373,7 +383,22 @@ public class StatisticService : IStatisticService
|
||||
var minDay = results.Min(d => d.Value);
|
||||
for (var date = minDay; date < DateTime.Now; date = date.AddDays(1))
|
||||
{
|
||||
if (results.Any(d => d.Value == date)) continue;
|
||||
var resultsForDay = results.Where(d => d.Value == date).ToList();
|
||||
if (resultsForDay.Count > 0)
|
||||
{
|
||||
// Add in types that aren't there (there is a bug in UI library that will cause dates to get out of order)
|
||||
var existingFormats = resultsForDay.Select(r => r.Format).Distinct();
|
||||
foreach (var format in Enum.GetValues(typeof(MangaFormat)).Cast<MangaFormat>().Where(f => f != MangaFormat.Unknown && !existingFormats.Contains(f)))
|
||||
{
|
||||
results.Add(new PagesReadOnADayCount<DateTime>()
|
||||
{
|
||||
Format = format,
|
||||
Value = date,
|
||||
Count = 0
|
||||
});
|
||||
}
|
||||
continue;
|
||||
}
|
||||
results.Add(new PagesReadOnADayCount<DateTime>()
|
||||
{
|
||||
Format = MangaFormat.Archive,
|
||||
@ -401,7 +426,7 @@ public class StatisticService : IStatisticService
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
return results.OrderBy(r => r.Value);
|
||||
}
|
||||
|
||||
public IEnumerable<StatCount<DayOfWeek>> GetDayBreakdown()
|
||||
|
@ -161,6 +161,8 @@ public class ProcessSeries : IProcessSeries
|
||||
|
||||
UpdateSeriesMetadata(series, library);
|
||||
|
||||
//CreateReadingListsFromSeries(series, library); This will be implemented later when I solution it
|
||||
|
||||
// Update series FolderPath here
|
||||
await UpdateSeriesFolderPath(parsedInfos, library, series);
|
||||
|
||||
@ -203,6 +205,27 @@ public class ProcessSeries : IProcessSeries
|
||||
EnqueuePostSeriesProcessTasks(series.LibraryId, series.Id);
|
||||
}
|
||||
|
||||
private void CreateReadingListsFromSeries(Series series, Library library)
|
||||
{
|
||||
//if (!library.ManageReadingLists) return;
|
||||
_logger.LogInformation("Generating Reading Lists for {SeriesName}", series.Name);
|
||||
|
||||
series.Metadata ??= DbFactory.SeriesMetadata(new List<CollectionTag>());
|
||||
foreach (var chapter in series.Volumes.SelectMany(v => v.Chapters))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(chapter.StoryArc))
|
||||
{
|
||||
var readingLists = chapter.StoryArc.Split(',');
|
||||
var readingListOrders = chapter.StoryArcNumber.Split(',');
|
||||
if (readingListOrders.Length == 0)
|
||||
{
|
||||
_logger.LogDebug("[ScannerService] There are no StoryArc orders listed, all reading lists fueled from StoryArc will be unordered");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task UpdateSeriesFolderPath(IEnumerable<ParserInfo> parsedInfos, Library library, Series series)
|
||||
{
|
||||
var seriesDirs = _directoryService.FindHighestDirectoriesFromFiles(library.Folders.Select(l => l.Path),
|
||||
@ -660,6 +683,33 @@ public class ProcessSeries : IProcessSeries
|
||||
chapter.SeriesGroup = comicInfo.SeriesGroup;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(comicInfo.StoryArc))
|
||||
{
|
||||
chapter.StoryArc = comicInfo.StoryArc;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(comicInfo.AlternateSeries))
|
||||
{
|
||||
chapter.AlternateSeries = comicInfo.AlternateSeries;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(comicInfo.AlternateNumber))
|
||||
{
|
||||
chapter.AlternateNumber = comicInfo.AlternateNumber;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(comicInfo.StoryArcNumber))
|
||||
{
|
||||
chapter.StoryArcNumber = comicInfo.StoryArcNumber;
|
||||
}
|
||||
|
||||
|
||||
if (comicInfo.AlternateCount > 0)
|
||||
{
|
||||
chapter.AlternateCount = comicInfo.AlternateCount;
|
||||
}
|
||||
|
||||
|
||||
if (comicInfo.Count > 0)
|
||||
{
|
||||
chapter.TotalCount = comicInfo.Count;
|
||||
@ -759,7 +809,7 @@ public class ProcessSeries : IProcessSeries
|
||||
|
||||
if (!string.IsNullOrEmpty(comicInfoTagSeparatedByComma))
|
||||
{
|
||||
return comicInfoTagSeparatedByComma.Split(",").Select(s => s.Trim()).DistinctBy(s => s.Normalize()).ToList();
|
||||
return comicInfoTagSeparatedByComma.Split(",").Select(s => s.Trim()).DistinctBy(Parser.Parser.Normalize).ToList();
|
||||
}
|
||||
return ImmutableList<string>.Empty;
|
||||
}
|
||||
|
18394
UI/Web/package-lock.json
generated
18394
UI/Web/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -27,6 +27,7 @@
|
||||
"@angular/router": "^15.1.2",
|
||||
"@fortawesome/fontawesome-free": "^6.2.0",
|
||||
"@iharbeck/ngx-virtual-scroller": "^15.0.0",
|
||||
"@iplab/ngx-file-upload": "^15.0.0",
|
||||
"@microsoft/signalr": "^7.0.2",
|
||||
"@ng-bootstrap/ng-bootstrap": "^14.0.1",
|
||||
"@popperjs/core": "^2.11.6",
|
||||
|
@ -0,0 +1,8 @@
|
||||
import { CblImportReason } from "./cbl-import-reason.enum";
|
||||
|
||||
export interface CblBookResult {
|
||||
series: string;
|
||||
volume: string;
|
||||
number: string;
|
||||
reason: CblImportReason;
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
export enum CblImportReason {
|
||||
ChapterMissing = 0,
|
||||
VolumeMissing = 1,
|
||||
SeriesMissing = 2,
|
||||
NameConflict = 3,
|
||||
AllSeriesMissing = 4,
|
||||
EmptyFile = 5,
|
||||
SeriesCollision = 6,
|
||||
AllChapterMissing = 7,
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
export enum CblImportResult {
|
||||
Fail = 0,
|
||||
Partial = 1,
|
||||
Success = 2
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
import { Series } from "../../series";
|
||||
import { CblBookResult } from "./cbl-book-result";
|
||||
import { CblImportResult } from "./cbl-import-result.enum";
|
||||
|
||||
export interface CblConflictQuestion {
|
||||
seriesName: string;
|
||||
librariesIds: Array<number>;
|
||||
}
|
||||
|
||||
export interface CblImportSummary {
|
||||
cblName: string;
|
||||
results: Array<CblBookResult>;
|
||||
success: CblImportResult;
|
||||
successfulInserts: Array<CblBookResult>;
|
||||
conflicts: Array<Series>;
|
||||
conflicts2: Array<CblConflictQuestion>;
|
||||
|
||||
}
|
@ -4,7 +4,6 @@ import { Chapter } from '../_models/chapter';
|
||||
import { CollectionTag } from '../_models/collection-tag';
|
||||
import { Device } from '../_models/device/device';
|
||||
import { Library } from '../_models/library';
|
||||
import { MangaFormat } from '../_models/manga-format';
|
||||
import { ReadingList } from '../_models/reading-list';
|
||||
import { Series } from '../_models/series';
|
||||
import { Volume } from '../_models/volume';
|
||||
@ -85,6 +84,10 @@ export enum Action {
|
||||
* Send to a device
|
||||
*/
|
||||
SendTo = 17,
|
||||
/**
|
||||
* Import some data into Kavita
|
||||
*/
|
||||
Import = 18,
|
||||
}
|
||||
|
||||
export interface ActionItem<T> {
|
||||
|
@ -7,6 +7,7 @@ import { BulkAddToCollectionComponent } from '../cards/_modals/bulk-add-to-colle
|
||||
import { AddToListModalComponent, ADD_FLOW } from '../reading-list/_modals/add-to-list-modal/add-to-list-modal.component';
|
||||
import { EditReadingListModalComponent } from '../reading-list/_modals/edit-reading-list-modal/edit-reading-list-modal.component';
|
||||
import { ConfirmService } from '../shared/confirm.service';
|
||||
import { LibrarySettingsModalComponent } from '../sidenav/_modals/library-settings-modal/library-settings-modal.component';
|
||||
import { Chapter } from '../_models/chapter';
|
||||
import { Device } from '../_models/device/device';
|
||||
import { Library } from '../_models/library';
|
||||
@ -99,6 +100,14 @@ export class ActionService implements OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
editLibrary(library: Partial<Library>, callback?: LibraryActionCallback) {
|
||||
const modalRef = this.modalService.open(LibrarySettingsModalComponent, { size: 'xl' });
|
||||
modalRef.componentInstance.library = library;
|
||||
modalRef.closed.subscribe((closeResult: {success: boolean, library: Library, coverImageUpdate: boolean}) => {
|
||||
if (callback) callback(library)
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Request an analysis of files for a given Library (currently just word count)
|
||||
* @param library Partial Library, must have id and name populated
|
||||
|
@ -5,6 +5,8 @@ import { environment } from 'src/environments/environment';
|
||||
import { UtilityService } from '../shared/_services/utility.service';
|
||||
import { PaginatedResult } from '../_models/pagination';
|
||||
import { ReadingList, ReadingListItem } from '../_models/reading-list';
|
||||
import { CblImportResult } from '../_models/reading-list/cbl/cbl-import-result.enum';
|
||||
import { CblImportSummary } from '../_models/reading-list/cbl/cbl-import-summary';
|
||||
import { TextResonse } from '../_types/text-response';
|
||||
import { ActionItem } from './action-factory.service';
|
||||
|
||||
@ -92,4 +94,8 @@ export class ReadingListService {
|
||||
nameExists(name: string) {
|
||||
return this.httpClient.get<boolean>(this.baseUrl + 'readinglist/name-exists?name=' + name);
|
||||
}
|
||||
|
||||
importCbl(form: FormData) {
|
||||
return this.httpClient.post<CblImportSummary>(this.baseUrl + 'readinglist/import-cbl', form);
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ export class CardDetailLayoutComponent implements OnInit, OnDestroy, OnChanges {
|
||||
}
|
||||
|
||||
hasCustomSort() {
|
||||
return this.filter.sortOptions !== null || this.filterSettings.presets?.sortOptions !== null;
|
||||
return this.filter.sortOptions !== null || this.filterSettings?.presets?.sortOptions !== null;
|
||||
}
|
||||
|
||||
performAction(action: ActionItem<any>) {
|
||||
|
@ -33,8 +33,7 @@ export class CardActionablesComponent implements OnInit {
|
||||
this.canDownload = this.accountService.hasDownloadRole(user);
|
||||
|
||||
// We want to avoid an empty menu when user doesn't have access to anything
|
||||
const validActions = this.actions.filter(a => a.children.length > 0 || a.dynamicList);
|
||||
if (!this.isAdmin && validActions.filter(a => !a.requiresAdmin).length === 0) {
|
||||
if (!this.isAdmin && this.actions.filter(a => !a.requiresAdmin).length === 0) {
|
||||
this.actions = [];
|
||||
}
|
||||
this.cdRef.markForCheck();
|
||||
|
@ -1,7 +1,8 @@
|
||||
<div class="container-fluid" style="padding-left: 0px; padding-right: 0px">
|
||||
<form [formGroup]="form">
|
||||
<ngx-file-drop (onFileDrop)="dropped($event)"
|
||||
(onFileOver)="fileOver($event)" (onFileLeave)="fileLeave($event)" [accept]="acceptableExtensions" [directory]="false" dropZoneClassName="file-upload" contentClassName="file-upload-zone" [directory]="false">
|
||||
(onFileOver)="fileOver($event)" (onFileLeave)="fileLeave($event)" [accept]="acceptableExtensions" [directory]="false"
|
||||
dropZoneClassName="file-upload" contentClassName="file-upload-zone">
|
||||
<ng-template ngx-file-drop-content-tmp let-openFileSelector="openFileSelector">
|
||||
<div class="row g-0 mt-3 pb-3" *ngIf="mode === 'all'">
|
||||
<div class="mx-auto">
|
||||
|
@ -207,7 +207,10 @@ export class LibraryDetailComponent implements OnInit, OnDestroy {
|
||||
this.actionService.scanLibrary(lib);
|
||||
break;
|
||||
case(Action.RefreshMetadata):
|
||||
this.actionService.refreshMetadata(lib);
|
||||
this.actionService.refreshMetadata(lib);
|
||||
break;
|
||||
case(Action.Edit):
|
||||
this.actionService.editLibrary(lib);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -1,6 +1,7 @@
|
||||
<app-side-nav-companion-bar>
|
||||
<app-side-nav-companion-bar >
|
||||
<h2 title>
|
||||
Reading Lists
|
||||
<app-card-actionables [actions]="globalActions" (actionHandler)="performGlobalAction($event)"></app-card-actionables>
|
||||
<span>Reading Lists</span>
|
||||
</h2>
|
||||
<h6 subtitle *ngIf="pagination">{{pagination.totalItems}} Items</h6>
|
||||
</app-side-nav-companion-bar>
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { ToastrService } from 'ngx-toastr';
|
||||
import { take } from 'rxjs/operators';
|
||||
import { JumpKey } from 'src/app/_models/jumpbar/jump-key';
|
||||
@ -11,6 +12,7 @@ import { ActionService } from 'src/app/_services/action.service';
|
||||
import { ImageService } from 'src/app/_services/image.service';
|
||||
import { JumpbarService } from 'src/app/_services/jumpbar.service';
|
||||
import { ReadingListService } from 'src/app/_services/reading-list.service';
|
||||
import { ImportCblModalComponent } from '../../_modals/import-cbl-modal/import-cbl-modal.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-reading-lists',
|
||||
@ -26,10 +28,11 @@ export class ReadingListsComponent implements OnInit {
|
||||
isAdmin: boolean = false;
|
||||
jumpbarKeys: Array<JumpKey> = [];
|
||||
actions: {[key: number]: Array<ActionItem<ReadingList>>} = {};
|
||||
globalActions: Array<ActionItem<any>> = []; //[{action: Action.Import, title: 'Import CBL', children: [], requiresAdmin: true, callback: this.importCbl.bind(this)}]
|
||||
|
||||
constructor(private readingListService: ReadingListService, public imageService: ImageService, private actionFactoryService: ActionFactoryService,
|
||||
private accountService: AccountService, private toastr: ToastrService, private router: Router, private actionService: ActionService,
|
||||
private jumpbarService: JumpbarService, private readonly cdRef: ChangeDetectorRef) { }
|
||||
private jumpbarService: JumpbarService, private readonly cdRef: ChangeDetectorRef, private ngbModal: NgbModal) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.accountService.currentUser$.pipe(take(1)).subscribe(user => {
|
||||
@ -51,6 +54,17 @@ export class ReadingListsComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
performGlobalAction(action: ActionItem<any>) {
|
||||
if (typeof action.callback === 'function') {
|
||||
action.callback(action, undefined);
|
||||
}
|
||||
}
|
||||
|
||||
importCbl() {
|
||||
const ref = this.ngbModal.open(ImportCblModalComponent, {size: 'xl'});
|
||||
ref.closed.subscribe(result => this.loadPage());
|
||||
}
|
||||
|
||||
handleReadingListActionCallback(action: ActionItem<ReadingList>, readingList: ReadingList) {
|
||||
switch(action.action) {
|
||||
case Action.Delete:
|
||||
|
@ -23,16 +23,18 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3 col-sm-12 ms-2">
|
||||
<div class="form-check form-switch">
|
||||
<input type="checkbox" id="tag-promoted" role="switch" formControlName="promoted" class="form-check-input"
|
||||
aria-labelledby="auto-close-label" aria-describedby="tag-promoted-help">
|
||||
<label class="form-check-label me-1" for="tag-promoted">Promote</label>
|
||||
<i class="fa fa-info-circle" aria-hidden="true" placement="left" [ngbTooltip]="promotedTooltip" role="button" tabindex="0"></i>
|
||||
<ng-template #promotedTooltip>Promotion means that the tag can be seen server-wide, not just for admin users. All series that have this tag will still have user-access restrictions placed on them.</ng-template>
|
||||
<span class="visually-hidden" id="tag-promoted-help"><ng-container [ngTemplateOutlet]="promotedTooltip"></ng-container></span>
|
||||
<ng-container *ngIf="(accountService.currentUser$ | async) as user">
|
||||
<div class="col-md-3 col-sm-12 ms-2" *ngIf="accountService.hasAdminRole(user)">
|
||||
<div class="form-check form-switch">
|
||||
<input type="checkbox" id="tag-promoted" role="switch" formControlName="promoted" class="form-check-input"
|
||||
aria-labelledby="auto-close-label" aria-describedby="tag-promoted-help">
|
||||
<label class="form-check-label me-1" for="tag-promoted">Promote</label>
|
||||
<i class="fa fa-info-circle" aria-hidden="true" placement="left" [ngbTooltip]="promotedTooltip" role="button" tabindex="0"></i>
|
||||
<ng-template #promotedTooltip>Promotion means that the tag can be seen server-wide, not just for admin users. All series that have this tag will still have user-access restrictions placed on them.</ng-template>
|
||||
<span class="visually-hidden" id="tag-promoted-help"><ng-container [ngTemplateOutlet]="promotedTooltip"></ng-container></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
</div>
|
||||
|
||||
<div class="row g-0 mb-3">
|
||||
|
@ -5,6 +5,7 @@ import { ToastrService } from 'ngx-toastr';
|
||||
import { debounceTime, distinctUntilChanged, forkJoin, Subject, switchMap, takeUntil, tap } from 'rxjs';
|
||||
import { Breakpoint, UtilityService } from 'src/app/shared/_services/utility.service';
|
||||
import { ReadingList } from 'src/app/_models/reading-list';
|
||||
import { AccountService } from 'src/app/_services/account.service';
|
||||
import { ImageService } from 'src/app/_services/image.service';
|
||||
import { ReadingListService } from 'src/app/_services/reading-list.service';
|
||||
import { UploadService } from 'src/app/_services/upload.service';
|
||||
@ -41,7 +42,7 @@ export class EditReadingListModalComponent implements OnInit, OnDestroy {
|
||||
|
||||
constructor(private ngModal: NgbActiveModal, private readingListService: ReadingListService,
|
||||
public utilityService: UtilityService, private uploadService: UploadService, private toastr: ToastrService,
|
||||
private imageService: ImageService, private readonly cdRef: ChangeDetectorRef) { }
|
||||
private imageService: ImageService, private readonly cdRef: ChangeDetectorRef, public accountService: AccountService) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.reviewGroup = new FormGroup({
|
||||
|
@ -0,0 +1,55 @@
|
||||
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="modal-basic-title">CBL Import: {{currentStep.title}}</h4>
|
||||
<button type="button" class="btn-close" aria-label="Close" (click)="close()"></button>
|
||||
</div>
|
||||
<div class="modal-body scrollable-modal {{utilityService.getActiveBreakpoint() === Breakpoint.Mobile ? '' : 'd-flex'}}">
|
||||
|
||||
<div class="row g-0" *ngIf="currentStep.index === 0">
|
||||
<p>Import a .cbl file as a reading list</p>
|
||||
<form [formGroup]="uploadForm" enctype="multipart/form-data">
|
||||
<file-upload formControlName="files"></file-upload>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<ng-container *ngIf="currentStep.index === 1">
|
||||
<div class="row g-0">
|
||||
<ng-container *ngIf="validateSummary; else noValidateIssues">
|
||||
<h5>There are issues with the CBL that will prevent an import. Correct these issues then try again.</h5>
|
||||
<ol class="list-group list-group-flush" >
|
||||
<li class="list-group-item no-hover" *ngFor="let result of validateSummary.results">
|
||||
{{result | cblConflictReason}}
|
||||
</li>
|
||||
</ol>
|
||||
</ng-container>
|
||||
<ng-template #noValidateIssues>No issues found with CBL, press next.</ng-template>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
<ng-container *ngIf="currentStep.index === 2 && dryRunSummary">
|
||||
<div class="row g-0">
|
||||
<h5>This is a dry run and shows what will happen if you press Next</h5>
|
||||
<h6>The import was a {{dryRunSummary.success}}</h6>
|
||||
<ul class="list-group list-group-flush" *ngIf="dryRunSummary">
|
||||
<li class="list-group-item no-hover" *ngFor="let result of dryRunSummary.results">
|
||||
{{result | cblConflictReason}}
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="list-group list-group-flush" *ngIf="dryRunSummary">
|
||||
<li class="list-group-item no-hover" *ngFor="let result of dryRunSummary.successfulInserts">
|
||||
{{result | cblConflictReason}}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a class="btn btn-icon" href="https://wiki.kavitareader.com/en/guides/get-started-using-your-library/reading-lists#creating-a-reading-list-via-cbl" target="_blank" rel="noopener noreferrer">Help</a>
|
||||
<button type="button" class="btn btn-secondary" (click)="close()">Close</button>
|
||||
<button type="button" class="btn btn-primary" (click)="nextStep()" [disabled]="!canMoveToNextStep()">Next</button>
|
||||
</div>
|
||||
|
||||
|
@ -0,0 +1,3 @@
|
||||
.file-input {
|
||||
display: none;
|
||||
}
|
@ -0,0 +1,139 @@
|
||||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, ViewChild } from '@angular/core';
|
||||
import { FormControl, FormGroup } from '@angular/forms';
|
||||
import { FileUploadValidators } from '@iplab/ngx-file-upload';
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { Breakpoint, UtilityService } from 'src/app/shared/_services/utility.service';
|
||||
import { CblImportSummary } from 'src/app/_models/reading-list/cbl/cbl-import-summary';
|
||||
import { ReadingListService } from 'src/app/_services/reading-list.service';
|
||||
|
||||
enum Step {
|
||||
Import = 0,
|
||||
Validate = 1,
|
||||
DryRun = 2,
|
||||
Finalize = 3
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-import-cbl-modal',
|
||||
templateUrl: './import-cbl-modal.component.html',
|
||||
styleUrls: ['./import-cbl-modal.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class ImportCblModalComponent {
|
||||
|
||||
@ViewChild('fileUpload') fileUpload!: ElementRef<HTMLInputElement>;
|
||||
|
||||
fileUploadControl = new FormControl<undefined | Array<File>>(undefined, [
|
||||
FileUploadValidators.filesLimit(1),
|
||||
FileUploadValidators.accept(['.cbl']),
|
||||
]);
|
||||
|
||||
uploadForm = new FormGroup({
|
||||
files: this.fileUploadControl
|
||||
});
|
||||
|
||||
importSummaries: Array<CblImportSummary> = [];
|
||||
validateSummary: CblImportSummary | undefined;
|
||||
dryRunSummary: CblImportSummary | undefined;
|
||||
|
||||
steps = [
|
||||
{title: 'Import CBL', index: Step.Import},
|
||||
{title: 'Validate File', index: Step.Validate},
|
||||
{title: 'Dry Run', index: Step.DryRun},
|
||||
{title: 'Final Import', index: Step.Finalize},
|
||||
];
|
||||
currentStep = this.steps[0];
|
||||
|
||||
get Breakpoint() { return Breakpoint; }
|
||||
get Step() { return Step; }
|
||||
|
||||
constructor(private ngModal: NgbActiveModal, private readingListService: ReadingListService,
|
||||
public utilityService: UtilityService, private readonly cdRef: ChangeDetectorRef) {}
|
||||
|
||||
close() {
|
||||
this.ngModal.close();
|
||||
}
|
||||
|
||||
nextStep() {
|
||||
|
||||
if (this.currentStep.index >= Step.Finalize) return;
|
||||
if (this.currentStep.index === Step.Import && !this.isFileSelected()) return;
|
||||
if (this.currentStep.index === Step.Validate && this.validateSummary && this.validateSummary.results.length > 0) return;
|
||||
|
||||
switch (this.currentStep.index) {
|
||||
case Step.Import:
|
||||
this.importFile();
|
||||
break;
|
||||
case Step.Validate:
|
||||
break;
|
||||
case Step.DryRun:
|
||||
break;
|
||||
case Step.Finalize:
|
||||
// Clear the models and allow user to do another import
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
canMoveToNextStep() {
|
||||
switch (this.currentStep.index) {
|
||||
case Step.Import:
|
||||
return this.isFileSelected();
|
||||
case Step.Validate:
|
||||
return this.validateSummary && this.validateSummary.results.length > 0;
|
||||
case Step.DryRun:
|
||||
return true;
|
||||
case Step.Finalize:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
isFileSelected() {
|
||||
const files = this.uploadForm.get('files')?.value;
|
||||
if (files) return files.length > 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
importFile() {
|
||||
const files = this.uploadForm.get('files')?.value;
|
||||
if (!files) return;
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('cbl', files[0]);
|
||||
formData.append('dryRun', (this.currentStep.index !== Step.Finalize) + '');
|
||||
this.readingListService.importCbl(formData).subscribe(res => {
|
||||
console.log('Result: ', res);
|
||||
if (this.currentStep.index === Step.Import) {
|
||||
this.validateSummary = res;
|
||||
}
|
||||
if (this.currentStep.index === Step.DryRun) {
|
||||
this.dryRunSummary = res;
|
||||
}
|
||||
this.importSummaries.push(res);
|
||||
this.currentStep.index++;
|
||||
this.cdRef.markForCheck();
|
||||
});
|
||||
}
|
||||
|
||||
// onFileSelected(event: any) {
|
||||
// console.log('event: ', event);
|
||||
// if (!(event.target as HTMLInputElement).files === null || (event.target as HTMLInputElement).files?.length === 0) return;
|
||||
|
||||
// const file = (event.target as HTMLInputElement).files![0];
|
||||
|
||||
// if (file) {
|
||||
|
||||
// //this.fileName = file.name;
|
||||
|
||||
// const formData = new FormData();
|
||||
|
||||
// formData.append("cbl", file);
|
||||
|
||||
// this.readingListService.importCbl(formData).subscribe(res => {
|
||||
// this.importSummaries.push(res);
|
||||
// this.cdRef.markForCheck();
|
||||
// });
|
||||
// this.fileUpload.value = '';
|
||||
// }
|
||||
// }
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import { CblBookResult } from 'src/app/_models/reading-list/cbl/cbl-book-result';
|
||||
import { CblImportReason } from 'src/app/_models/reading-list/cbl/cbl-import-reason.enum';
|
||||
|
||||
@Pipe({
|
||||
name: 'cblConflictReason'
|
||||
})
|
||||
export class CblConflictReasonPipe implements PipeTransform {
|
||||
|
||||
transform(result: CblBookResult): string {
|
||||
if (result.reason === undefined)
|
||||
return result.series + ' volume ' + result.volume + ' number ' + result.number + ' mapped successfully';
|
||||
switch (result.reason) {
|
||||
case CblImportReason.AllSeriesMissing:
|
||||
return 'Your account is missing access to all series in the list or Kavita does not have anything present in the list.';
|
||||
case CblImportReason.ChapterMissing:
|
||||
return 'Chapter ' + result.number + ' is missing from Kavita. This item will be skipped.';
|
||||
case CblImportReason.EmptyFile:
|
||||
return 'The Cbl file is empty, nothing to be done.';
|
||||
case CblImportReason.NameConflict:
|
||||
return 'A reading list already exists on your account that matches the Cbl file.';
|
||||
case CblImportReason.SeriesCollision:
|
||||
return 'The series, ' + result.series + ', collides with another series of the same name in another library.';
|
||||
case CblImportReason.SeriesMissing:
|
||||
return 'The series, ' + result.series + ', is missing from Kavita or your account does not have permission. All items with this series will be skipped from import.';
|
||||
case CblImportReason.VolumeMissing:
|
||||
return 'Volume ' + result.volume + ' is missing from Kavita. All items with this volume number will be skipped.';
|
||||
case CblImportReason.AllChapterMissing:
|
||||
return 'All chapters cannot be matched to Chapters in Kavita.';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -8,11 +8,14 @@ import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { EditReadingListModalComponent } from './_modals/edit-reading-list-modal/edit-reading-list-modal.component';
|
||||
import { PipeModule } from '../pipe/pipe.module';
|
||||
import { SharedModule } from '../shared/shared.module';
|
||||
import { NgbNavModule, NgbProgressbarModule, NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { NgbAccordionModule, NgbNavModule, NgbProgressbarModule, NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { SharedSideNavCardsModule } from '../shared-side-nav-cards/shared-side-nav-cards.module';
|
||||
import { ReadingListDetailComponent } from './_components/reading-list-detail/reading-list-detail.component';
|
||||
import { ReadingListItemComponent } from './_components/reading-list-item/reading-list-item.component';
|
||||
import { ReadingListsComponent } from './_components/reading-lists/reading-lists.component';
|
||||
import { ImportCblModalComponent } from './_modals/import-cbl-modal/import-cbl-modal.component';
|
||||
import { FileUploadModule } from '@iplab/ngx-file-upload';
|
||||
import { CblConflictReasonPipe } from './_pipes/cbl-conflict-reason.pipe';
|
||||
|
||||
|
||||
@NgModule({
|
||||
@ -22,7 +25,9 @@ import { ReadingListsComponent } from './_components/reading-lists/reading-lists
|
||||
AddToListModalComponent,
|
||||
ReadingListsComponent,
|
||||
EditReadingListModalComponent,
|
||||
ReadingListItemComponent
|
||||
ReadingListItemComponent,
|
||||
ImportCblModalComponent,
|
||||
CblConflictReasonPipe,
|
||||
],
|
||||
imports: [
|
||||
CommonModule,
|
||||
@ -37,6 +42,8 @@ import { ReadingListsComponent } from './_components/reading-lists/reading-lists
|
||||
SharedSideNavCardsModule,
|
||||
|
||||
ReadingListRoutingModule,
|
||||
NgbAccordionModule, // Import CBL
|
||||
FileUploadModule, // Import CBL
|
||||
],
|
||||
exports: [
|
||||
AddToListModalComponent,
|
||||
|
@ -12,7 +12,6 @@ import { Action, ActionFactoryService, ActionItem } from '../../../_services/act
|
||||
import { ActionService } from '../../../_services/action.service';
|
||||
import { LibraryService } from '../../../_services/library.service';
|
||||
import { NavService } from '../../../_services/nav.service';
|
||||
import { LibrarySettingsModalComponent } from '../../_modals/library-settings-modal/library-settings-modal.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-side-nav',
|
||||
@ -91,18 +90,7 @@ export class SideNavComponent implements OnInit, OnDestroy {
|
||||
this.actionService.analyzeFiles(library);
|
||||
break;
|
||||
case (Action.Edit):
|
||||
const modalRef = this.modalService.open(LibrarySettingsModalComponent, { size: 'xl' });
|
||||
modalRef.componentInstance.library = library;
|
||||
modalRef.closed.subscribe((closeResult: {success: boolean, library: Library, coverImageUpdate: boolean}) => {
|
||||
window.scrollTo(0, 0);
|
||||
if (closeResult.success) {
|
||||
|
||||
}
|
||||
|
||||
if (closeResult.coverImageUpdate) {
|
||||
|
||||
}
|
||||
});
|
||||
this.actionService.editLibrary(library, () => window.scrollTo(0, 0));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -2,7 +2,7 @@
|
||||
<div class="dashboard-card-content">
|
||||
<div class="row g-0 mb-2 align-items-center">
|
||||
<div class="col-4">
|
||||
<h4>Top Readers</h4>
|
||||
<h4>Reading Activity</h4>
|
||||
</div>
|
||||
<div class="col-8">
|
||||
<form [formGroup]="formGroup" class="d-inline-flex float-end">
|
||||
|
@ -1,7 +1,7 @@
|
||||
<div class="row g-0 mt-4 mb-3 d-flex justify-content-around">
|
||||
<ng-container>
|
||||
<div class="col-auto mb-2">
|
||||
<app-icon-and-title label="Total Pages Read" [clickable]="true" fontClasses="fa-regular fa-file-lines" title="Total Pages Read" (click)="openPageByYearList();$event.stopPropagation();">
|
||||
<app-icon-and-title label="Total Pages Read: {{totalPagesRead}}" [clickable]="true" fontClasses="fa-regular fa-file-lines" title="Total Pages Read" (click)="openPageByYearList();$event.stopPropagation();">
|
||||
{{totalPagesRead | compactNumber}}
|
||||
</app-icon-and-title>
|
||||
</div>
|
||||
@ -10,7 +10,7 @@
|
||||
|
||||
<ng-container>
|
||||
<div class="col-auto mb-2">
|
||||
<app-icon-and-title label="Total Words Read" [clickable]="false" fontClasses="fa-regular fa-file-lines" title="Total Words Read" (click)="openWordByYearList();$event.stopPropagation();">
|
||||
<app-icon-and-title label="Total Words Read: {{totalWordsRead}}" [clickable]="false" fontClasses="fa-regular fa-file-lines" title="Total Words Read" (click)="openWordByYearList();$event.stopPropagation();">
|
||||
{{totalWordsRead | compactNumber}}
|
||||
</app-icon-and-title>
|
||||
</div>
|
||||
@ -19,7 +19,7 @@
|
||||
|
||||
<ng-container >
|
||||
<div class="col-auto mb-2">
|
||||
<app-icon-and-title label="Time Spent Reading" [clickable]="false" fontClasses="fas fa-eye" title="Time Spent Reading">
|
||||
<app-icon-and-title label="Time Spent Reading: {{timeSpentReading}}" [clickable]="false" fontClasses="fas fa-eye" title="Time Spent Reading">
|
||||
{{timeSpentReading | compactNumber}} hours
|
||||
</app-icon-and-title>
|
||||
</div>
|
||||
|
24
openapi.json
24
openapi.json
@ -7,7 +7,7 @@
|
||||
"name": "GPL-3.0",
|
||||
"url": "https://github.com/Kareadita/Kavita/blob/develop/LICENSE"
|
||||
},
|
||||
"version": "0.6.1.37"
|
||||
"version": "0.6.1.38"
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
@ -8557,6 +8557,7 @@
|
||||
"Upload"
|
||||
],
|
||||
"summary": "Replaces reading list cover image and locks it with a base64 encoded image",
|
||||
"description": "This is the only API that can be called by non-admins, but the authenticated user must have a readinglist permission",
|
||||
"requestBody": {
|
||||
"description": "",
|
||||
"content": {
|
||||
@ -9980,6 +9981,27 @@
|
||||
"description": "SeriesGroup tag in ComicInfo",
|
||||
"nullable": true
|
||||
},
|
||||
"storyArc": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"storyArcNumber": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"alternateNumber": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"alternateSeries": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"alternateCount": {
|
||||
"type": "integer",
|
||||
"description": "Not currently used in Kavita",
|
||||
"format": "int32"
|
||||
},
|
||||
"wordCount": {
|
||||
"type": "integer",
|
||||
"description": "Total Word count of all chapters in this chapter.",
|
||||
|
Loading…
x
Reference in New Issue
Block a user