mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-07-07 10:14:12 -04:00
Browse by Genre/Tag/Person with new metadata system for People (#3835)
Co-authored-by: Stepan Goremykin <s.goremykin@proton.me> Co-authored-by: goremykin <goremukin@gmail.com> Co-authored-by: Christopher <39032787+MrRobotjs@users.noreply.github.com> Co-authored-by: Fesaa <77553571+Fesaa@users.noreply.github.com>
This commit is contained in:
parent
00c4712fc3
commit
c52ed1f65d
@ -161,10 +161,10 @@ public class ImageServiceTests
|
||||
|
||||
private static void GenerateColorImage(string hexColor, string outputPath)
|
||||
{
|
||||
var color = ImageService.HexToRgb(hexColor);
|
||||
using var colorImage = Image.Black(200, 100);
|
||||
using var output = colorImage + new[] { color.R / 255.0, color.G / 255.0, color.B / 255.0 };
|
||||
output.WriteToFile(outputPath);
|
||||
var (r, g, b) = ImageService.HexToRgb(hexColor);
|
||||
using var blackImage = Image.Black(200, 100);
|
||||
using var colorImage = blackImage.NewFromImage(r, g, b);
|
||||
colorImage.WriteToFile(outputPath);
|
||||
}
|
||||
|
||||
private void GenerateHtmlFileForColorScape()
|
||||
|
@ -97,9 +97,9 @@
|
||||
</PackageReference>
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="8.1.1" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="8.0.3" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="9.0.5" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.9.0" />
|
||||
<PackageReference Include="System.IO.Abstractions" Version="22.0.14" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="9.0.4" />
|
||||
<PackageReference Include="VersOne.Epub" Version="3.3.4" />
|
||||
<PackageReference Include="YamlDotNet" Version="16.3.0" />
|
||||
</ItemGroup>
|
||||
|
@ -6,8 +6,10 @@ using System.Threading.Tasks;
|
||||
using API.Constants;
|
||||
using API.Data;
|
||||
using API.Data.Repositories;
|
||||
using API.DTOs;
|
||||
using API.DTOs.Filtering;
|
||||
using API.DTOs.Metadata;
|
||||
using API.DTOs.Metadata.Browse;
|
||||
using API.DTOs.Person;
|
||||
using API.DTOs.Recommendation;
|
||||
using API.DTOs.SeriesDetail;
|
||||
@ -46,6 +48,22 @@ public class MetadataController(IUnitOfWork unitOfWork, ILocalizationService loc
|
||||
return Ok(await unitOfWork.GenreRepository.GetAllGenreDtosForLibrariesAsync(User.GetUserId(), ids, context));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of Genres with counts for counts when Genre is on Series/Chapter
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("genres-with-counts")]
|
||||
[ResponseCache(CacheProfileName = ResponseCacheProfiles.FiveMinute)]
|
||||
public async Task<ActionResult<PagedList<BrowseGenreDto>>> GetBrowseGenres(UserParams? userParams = null)
|
||||
{
|
||||
userParams ??= UserParams.Default;
|
||||
|
||||
var list = await unitOfWork.GenreRepository.GetBrowseableGenre(User.GetUserId(), userParams);
|
||||
Response.AddPaginationHeader(list.CurrentPage, list.PageSize, list.TotalCount, list.TotalPages);
|
||||
|
||||
return Ok(list);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches people from the instance by role
|
||||
/// </summary>
|
||||
@ -95,6 +113,22 @@ public class MetadataController(IUnitOfWork unitOfWork, ILocalizationService loc
|
||||
return Ok(await unitOfWork.TagRepository.GetAllTagDtosForLibrariesAsync(User.GetUserId()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of Tags with counts for counts when Tag is on Series/Chapter
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("tags-with-counts")]
|
||||
[ResponseCache(CacheProfileName = ResponseCacheProfiles.FiveMinute)]
|
||||
public async Task<ActionResult<PagedList<BrowseTagDto>>> GetBrowseTags(UserParams? userParams = null)
|
||||
{
|
||||
userParams ??= UserParams.Default;
|
||||
|
||||
var list = await unitOfWork.TagRepository.GetBrowseableTag(User.GetUserId(), userParams);
|
||||
Response.AddPaginationHeader(list.CurrentPage, list.PageSize, list.TotalCount, list.TotalPages);
|
||||
|
||||
return Ok(list);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches all age ratings from the instance
|
||||
/// </summary>
|
||||
|
@ -4,6 +4,9 @@ using System.Threading.Tasks;
|
||||
using API.Data;
|
||||
using API.Data.Repositories;
|
||||
using API.DTOs;
|
||||
using API.DTOs.Filtering.v2;
|
||||
using API.DTOs.Metadata.Browse;
|
||||
using API.DTOs.Metadata.Browse.Requests;
|
||||
using API.DTOs.Person;
|
||||
using API.Entities.Enums;
|
||||
using API.Extensions;
|
||||
@ -77,11 +80,13 @@ public class PersonController : BaseApiController
|
||||
/// <param name="userParams"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("all")]
|
||||
public async Task<ActionResult<PagedList<BrowsePersonDto>>> GetAuthorsForBrowse([FromQuery] UserParams? userParams)
|
||||
public async Task<ActionResult<PagedList<BrowsePersonDto>>> GetPeopleForBrowse(BrowsePersonFilterDto filter, [FromQuery] UserParams? userParams)
|
||||
{
|
||||
userParams ??= UserParams.Default;
|
||||
var list = await _unitOfWork.PersonRepository.GetAllWritersAndSeriesCount(User.GetUserId(), userParams);
|
||||
|
||||
var list = await _unitOfWork.PersonRepository.GetBrowsePersonDtos(User.GetUserId(), filter, userParams);
|
||||
Response.AddPaginationHeader(list.CurrentPage, list.PageSize, list.TotalCount, list.TotalPages);
|
||||
|
||||
return Ok(list);
|
||||
}
|
||||
|
||||
@ -112,6 +117,7 @@ public class PersonController : BaseApiController
|
||||
|
||||
|
||||
person.Name = dto.Name?.Trim();
|
||||
person.NormalizedName = person.Name.ToNormalized();
|
||||
person.Description = dto.Description ?? string.Empty;
|
||||
person.CoverImageLocked = dto.CoverImageLocked;
|
||||
|
||||
|
8
API/DTOs/Filtering/PersonSortField.cs
Normal file
8
API/DTOs/Filtering/PersonSortField.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace API.DTOs.Filtering;
|
||||
|
||||
public enum PersonSortField
|
||||
{
|
||||
Name = 1,
|
||||
SeriesCount = 2,
|
||||
ChapterCount = 3
|
||||
}
|
@ -8,3 +8,12 @@ public sealed record SortOptions
|
||||
public SortField SortField { get; set; }
|
||||
public bool IsAscending { get; set; } = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// All Sorting Options for a query related to Person Entity
|
||||
/// </summary>
|
||||
public sealed record PersonSortOptions
|
||||
{
|
||||
public PersonSortField SortField { get; set; }
|
||||
public bool IsAscending { get; set; } = true;
|
||||
}
|
||||
|
@ -56,5 +56,12 @@ public enum FilterField
|
||||
/// Last time User Read
|
||||
/// </summary>
|
||||
ReadLast = 32,
|
||||
|
||||
}
|
||||
|
||||
public enum PersonFilterField
|
||||
{
|
||||
Role = 1,
|
||||
Name = 2,
|
||||
SeriesCount = 3,
|
||||
ChapterCount = 4,
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace API.DTOs.Filtering.v2;
|
||||
using API.DTOs.Metadata.Browse.Requests;
|
||||
|
||||
namespace API.DTOs.Filtering.v2;
|
||||
|
||||
public sealed record FilterStatementDto
|
||||
{
|
||||
@ -6,3 +8,10 @@ public sealed record FilterStatementDto
|
||||
public FilterField Field { get; set; }
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
public sealed record PersonFilterStatementDto
|
||||
{
|
||||
public FilterComparison Comparison { get; set; }
|
||||
public PersonFilterField Field { get; set; }
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public sealed record FilterV2Dto
|
||||
/// The name of the filter
|
||||
/// </summary>
|
||||
public string? Name { get; set; }
|
||||
public ICollection<FilterStatementDto> Statements { get; set; } = new List<FilterStatementDto>();
|
||||
public ICollection<FilterStatementDto> Statements { get; set; } = [];
|
||||
public FilterCombination Combination { get; set; } = FilterCombination.And;
|
||||
public SortOptions? SortOptions { get; set; }
|
||||
|
||||
|
@ -15,5 +15,9 @@ public enum MatchStateOption
|
||||
public sealed record ManageMatchFilterDto
|
||||
{
|
||||
public MatchStateOption MatchStateOption { get; set; } = MatchStateOption.All;
|
||||
/// <summary>
|
||||
/// Library Type in int form. -1 indicates to ignore the field.
|
||||
/// </summary>
|
||||
public int LibraryType { get; set; } = -1;
|
||||
public string SearchTerm { get; set; } = string.Empty;
|
||||
}
|
||||
|
13
API/DTOs/Metadata/Browse/BrowseGenreDto.cs
Normal file
13
API/DTOs/Metadata/Browse/BrowseGenreDto.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace API.DTOs.Metadata.Browse;
|
||||
|
||||
public sealed record BrowseGenreDto : GenreTagDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Number of Series this Entity is on
|
||||
/// </summary>
|
||||
public int SeriesCount { get; set; }
|
||||
/// <summary>
|
||||
/// Number of Chapters this Entity is on
|
||||
/// </summary>
|
||||
public int ChapterCount { get; set; }
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
using API.DTOs.Person;
|
||||
|
||||
namespace API.DTOs;
|
||||
namespace API.DTOs.Metadata.Browse;
|
||||
|
||||
/// <summary>
|
||||
/// Used to browse writers and click in to see their series
|
||||
@ -12,7 +12,7 @@ public class BrowsePersonDto : PersonDto
|
||||
/// </summary>
|
||||
public int SeriesCount { get; set; }
|
||||
/// <summary>
|
||||
/// Number or Issues this Person is the Writer for
|
||||
/// Number of Issues this Person is the Writer for
|
||||
/// </summary>
|
||||
public int IssueCount { get; set; }
|
||||
public int ChapterCount { get; set; }
|
||||
}
|
13
API/DTOs/Metadata/Browse/BrowseTagDto.cs
Normal file
13
API/DTOs/Metadata/Browse/BrowseTagDto.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace API.DTOs.Metadata.Browse;
|
||||
|
||||
public sealed record BrowseTagDto : TagDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Number of Series this Entity is on
|
||||
/// </summary>
|
||||
public int SeriesCount { get; set; }
|
||||
/// <summary>
|
||||
/// Number of Chapters this Entity is on
|
||||
/// </summary>
|
||||
public int ChapterCount { get; set; }
|
||||
}
|
27
API/DTOs/Metadata/Browse/Requests/BrowsePersonFilterDto.cs
Normal file
27
API/DTOs/Metadata/Browse/Requests/BrowsePersonFilterDto.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System.Collections.Generic;
|
||||
using API.DTOs.Filtering;
|
||||
using API.DTOs.Filtering.v2;
|
||||
using API.Entities.Enums;
|
||||
|
||||
namespace API.DTOs.Metadata.Browse.Requests;
|
||||
#nullable enable
|
||||
|
||||
public sealed record BrowsePersonFilterDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Not used - For parity with Series Filter
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// Not used - For parity with Series Filter
|
||||
/// </summary>
|
||||
public string? Name { get; set; }
|
||||
public ICollection<PersonFilterStatementDto> Statements { get; set; } = [];
|
||||
public FilterCombination Combination { get; set; } = FilterCombination.And;
|
||||
public PersonSortOptions? SortOptions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Limit the number of rows returned. Defaults to not applying a limit (aka 0)
|
||||
/// </summary>
|
||||
public int LimitTo { get; set; } = 0;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
namespace API.DTOs.Metadata;
|
||||
|
||||
public sealed record GenreTagDto
|
||||
public record GenreTagDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public required string Title { get; set; }
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace API.DTOs.Metadata;
|
||||
|
||||
public sealed record TagDto
|
||||
public record TagDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public required string Title { get; set; }
|
||||
|
@ -49,6 +49,11 @@ public sealed record ReadingListDto : IHasCoverImage
|
||||
/// </summary>
|
||||
public required AgeRating AgeRating { get; set; } = AgeRating.Unknown;
|
||||
|
||||
/// <summary>
|
||||
/// Username of the User that owns (in the case of a promoted list)
|
||||
/// </summary>
|
||||
public string OwnerUserName { get; set; }
|
||||
|
||||
public void ResetColorScape()
|
||||
{
|
||||
PrimaryColor = string.Empty;
|
||||
|
@ -64,6 +64,9 @@ public sealed record UserReadingProfileDto
|
||||
/// <inheritdoc cref="AppUserReadingProfile.WidthOverride"/>
|
||||
public int? WidthOverride { get; set; }
|
||||
|
||||
/// <inheritdoc cref="AppUserReadingProfile.DisableWidthOverride"/>
|
||||
public BreakPoint DisableWidthOverride { get; set; } = BreakPoint.Never;
|
||||
|
||||
#endregion
|
||||
|
||||
#region EpubReader
|
||||
|
3701
API/Data/Migrations/20250610210618_AppUserReadingProfileDisableWidthOverrideBreakPoint.Designer.cs
generated
Normal file
3701
API/Data/Migrations/20250610210618_AppUserReadingProfileDisableWidthOverrideBreakPoint.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace API.Data.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AppUserReadingProfileDisableWidthOverrideBreakPoint : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "DisableWidthOverride",
|
||||
table: "AppUserReadingProfiles",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "DisableWidthOverride",
|
||||
table: "AppUserReadingProfiles");
|
||||
}
|
||||
}
|
||||
}
|
@ -665,6 +665,9 @@ namespace API.Data.Migrations
|
||||
.HasColumnType("TEXT")
|
||||
.HasDefaultValue("Dark");
|
||||
|
||||
b.Property<int>("DisableWidthOverride")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<bool>("EmulateBook")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
@ -704,7 +707,7 @@ namespace API.Data.Migrations
|
||||
b.Property<int>("ScalingOption")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.PrimitiveCollection<string>("SeriesIds")
|
||||
b.Property<string>("SeriesIds")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<bool>("ShowScreenHints")
|
||||
|
@ -108,14 +108,17 @@ public class ExternalSeriesMetadataRepository : IExternalSeriesMetadataRepositor
|
||||
|
||||
public async Task<bool> NeedsDataRefresh(int seriesId)
|
||||
{
|
||||
// TODO: Add unit test
|
||||
var row = await _context.ExternalSeriesMetadata
|
||||
.Where(s => s.SeriesId == seriesId)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
return row == null || row.ValidUntilUtc <= DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public async Task<SeriesDetailPlusDto?> GetSeriesDetailPlusDto(int seriesId)
|
||||
{
|
||||
// TODO: Add unit test
|
||||
var seriesDetailDto = await _context.ExternalSeriesMetadata
|
||||
.Where(m => m.SeriesId == seriesId)
|
||||
.Include(m => m.ExternalRatings)
|
||||
@ -144,7 +147,7 @@ public class ExternalSeriesMetadataRepository : IExternalSeriesMetadataRepositor
|
||||
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
|
||||
.ToListAsync();
|
||||
|
||||
IEnumerable<UserReviewDto> reviews = new List<UserReviewDto>();
|
||||
IEnumerable<UserReviewDto> reviews = [];
|
||||
if (seriesDetailDto.ExternalReviews != null && seriesDetailDto.ExternalReviews.Any())
|
||||
{
|
||||
reviews = seriesDetailDto.ExternalReviews
|
||||
@ -231,6 +234,7 @@ public class ExternalSeriesMetadataRepository : IExternalSeriesMetadataRepositor
|
||||
.Include(s => s.ExternalSeriesMetadata)
|
||||
.Where(s => !ExternalMetadataService.NonEligibleLibraryTypes.Contains(s.Library.Type))
|
||||
.Where(s => s.Library.AllowMetadataMatching)
|
||||
.WhereIf(filter.LibraryType >= 0, s => s.Library.Type == (LibraryType) filter.LibraryType)
|
||||
.FilterMatchState(filter.MatchStateOption)
|
||||
.OrderBy(s => s.NormalizedName)
|
||||
.ProjectTo<ManageMatchSeriesDto>(_mapper.ConfigurationProvider)
|
||||
|
@ -3,9 +3,11 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using API.DTOs.Metadata;
|
||||
using API.DTOs.Metadata.Browse;
|
||||
using API.Entities;
|
||||
using API.Extensions;
|
||||
using API.Extensions.QueryExtensions;
|
||||
using API.Helpers;
|
||||
using API.Services.Tasks.Scanner.Parser;
|
||||
using AutoMapper;
|
||||
using AutoMapper.QueryableExtensions;
|
||||
@ -27,6 +29,7 @@ public interface IGenreRepository
|
||||
Task<GenreTagDto> GetRandomGenre();
|
||||
Task<GenreTagDto> GetGenreById(int id);
|
||||
Task<List<string>> GetAllGenresNotInListAsync(ICollection<string> genreNames);
|
||||
Task<PagedList<BrowseGenreDto>> GetBrowseableGenre(int userId, UserParams userParams);
|
||||
}
|
||||
|
||||
public class GenreRepository : IGenreRepository
|
||||
@ -165,4 +168,28 @@ public class GenreRepository : IGenreRepository
|
||||
// Return the original non-normalized genres for the missing ones
|
||||
return missingGenres.Select(normalizedName => normalizedToOriginalMap[normalizedName]).ToList();
|
||||
}
|
||||
|
||||
public async Task<PagedList<BrowseGenreDto>> GetBrowseableGenre(int userId, UserParams userParams)
|
||||
{
|
||||
var ageRating = await _context.AppUser.GetUserAgeRestriction(userId);
|
||||
|
||||
var query = _context.Genre
|
||||
.RestrictAgainstAgeRestriction(ageRating)
|
||||
.Select(g => new BrowseGenreDto
|
||||
{
|
||||
Id = g.Id,
|
||||
Title = g.Title,
|
||||
SeriesCount = g.SeriesMetadatas
|
||||
.Select(sm => sm.Id)
|
||||
.Distinct()
|
||||
.Count(),
|
||||
ChapterCount = g.Chapters
|
||||
.Select(ch => ch.Id)
|
||||
.Distinct()
|
||||
.Count()
|
||||
})
|
||||
.OrderBy(g => g.Title);
|
||||
|
||||
return await PagedList<BrowseGenreDto>.CreateAsync(query, userParams.PageNumber, userParams.PageSize);
|
||||
}
|
||||
}
|
||||
|
@ -2,13 +2,19 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using API.Data.Misc;
|
||||
using API.DTOs;
|
||||
using API.DTOs.Filtering.v2;
|
||||
using API.DTOs.Metadata.Browse;
|
||||
using API.DTOs.Metadata.Browse.Requests;
|
||||
using API.DTOs.Person;
|
||||
using API.Entities.Enums;
|
||||
using API.Entities.Person;
|
||||
using API.Extensions;
|
||||
using API.Extensions.QueryExtensions;
|
||||
using API.Extensions.QueryExtensions.Filtering;
|
||||
using API.Helpers;
|
||||
using API.Helpers.Converters;
|
||||
using AutoMapper;
|
||||
using AutoMapper.QueryableExtensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@ -45,7 +51,7 @@ public interface IPersonRepository
|
||||
Task<string?> GetCoverImageAsync(int personId);
|
||||
Task<string?> GetCoverImageByNameAsync(string name);
|
||||
Task<IEnumerable<PersonRole>> GetRolesForPersonByName(int personId, int userId);
|
||||
Task<PagedList<BrowsePersonDto>> GetAllWritersAndSeriesCount(int userId, UserParams userParams);
|
||||
Task<PagedList<BrowsePersonDto>> GetBrowsePersonDtos(int userId, BrowsePersonFilterDto filter, UserParams userParams);
|
||||
Task<Person?> GetPersonById(int personId, PersonIncludes includes = PersonIncludes.None);
|
||||
Task<PersonDto?> GetPersonDtoByName(string name, int userId, PersonIncludes includes = PersonIncludes.Aliases);
|
||||
/// <summary>
|
||||
@ -194,36 +200,82 @@ public class PersonRepository : IPersonRepository
|
||||
return chapterRoles.Union(seriesRoles).Distinct();
|
||||
}
|
||||
|
||||
public async Task<PagedList<BrowsePersonDto>> GetAllWritersAndSeriesCount(int userId, UserParams userParams)
|
||||
public async Task<PagedList<BrowsePersonDto>> GetBrowsePersonDtos(int userId, BrowsePersonFilterDto filter, UserParams userParams)
|
||||
{
|
||||
List<PersonRole> roles = [PersonRole.Writer, PersonRole.CoverArtist];
|
||||
var ageRating = await _context.AppUser.GetUserAgeRestriction(userId);
|
||||
|
||||
var query = _context.Person
|
||||
.Where(p => p.SeriesMetadataPeople.Any(smp => roles.Contains(smp.Role)) || p.ChapterPeople.Any(cmp => roles.Contains(cmp.Role)))
|
||||
.RestrictAgainstAgeRestriction(ageRating)
|
||||
.Select(p => new BrowsePersonDto
|
||||
{
|
||||
Id = p.Id,
|
||||
Name = p.Name,
|
||||
Description = p.Description,
|
||||
CoverImage = p.CoverImage,
|
||||
SeriesCount = p.SeriesMetadataPeople
|
||||
.Where(smp => roles.Contains(smp.Role))
|
||||
.Select(smp => smp.SeriesMetadata.SeriesId)
|
||||
.Distinct()
|
||||
.Count(),
|
||||
IssueCount = p.ChapterPeople
|
||||
.Where(cp => roles.Contains(cp.Role))
|
||||
.Select(cp => cp.Chapter.Id)
|
||||
.Distinct()
|
||||
.Count()
|
||||
})
|
||||
.OrderBy(p => p.Name);
|
||||
var query = CreateFilteredPersonQueryable(userId, filter, ageRating);
|
||||
|
||||
return await PagedList<BrowsePersonDto>.CreateAsync(query, userParams.PageNumber, userParams.PageSize);
|
||||
}
|
||||
|
||||
private IQueryable<BrowsePersonDto> CreateFilteredPersonQueryable(int userId, BrowsePersonFilterDto filter, AgeRestriction ageRating)
|
||||
{
|
||||
var query = _context.Person.AsNoTracking();
|
||||
|
||||
// Apply filtering based on statements
|
||||
query = BuildPersonFilterQuery(userId, filter, query);
|
||||
|
||||
// Apply age restriction
|
||||
query = query.RestrictAgainstAgeRestriction(ageRating);
|
||||
|
||||
// Apply sorting and limiting
|
||||
var sortedQuery = query.SortBy(filter.SortOptions);
|
||||
|
||||
var limitedQuery = ApplyPersonLimit(sortedQuery, filter.LimitTo);
|
||||
|
||||
// Project to DTO
|
||||
var projectedQuery = limitedQuery.Select(p => new BrowsePersonDto
|
||||
{
|
||||
Id = p.Id,
|
||||
Name = p.Name,
|
||||
Description = p.Description,
|
||||
CoverImage = p.CoverImage,
|
||||
SeriesCount = p.SeriesMetadataPeople
|
||||
.Select(smp => smp.SeriesMetadata.SeriesId)
|
||||
.Distinct()
|
||||
.Count(),
|
||||
ChapterCount = p.ChapterPeople
|
||||
.Select(cp => cp.Chapter.Id)
|
||||
.Distinct()
|
||||
.Count()
|
||||
});
|
||||
|
||||
return projectedQuery;
|
||||
}
|
||||
|
||||
private static IQueryable<Person> BuildPersonFilterQuery(int userId, BrowsePersonFilterDto filterDto, IQueryable<Person> query)
|
||||
{
|
||||
if (filterDto.Statements == null || filterDto.Statements.Count == 0) return query;
|
||||
|
||||
var queries = filterDto.Statements
|
||||
.Select(statement => BuildPersonFilterGroup(userId, statement, query))
|
||||
.ToList();
|
||||
|
||||
return filterDto.Combination == FilterCombination.And
|
||||
? queries.Aggregate((q1, q2) => q1.Intersect(q2))
|
||||
: queries.Aggregate((q1, q2) => q1.Union(q2));
|
||||
}
|
||||
|
||||
private static IQueryable<Person> BuildPersonFilterGroup(int userId, PersonFilterStatementDto statement, IQueryable<Person> query)
|
||||
{
|
||||
var value = PersonFilterFieldValueConverter.ConvertValue(statement.Field, statement.Value);
|
||||
|
||||
return statement.Field switch
|
||||
{
|
||||
PersonFilterField.Name => query.HasPersonName(true, statement.Comparison, (string)value),
|
||||
PersonFilterField.Role => query.HasPersonRole(true, statement.Comparison, (IList<PersonRole>)value),
|
||||
PersonFilterField.SeriesCount => query.HasPersonSeriesCount(true, statement.Comparison, (int)value),
|
||||
PersonFilterField.ChapterCount => query.HasPersonChapterCount(true, statement.Comparison, (int)value),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(statement.Field), $"Unexpected value for field: {statement.Field}")
|
||||
};
|
||||
}
|
||||
|
||||
private static IQueryable<Person> ApplyPersonLimit(IQueryable<Person> query, int limit)
|
||||
{
|
||||
return limit <= 0 ? query : query.Take(limit);
|
||||
}
|
||||
|
||||
public async Task<Person?> GetPersonById(int personId, PersonIncludes includes = PersonIncludes.None)
|
||||
{
|
||||
return await _context.Person.Where(p => p.Id == personId)
|
||||
|
@ -735,6 +735,7 @@ public class SeriesRepository : ISeriesRepository
|
||||
{
|
||||
return await _context.Series
|
||||
.Where(s => s.Id == seriesId)
|
||||
.Include(s => s.ExternalSeriesMetadata)
|
||||
.Select(series => new PlusSeriesRequestDto()
|
||||
{
|
||||
MediaFormat = series.Library.Type.ConvertToPlusMediaFormat(series.Format),
|
||||
@ -744,6 +745,7 @@ public class SeriesRepository : ISeriesRepository
|
||||
ScrobblingService.AniListWeblinkWebsite),
|
||||
MalId = ScrobblingService.ExtractId<long?>(series.Metadata.WebLinks,
|
||||
ScrobblingService.MalWeblinkWebsite),
|
||||
CbrId = series.ExternalSeriesMetadata.CbrId,
|
||||
GoogleBooksId = ScrobblingService.ExtractId<string?>(series.Metadata.WebLinks,
|
||||
ScrobblingService.GoogleBooksWeblinkWebsite),
|
||||
MangaDexId = ScrobblingService.ExtractId<string?>(series.Metadata.WebLinks,
|
||||
@ -1088,8 +1090,6 @@ public class SeriesRepository : ISeriesRepository
|
||||
return query.Where(s => false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// First setup any FilterField.Libraries in the statements, as these don't have any traditional query statements applied here
|
||||
query = ApplyLibraryFilter(filter, query);
|
||||
|
||||
@ -1290,7 +1290,7 @@ public class SeriesRepository : ISeriesRepository
|
||||
FilterField.ReadingDate => query.HasReadingDate(true, statement.Comparison, (DateTime) value, userId),
|
||||
FilterField.ReadLast => query.HasReadLast(true, statement.Comparison, (int) value, userId),
|
||||
FilterField.AverageRating => query.HasAverageRating(true, statement.Comparison, (float) value),
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(statement.Field), $"Unexpected value for field: {statement.Field}")
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,11 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using API.DTOs.Metadata;
|
||||
using API.DTOs.Metadata.Browse;
|
||||
using API.Entities;
|
||||
using API.Extensions;
|
||||
using API.Extensions.QueryExtensions;
|
||||
using API.Helpers;
|
||||
using API.Services.Tasks.Scanner.Parser;
|
||||
using AutoMapper;
|
||||
using AutoMapper.QueryableExtensions;
|
||||
@ -23,6 +25,7 @@ public interface ITagRepository
|
||||
Task RemoveAllTagNoLongerAssociated();
|
||||
Task<IList<TagDto>> GetAllTagDtosForLibrariesAsync(int userId, IList<int>? libraryIds = null);
|
||||
Task<List<string>> GetAllTagsNotInListAsync(ICollection<string> tags);
|
||||
Task<PagedList<BrowseTagDto>> GetBrowseableTag(int userId, UserParams userParams);
|
||||
}
|
||||
|
||||
public class TagRepository : ITagRepository
|
||||
@ -104,6 +107,30 @@ public class TagRepository : ITagRepository
|
||||
return missingTags.Select(normalizedName => normalizedToOriginalMap[normalizedName]).ToList();
|
||||
}
|
||||
|
||||
public async Task<PagedList<BrowseTagDto>> GetBrowseableTag(int userId, UserParams userParams)
|
||||
{
|
||||
var ageRating = await _context.AppUser.GetUserAgeRestriction(userId);
|
||||
|
||||
var query = _context.Tag
|
||||
.RestrictAgainstAgeRestriction(ageRating)
|
||||
.Select(g => new BrowseTagDto
|
||||
{
|
||||
Id = g.Id,
|
||||
Title = g.Title,
|
||||
SeriesCount = g.SeriesMetadatas
|
||||
.Select(sm => sm.Id)
|
||||
.Distinct()
|
||||
.Count(),
|
||||
ChapterCount = g.Chapters
|
||||
.Select(ch => ch.Id)
|
||||
.Distinct()
|
||||
.Count()
|
||||
})
|
||||
.OrderBy(g => g.Title);
|
||||
|
||||
return await PagedList<BrowseTagDto>.CreateAsync(query, userParams.PageNumber, userParams.PageSize);
|
||||
}
|
||||
|
||||
public async Task<IList<Tag>> GetAllTagsAsync()
|
||||
{
|
||||
return await _context.Tag.ToListAsync();
|
||||
|
@ -120,7 +120,7 @@ public static class Seed
|
||||
new AppUserSideNavStream()
|
||||
{
|
||||
Name = "browse-authors",
|
||||
StreamType = SideNavStreamType.BrowseAuthors,
|
||||
StreamType = SideNavStreamType.BrowsePeople,
|
||||
Order = 6,
|
||||
IsProvided = true,
|
||||
Visible = true
|
||||
|
@ -1,9 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using API.Entities.Enums;
|
||||
using API.Entities.Enums.UserPreferences;
|
||||
|
||||
namespace API.Entities;
|
||||
|
||||
public enum BreakPoint
|
||||
{
|
||||
[Description("Never")]
|
||||
Never = 0,
|
||||
[Description("Mobile")]
|
||||
Mobile = 1,
|
||||
[Description("Tablet")]
|
||||
Tablet = 2,
|
||||
[Description("Desktop")]
|
||||
Desktop = 3,
|
||||
}
|
||||
|
||||
public class AppUserReadingProfile
|
||||
{
|
||||
public int Id { get; set; }
|
||||
@ -72,6 +85,10 @@ public class AppUserReadingProfile
|
||||
/// Manga Reader Option: Optional fixed width override
|
||||
/// </summary>
|
||||
public int? WidthOverride { get; set; } = null;
|
||||
/// <summary>
|
||||
/// Manga Reader Option: Disable the width override if the screen is past the breakpoint
|
||||
/// </summary>
|
||||
public BreakPoint DisableWidthOverride { get; set; } = BreakPoint.Never;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -10,5 +10,5 @@ public enum SideNavStreamType
|
||||
ExternalSource = 6,
|
||||
AllSeries = 7,
|
||||
WantToRead = 8,
|
||||
BrowseAuthors = 9
|
||||
BrowsePeople = 9
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using API.Data.Misc;
|
||||
using API.Entities.Enums;
|
||||
using API.Entities.Metadata;
|
||||
|
||||
namespace API.Extensions;
|
||||
#nullable enable
|
||||
@ -42,4 +43,16 @@ public static class EnumerableExtensions
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
public static IEnumerable<SeriesMetadata> RestrictAgainstAgeRestriction(this IEnumerable<SeriesMetadata> items, AgeRestriction restriction)
|
||||
{
|
||||
if (restriction.AgeRating == AgeRating.NotApplicable) return items;
|
||||
var q = items.Where(s => s.AgeRating <= restriction.AgeRating);
|
||||
if (!restriction.IncludeUnknowns)
|
||||
{
|
||||
return q.Where(s => s.AgeRating != AgeRating.Unknown);
|
||||
}
|
||||
|
||||
return q;
|
||||
}
|
||||
}
|
||||
|
136
API/Extensions/QueryExtensions/Filtering/PersonFilter.cs
Normal file
136
API/Extensions/QueryExtensions/Filtering/PersonFilter.cs
Normal file
@ -0,0 +1,136 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using API.DTOs.Filtering.v2;
|
||||
using API.Entities.Enums;
|
||||
using API.Entities.Person;
|
||||
using Kavita.Common;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace API.Extensions.QueryExtensions.Filtering;
|
||||
|
||||
public static class PersonFilter
|
||||
{
|
||||
public static IQueryable<Person> HasPersonName(this IQueryable<Person> queryable, bool condition,
|
||||
FilterComparison comparison, string queryString)
|
||||
{
|
||||
if (string.IsNullOrEmpty(queryString) || !condition) return queryable;
|
||||
|
||||
return comparison switch
|
||||
{
|
||||
FilterComparison.Equal => queryable.Where(p => p.Name.Equals(queryString)),
|
||||
FilterComparison.BeginsWith => queryable.Where(p => EF.Functions.Like(p.Name, $"{queryString}%")),
|
||||
FilterComparison.EndsWith => queryable.Where(p => EF.Functions.Like(p.Name, $"%{queryString}")),
|
||||
FilterComparison.Matches => queryable.Where(p => EF.Functions.Like(p.Name, $"%{queryString}%")),
|
||||
FilterComparison.NotEqual => queryable.Where(p => p.Name != queryString),
|
||||
FilterComparison.NotContains or FilterComparison.GreaterThan or FilterComparison.GreaterThanEqual
|
||||
or FilterComparison.LessThan or FilterComparison.LessThanEqual or FilterComparison.Contains
|
||||
or FilterComparison.IsBefore or FilterComparison.IsAfter or FilterComparison.IsInLast
|
||||
or FilterComparison.IsNotInLast or FilterComparison.MustContains
|
||||
or FilterComparison.IsEmpty =>
|
||||
throw new KavitaException($"{comparison} not applicable for Person.Name"),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(comparison), comparison,
|
||||
"Filter Comparison is not supported")
|
||||
};
|
||||
}
|
||||
public static IQueryable<Person> HasPersonRole(this IQueryable<Person> queryable, bool condition,
|
||||
FilterComparison comparison, IList<PersonRole> roles)
|
||||
{
|
||||
if (roles == null || roles.Count == 0 || !condition) return queryable;
|
||||
|
||||
return comparison switch
|
||||
{
|
||||
FilterComparison.Contains or FilterComparison.MustContains => queryable.Where(p =>
|
||||
p.SeriesMetadataPeople.Any(smp => roles.Contains(smp.Role)) ||
|
||||
p.ChapterPeople.Any(cmp => roles.Contains(cmp.Role))),
|
||||
FilterComparison.NotContains => queryable.Where(p =>
|
||||
!p.SeriesMetadataPeople.Any(smp => roles.Contains(smp.Role)) &&
|
||||
!p.ChapterPeople.Any(cmp => roles.Contains(cmp.Role))),
|
||||
FilterComparison.Equal or FilterComparison.NotEqual or FilterComparison.BeginsWith
|
||||
or FilterComparison.EndsWith or FilterComparison.Matches or FilterComparison.GreaterThan
|
||||
or FilterComparison.GreaterThanEqual or FilterComparison.LessThan or FilterComparison.LessThanEqual
|
||||
or FilterComparison.IsBefore or FilterComparison.IsAfter or FilterComparison.IsInLast
|
||||
or FilterComparison.IsNotInLast
|
||||
or FilterComparison.IsEmpty =>
|
||||
throw new KavitaException($"{comparison} not applicable for Person.Role"),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(comparison), comparison,
|
||||
"Filter Comparison is not supported")
|
||||
};
|
||||
}
|
||||
|
||||
public static IQueryable<Person> HasPersonSeriesCount(this IQueryable<Person> queryable, bool condition,
|
||||
FilterComparison comparison, int count)
|
||||
{
|
||||
if (!condition) return queryable;
|
||||
|
||||
return comparison switch
|
||||
{
|
||||
FilterComparison.Equal => queryable.Where(p => p.SeriesMetadataPeople
|
||||
.Select(smp => smp.SeriesMetadata.SeriesId)
|
||||
.Distinct()
|
||||
.Count() == count),
|
||||
FilterComparison.GreaterThan => queryable.Where(p => p.SeriesMetadataPeople
|
||||
.Select(smp => smp.SeriesMetadata.SeriesId)
|
||||
.Distinct()
|
||||
.Count() > count),
|
||||
FilterComparison.GreaterThanEqual => queryable.Where(p => p.SeriesMetadataPeople
|
||||
.Select(smp => smp.SeriesMetadata.SeriesId)
|
||||
.Distinct()
|
||||
.Count() >= count),
|
||||
FilterComparison.LessThan => queryable.Where(p => p.SeriesMetadataPeople
|
||||
.Select(smp => smp.SeriesMetadata.SeriesId)
|
||||
.Distinct()
|
||||
.Count() < count),
|
||||
FilterComparison.LessThanEqual => queryable.Where(p => p.SeriesMetadataPeople
|
||||
.Select(smp => smp.SeriesMetadata.SeriesId)
|
||||
.Distinct()
|
||||
.Count() <= count),
|
||||
FilterComparison.NotEqual => queryable.Where(p => p.SeriesMetadataPeople
|
||||
.Select(smp => smp.SeriesMetadata.SeriesId)
|
||||
.Distinct()
|
||||
.Count() != count),
|
||||
FilterComparison.BeginsWith or FilterComparison.EndsWith or FilterComparison.Matches
|
||||
or FilterComparison.Contains or FilterComparison.NotContains or FilterComparison.IsBefore
|
||||
or FilterComparison.IsAfter or FilterComparison.IsInLast or FilterComparison.IsNotInLast
|
||||
or FilterComparison.MustContains
|
||||
or FilterComparison.IsEmpty => throw new KavitaException(
|
||||
$"{comparison} not applicable for Person.SeriesCount"),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(comparison), comparison, "Filter Comparison is not supported")
|
||||
};
|
||||
}
|
||||
|
||||
public static IQueryable<Person> HasPersonChapterCount(this IQueryable<Person> queryable, bool condition,
|
||||
FilterComparison comparison, int count)
|
||||
{
|
||||
if (!condition) return queryable;
|
||||
|
||||
return comparison switch
|
||||
{
|
||||
FilterComparison.Equal => queryable.Where(p =>
|
||||
p.ChapterPeople.Select(cp => cp.Chapter.Id).Distinct().Count() == count),
|
||||
FilterComparison.GreaterThan => queryable.Where(p => p.ChapterPeople
|
||||
.Select(cp => cp.Chapter.Id)
|
||||
.Distinct()
|
||||
.Count() > count),
|
||||
FilterComparison.GreaterThanEqual => queryable.Where(p => p.ChapterPeople
|
||||
.Select(cp => cp.Chapter.Id)
|
||||
.Distinct()
|
||||
.Count() >= count),
|
||||
FilterComparison.LessThan => queryable.Where(p =>
|
||||
p.ChapterPeople.Select(cp => cp.Chapter.Id).Distinct().Count() < count),
|
||||
FilterComparison.LessThanEqual => queryable.Where(p => p.ChapterPeople
|
||||
.Select(cp => cp.Chapter.Id)
|
||||
.Distinct()
|
||||
.Count() <= count),
|
||||
FilterComparison.NotEqual => queryable.Where(p =>
|
||||
p.ChapterPeople.Select(cp => cp.Chapter.Id).Distinct().Count() != count),
|
||||
FilterComparison.BeginsWith or FilterComparison.EndsWith or FilterComparison.Matches
|
||||
or FilterComparison.Contains or FilterComparison.NotContains or FilterComparison.IsBefore
|
||||
or FilterComparison.IsAfter or FilterComparison.IsInLast or FilterComparison.IsNotInLast
|
||||
or FilterComparison.MustContains
|
||||
or FilterComparison.IsEmpty => throw new KavitaException(
|
||||
$"{comparison} not applicable for Person.ChapterCount"),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(comparison), comparison, "Filter Comparison is not supported")
|
||||
};
|
||||
}
|
||||
}
|
@ -5,10 +5,13 @@ using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using API.Data.Misc;
|
||||
using API.Data.Repositories;
|
||||
using API.DTOs;
|
||||
using API.DTOs.Filtering;
|
||||
using API.DTOs.KavitaPlus.Manage;
|
||||
using API.DTOs.Metadata.Browse;
|
||||
using API.Entities;
|
||||
using API.Entities.Enums;
|
||||
using API.Entities.Person;
|
||||
using API.Entities.Scrobble;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
@ -273,6 +276,27 @@ public static class QueryableExtensions
|
||||
};
|
||||
}
|
||||
|
||||
public static IQueryable<Person> SortBy(this IQueryable<Person> query, PersonSortOptions? sort)
|
||||
{
|
||||
if (sort == null)
|
||||
{
|
||||
return query.OrderBy(p => p.Name);
|
||||
}
|
||||
|
||||
return sort.SortField switch
|
||||
{
|
||||
PersonSortField.Name when sort.IsAscending => query.OrderBy(p => p.Name),
|
||||
PersonSortField.Name => query.OrderByDescending(p => p.Name),
|
||||
PersonSortField.SeriesCount when sort.IsAscending => query.OrderBy(p => p.SeriesMetadataPeople.Count),
|
||||
PersonSortField.SeriesCount => query.OrderByDescending(p => p.SeriesMetadataPeople.Count),
|
||||
PersonSortField.ChapterCount when sort.IsAscending => query.OrderBy(p => p.ChapterPeople.Count),
|
||||
PersonSortField.ChapterCount => query.OrderByDescending(p => p.ChapterPeople.Count),
|
||||
_ => query.OrderBy(p => p.Name)
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs either OrderBy or OrderByDescending on the given query based on the value of SortOptions.IsAscending.
|
||||
/// </summary>
|
||||
|
@ -3,6 +3,7 @@ using System.Linq;
|
||||
using API.Data.Misc;
|
||||
using API.Entities;
|
||||
using API.Entities.Enums;
|
||||
using API.Entities.Metadata;
|
||||
using API.Entities.Person;
|
||||
|
||||
namespace API.Extensions.QueryExtensions;
|
||||
@ -26,6 +27,7 @@ public static class RestrictByAgeExtensions
|
||||
return q;
|
||||
}
|
||||
|
||||
|
||||
public static IQueryable<Chapter> RestrictAgainstAgeRestriction(this IQueryable<Chapter> queryable, AgeRestriction restriction)
|
||||
{
|
||||
if (restriction.AgeRating == AgeRating.NotApplicable) return queryable;
|
||||
@ -39,20 +41,6 @@ public static class RestrictByAgeExtensions
|
||||
return q;
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public static IQueryable<CollectionTag> RestrictAgainstAgeRestriction(this IQueryable<CollectionTag> queryable, AgeRestriction restriction)
|
||||
{
|
||||
if (restriction.AgeRating == AgeRating.NotApplicable) return queryable;
|
||||
|
||||
if (restriction.IncludeUnknowns)
|
||||
{
|
||||
return queryable.Where(c => c.SeriesMetadatas.All(sm =>
|
||||
sm.AgeRating <= restriction.AgeRating));
|
||||
}
|
||||
|
||||
return queryable.Where(c => c.SeriesMetadatas.All(sm =>
|
||||
sm.AgeRating <= restriction.AgeRating && sm.AgeRating > AgeRating.Unknown));
|
||||
}
|
||||
|
||||
public static IQueryable<AppUserCollection> RestrictAgainstAgeRestriction(this IQueryable<AppUserCollection> queryable, AgeRestriction restriction)
|
||||
{
|
||||
@ -74,12 +62,15 @@ public static class RestrictByAgeExtensions
|
||||
|
||||
if (restriction.IncludeUnknowns)
|
||||
{
|
||||
return queryable.Where(c => c.SeriesMetadatas.All(sm =>
|
||||
sm.AgeRating <= restriction.AgeRating));
|
||||
return queryable.Where(c =>
|
||||
c.SeriesMetadatas.Any(sm => sm.AgeRating <= restriction.AgeRating) ||
|
||||
c.Chapters.Any(cp => cp.AgeRating <= restriction.AgeRating));
|
||||
}
|
||||
|
||||
return queryable.Where(c => c.SeriesMetadatas.All(sm =>
|
||||
sm.AgeRating <= restriction.AgeRating && sm.AgeRating > AgeRating.Unknown));
|
||||
return queryable.Where(c =>
|
||||
c.SeriesMetadatas.Any(sm => sm.AgeRating <= restriction.AgeRating && sm.AgeRating != AgeRating.Unknown) ||
|
||||
c.Chapters.Any(cp => cp.AgeRating <= restriction.AgeRating && cp.AgeRating != AgeRating.Unknown)
|
||||
);
|
||||
}
|
||||
|
||||
public static IQueryable<Tag> RestrictAgainstAgeRestriction(this IQueryable<Tag> queryable, AgeRestriction restriction)
|
||||
@ -88,12 +79,15 @@ public static class RestrictByAgeExtensions
|
||||
|
||||
if (restriction.IncludeUnknowns)
|
||||
{
|
||||
return queryable.Where(c => c.SeriesMetadatas.All(sm =>
|
||||
sm.AgeRating <= restriction.AgeRating));
|
||||
return queryable.Where(c =>
|
||||
c.SeriesMetadatas.Any(sm => sm.AgeRating <= restriction.AgeRating) ||
|
||||
c.Chapters.Any(cp => cp.AgeRating <= restriction.AgeRating));
|
||||
}
|
||||
|
||||
return queryable.Where(c => c.SeriesMetadatas.All(sm =>
|
||||
sm.AgeRating <= restriction.AgeRating && sm.AgeRating > AgeRating.Unknown));
|
||||
return queryable.Where(c =>
|
||||
c.SeriesMetadatas.Any(sm => sm.AgeRating <= restriction.AgeRating && sm.AgeRating != AgeRating.Unknown) ||
|
||||
c.Chapters.Any(cp => cp.AgeRating <= restriction.AgeRating && cp.AgeRating != AgeRating.Unknown)
|
||||
);
|
||||
}
|
||||
|
||||
public static IQueryable<Person> RestrictAgainstAgeRestriction(this IQueryable<Person> queryable, AgeRestriction restriction)
|
||||
|
@ -286,7 +286,8 @@ public class AutoMapperProfiles : Profile
|
||||
CreateMap<AppUserBookmark, BookmarkDto>();
|
||||
|
||||
CreateMap<ReadingList, ReadingListDto>()
|
||||
.ForMember(dest => dest.ItemCount, opt => opt.MapFrom(src => src.Items.Count));
|
||||
.ForMember(dest => dest.ItemCount, opt => opt.MapFrom(src => src.Items.Count))
|
||||
.ForMember(dest => dest.OwnerUserName, opt => opt.MapFrom(src => src.AppUser.UserName));
|
||||
CreateMap<ReadingListItem, ReadingListItemDto>();
|
||||
CreateMap<ScrobbleError, ScrobbleErrorDto>();
|
||||
CreateMap<ChapterDto, TachiyomiChapterDto>();
|
||||
|
31
API/Helpers/Converters/PersonFilterFieldValueConverter.cs
Normal file
31
API/Helpers/Converters/PersonFilterFieldValueConverter.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using API.DTOs.Filtering.v2;
|
||||
using API.Entities.Enums;
|
||||
|
||||
namespace API.Helpers.Converters;
|
||||
|
||||
public static class PersonFilterFieldValueConverter
|
||||
{
|
||||
public static object ConvertValue(PersonFilterField field, string value)
|
||||
{
|
||||
return field switch
|
||||
{
|
||||
PersonFilterField.Name => value,
|
||||
PersonFilterField.Role => ParsePersonRoles(value),
|
||||
PersonFilterField.SeriesCount => int.Parse(value),
|
||||
PersonFilterField.ChapterCount => int.Parse(value),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(field), field, "Field is not supported")
|
||||
};
|
||||
}
|
||||
|
||||
private static IList<PersonRole> ParsePersonRoles(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return [];
|
||||
|
||||
return value.Split(',', StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(v => Enum.Parse<PersonRole>(v.Trim()))
|
||||
.ToList();
|
||||
}
|
||||
}
|
@ -10,11 +10,9 @@ using API.Entities.Interfaces;
|
||||
using API.Extensions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NetVips;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using SixLabors.ImageSharp.Processing;
|
||||
using SixLabors.ImageSharp.Processing.Processors.Quantization;
|
||||
using Color = System.Drawing.Color;
|
||||
using Image = NetVips.Image;
|
||||
|
||||
namespace API.Services;
|
||||
@ -750,7 +748,7 @@ public class ImageService : IImageService
|
||||
}
|
||||
|
||||
|
||||
public static Color HexToRgb(string? hex)
|
||||
public static (int R, int G, int B) HexToRgb(string? hex)
|
||||
{
|
||||
if (string.IsNullOrEmpty(hex)) throw new ArgumentException("Hex cannot be null");
|
||||
|
||||
@ -774,7 +772,7 @@ public class ImageService : IImageService
|
||||
var g = Convert.ToInt32(hex.Substring(2, 2), 16);
|
||||
var b = Convert.ToInt32(hex.Substring(4, 2), 16);
|
||||
|
||||
return Color.FromArgb(r, g, b);
|
||||
return (r, g, b);
|
||||
}
|
||||
|
||||
|
||||
|
@ -200,6 +200,9 @@ public class ExternalMetadataService : IExternalMetadataService
|
||||
/// <summary>
|
||||
/// Returns the match results for a Series from UI Flow
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Will extract alternative names like Localized name, year will send as ReleaseYear but fallback to Comic Vine syntax if applicable
|
||||
/// </remarks>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IList<ExternalSeriesMatchDto>> MatchSeries(MatchSeriesDto dto)
|
||||
@ -212,19 +215,26 @@ public class ExternalMetadataService : IExternalMetadataService
|
||||
var potentialAnilistId = ScrobblingService.ExtractId<int?>(dto.Query, ScrobblingService.AniListWeblinkWebsite);
|
||||
var potentialMalId = ScrobblingService.ExtractId<long?>(dto.Query, ScrobblingService.MalWeblinkWebsite);
|
||||
|
||||
List<string> altNames = [series.LocalizedName, series.OriginalName];
|
||||
if (potentialAnilistId == null && potentialMalId == null && !string.IsNullOrEmpty(dto.Query))
|
||||
var format = series.Library.Type.ConvertToPlusMediaFormat(series.Format);
|
||||
var otherNames = ExtractAlternativeNames(series);
|
||||
|
||||
var year = series.Metadata.ReleaseYear;
|
||||
if (year == 0 && format == PlusMediaFormat.Comic && !string.IsNullOrWhiteSpace(series.Name))
|
||||
{
|
||||
altNames.Add(dto.Query);
|
||||
var potentialYear = Parser.ParseYear(series.Name);
|
||||
if (!string.IsNullOrEmpty(potentialYear))
|
||||
{
|
||||
year = int.Parse(potentialYear);
|
||||
}
|
||||
}
|
||||
|
||||
var matchRequest = new MatchSeriesRequestDto()
|
||||
{
|
||||
Format = series.Library.Type.ConvertToPlusMediaFormat(series.Format),
|
||||
Format = format,
|
||||
Query = dto.Query,
|
||||
SeriesName = series.Name,
|
||||
AlternativeNames = altNames.Where(s => !string.IsNullOrEmpty(s)).ToList(),
|
||||
Year = series.Metadata.ReleaseYear,
|
||||
AlternativeNames = otherNames,
|
||||
Year = year,
|
||||
AniListId = potentialAnilistId ?? ScrobblingService.GetAniListId(series),
|
||||
MalId = potentialMalId ?? ScrobblingService.GetMalId(series)
|
||||
};
|
||||
@ -254,6 +264,12 @@ public class ExternalMetadataService : IExternalMetadataService
|
||||
return ArraySegment<ExternalSeriesMatchDto>.Empty;
|
||||
}
|
||||
|
||||
private static List<string> ExtractAlternativeNames(Series series)
|
||||
{
|
||||
List<string> altNames = [series.LocalizedName, series.OriginalName];
|
||||
return altNames.Where(s => !string.IsNullOrEmpty(s)).Distinct().ToList();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves Metadata about a Recommended External Series
|
||||
|
@ -130,22 +130,23 @@ public class LicenseService(
|
||||
if (cacheValue.HasValue) return cacheValue.Value;
|
||||
}
|
||||
|
||||
var result = false;
|
||||
try
|
||||
{
|
||||
var serverSetting = await unitOfWork.SettingsRepository.GetSettingAsync(ServerSettingKey.LicenseKey);
|
||||
var result = await IsLicenseValid(serverSetting.Value);
|
||||
await provider.FlushAsync();
|
||||
await provider.SetAsync(CacheKey, result, _licenseCacheTimeout);
|
||||
return result;
|
||||
result = await IsLicenseValid(serverSetting.Value);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "There was an issue connecting to Kavita+");
|
||||
}
|
||||
finally
|
||||
{
|
||||
await provider.FlushAsync();
|
||||
await provider.SetAsync(CacheKey, false, _licenseCacheTimeout);
|
||||
await provider.SetAsync(CacheKey, result, _licenseCacheTimeout);
|
||||
}
|
||||
|
||||
return false;
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -432,6 +432,7 @@ public class ReadingProfileService(IUnitOfWork unitOfWork, ILocalizationService
|
||||
existingProfile.SwipeToPaginate = dto.SwipeToPaginate;
|
||||
existingProfile.AllowAutomaticWebtoonReaderDetection = dto.AllowAutomaticWebtoonReaderDetection;
|
||||
existingProfile.WidthOverride = dto.WidthOverride;
|
||||
existingProfile.DisableWidthOverride = dto.DisableWidthOverride;
|
||||
|
||||
// Book Reader
|
||||
existingProfile.BookReaderMargin = dto.BookReaderMargin;
|
||||
|
@ -206,17 +206,12 @@ public class CoverDbService : ICoverDbService
|
||||
throw new KavitaException($"Could not grab publisher image for {publisherName}");
|
||||
}
|
||||
|
||||
_logger.LogTrace("Fetching publisher image from {Url}", publisherLink.Sanitize());
|
||||
// Download the publisher file using Flurl
|
||||
var publisherStream = await publisherLink
|
||||
.AllowHttpStatus("2xx,304")
|
||||
.GetStreamAsync();
|
||||
|
||||
// Create the destination file path
|
||||
using var image = Image.NewFromStream(publisherStream);
|
||||
var filename = ImageService.GetPublisherFormat(publisherName, encodeFormat);
|
||||
|
||||
image.WriteToFile(Path.Combine(_directoryService.PublisherDirectory, filename));
|
||||
_logger.LogTrace("Fetching publisher image from {Url}", publisherLink.Sanitize());
|
||||
await DownloadImageFromUrl(publisherName, encodeFormat, publisherLink, _directoryService.PublisherDirectory);
|
||||
|
||||
_logger.LogDebug("Publisher image for {PublisherName} downloaded and saved successfully", publisherName.Sanitize());
|
||||
|
||||
return filename;
|
||||
@ -302,7 +297,27 @@ public class CoverDbService : ICoverDbService
|
||||
.GetStreamAsync();
|
||||
|
||||
using var image = Image.NewFromStream(imageStream);
|
||||
image.WriteToFile(targetFile);
|
||||
try
|
||||
{
|
||||
image.WriteToFile(targetFile);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
switch (encodeFormat)
|
||||
{
|
||||
case EncodeFormat.PNG:
|
||||
image.Pngsave(Path.Combine(_directoryService.FaviconDirectory, filename));
|
||||
break;
|
||||
case EncodeFormat.WEBP:
|
||||
image.Webpsave(Path.Combine(_directoryService.FaviconDirectory, filename));
|
||||
break;
|
||||
case EncodeFormat.AVIF:
|
||||
image.Heifsave(Path.Combine(_directoryService.FaviconDirectory, filename));
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(encodeFormat), encodeFormat, null);
|
||||
}
|
||||
}
|
||||
|
||||
return filename;
|
||||
}
|
||||
@ -385,14 +400,13 @@ public class CoverDbService : ICoverDbService
|
||||
private async Task<string> FallbackToKavitaReaderPublisher(string publisherName)
|
||||
{
|
||||
const string publisherFileName = "publishers.txt";
|
||||
var externalLink = string.Empty;
|
||||
var allOverrides = await GetCachedData(publisherFileName) ??
|
||||
await $"{NewHost}publishers/{publisherFileName}".GetStringAsync();
|
||||
|
||||
// Cache immediately
|
||||
await CacheDataAsync(publisherFileName, allOverrides);
|
||||
|
||||
if (string.IsNullOrEmpty(allOverrides)) return externalLink;
|
||||
if (string.IsNullOrEmpty(allOverrides)) return string.Empty;
|
||||
|
||||
var externalFile = allOverrides
|
||||
.Split("\n")
|
||||
@ -415,7 +429,7 @@ public class CoverDbService : ICoverDbService
|
||||
throw new KavitaException($"Could not grab publisher image for {publisherName}");
|
||||
}
|
||||
|
||||
return $"{NewHost}publishers/{externalLink}";
|
||||
return $"{NewHost}publishers/{externalFile}";
|
||||
}
|
||||
|
||||
private async Task CacheDataAsync(string fileName, string? content)
|
||||
@ -572,8 +586,7 @@ public class CoverDbService : ICoverDbService
|
||||
var choseNewImage = string.Equals(betterImage, tempFullPath, StringComparison.OrdinalIgnoreCase);
|
||||
if (choseNewImage)
|
||||
{
|
||||
|
||||
// Don't delete series cover, unless it's an override, otherwise the first chapter cover will be null
|
||||
// Don't delete the Series cover unless it is an override, otherwise the first chapter will be null
|
||||
if (existingPath.Contains(ImageService.GetSeriesFormat(series.Id)))
|
||||
{
|
||||
_directoryService.DeleteFiles([existingPath]);
|
||||
@ -624,6 +637,7 @@ public class CoverDbService : ICoverDbService
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Refactor this to IHasCoverImage instead of a hard entity type
|
||||
public async Task SetChapterCoverByUrl(Chapter chapter, string url, bool fromBase64 = true, bool chooseBetterImage = false)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
|
@ -1159,6 +1159,12 @@ public static partial class Parser
|
||||
return !string.IsNullOrEmpty(name) && SeriesAndYearRegex.IsMatch(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse a Year from a Comic Series: Series Name (YEAR)
|
||||
/// </summary>
|
||||
/// <example>Harley Quinn (2024) returns 2024</example>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public static string ParseYear(string? name)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name)) return string.Empty;
|
||||
|
@ -17,7 +17,7 @@ public static class Configuration
|
||||
private static readonly string AppSettingsFilename = Path.Join("config", GetAppSettingFilename());
|
||||
|
||||
public static readonly string KavitaPlusApiUrl = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == Environments.Development
|
||||
? "https://plus.kavitareader.com" : "https://plus.kavitareader.com";
|
||||
? "http://localhost:5020" : "https://plus.kavitareader.com";
|
||||
public static readonly string StatsApiUrl = "https://stats.kavitareader.com";
|
||||
|
||||
public static int Port
|
||||
|
@ -107,13 +107,10 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
|
||||
## Mega Sponsors
|
||||
<img src="https://opencollective.com/Kavita/tiers/mega-sponsor.svg?width=890"></a>
|
||||
|
||||
## JetBrains
|
||||
Thank you to [<img src="/Logo/jetbrains.svg" alt="" width="32"> JetBrains](http://www.jetbrains.com/) for providing us with free licenses to their great tools.
|
||||
|
||||
* [<img src="/Logo/rider.svg" alt="" width="32"> Rider](http://www.jetbrains.com/rider/)
|
||||
## Powered By
|
||||
[](https://jb.gg/OpenSource)
|
||||
|
||||
### License
|
||||
|
||||
* [GNU GPL v3](http://www.gnu.org/licenses/gpl.html)
|
||||
* Copyright 2020-2024
|
||||
|
||||
|
30
UI/Web/src/_tag-card-common.scss
Normal file
30
UI/Web/src/_tag-card-common.scss
Normal file
@ -0,0 +1,30 @@
|
||||
.tag-card {
|
||||
background-color: var(--bs-card-color, #2c2c2c);
|
||||
padding: 1rem;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
|
||||
transition: transform 0.2s ease, background 0.3s ease;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.tag-card:hover {
|
||||
background-color: #3a3a3a;
|
||||
//transform: translateY(-3px); // Cool effect but has a weird background issue. ROBBIE: Fix this
|
||||
}
|
||||
|
||||
.tag-name {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 600;
|
||||
margin-bottom: 0.5rem;
|
||||
max-height: 8rem;
|
||||
height: 8rem;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.tag-meta {
|
||||
font-size: 0.85rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
color: var(--text-muted-color, #bbb);
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
import {MatchStateOption} from "./match-state-option";
|
||||
import {LibraryType} from "../library/library";
|
||||
|
||||
export interface ManageMatchFilter {
|
||||
matchStateOption: MatchStateOption;
|
||||
libraryType: LibraryType | -1;
|
||||
searchTerm: string;
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ export enum LibraryType {
|
||||
}
|
||||
|
||||
export const allLibraryTypes = [LibraryType.Manga, LibraryType.ComicVine, LibraryType.Comic, LibraryType.Book, LibraryType.LightNovel, LibraryType.Images];
|
||||
export const allKavitaPlusMetadataApplicableTypes = [LibraryType.Manga, LibraryType.LightNovel, LibraryType.ComicVine, LibraryType.Comic];
|
||||
export const allKavitaPlusScrobbleEligibleTypes = [LibraryType.Manga, LibraryType.LightNovel];
|
||||
|
||||
export interface Library {
|
||||
id: number;
|
||||
|
6
UI/Web/src/app/_models/metadata/browse/browse-genre.ts
Normal file
6
UI/Web/src/app/_models/metadata/browse/browse-genre.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import {Genre} from "../genre";
|
||||
|
||||
export interface BrowseGenre extends Genre {
|
||||
seriesCount: number;
|
||||
chapterCount: number;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import {Person} from "../metadata/person";
|
||||
import {Person} from "../person";
|
||||
|
||||
export interface BrowsePerson extends Person {
|
||||
seriesCount: number;
|
||||
issueCount: number;
|
||||
chapterCount: number;
|
||||
}
|
6
UI/Web/src/app/_models/metadata/browse/browse-tag.ts
Normal file
6
UI/Web/src/app/_models/metadata/browse/browse-tag.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import {Tag} from "../../tag";
|
||||
|
||||
export interface BrowseTag extends Tag {
|
||||
seriesCount: number;
|
||||
chapterCount: number;
|
||||
}
|
@ -4,7 +4,10 @@ export interface Language {
|
||||
}
|
||||
|
||||
export interface KavitaLocale {
|
||||
fileName: string; // isoCode aka what maps to the file on disk and what transloco loads
|
||||
/**
|
||||
* isoCode aka what maps to the file on disk and what transloco loads
|
||||
*/
|
||||
fileName: string;
|
||||
renderName: string;
|
||||
translationCompletion: number;
|
||||
isRtL: boolean;
|
||||
|
@ -2,7 +2,6 @@ import {IHasCover} from "../common/i-has-cover";
|
||||
|
||||
export enum PersonRole {
|
||||
Other = 1,
|
||||
Artist = 2,
|
||||
Writer = 3,
|
||||
Penciller = 4,
|
||||
Inker = 5,
|
||||
@ -32,3 +31,22 @@ export interface Person extends IHasCover {
|
||||
primaryColor: string;
|
||||
secondaryColor: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Excludes Other as it's not in use
|
||||
*/
|
||||
export const allPeopleRoles = [
|
||||
PersonRole.Writer,
|
||||
PersonRole.Penciller,
|
||||
PersonRole.Inker,
|
||||
PersonRole.Colorist,
|
||||
PersonRole.Letterer,
|
||||
PersonRole.CoverArtist,
|
||||
PersonRole.Editor,
|
||||
PersonRole.Publisher,
|
||||
PersonRole.Character,
|
||||
PersonRole.Translator,
|
||||
PersonRole.Imprint,
|
||||
PersonRole.Team,
|
||||
PersonRole.Location
|
||||
]
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {MangaFormat} from "../manga-format";
|
||||
import {SeriesFilterV2} from "./v2/series-filter-v2";
|
||||
import {FilterV2} from "./v2/filter-v2";
|
||||
|
||||
export interface FilterItem<T> {
|
||||
title: string;
|
||||
@ -7,10 +7,6 @@ export interface FilterItem<T> {
|
||||
selected: boolean;
|
||||
}
|
||||
|
||||
export interface SortOptions {
|
||||
sortField: SortField;
|
||||
isAscending: boolean;
|
||||
}
|
||||
|
||||
export enum SortField {
|
||||
SortName = 1,
|
||||
@ -27,7 +23,7 @@ export enum SortField {
|
||||
Random = 9
|
||||
}
|
||||
|
||||
export const allSortFields = Object.keys(SortField)
|
||||
export const allSeriesSortFields = Object.keys(SortField)
|
||||
.filter(key => !isNaN(Number(key)) && parseInt(key, 10) >= 0)
|
||||
.map(key => parseInt(key, 10)) as SortField[];
|
||||
|
||||
@ -54,8 +50,8 @@ export const mangaFormatFilters = [
|
||||
}
|
||||
];
|
||||
|
||||
export interface FilterEvent {
|
||||
filterV2: SeriesFilterV2;
|
||||
export interface FilterEvent<TFilter extends number = number, TSort extends number = number> {
|
||||
filterV2: FilterV2<TFilter, TSort>;
|
||||
isFirst: boolean;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,8 @@
|
||||
import {PersonRole} from "../person";
|
||||
import {PersonSortOptions} from "./sort-options";
|
||||
|
||||
export interface BrowsePersonFilter {
|
||||
roles: Array<PersonRole>;
|
||||
query?: string;
|
||||
sortOptions?: PersonSortOptions;
|
||||
}
|
@ -48,7 +48,7 @@ const enumArray = Object.keys(FilterField)
|
||||
|
||||
enumArray.sort((a, b) => a.value.localeCompare(b.value));
|
||||
|
||||
export const allFields = enumArray
|
||||
export const allSeriesFilterFields = enumArray
|
||||
.map(key => parseInt(key.key, 10))as FilterField[];
|
||||
|
||||
export const allPeople = [
|
||||
@ -66,7 +66,6 @@ export const allPeople = [
|
||||
|
||||
export const personRoleForFilterField = (role: PersonRole) => {
|
||||
switch (role) {
|
||||
case PersonRole.Artist: return FilterField.CoverArtist;
|
||||
case PersonRole.Character: return FilterField.Characters;
|
||||
case PersonRole.Colorist: return FilterField.Colorist;
|
||||
case PersonRole.CoverArtist: return FilterField.CoverArtist;
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { FilterComparison } from "./filter-comparison";
|
||||
import { FilterField } from "./filter-field";
|
||||
import {FilterComparison} from "./filter-comparison";
|
||||
|
||||
export interface FilterStatement {
|
||||
export interface FilterStatement<T extends number = number> {
|
||||
comparison: FilterComparison;
|
||||
field: FilterField;
|
||||
field: T;
|
||||
value: string;
|
||||
}
|
||||
}
|
||||
|
11
UI/Web/src/app/_models/metadata/v2/filter-v2.ts
Normal file
11
UI/Web/src/app/_models/metadata/v2/filter-v2.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import {FilterStatement} from "./filter-statement";
|
||||
import {FilterCombination} from "./filter-combination";
|
||||
import {SortOptions} from "./sort-options";
|
||||
|
||||
export interface FilterV2<TFilter extends number = number, TSort extends number = number> {
|
||||
name?: string;
|
||||
statements: Array<FilterStatement<TFilter>>;
|
||||
combination: FilterCombination;
|
||||
sortOptions?: SortOptions<TSort>;
|
||||
limitTo: number;
|
||||
}
|
12
UI/Web/src/app/_models/metadata/v2/person-filter-field.ts
Normal file
12
UI/Web/src/app/_models/metadata/v2/person-filter-field.ts
Normal file
@ -0,0 +1,12 @@
|
||||
export enum PersonFilterField {
|
||||
Role = 1,
|
||||
Name = 2,
|
||||
SeriesCount = 3,
|
||||
ChapterCount = 4,
|
||||
}
|
||||
|
||||
|
||||
export const allPersonFilterFields = Object.keys(PersonFilterField)
|
||||
.filter(key => !isNaN(Number(key)) && parseInt(key, 10) >= 0)
|
||||
.map(key => parseInt(key, 10)) as PersonFilterField[];
|
||||
|
9
UI/Web/src/app/_models/metadata/v2/person-sort-field.ts
Normal file
9
UI/Web/src/app/_models/metadata/v2/person-sort-field.ts
Normal file
@ -0,0 +1,9 @@
|
||||
export enum PersonSortField {
|
||||
Name = 1,
|
||||
SeriesCount = 2,
|
||||
ChapterCount = 3
|
||||
}
|
||||
|
||||
export const allPersonSortFields = Object.keys(PersonSortField)
|
||||
.filter(key => !isNaN(Number(key)) && parseInt(key, 10) >= 0)
|
||||
.map(key => parseInt(key, 10)) as PersonSortField[];
|
@ -1,11 +0,0 @@
|
||||
import { SortOptions } from "../series-filter";
|
||||
import {FilterStatement} from "./filter-statement";
|
||||
import {FilterCombination} from "./filter-combination";
|
||||
|
||||
export interface SeriesFilterV2 {
|
||||
name?: string;
|
||||
statements: Array<FilterStatement>;
|
||||
combination: FilterCombination;
|
||||
sortOptions?: SortOptions;
|
||||
limitTo: number;
|
||||
}
|
17
UI/Web/src/app/_models/metadata/v2/sort-options.ts
Normal file
17
UI/Web/src/app/_models/metadata/v2/sort-options.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import {PersonSortField} from "./person-sort-field";
|
||||
|
||||
/**
|
||||
* Series-based Sort options
|
||||
*/
|
||||
export interface SortOptions<TSort extends number = number> {
|
||||
sortField: TSort;
|
||||
isAscending: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Person-based Sort Options
|
||||
*/
|
||||
export interface PersonSortOptions {
|
||||
sortField: PersonSortField;
|
||||
isAscending: boolean;
|
||||
}
|
@ -12,6 +12,7 @@ import {PdfLayoutMode} from "./pdf-layout-mode";
|
||||
import {PdfSpreadMode} from "./pdf-spread-mode";
|
||||
import {Series} from "../series";
|
||||
import {Library} from "../library/library";
|
||||
import {UserBreakpoint} from "../../shared/_services/utility.service";
|
||||
|
||||
export enum ReadingProfileKind {
|
||||
Default = 0,
|
||||
@ -39,6 +40,7 @@ export interface ReadingProfile {
|
||||
swipeToPaginate: boolean;
|
||||
allowAutomaticWebtoonReaderDetection: boolean;
|
||||
widthOverride?: number;
|
||||
disableWidthOverride: UserBreakpoint;
|
||||
|
||||
// Book Reader
|
||||
bookReaderMargin: number;
|
||||
@ -75,3 +77,4 @@ export const pdfLayoutModes = [{text: 'pdf-multiple', value: PdfLayoutMode.Multi
|
||||
export const pdfScrollModes = [{text: 'pdf-vertical', value: PdfScrollMode.Vertical}, {text: 'pdf-horizontal', value: PdfScrollMode.Horizontal}, {text: 'pdf-page', value: PdfScrollMode.Page}];
|
||||
export const pdfSpreadModes = [{text: 'pdf-none', value: PdfSpreadMode.None}, {text: 'pdf-odd', value: PdfSpreadMode.Odd}, {text: 'pdf-even', value: PdfSpreadMode.Even}];
|
||||
export const pdfThemes = [{text: 'pdf-light', value: PdfTheme.Light}, {text: 'pdf-dark', value: PdfTheme.Dark}];
|
||||
export const breakPoints = [UserBreakpoint.Never, UserBreakpoint.Mobile, UserBreakpoint.Tablet, UserBreakpoint.Desktop]
|
||||
|
@ -20,5 +20,6 @@ export enum WikiLink {
|
||||
UpdateNative = 'https://wiki.kavitareader.com/guides/updating/updating-native',
|
||||
UpdateDocker = 'https://wiki.kavitareader.com/guides/updating/updating-docker',
|
||||
OpdsClients = 'https://wiki.kavitareader.com/guides/features/opds/#opds-capable-clients',
|
||||
Guides = 'https://wiki.kavitareader.com/guides'
|
||||
Guides = 'https://wiki.kavitareader.com/guides',
|
||||
ReadingProfiles = "https://wiki.kavitareader.com/guides/user-settings/reading-profiles/",
|
||||
}
|
||||
|
25
UI/Web/src/app/_pipes/breakpoint.pipe.ts
Normal file
25
UI/Web/src/app/_pipes/breakpoint.pipe.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import {Pipe, PipeTransform} from '@angular/core';
|
||||
import {translate} from "@jsverse/transloco";
|
||||
import {UserBreakpoint} from "../shared/_services/utility.service";
|
||||
|
||||
@Pipe({
|
||||
name: 'breakpoint'
|
||||
})
|
||||
export class BreakpointPipe implements PipeTransform {
|
||||
|
||||
transform(value: UserBreakpoint): string {
|
||||
const v = parseInt(value + '', 10) as UserBreakpoint;
|
||||
switch (v) {
|
||||
case UserBreakpoint.Never:
|
||||
return translate('breakpoint-pipe.never');
|
||||
case UserBreakpoint.Mobile:
|
||||
return translate('breakpoint-pipe.mobile');
|
||||
case UserBreakpoint.Tablet:
|
||||
return translate('breakpoint-pipe.tablet');
|
||||
case UserBreakpoint.Desktop:
|
||||
return translate('breakpoint-pipe.desktop');
|
||||
}
|
||||
throw new Error("unknown breakpoint value: " + value);
|
||||
}
|
||||
|
||||
}
|
78
UI/Web/src/app/_pipes/browse-title.pipe.ts
Normal file
78
UI/Web/src/app/_pipes/browse-title.pipe.ts
Normal file
@ -0,0 +1,78 @@
|
||||
import {Pipe, PipeTransform} from '@angular/core';
|
||||
import {FilterField} from "../_models/metadata/v2/filter-field";
|
||||
import {translate} from "@jsverse/transloco";
|
||||
|
||||
/**
|
||||
* Responsible for taking a filter field and value (as a string) and translating into a "Browse X" heading for All Series page
|
||||
* Example: Genre & "Action" -> Browse Action
|
||||
* Example: Artist & "Joe Shmo" -> Browse Joe Shmo Works
|
||||
*/
|
||||
@Pipe({
|
||||
name: 'browseTitle'
|
||||
})
|
||||
export class BrowseTitlePipe implements PipeTransform {
|
||||
|
||||
transform(field: FilterField, value: string): string {
|
||||
switch (field) {
|
||||
case FilterField.PublicationStatus:
|
||||
return translate('browse-title-pipe.publication-status', {value});
|
||||
case FilterField.AgeRating:
|
||||
return translate('browse-title-pipe.age-rating', {value});
|
||||
case FilterField.UserRating:
|
||||
return translate('browse-title-pipe.user-rating', {value});
|
||||
case FilterField.Tags:
|
||||
return translate('browse-title-pipe.tag', {value});
|
||||
case FilterField.Translators:
|
||||
return translate('browse-title-pipe.translator', {value});
|
||||
case FilterField.Characters:
|
||||
return translate('browse-title-pipe.character', {value});
|
||||
case FilterField.Publisher:
|
||||
return translate('browse-title-pipe.publisher', {value});
|
||||
case FilterField.Editor:
|
||||
return translate('browse-title-pipe.editor', {value});
|
||||
case FilterField.CoverArtist:
|
||||
return translate('browse-title-pipe.artist', {value});
|
||||
case FilterField.Letterer:
|
||||
return translate('browse-title-pipe.letterer', {value});
|
||||
case FilterField.Colorist:
|
||||
return translate('browse-title-pipe.colorist', {value});
|
||||
case FilterField.Inker:
|
||||
return translate('browse-title-pipe.inker', {value});
|
||||
case FilterField.Penciller:
|
||||
return translate('browse-title-pipe.penciller', {value});
|
||||
case FilterField.Writers:
|
||||
return translate('browse-title-pipe.writer', {value});
|
||||
case FilterField.Genres:
|
||||
return translate('browse-title-pipe.genre', {value});
|
||||
case FilterField.Libraries:
|
||||
return translate('browse-title-pipe.library', {value});
|
||||
case FilterField.Formats:
|
||||
return translate('browse-title-pipe.format', {value});
|
||||
case FilterField.ReleaseYear:
|
||||
return translate('browse-title-pipe.release-year', {value});
|
||||
case FilterField.Imprint:
|
||||
return translate('browse-title-pipe.imprint', {value});
|
||||
case FilterField.Team:
|
||||
return translate('browse-title-pipe.team', {value});
|
||||
case FilterField.Location:
|
||||
return translate('browse-title-pipe.location', {value});
|
||||
|
||||
// These have no natural links in the app to demand a richer title experience
|
||||
case FilterField.Languages:
|
||||
case FilterField.CollectionTags:
|
||||
case FilterField.ReadProgress:
|
||||
case FilterField.ReadTime:
|
||||
case FilterField.Path:
|
||||
case FilterField.FilePath:
|
||||
case FilterField.WantToRead:
|
||||
case FilterField.ReadingDate:
|
||||
case FilterField.AverageRating:
|
||||
case FilterField.ReadLast:
|
||||
case FilterField.Summary:
|
||||
case FilterField.SeriesName:
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
108
UI/Web/src/app/_pipes/generic-filter-field.pipe.ts
Normal file
108
UI/Web/src/app/_pipes/generic-filter-field.pipe.ts
Normal file
@ -0,0 +1,108 @@
|
||||
import {Pipe, PipeTransform} from '@angular/core';
|
||||
import {FilterField} from "../_models/metadata/v2/filter-field";
|
||||
import {translate} from "@jsverse/transloco";
|
||||
import {ValidFilterEntity} from "../metadata-filter/filter-settings";
|
||||
import {PersonFilterField} from "../_models/metadata/v2/person-filter-field";
|
||||
|
||||
@Pipe({
|
||||
name: 'genericFilterField'
|
||||
})
|
||||
export class GenericFilterFieldPipe implements PipeTransform {
|
||||
|
||||
transform<T extends number>(value: T, entityType: ValidFilterEntity): string {
|
||||
|
||||
switch (entityType) {
|
||||
case "series":
|
||||
return this.translateFilterField(value as FilterField);
|
||||
case "person":
|
||||
return this.translatePersonFilterField(value as PersonFilterField);
|
||||
}
|
||||
}
|
||||
|
||||
private translatePersonFilterField(value: PersonFilterField) {
|
||||
switch (value) {
|
||||
case PersonFilterField.Role:
|
||||
return translate('generic-filter-field-pipe.person-role');
|
||||
case PersonFilterField.Name:
|
||||
return translate('generic-filter-field-pipe.person-name');
|
||||
case PersonFilterField.SeriesCount:
|
||||
return translate('generic-filter-field-pipe.person-series-count');
|
||||
case PersonFilterField.ChapterCount:
|
||||
return translate('generic-filter-field-pipe.person-chapter-count');
|
||||
}
|
||||
}
|
||||
|
||||
private translateFilterField(value: FilterField) {
|
||||
switch (value) {
|
||||
case FilterField.AgeRating:
|
||||
return translate('filter-field-pipe.age-rating');
|
||||
case FilterField.Characters:
|
||||
return translate('filter-field-pipe.characters');
|
||||
case FilterField.CollectionTags:
|
||||
return translate('filter-field-pipe.collection-tags');
|
||||
case FilterField.Colorist:
|
||||
return translate('filter-field-pipe.colorist');
|
||||
case FilterField.CoverArtist:
|
||||
return translate('filter-field-pipe.cover-artist');
|
||||
case FilterField.Editor:
|
||||
return translate('filter-field-pipe.editor');
|
||||
case FilterField.Formats:
|
||||
return translate('filter-field-pipe.formats');
|
||||
case FilterField.Genres:
|
||||
return translate('filter-field-pipe.genres');
|
||||
case FilterField.Inker:
|
||||
return translate('filter-field-pipe.inker');
|
||||
case FilterField.Imprint:
|
||||
return translate('filter-field-pipe.imprint');
|
||||
case FilterField.Team:
|
||||
return translate('filter-field-pipe.team');
|
||||
case FilterField.Location:
|
||||
return translate('filter-field-pipe.location');
|
||||
case FilterField.Languages:
|
||||
return translate('filter-field-pipe.languages');
|
||||
case FilterField.Libraries:
|
||||
return translate('filter-field-pipe.libraries');
|
||||
case FilterField.Letterer:
|
||||
return translate('filter-field-pipe.letterer');
|
||||
case FilterField.PublicationStatus:
|
||||
return translate('filter-field-pipe.publication-status');
|
||||
case FilterField.Penciller:
|
||||
return translate('filter-field-pipe.penciller');
|
||||
case FilterField.Publisher:
|
||||
return translate('filter-field-pipe.publisher');
|
||||
case FilterField.ReadProgress:
|
||||
return translate('filter-field-pipe.read-progress');
|
||||
case FilterField.ReadTime:
|
||||
return translate('filter-field-pipe.read-time');
|
||||
case FilterField.ReleaseYear:
|
||||
return translate('filter-field-pipe.release-year');
|
||||
case FilterField.SeriesName:
|
||||
return translate('filter-field-pipe.series-name');
|
||||
case FilterField.Summary:
|
||||
return translate('filter-field-pipe.summary');
|
||||
case FilterField.Tags:
|
||||
return translate('filter-field-pipe.tags');
|
||||
case FilterField.Translators:
|
||||
return translate('filter-field-pipe.translators');
|
||||
case FilterField.UserRating:
|
||||
return translate('filter-field-pipe.user-rating');
|
||||
case FilterField.Writers:
|
||||
return translate('filter-field-pipe.writers');
|
||||
case FilterField.Path:
|
||||
return translate('filter-field-pipe.path');
|
||||
case FilterField.FilePath:
|
||||
return translate('filter-field-pipe.file-path');
|
||||
case FilterField.WantToRead:
|
||||
return translate('filter-field-pipe.want-to-read');
|
||||
case FilterField.ReadingDate:
|
||||
return translate('filter-field-pipe.read-date');
|
||||
case FilterField.ReadLast:
|
||||
return translate('filter-field-pipe.read-last');
|
||||
case FilterField.AverageRating:
|
||||
return translate('filter-field-pipe.average-rating');
|
||||
default:
|
||||
throw new Error(`Invalid FilterField value: ${value}`);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import {inject, Pipe, PipeTransform} from '@angular/core';
|
||||
import { PersonRole } from '../_models/metadata/person';
|
||||
import {translate, TranslocoService} from "@jsverse/transloco";
|
||||
import {Pipe, PipeTransform} from '@angular/core';
|
||||
import {PersonRole} from '../_models/metadata/person';
|
||||
import {translate} from "@jsverse/transloco";
|
||||
|
||||
@Pipe({
|
||||
name: 'personRole',
|
||||
@ -10,8 +10,6 @@ export class PersonRolePipe implements PipeTransform {
|
||||
|
||||
transform(value: PersonRole): string {
|
||||
switch (value) {
|
||||
case PersonRole.Artist:
|
||||
return translate('person-role-pipe.artist');
|
||||
case PersonRole.Character:
|
||||
return translate('person-role-pipe.character');
|
||||
case PersonRole.Colorist:
|
||||
|
@ -1,6 +1,8 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import {Pipe, PipeTransform} from '@angular/core';
|
||||
import {SortField} from "../_models/metadata/series-filter";
|
||||
import {TranslocoService} from "@jsverse/transloco";
|
||||
import {ValidFilterEntity} from "../metadata-filter/filter-settings";
|
||||
import {PersonSortField} from "../_models/metadata/v2/person-sort-field";
|
||||
|
||||
@Pipe({
|
||||
name: 'sortField',
|
||||
@ -11,7 +13,30 @@ export class SortFieldPipe implements PipeTransform {
|
||||
constructor(private translocoService: TranslocoService) {
|
||||
}
|
||||
|
||||
transform(value: SortField): string {
|
||||
transform<T extends number>(value: T, entityType: ValidFilterEntity): string {
|
||||
|
||||
switch (entityType) {
|
||||
case 'series':
|
||||
return this.seriesSortFields(value as SortField);
|
||||
case 'person':
|
||||
return this.personSortFields(value as PersonSortField);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private personSortFields(value: PersonSortField) {
|
||||
switch (value) {
|
||||
case PersonSortField.Name:
|
||||
return this.translocoService.translate('sort-field-pipe.person-name');
|
||||
case PersonSortField.SeriesCount:
|
||||
return this.translocoService.translate('sort-field-pipe.person-series-count');
|
||||
case PersonSortField.ChapterCount:
|
||||
return this.translocoService.translate('sort-field-pipe.person-chapter-count');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private seriesSortFields(value: SortField) {
|
||||
switch (value) {
|
||||
case SortField.SortName:
|
||||
return this.translocoService.translate('sort-field-pipe.sort-name');
|
||||
@ -32,7 +57,6 @@ export class SortFieldPipe implements PipeTransform {
|
||||
case SortField.Random:
|
||||
return this.translocoService.translate('sort-field-pipe.random');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
22
UI/Web/src/app/_resolvers/url-filter.resolver.ts
Normal file
22
UI/Web/src/app/_resolvers/url-filter.resolver.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import {Injectable} from "@angular/core";
|
||||
import {ActivatedRouteSnapshot, Resolve, RouterStateSnapshot} from "@angular/router";
|
||||
import {Observable, of} from "rxjs";
|
||||
import {FilterV2} from "../_models/metadata/v2/filter-v2";
|
||||
import {FilterUtilitiesService} from "../shared/_services/filter-utilities.service";
|
||||
|
||||
/**
|
||||
* Checks the url for a filter and resolves one if applicable, otherwise returns null.
|
||||
* It is up to the consumer to cast appropriately.
|
||||
*/
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class UrlFilterResolver implements Resolve<any> {
|
||||
|
||||
constructor(private filterUtilitiesService: FilterUtilitiesService) {}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<FilterV2 | null> {
|
||||
if (!state.url.includes('?')) return of(null);
|
||||
return this.filterUtilitiesService.decodeFilter(state.url.split('?')[1]);
|
||||
}
|
||||
}
|
@ -1,7 +1,13 @@
|
||||
import { Routes } from "@angular/router";
|
||||
import { AllSeriesComponent } from "../all-series/_components/all-series/all-series.component";
|
||||
import {Routes} from "@angular/router";
|
||||
import {AllSeriesComponent} from "../all-series/_components/all-series/all-series.component";
|
||||
import {UrlFilterResolver} from "../_resolvers/url-filter.resolver";
|
||||
|
||||
|
||||
export const routes: Routes = [
|
||||
{path: '', component: AllSeriesComponent, pathMatch: 'full'},
|
||||
{path: '', component: AllSeriesComponent, pathMatch: 'full',
|
||||
runGuardsAndResolvers: 'always',
|
||||
resolve: {
|
||||
filter: UrlFilterResolver
|
||||
}
|
||||
},
|
||||
];
|
||||
|
@ -1,6 +1,12 @@
|
||||
import { Routes } from "@angular/router";
|
||||
import { BookmarksComponent } from "../bookmark/_components/bookmarks/bookmarks.component";
|
||||
import {Routes} from "@angular/router";
|
||||
import {BookmarksComponent} from "../bookmark/_components/bookmarks/bookmarks.component";
|
||||
import {UrlFilterResolver} from "../_resolvers/url-filter.resolver";
|
||||
|
||||
export const routes: Routes = [
|
||||
{path: '', component: BookmarksComponent, pathMatch: 'full'},
|
||||
{path: '', component: BookmarksComponent, pathMatch: 'full',
|
||||
resolve: {
|
||||
filter: UrlFilterResolver
|
||||
},
|
||||
runGuardsAndResolvers: 'always',
|
||||
},
|
||||
];
|
||||
|
@ -1,8 +0,0 @@
|
||||
import { Routes } from "@angular/router";
|
||||
import { AllSeriesComponent } from "../all-series/_components/all-series/all-series.component";
|
||||
import {BrowseAuthorsComponent} from "../browse-people/browse-authors.component";
|
||||
|
||||
|
||||
export const routes: Routes = [
|
||||
{path: '', component: BrowseAuthorsComponent, pathMatch: 'full'},
|
||||
];
|
24
UI/Web/src/app/_routes/browse-routing.module.ts
Normal file
24
UI/Web/src/app/_routes/browse-routing.module.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import {Routes} from "@angular/router";
|
||||
import {BrowsePeopleComponent} from "../browse/browse-people/browse-people.component";
|
||||
import {BrowseGenresComponent} from "../browse/browse-genres/browse-genres.component";
|
||||
import {BrowseTagsComponent} from "../browse/browse-tags/browse-tags.component";
|
||||
import {UrlFilterResolver} from "../_resolvers/url-filter.resolver";
|
||||
|
||||
|
||||
export const routes: Routes = [
|
||||
// Legacy route
|
||||
{path: 'authors', component: BrowsePeopleComponent, pathMatch: 'full',
|
||||
resolve: {
|
||||
filter: UrlFilterResolver
|
||||
},
|
||||
runGuardsAndResolvers: 'always',
|
||||
},
|
||||
{path: 'people', component: BrowsePeopleComponent, pathMatch: 'full',
|
||||
resolve: {
|
||||
filter: UrlFilterResolver
|
||||
},
|
||||
runGuardsAndResolvers: 'always',
|
||||
},
|
||||
{path: 'genres', component: BrowseGenresComponent, pathMatch: 'full'},
|
||||
{path: 'tags', component: BrowseTagsComponent, pathMatch: 'full'},
|
||||
];
|
@ -1,9 +1,15 @@
|
||||
import { Routes } from '@angular/router';
|
||||
import { AllCollectionsComponent } from '../collections/_components/all-collections/all-collections.component';
|
||||
import { CollectionDetailComponent } from '../collections/_components/collection-detail/collection-detail.component';
|
||||
import {Routes} from '@angular/router';
|
||||
import {AllCollectionsComponent} from '../collections/_components/all-collections/all-collections.component';
|
||||
import {CollectionDetailComponent} from '../collections/_components/collection-detail/collection-detail.component';
|
||||
import {UrlFilterResolver} from "../_resolvers/url-filter.resolver";
|
||||
|
||||
export const routes: Routes = [
|
||||
{path: '', component: AllCollectionsComponent, pathMatch: 'full'},
|
||||
{path: ':id', component: CollectionDetailComponent},
|
||||
{path: ':id', component: CollectionDetailComponent,
|
||||
resolve: {
|
||||
filter: UrlFilterResolver
|
||||
},
|
||||
runGuardsAndResolvers: 'always',
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { Routes } from '@angular/router';
|
||||
import { AuthGuard } from '../_guards/auth.guard';
|
||||
import { LibraryAccessGuard } from '../_guards/library-access.guard';
|
||||
import { LibraryDetailComponent } from '../library-detail/library-detail.component';
|
||||
import {Routes} from '@angular/router';
|
||||
import {AuthGuard} from '../_guards/auth.guard';
|
||||
import {LibraryAccessGuard} from '../_guards/library-access.guard';
|
||||
import {LibraryDetailComponent} from '../library-detail/library-detail.component';
|
||||
import {UrlFilterResolver} from "../_resolvers/url-filter.resolver";
|
||||
|
||||
|
||||
export const routes: Routes = [
|
||||
@ -9,12 +10,18 @@ export const routes: Routes = [
|
||||
path: ':libraryId',
|
||||
runGuardsAndResolvers: 'always',
|
||||
canActivate: [AuthGuard, LibraryAccessGuard],
|
||||
component: LibraryDetailComponent
|
||||
component: LibraryDetailComponent,
|
||||
resolve: {
|
||||
filter: UrlFilterResolver
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '',
|
||||
runGuardsAndResolvers: 'always',
|
||||
canActivate: [AuthGuard, LibraryAccessGuard],
|
||||
component: LibraryDetailComponent
|
||||
}
|
||||
component: LibraryDetailComponent,
|
||||
resolve: {
|
||||
filter: UrlFilterResolver
|
||||
},
|
||||
},
|
||||
];
|
||||
|
@ -1,6 +1,10 @@
|
||||
import { Routes } from '@angular/router';
|
||||
import { WantToReadComponent } from '../want-to-read/_components/want-to-read/want-to-read.component';
|
||||
import {Routes} from '@angular/router';
|
||||
import {WantToReadComponent} from '../want-to-read/_components/want-to-read/want-to-read.component';
|
||||
import {UrlFilterResolver} from "../_resolvers/url-filter.resolver";
|
||||
|
||||
export const routes: Routes = [
|
||||
{path: '', component: WantToReadComponent, pathMatch: 'full'},
|
||||
{path: '', component: WantToReadComponent, pathMatch: 'full', runGuardsAndResolvers: 'always', resolve: {
|
||||
filter: UrlFilterResolver
|
||||
}
|
||||
},
|
||||
];
|
||||
|
@ -132,6 +132,33 @@ export class AccountService {
|
||||
return roles.some(role => user.roles.includes(role));
|
||||
}
|
||||
|
||||
/**
|
||||
* If User or Admin, will return false
|
||||
* @param user
|
||||
* @param restrictedRoles
|
||||
*/
|
||||
hasAnyRestrictedRole(user: User, restrictedRoles: Array<Role> = []) {
|
||||
if (!user || !user.roles) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (restrictedRoles.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the user is an admin, they have the role
|
||||
if (this.hasAdminRole(user)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (restrictedRoles.length > 0 && restrictedRoles.some(role => user.roles.includes(role))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
hasAdminRole(user: User) {
|
||||
return user && user.roles.includes(Role.Admin);
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {SeriesFilterV2} from "../_models/metadata/v2/series-filter-v2";
|
||||
import {Injectable} from '@angular/core';
|
||||
import {FilterV2} from "../_models/metadata/v2/filter-v2";
|
||||
import {environment} from "../../environments/environment";
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import {JumpKey} from "../_models/jumpbar/jump-key";
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {SmartFilter} from "../_models/metadata/v2/smart-filter";
|
||||
|
||||
@Injectable({
|
||||
@ -13,7 +12,7 @@ export class FilterService {
|
||||
baseUrl = environment.apiUrl;
|
||||
constructor(private httpClient: HttpClient) { }
|
||||
|
||||
saveFilter(filter: SeriesFilterV2) {
|
||||
saveFilter(filter: FilterV2<number>) {
|
||||
return this.httpClient.post(this.baseUrl + 'filter/update', filter);
|
||||
}
|
||||
getAllFilters() {
|
||||
@ -26,5 +25,4 @@ export class FilterService {
|
||||
renameSmartFilter(filter: SmartFilter) {
|
||||
return this.httpClient.post(this.baseUrl + `filter/rename?filterId=${filter.id}&name=${filter.name.trim()}`, {});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { JumpKey } from '../_models/jumpbar/jump-key';
|
||||
import {Injectable} from '@angular/core';
|
||||
import {JumpKey} from '../_models/jumpbar/jump-key';
|
||||
|
||||
const keySize = 25; // Height of the JumpBar button
|
||||
|
||||
@ -105,14 +105,18 @@ export class JumpbarService {
|
||||
getJumpKeys(data :Array<any>, keySelector: (data: any) => string) {
|
||||
const keys: {[key: string]: number} = {};
|
||||
data.forEach(obj => {
|
||||
let ch = keySelector(obj).charAt(0).toUpperCase();
|
||||
if (/\d|\#|!|%|@|\(|\)|\^|\.|_|\*/g.test(ch)) {
|
||||
ch = '#';
|
||||
try {
|
||||
let ch = keySelector(obj).charAt(0).toUpperCase();
|
||||
if (/\d|\#|!|%|@|\(|\)|\^|\.|_|\*/g.test(ch)) {
|
||||
ch = '#';
|
||||
}
|
||||
if (!keys.hasOwnProperty(ch)) {
|
||||
keys[ch] = 0;
|
||||
}
|
||||
keys[ch] += 1;
|
||||
} catch (e) {
|
||||
console.error('Failed to calculate jump key for ', obj, e);
|
||||
}
|
||||
if (!keys.hasOwnProperty(ch)) {
|
||||
keys[ch] = 0;
|
||||
}
|
||||
keys[ch] += 1;
|
||||
});
|
||||
return Object.keys(keys).map(k => {
|
||||
k = k.toUpperCase();
|
||||
|
@ -1,33 +1,54 @@
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Injectable} from '@angular/core';
|
||||
import {HttpClient, HttpParams} from '@angular/common/http';
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {tap} from 'rxjs/operators';
|
||||
import {of} from 'rxjs';
|
||||
import {map, of} from 'rxjs';
|
||||
import {environment} from 'src/environments/environment';
|
||||
import {Genre} from '../_models/metadata/genre';
|
||||
import {AgeRatingDto} from '../_models/metadata/age-rating-dto';
|
||||
import {Language} from '../_models/metadata/language';
|
||||
import {PublicationStatusDto} from '../_models/metadata/publication-status-dto';
|
||||
import {Person, PersonRole} from '../_models/metadata/person';
|
||||
import {allPeopleRoles, Person, PersonRole} from '../_models/metadata/person';
|
||||
import {Tag} from '../_models/tag';
|
||||
import {FilterComparison} from '../_models/metadata/v2/filter-comparison';
|
||||
import {FilterField} from '../_models/metadata/v2/filter-field';
|
||||
import {SortField} from "../_models/metadata/series-filter";
|
||||
import {mangaFormatFilters, SortField} from "../_models/metadata/series-filter";
|
||||
import {FilterCombination} from "../_models/metadata/v2/filter-combination";
|
||||
import {SeriesFilterV2} from "../_models/metadata/v2/series-filter-v2";
|
||||
import {FilterV2} from "../_models/metadata/v2/filter-v2";
|
||||
import {FilterStatement} from "../_models/metadata/v2/filter-statement";
|
||||
import {SeriesDetailPlus} from "../_models/series-detail/series-detail-plus";
|
||||
import {LibraryType} from "../_models/library/library";
|
||||
import {IHasCast} from "../_models/common/i-has-cast";
|
||||
import {TextResonse} from "../_types/text-response";
|
||||
import {QueryContext} from "../_models/metadata/v2/query-context";
|
||||
import {AgeRatingPipe} from "../_pipes/age-rating.pipe";
|
||||
import {MangaFormatPipe} from "../_pipes/manga-format.pipe";
|
||||
import {TranslocoService} from "@jsverse/transloco";
|
||||
import {LibraryService} from './library.service';
|
||||
import {CollectionTagService} from "./collection-tag.service";
|
||||
import {PaginatedResult} from "../_models/pagination";
|
||||
import {UtilityService} from "../shared/_services/utility.service";
|
||||
import {BrowseGenre} from "../_models/metadata/browse/browse-genre";
|
||||
import {BrowseTag} from "../_models/metadata/browse/browse-tag";
|
||||
import {ValidFilterEntity} from "../metadata-filter/filter-settings";
|
||||
import {PersonFilterField} from "../_models/metadata/v2/person-filter-field";
|
||||
import {PersonRolePipe} from "../_pipes/person-role.pipe";
|
||||
import {PersonSortField} from "../_models/metadata/v2/person-sort-field";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class MetadataService {
|
||||
|
||||
private readonly translocoService = inject(TranslocoService);
|
||||
private readonly libraryService = inject(LibraryService);
|
||||
private readonly collectionTagService = inject(CollectionTagService);
|
||||
private readonly utilityService = inject(UtilityService);
|
||||
|
||||
baseUrl = environment.apiUrl;
|
||||
private validLanguages: Array<Language> = [];
|
||||
private ageRatingPipe = new AgeRatingPipe();
|
||||
private mangaFormatPipe = new MangaFormatPipe(this.translocoService);
|
||||
private personRolePipe = new PersonRolePipe();
|
||||
|
||||
constructor(private httpClient: HttpClient) { }
|
||||
|
||||
@ -74,6 +95,28 @@ export class MetadataService {
|
||||
return this.httpClient.get<Array<Genre>>(this.baseUrl + method);
|
||||
}
|
||||
|
||||
getGenreWithCounts(pageNum?: number, itemsPerPage?: number) {
|
||||
let params = new HttpParams();
|
||||
params = this.utilityService.addPaginationIfExists(params, pageNum, itemsPerPage);
|
||||
|
||||
return this.httpClient.post<PaginatedResult<BrowseGenre[]>>(this.baseUrl + 'metadata/genres-with-counts', {}, {observe: 'response', params}).pipe(
|
||||
map((response: any) => {
|
||||
return this.utilityService.createPaginatedResult(response) as PaginatedResult<BrowseGenre[]>;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
getTagWithCounts(pageNum?: number, itemsPerPage?: number) {
|
||||
let params = new HttpParams();
|
||||
params = this.utilityService.addPaginationIfExists(params, pageNum, itemsPerPage);
|
||||
|
||||
return this.httpClient.post<PaginatedResult<BrowseTag[]>>(this.baseUrl + 'metadata/tags-with-counts', {}, {observe: 'response', params}).pipe(
|
||||
map((response: any) => {
|
||||
return this.utilityService.createPaginatedResult(response) as PaginatedResult<BrowseTag[]>;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
getAllLanguages(libraries?: Array<number>) {
|
||||
let method = 'metadata/languages'
|
||||
if (libraries != undefined && libraries.length > 0) {
|
||||
@ -110,19 +153,28 @@ export class MetadataService {
|
||||
return this.httpClient.get<Array<Person>>(this.baseUrl + 'metadata/people-by-role?role=' + role);
|
||||
}
|
||||
|
||||
createDefaultFilterDto(): SeriesFilterV2 {
|
||||
createDefaultFilterDto<TFilter extends number, TSort extends number>(entityType: ValidFilterEntity): FilterV2<TFilter, TSort> {
|
||||
return {
|
||||
statements: [] as FilterStatement[],
|
||||
statements: [] as FilterStatement<TFilter>[],
|
||||
combination: FilterCombination.And,
|
||||
limitTo: 0,
|
||||
sortOptions: {
|
||||
isAscending: true,
|
||||
sortField: SortField.SortName
|
||||
sortField: (entityType === 'series' ? SortField.SortName : PersonSortField.Name) as TSort
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
createDefaultFilterStatement(field: FilterField = FilterField.SeriesName, comparison = FilterComparison.Equal, value = '') {
|
||||
createDefaultFilterStatement(entityType: ValidFilterEntity) {
|
||||
switch (entityType) {
|
||||
case 'series':
|
||||
return this.createFilterStatement(FilterField.SeriesName);
|
||||
case 'person':
|
||||
return this.createFilterStatement(PersonFilterField.Role, FilterComparison.Contains, `${PersonRole.CoverArtist},${PersonRole.Writer}`);
|
||||
}
|
||||
}
|
||||
|
||||
createFilterStatement<T extends number = number>(field: T, comparison = FilterComparison.Equal, value = '') {
|
||||
return {
|
||||
comparison: comparison,
|
||||
field: field,
|
||||
@ -130,7 +182,7 @@ export class MetadataService {
|
||||
};
|
||||
}
|
||||
|
||||
updateFilter(arr: Array<FilterStatement>, index: number, filterStmt: FilterStatement) {
|
||||
updateFilter(arr: Array<FilterStatement<number>>, index: number, filterStmt: FilterStatement<number>) {
|
||||
arr[index].comparison = filterStmt.comparison;
|
||||
arr[index].field = filterStmt.field;
|
||||
arr[index].value = filterStmt.value ? filterStmt.value + '' : '';
|
||||
@ -140,8 +192,6 @@ export class MetadataService {
|
||||
switch (role) {
|
||||
case PersonRole.Other:
|
||||
break;
|
||||
case PersonRole.Artist:
|
||||
break;
|
||||
case PersonRole.CoverArtist:
|
||||
entity.coverArtists = persons;
|
||||
break;
|
||||
@ -183,4 +233,85 @@ export class MetadataService {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the underlying Options (for Metadata Filter Dropdowns)
|
||||
* @param filterField
|
||||
* @param entityType
|
||||
*/
|
||||
getOptionsForFilterField<T extends number>(filterField: T, entityType: ValidFilterEntity) {
|
||||
|
||||
switch (entityType) {
|
||||
case 'series':
|
||||
return this.getSeriesOptionsForFilterField(filterField as FilterField);
|
||||
case 'person':
|
||||
return this.getPersonOptionsForFilterField(filterField as PersonFilterField);
|
||||
}
|
||||
}
|
||||
|
||||
private getPersonOptionsForFilterField(field: PersonFilterField) {
|
||||
switch (field) {
|
||||
case PersonFilterField.Role:
|
||||
return of(allPeopleRoles.map(r => {return {value: r, label: this.personRolePipe.transform(r)}}));
|
||||
}
|
||||
return of([])
|
||||
}
|
||||
|
||||
private getSeriesOptionsForFilterField(field: FilterField) {
|
||||
switch (field) {
|
||||
case FilterField.PublicationStatus:
|
||||
return this.getAllPublicationStatus().pipe(map(pubs => pubs.map(pub => {
|
||||
return {value: pub.value, label: pub.title}
|
||||
})));
|
||||
case FilterField.AgeRating:
|
||||
return this.getAllAgeRatings().pipe(map(ratings => ratings.map(rating => {
|
||||
return {value: rating.value, label: this.ageRatingPipe.transform(rating.value)}
|
||||
})));
|
||||
case FilterField.Genres:
|
||||
return this.getAllGenres().pipe(map(genres => genres.map(genre => {
|
||||
return {value: genre.id, label: genre.title}
|
||||
})));
|
||||
case FilterField.Languages:
|
||||
return this.getAllLanguages().pipe(map(statuses => statuses.map(status => {
|
||||
return {value: status.isoCode, label: status.title + ` (${status.isoCode})`}
|
||||
})));
|
||||
case FilterField.Formats:
|
||||
return of(mangaFormatFilters).pipe(map(statuses => statuses.map(status => {
|
||||
return {value: status.value, label: this.mangaFormatPipe.transform(status.value)}
|
||||
})));
|
||||
case FilterField.Libraries:
|
||||
return this.libraryService.getLibraries().pipe(map(libs => libs.map(lib => {
|
||||
return {value: lib.id, label: lib.name}
|
||||
})));
|
||||
case FilterField.Tags:
|
||||
return this.getAllTags().pipe(map(statuses => statuses.map(status => {
|
||||
return {value: status.id, label: status.title}
|
||||
})));
|
||||
case FilterField.CollectionTags:
|
||||
return this.collectionTagService.allCollections().pipe(map(statuses => statuses.map(status => {
|
||||
return {value: status.id, label: status.title}
|
||||
})));
|
||||
case FilterField.Characters: return this.getPersonOptions(PersonRole.Character);
|
||||
case FilterField.Colorist: return this.getPersonOptions(PersonRole.Colorist);
|
||||
case FilterField.CoverArtist: return this.getPersonOptions(PersonRole.CoverArtist);
|
||||
case FilterField.Editor: return this.getPersonOptions(PersonRole.Editor);
|
||||
case FilterField.Inker: return this.getPersonOptions(PersonRole.Inker);
|
||||
case FilterField.Letterer: return this.getPersonOptions(PersonRole.Letterer);
|
||||
case FilterField.Penciller: return this.getPersonOptions(PersonRole.Penciller);
|
||||
case FilterField.Publisher: return this.getPersonOptions(PersonRole.Publisher);
|
||||
case FilterField.Imprint: return this.getPersonOptions(PersonRole.Imprint);
|
||||
case FilterField.Team: return this.getPersonOptions(PersonRole.Team);
|
||||
case FilterField.Location: return this.getPersonOptions(PersonRole.Location);
|
||||
case FilterField.Translators: return this.getPersonOptions(PersonRole.Translator);
|
||||
case FilterField.Writers: return this.getPersonOptions(PersonRole.Writer);
|
||||
}
|
||||
|
||||
return of([]);
|
||||
}
|
||||
|
||||
private getPersonOptions(role: PersonRole) {
|
||||
return this.getAllPeopleByRole(role).pipe(map(people => people.map(person => {
|
||||
return {value: person.id, label: person.name}
|
||||
})));
|
||||
}
|
||||
}
|
||||
|
@ -6,9 +6,12 @@ import {PaginatedResult} from "../_models/pagination";
|
||||
import {Series} from "../_models/series";
|
||||
import {map} from "rxjs/operators";
|
||||
import {UtilityService} from "../shared/_services/utility.service";
|
||||
import {BrowsePerson} from "../_models/person/browse-person";
|
||||
import {BrowsePerson} from "../_models/metadata/browse/browse-person";
|
||||
import {StandaloneChapter} from "../_models/standalone-chapter";
|
||||
import {TextResonse} from "../_types/text-response";
|
||||
import {FilterV2} from "../_models/metadata/v2/filter-v2";
|
||||
import {PersonFilterField} from "../_models/metadata/v2/person-filter-field";
|
||||
import {PersonSortField} from "../_models/metadata/v2/person-sort-field";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@ -43,17 +46,28 @@ export class PersonService {
|
||||
return this.httpClient.get<Array<StandaloneChapter>>(this.baseUrl + `person/chapters-by-role?personId=${personId}&role=${role}`);
|
||||
}
|
||||
|
||||
getAuthorsToBrowse(pageNum?: number, itemsPerPage?: number) {
|
||||
getAuthorsToBrowse(filter: FilterV2<PersonFilterField, PersonSortField>, pageNum?: number, itemsPerPage?: number) {
|
||||
let params = new HttpParams();
|
||||
params = this.utilityService.addPaginationIfExists(params, pageNum, itemsPerPage);
|
||||
|
||||
return this.httpClient.post<PaginatedResult<BrowsePerson[]>>(this.baseUrl + 'person/all', {}, {observe: 'response', params}).pipe(
|
||||
return this.httpClient.post<PaginatedResult<BrowsePerson[]>>(this.baseUrl + `person/all`, filter, {observe: 'response', params}).pipe(
|
||||
map((response: any) => {
|
||||
return this.utilityService.createPaginatedResult(response) as PaginatedResult<BrowsePerson[]>;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// getAuthorsToBrowse(filter: BrowsePersonFilter, pageNum?: number, itemsPerPage?: number) {
|
||||
// let params = new HttpParams();
|
||||
// params = this.utilityService.addPaginationIfExists(params, pageNum, itemsPerPage);
|
||||
//
|
||||
// return this.httpClient.post<PaginatedResult<BrowsePerson[]>>(this.baseUrl + `person/all`, filter, {observe: 'response', params}).pipe(
|
||||
// map((response: any) => {
|
||||
// return this.utilityService.createPaginatedResult(response) as PaginatedResult<BrowsePerson[]>;
|
||||
// })
|
||||
// );
|
||||
// }
|
||||
|
||||
downloadCover(personId: number) {
|
||||
return this.httpClient.post<string>(this.baseUrl + 'person/fetch-cover?personId=' + personId, {}, TextResonse);
|
||||
}
|
||||
|
@ -16,13 +16,14 @@ import {TextResonse} from '../_types/text-response';
|
||||
import {AccountService} from './account.service';
|
||||
import {takeUntilDestroyed} from "@angular/core/rxjs-interop";
|
||||
import {PersonalToC} from "../_models/readers/personal-toc";
|
||||
import {SeriesFilterV2} from "../_models/metadata/v2/series-filter-v2";
|
||||
import {FilterV2} from "../_models/metadata/v2/filter-v2";
|
||||
import NoSleep from 'nosleep.js';
|
||||
import {FullProgress} from "../_models/readers/full-progress";
|
||||
import {Volume} from "../_models/volume";
|
||||
import {UtilityService} from "../shared/_services/utility.service";
|
||||
import {translate} from "@jsverse/transloco";
|
||||
import {ToastrService} from "ngx-toastr";
|
||||
import {FilterField} from "../_models/metadata/v2/filter-field";
|
||||
|
||||
|
||||
export const CHAPTER_ID_DOESNT_EXIST = -1;
|
||||
@ -107,7 +108,7 @@ export class ReaderService {
|
||||
return this.httpClient.post(this.baseUrl + 'reader/unbookmark', {seriesId, volumeId, chapterId, page});
|
||||
}
|
||||
|
||||
getAllBookmarks(filter: SeriesFilterV2 | undefined) {
|
||||
getAllBookmarks(filter: FilterV2<FilterField> | undefined) {
|
||||
return this.httpClient.post<PageBookmark[]>(this.baseUrl + 'reader/all-bookmarks', filter);
|
||||
}
|
||||
|
||||
|
@ -1,28 +1,26 @@
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { UtilityService } from '../shared/_services/utility.service';
|
||||
import { Chapter } from '../_models/chapter';
|
||||
import { PaginatedResult } from '../_models/pagination';
|
||||
import { Series } from '../_models/series';
|
||||
import { RelatedSeries } from '../_models/series-detail/related-series';
|
||||
import { SeriesDetail } from '../_models/series-detail/series-detail';
|
||||
import { SeriesGroup } from '../_models/series-group';
|
||||
import { SeriesMetadata } from '../_models/metadata/series-metadata';
|
||||
import { Volume } from '../_models/volume';
|
||||
import { ImageService } from './image.service';
|
||||
import { TextResonse } from '../_types/text-response';
|
||||
import { SeriesFilterV2 } from '../_models/metadata/v2/series-filter-v2';
|
||||
import {UserReview} from "../_single-module/review-card/user-review";
|
||||
import {HttpClient, HttpParams} from '@angular/common/http';
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Observable} from 'rxjs';
|
||||
import {map} from 'rxjs/operators';
|
||||
import {environment} from 'src/environments/environment';
|
||||
import {UtilityService} from '../shared/_services/utility.service';
|
||||
import {Chapter} from '../_models/chapter';
|
||||
import {PaginatedResult} from '../_models/pagination';
|
||||
import {Series} from '../_models/series';
|
||||
import {RelatedSeries} from '../_models/series-detail/related-series';
|
||||
import {SeriesDetail} from '../_models/series-detail/series-detail';
|
||||
import {SeriesGroup} from '../_models/series-group';
|
||||
import {SeriesMetadata} from '../_models/metadata/series-metadata';
|
||||
import {Volume} from '../_models/volume';
|
||||
import {TextResonse} from '../_types/text-response';
|
||||
import {FilterV2} from '../_models/metadata/v2/filter-v2';
|
||||
import {Rating} from "../_models/rating";
|
||||
import {Recommendation} from "../_models/series-detail/recommendation";
|
||||
import {ExternalSeriesDetail} from "../_models/series-detail/external-series-detail";
|
||||
import {NextExpectedChapter} from "../_models/series-detail/next-expected-chapter";
|
||||
import {QueryContext} from "../_models/metadata/v2/query-context";
|
||||
import {ExternalSeries} from "../_models/series-detail/external-series";
|
||||
import {ExternalSeriesMatch} from "../_models/series-detail/external-series-match";
|
||||
import {FilterField} from "../_models/metadata/v2/filter-field";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@ -33,10 +31,9 @@ export class SeriesService {
|
||||
paginatedResults: PaginatedResult<Series[]> = new PaginatedResult<Series[]>();
|
||||
paginatedSeriesForTagsResults: PaginatedResult<Series[]> = new PaginatedResult<Series[]>();
|
||||
|
||||
constructor(private httpClient: HttpClient, private imageService: ImageService,
|
||||
private utilityService: UtilityService) { }
|
||||
constructor(private httpClient: HttpClient, private utilityService: UtilityService) { }
|
||||
|
||||
getAllSeriesV2(pageNum?: number, itemsPerPage?: number, filter?: SeriesFilterV2, context: QueryContext = QueryContext.None) {
|
||||
getAllSeriesV2(pageNum?: number, itemsPerPage?: number, filter?: FilterV2<FilterField>, context: QueryContext = QueryContext.None) {
|
||||
let params = new HttpParams();
|
||||
params = this.utilityService.addPaginationIfExists(params, pageNum, itemsPerPage);
|
||||
const data = filter || {};
|
||||
@ -48,7 +45,7 @@ export class SeriesService {
|
||||
);
|
||||
}
|
||||
|
||||
getSeriesForLibraryV2(pageNum?: number, itemsPerPage?: number, filter?: SeriesFilterV2) {
|
||||
getSeriesForLibraryV2(pageNum?: number, itemsPerPage?: number, filter?: FilterV2<FilterField>) {
|
||||
let params = new HttpParams();
|
||||
params = this.utilityService.addPaginationIfExists(params, pageNum, itemsPerPage);
|
||||
const data = filter || {};
|
||||
@ -100,7 +97,7 @@ export class SeriesService {
|
||||
return this.httpClient.post<void>(this.baseUrl + 'reader/mark-unread', {seriesId});
|
||||
}
|
||||
|
||||
getRecentlyAdded(pageNum?: number, itemsPerPage?: number, filter?: SeriesFilterV2) {
|
||||
getRecentlyAdded(pageNum?: number, itemsPerPage?: number, filter?: FilterV2<FilterField>) {
|
||||
let params = new HttpParams();
|
||||
params = this.utilityService.addPaginationIfExists(params, pageNum, itemsPerPage);
|
||||
|
||||
@ -116,7 +113,7 @@ export class SeriesService {
|
||||
return this.httpClient.post<SeriesGroup[]>(this.baseUrl + 'series/recently-updated-series', {});
|
||||
}
|
||||
|
||||
getWantToRead(pageNum?: number, itemsPerPage?: number, filter?: SeriesFilterV2): Observable<PaginatedResult<Series[]>> {
|
||||
getWantToRead(pageNum?: number, itemsPerPage?: number, filter?: FilterV2<FilterField>): Observable<PaginatedResult<Series[]>> {
|
||||
let params = new HttpParams();
|
||||
params = this.utilityService.addPaginationIfExists(params, pageNum, itemsPerPage);
|
||||
const data = filter || {};
|
||||
@ -134,7 +131,7 @@ export class SeriesService {
|
||||
}));
|
||||
}
|
||||
|
||||
getOnDeck(libraryId: number = 0, pageNum?: number, itemsPerPage?: number, filter?: SeriesFilterV2) {
|
||||
getOnDeck(libraryId: number = 0, pageNum?: number, itemsPerPage?: number, filter?: FilterV2<FilterField>) {
|
||||
let params = new HttpParams();
|
||||
params = this.utilityService.addPaginationIfExists(params, pageNum, itemsPerPage);
|
||||
const data = filter || {};
|
||||
@ -230,5 +227,4 @@ export class SeriesService {
|
||||
updateDontMatch(seriesId: number, dontMatch: boolean) {
|
||||
return this.httpClient.post<string>(this.baseUrl + `series/dont-match?seriesId=${seriesId}&dontMatch=${dontMatch}`, {}, TextResonse);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { NavigationStart, Router } from '@angular/router';
|
||||
import { filter, ReplaySubject, take } from 'rxjs';
|
||||
import {Injectable} from '@angular/core';
|
||||
import {NavigationStart, Router} from '@angular/router';
|
||||
import {filter, ReplaySubject, take} from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@ -29,7 +29,7 @@ export class ToggleService {
|
||||
this.toggleState = !state;
|
||||
this.toggleStateSource.next(this.toggleState);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
set(state: boolean) {
|
||||
|
@ -33,10 +33,10 @@
|
||||
} @else {
|
||||
<div class="d-flex pt-3 justify-content-between">
|
||||
@if ((item.series.volumes || 0) > 0 || (item.series.chapters || 0) > 0) {
|
||||
<span class="me-1">{{t('volume-count', {num: item.series.volumes})}}</span>
|
||||
@if (item.series.plusMediaFormat === PlusMediaFormat.Comic) {
|
||||
<span class="me-1">{{t('issue-count', {num: item.series.chapters})}}</span>
|
||||
} @else {
|
||||
<span class="me-1">{{t('volume-count', {num: item.series.volumes})}}</span>
|
||||
<span class="me-1">{{t('chapter-count', {num: item.series.chapters})}}</span>
|
||||
}
|
||||
} @else {
|
||||
|
@ -0,0 +1,9 @@
|
||||
<ng-container *transloco="let t">
|
||||
<button class="btn btn-sm btn-icon" (click)="updateSortOrder()" style="height: 25px; padding-bottom: 0;" [disabled]="disabled()">
|
||||
@if (isAscending()) {
|
||||
<i class="fa fa-arrow-up" [title]="t('metadata-filter.ascending-alt')"></i>
|
||||
} @else {
|
||||
<i class="fa fa-arrow-down" [title]="t('metadata-filter.descending-alt')"></i>
|
||||
}
|
||||
</button>
|
||||
</ng-container>
|
@ -0,0 +1,21 @@
|
||||
import {ChangeDetectionStrategy, Component, input, model} from '@angular/core';
|
||||
import {TranslocoDirective} from "@jsverse/transloco";
|
||||
|
||||
@Component({
|
||||
selector: 'app-sort-button',
|
||||
imports: [
|
||||
TranslocoDirective
|
||||
],
|
||||
templateUrl: './sort-button.component.html',
|
||||
styleUrl: './sort-button.component.scss',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class SortButtonComponent {
|
||||
|
||||
disabled = input<boolean>(false);
|
||||
isAscending = model<boolean>(true);
|
||||
|
||||
updateSortOrder() {
|
||||
this.isAscending.set(!this.isAscending());
|
||||
}
|
||||
}
|
@ -3,8 +3,17 @@
|
||||
|
||||
<form [formGroup]="filterGroup">
|
||||
<div class="row g-0">
|
||||
<div class="col-auto ms-auto">
|
||||
<label for="match-filter">Match State</label>
|
||||
<div class="col-auto ms-auto me-3">
|
||||
<label for="libtype-filter">{{t('library-type')}}</label>
|
||||
<select class="form-select" formControlName="libraryType" id="libtype-filter">
|
||||
<option [value]="-1">{{t('all-status-label')}}</option>
|
||||
@for(libType of allLibraryTypes; track libType) {
|
||||
<option [value]="libType">{{libType | libraryType}}</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<label for="match-filter">{{t('matched-state-label')}}</label>
|
||||
<select class="form-select" formControlName="matchState" id="match-filter">
|
||||
@for(state of allMatchStates; track state) {
|
||||
<option [value]="state">{{state | matchStateOption}}</option>
|
||||
|
@ -21,20 +21,23 @@ import {LibraryNamePipe} from "../../_pipes/library-name.pipe";
|
||||
import {AsyncPipe} from "@angular/common";
|
||||
import {EVENTS, MessageHubService} from "../../_services/message-hub.service";
|
||||
import {ScanSeriesEvent} from "../../_models/events/scan-series-event";
|
||||
import {LibraryTypePipe} from "../../_pipes/library-type.pipe";
|
||||
import {allKavitaPlusMetadataApplicableTypes} from "../../_models/library/library";
|
||||
|
||||
@Component({
|
||||
selector: 'app-manage-matched-metadata',
|
||||
imports: [
|
||||
TranslocoDirective,
|
||||
ImageComponent,
|
||||
VirtualScrollerModule,
|
||||
ReactiveFormsModule,
|
||||
MatchStateOptionPipe,
|
||||
UtcToLocalTimePipe,
|
||||
DefaultValuePipe,
|
||||
NgxDatatableModule,
|
||||
LibraryNamePipe,
|
||||
AsyncPipe,
|
||||
TranslocoDirective,
|
||||
ImageComponent,
|
||||
VirtualScrollerModule,
|
||||
ReactiveFormsModule,
|
||||
MatchStateOptionPipe,
|
||||
UtcToLocalTimePipe,
|
||||
DefaultValuePipe,
|
||||
NgxDatatableModule,
|
||||
LibraryNamePipe,
|
||||
AsyncPipe,
|
||||
LibraryTypePipe,
|
||||
],
|
||||
templateUrl: './manage-matched-metadata.component.html',
|
||||
styleUrl: './manage-matched-metadata.component.scss',
|
||||
@ -44,6 +47,7 @@ export class ManageMatchedMetadataComponent implements OnInit {
|
||||
protected readonly ColumnMode = ColumnMode;
|
||||
protected readonly MatchStateOption = MatchStateOption;
|
||||
protected readonly allMatchStates = allMatchStates.filter(m => m !== MatchStateOption.Matched); // Matched will have too many
|
||||
protected readonly allLibraryTypes = allKavitaPlusMetadataApplicableTypes;
|
||||
|
||||
private readonly licenseService = inject(LicenseService);
|
||||
private readonly actionService = inject(ActionService);
|
||||
@ -58,6 +62,7 @@ export class ManageMatchedMetadataComponent implements OnInit {
|
||||
data: Array<ManageMatchSeries> = [];
|
||||
filterGroup = new FormGroup({
|
||||
'matchState': new FormControl(MatchStateOption.Error, []),
|
||||
'libraryType': new FormControl(-1, []), // Denotes all
|
||||
});
|
||||
|
||||
ngOnInit() {
|
||||
@ -99,6 +104,7 @@ export class ManageMatchedMetadataComponent implements OnInit {
|
||||
loadData() {
|
||||
const filter: ManageMatchFilter = {
|
||||
matchStateOption: parseInt(this.filterGroup.get('matchState')!.value + '', 10),
|
||||
libraryType: parseInt(this.filterGroup.get('libraryType')!.value + '', 10),
|
||||
searchTerm: ''
|
||||
};
|
||||
|
||||
|
@ -13,10 +13,10 @@
|
||||
<app-card-detail-layout
|
||||
[isLoading]="loadingSeries"
|
||||
[items]="series"
|
||||
[trackByIdentity]="trackByIdentity"
|
||||
[filterSettings]="filterSettings"
|
||||
[filterOpen]="filterOpen"
|
||||
[jumpBarKeys]="jumpbarKeys"
|
||||
[trackByIdentity]="trackByIdentity"
|
||||
[filterSettings]="filterSettings"
|
||||
(applyFilter)="updateFilter($event)"
|
||||
>
|
||||
<ng-template #cardItem let-item let-position="idx">
|
||||
|
@ -11,13 +11,12 @@ import {Title} from '@angular/platform-browser';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {debounceTime, take} from 'rxjs/operators';
|
||||
import {BulkSelectionService} from 'src/app/cards/bulk-selection.service';
|
||||
import {FilterSettings} from 'src/app/metadata-filter/filter-settings';
|
||||
import {FilterUtilitiesService} from 'src/app/shared/_services/filter-utilities.service';
|
||||
import {UtilityService} from 'src/app/shared/_services/utility.service';
|
||||
import {JumpKey} from 'src/app/_models/jumpbar/jump-key';
|
||||
import {Pagination} from 'src/app/_models/pagination';
|
||||
import {Series} from 'src/app/_models/series';
|
||||
import {FilterEvent} from 'src/app/_models/metadata/series-filter';
|
||||
import {FilterEvent, SortField} from 'src/app/_models/metadata/series-filter';
|
||||
import {Action, ActionItem} from 'src/app/_services/action-factory.service';
|
||||
import {ActionService} from 'src/app/_services/action.service';
|
||||
import {JumpbarService} from 'src/app/_services/jumpbar.service';
|
||||
@ -32,7 +31,15 @@ import {
|
||||
SideNavCompanionBarComponent
|
||||
} from '../../../sidenav/_components/side-nav-companion-bar/side-nav-companion-bar.component';
|
||||
import {translate, TranslocoDirective} from "@jsverse/transloco";
|
||||
import {SeriesFilterV2} from "../../../_models/metadata/v2/series-filter-v2";
|
||||
import {FilterV2} from "../../../_models/metadata/v2/filter-v2";
|
||||
import {FilterComparison} from "../../../_models/metadata/v2/filter-comparison";
|
||||
import {BrowseTitlePipe} from "../../../_pipes/browse-title.pipe";
|
||||
import {MetadataService} from "../../../_services/metadata.service";
|
||||
import {Observable} from "rxjs";
|
||||
import {FilterField} from "../../../_models/metadata/v2/filter-field";
|
||||
import {SeriesFilterSettings} from "../../../metadata-filter/filter-settings";
|
||||
import {FilterStatement} from "../../../_models/metadata/v2/filter-statement";
|
||||
import {Select2Option} from "ng-select2-component";
|
||||
|
||||
|
||||
@Component({
|
||||
@ -57,18 +64,19 @@ export class AllSeriesComponent implements OnInit {
|
||||
private readonly jumpbarService = inject(JumpbarService);
|
||||
private readonly cdRef = inject(ChangeDetectorRef);
|
||||
protected readonly bulkSelectionService = inject(BulkSelectionService);
|
||||
protected readonly metadataService = inject(MetadataService);
|
||||
|
||||
title: string = translate('side-nav.all-series');
|
||||
series: Series[] = [];
|
||||
loadingSeries = false;
|
||||
pagination: Pagination = new Pagination();
|
||||
filter: SeriesFilterV2 | undefined = undefined;
|
||||
filterSettings: FilterSettings = new FilterSettings();
|
||||
filter: FilterV2<FilterField, SortField> | undefined = undefined;
|
||||
filterSettings: SeriesFilterSettings = new SeriesFilterSettings();
|
||||
filterOpen: EventEmitter<boolean> = new EventEmitter();
|
||||
filterActiveCheck!: SeriesFilterV2;
|
||||
filterActiveCheck!: FilterV2<FilterField>;
|
||||
filterActive: boolean = false;
|
||||
jumpbarKeys: Array<JumpKey> = [];
|
||||
|
||||
browseTitlePipe = new BrowseTitlePipe();
|
||||
|
||||
bulkActionCallback = (action: ActionItem<any>, data: any) => {
|
||||
const selectedSeriesIndexies = this.bulkSelectionService.getSelectedCardsForSource('series');
|
||||
@ -124,13 +132,42 @@ export class AllSeriesComponent implements OnInit {
|
||||
constructor() {
|
||||
this.router.routeReuseStrategy.shouldReuseRoute = () => false;
|
||||
|
||||
this.filterUtilityService.filterPresetsFromUrl(this.route.snapshot).subscribe(filter => {
|
||||
this.filter = filter;
|
||||
this.title = this.route.snapshot.queryParamMap.get('title') || this.filter.name || this.title;
|
||||
|
||||
this.route.data.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(data => {
|
||||
this.filter = data['filter'] as FilterV2<FilterField, SortField>;
|
||||
|
||||
if (this.filter == null) {
|
||||
this.filter = this.metadataService.createDefaultFilterDto('series');
|
||||
this.filter.statements.push(this.metadataService.createDefaultFilterStatement('series') as FilterStatement<FilterField>);
|
||||
}
|
||||
|
||||
this.title = this.route.snapshot.queryParamMap.get('title') || this.filter!.name || this.title;
|
||||
this.titleService.setTitle('Kavita - ' + this.title);
|
||||
this.filterActiveCheck = this.filterUtilityService.createSeriesV2Filter();
|
||||
this.filterActiveCheck!.statements.push(this.filterUtilityService.createSeriesV2DefaultStatement());
|
||||
this.filterSettings.presetsV2 = this.filter;
|
||||
|
||||
// To provide a richer experience, when we are browsing just a Genre/Tag/etc, we regenerate the title (if not explicitly passed) to "Browse {GenreName}"
|
||||
if (this.shouldRewriteTitle()) {
|
||||
const field = this.filter!.statements[0].field;
|
||||
|
||||
// This api returns value as string and number, it will complain without the casting
|
||||
(this.metadataService.getOptionsForFilterField<FilterField>(field, 'series') as Observable<Select2Option[]>).subscribe((opts: Select2Option[]) => {
|
||||
|
||||
const matchingOpts = opts.filter(m => `${m.value}` === `${this.filter!.statements[0].value}`);
|
||||
if (matchingOpts.length === 0) return;
|
||||
|
||||
const value = matchingOpts[0].label;
|
||||
const newTitle = this.browseTitlePipe.transform(field, value);
|
||||
if (newTitle !== '') {
|
||||
this.title = newTitle;
|
||||
this.titleService.setTitle('Kavita - ' + this.title);
|
||||
this.cdRef.markForCheck();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
this.filterActiveCheck = this.metadataService.createDefaultFilterDto('series');
|
||||
this.filterActiveCheck.statements.push(this.metadataService.createDefaultFilterStatement('series') as FilterStatement<FilterField>);
|
||||
this.filterSettings.presetsV2 = this.filter;
|
||||
|
||||
this.cdRef.markForCheck();
|
||||
});
|
||||
@ -143,7 +180,11 @@ export class AllSeriesComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
updateFilter(data: FilterEvent) {
|
||||
shouldRewriteTitle() {
|
||||
return this.title === translate('side-nav.all-series') && this.filter && this.filter.statements.length === 1 && this.filter.statements[0].comparison === FilterComparison.Equal
|
||||
}
|
||||
|
||||
updateFilter(data: FilterEvent<FilterField, SortField>) {
|
||||
if (data.filterV2 === undefined) return;
|
||||
this.filter = data.filterV2;
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule, PreloadAllModules } from '@angular/router';
|
||||
import { AuthGuard } from './_guards/auth.guard';
|
||||
import { LibraryAccessGuard } from './_guards/library-access.guard';
|
||||
import { AdminGuard } from './_guards/admin.guard';
|
||||
import {NgModule} from '@angular/core';
|
||||
import {PreloadAllModules, RouterModule, Routes} from '@angular/router';
|
||||
import {AuthGuard} from './_guards/auth.guard';
|
||||
import {LibraryAccessGuard} from './_guards/library-access.guard';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
@ -51,8 +50,8 @@ const routes: Routes = [
|
||||
loadChildren: () => import('./_routes/person-detail-routing.module').then(m => m.routes)
|
||||
},
|
||||
{
|
||||
path: 'browse/authors',
|
||||
loadChildren: () => import('./_routes/browse-authors-routing.module').then(m => m.routes)
|
||||
path: 'browse',
|
||||
loadChildren: () => import('./_routes/browse-routing.module').then(m => m.routes)
|
||||
},
|
||||
{
|
||||
path: 'library',
|
||||
|
@ -107,6 +107,7 @@ export class AppComponent implements OnInit {
|
||||
const vh = window.innerHeight * 0.01;
|
||||
this.document.documentElement.style.setProperty('--vh', `${vh}px`);
|
||||
this.utilityService.activeBreakpointSource.next(this.utilityService.getActiveBreakpoint());
|
||||
this.utilityService.updateUserBreakpoint();
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
|
@ -1,9 +1,16 @@
|
||||
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, inject, OnInit} from '@angular/core';
|
||||
import {
|
||||
ChangeDetectionStrategy,
|
||||
ChangeDetectorRef,
|
||||
Component,
|
||||
DestroyRef,
|
||||
EventEmitter,
|
||||
inject,
|
||||
OnInit
|
||||
} from '@angular/core';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {ToastrService} from 'ngx-toastr';
|
||||
import {take} from 'rxjs';
|
||||
import {BulkSelectionService} from 'src/app/cards/bulk-selection.service';
|
||||
import {FilterSettings} from 'src/app/metadata-filter/filter-settings';
|
||||
import {ConfirmService} from 'src/app/shared/confirm.service';
|
||||
import {DownloadService} from 'src/app/shared/_services/download.service';
|
||||
import {FilterUtilitiesService} from 'src/app/shared/_services/filter-utilities.service';
|
||||
@ -11,7 +18,7 @@ import {JumpKey} from 'src/app/_models/jumpbar/jump-key';
|
||||
import {PageBookmark} from 'src/app/_models/readers/page-bookmark';
|
||||
import {Pagination} from 'src/app/_models/pagination';
|
||||
import {Series} from 'src/app/_models/series';
|
||||
import {FilterEvent} from 'src/app/_models/metadata/series-filter';
|
||||
import {FilterEvent, SortField} from 'src/app/_models/metadata/series-filter';
|
||||
import {Action, ActionFactoryService, ActionItem} from 'src/app/_services/action-factory.service';
|
||||
import {ImageService} from 'src/app/_services/image.service';
|
||||
import {JumpbarService} from 'src/app/_services/jumpbar.service';
|
||||
@ -24,9 +31,14 @@ import {
|
||||
SideNavCompanionBarComponent
|
||||
} from '../../../sidenav/_components/side-nav-companion-bar/side-nav-companion-bar.component';
|
||||
import {translate, TranslocoDirective, TranslocoService} from "@jsverse/transloco";
|
||||
import {SeriesFilterV2} from "../../../_models/metadata/v2/series-filter-v2";
|
||||
import {FilterV2} from "../../../_models/metadata/v2/filter-v2";
|
||||
import {Title} from "@angular/platform-browser";
|
||||
import {WikiLink} from "../../../_models/wiki";
|
||||
import {FilterField} from "../../../_models/metadata/v2/filter-field";
|
||||
import {SeriesFilterSettings} from "../../../metadata-filter/filter-settings";
|
||||
import {takeUntilDestroyed} from "@angular/core/rxjs-interop";
|
||||
import {FilterStatement} from "../../../_models/metadata/v2/filter-statement";
|
||||
import {MetadataService} from "../../../_services/metadata.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-bookmarks',
|
||||
@ -51,6 +63,8 @@ export class BookmarksComponent implements OnInit {
|
||||
private readonly titleService = inject(Title);
|
||||
public readonly bulkSelectionService = inject(BulkSelectionService);
|
||||
public readonly imageService = inject(ImageService);
|
||||
public readonly metadataService = inject(MetadataService);
|
||||
public readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
protected readonly WikiLink = WikiLink;
|
||||
|
||||
@ -63,27 +77,34 @@ export class BookmarksComponent implements OnInit {
|
||||
jumpbarKeys: Array<JumpKey> = [];
|
||||
|
||||
pagination: Pagination = new Pagination();
|
||||
filter: SeriesFilterV2 | undefined = undefined;
|
||||
filterSettings: FilterSettings = new FilterSettings();
|
||||
filter: FilterV2<FilterField> | undefined = undefined;
|
||||
filterSettings: SeriesFilterSettings = new SeriesFilterSettings();
|
||||
filterOpen: EventEmitter<boolean> = new EventEmitter();
|
||||
filterActive: boolean = false;
|
||||
filterActiveCheck!: SeriesFilterV2;
|
||||
filterActiveCheck!: FilterV2<FilterField>;
|
||||
|
||||
trackByIdentity = (index: number, item: Series) => `${item.name}_${item.localizedName}_${item.pagesRead}`;
|
||||
refresh: EventEmitter<void> = new EventEmitter();
|
||||
|
||||
constructor() {
|
||||
this.filterUtilityService.filterPresetsFromUrl(this.route.snapshot).subscribe(filter => {
|
||||
this.filter = filter;
|
||||
|
||||
this.filterActiveCheck = this.filterUtilityService.createSeriesV2Filter();
|
||||
this.filterActiveCheck!.statements.push(this.filterUtilityService.createSeriesV2DefaultStatement());
|
||||
this.route.data.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(data => {
|
||||
this.filter = data['filter'] as FilterV2<FilterField, SortField>;
|
||||
|
||||
if (this.filter == null) {
|
||||
this.filter = this.metadataService.createDefaultFilterDto('series');
|
||||
this.filter.statements.push(this.metadataService.createDefaultFilterStatement('series') as FilterStatement<FilterField>);
|
||||
}
|
||||
|
||||
this.filterActiveCheck = this.metadataService.createDefaultFilterDto('series');
|
||||
this.filterActiveCheck.statements.push(this.metadataService.createDefaultFilterStatement('series') as FilterStatement<FilterField>);
|
||||
this.filterSettings.presetsV2 = this.filter;
|
||||
this.filterSettings.statementLimit = 1;
|
||||
|
||||
this.cdRef.markForCheck();
|
||||
});
|
||||
|
||||
|
||||
this.titleService.setTitle('Kavita - ' + translate('bookmarks.title'));
|
||||
}
|
||||
|
||||
@ -190,7 +211,7 @@ export class BookmarksComponent implements OnInit {
|
||||
this.downloadService.download('bookmark', this.bookmarks.filter(bmk => bmk.seriesId === series.id));
|
||||
}
|
||||
|
||||
updateFilter(data: FilterEvent) {
|
||||
updateFilter(data: FilterEvent<FilterField, SortField>) {
|
||||
if (data.filterV2 === undefined) return;
|
||||
this.filter = data.filterV2;
|
||||
|
||||
|
@ -1,87 +0,0 @@
|
||||
import {
|
||||
ChangeDetectionStrategy,
|
||||
ChangeDetectorRef,
|
||||
Component,
|
||||
DestroyRef,
|
||||
EventEmitter,
|
||||
inject,
|
||||
OnInit
|
||||
} from '@angular/core';
|
||||
import {
|
||||
SideNavCompanionBarComponent
|
||||
} from "../sidenav/_components/side-nav-companion-bar/side-nav-companion-bar.component";
|
||||
import {CardDetailLayoutComponent} from "../cards/card-detail-layout/card-detail-layout.component";
|
||||
import {DecimalPipe} from "@angular/common";
|
||||
import {Series} from "../_models/series";
|
||||
import {Pagination} from "../_models/pagination";
|
||||
import {JumpKey} from "../_models/jumpbar/jump-key";
|
||||
import {ActivatedRoute, Router} from "@angular/router";
|
||||
import {Title} from "@angular/platform-browser";
|
||||
import {ActionFactoryService} from "../_services/action-factory.service";
|
||||
import {ActionService} from "../_services/action.service";
|
||||
import {MessageHubService} from "../_services/message-hub.service";
|
||||
import {UtilityService} from "../shared/_services/utility.service";
|
||||
import {PersonService} from "../_services/person.service";
|
||||
import {BrowsePerson} from "../_models/person/browse-person";
|
||||
import {JumpbarService} from "../_services/jumpbar.service";
|
||||
import {PersonCardComponent} from "../cards/person-card/person-card.component";
|
||||
import {ImageService} from "../_services/image.service";
|
||||
import {TranslocoDirective} from "@jsverse/transloco";
|
||||
import {CompactNumberPipe} from "../_pipes/compact-number.pipe";
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-browse-authors',
|
||||
imports: [
|
||||
SideNavCompanionBarComponent,
|
||||
TranslocoDirective,
|
||||
CardDetailLayoutComponent,
|
||||
DecimalPipe,
|
||||
PersonCardComponent,
|
||||
CompactNumberPipe,
|
||||
],
|
||||
templateUrl: './browse-authors.component.html',
|
||||
styleUrl: './browse-authors.component.scss',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class BrowseAuthorsComponent implements OnInit {
|
||||
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private readonly cdRef = inject(ChangeDetectorRef);
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly router = inject(Router);
|
||||
private readonly titleService = inject(Title);
|
||||
private readonly actionFactoryService = inject(ActionFactoryService);
|
||||
private readonly actionService = inject(ActionService);
|
||||
private readonly hubService = inject(MessageHubService);
|
||||
private readonly utilityService = inject(UtilityService);
|
||||
private readonly personService = inject(PersonService);
|
||||
private readonly jumpbarService = inject(JumpbarService);
|
||||
protected readonly imageService = inject(ImageService);
|
||||
|
||||
|
||||
series: Series[] = [];
|
||||
isLoading = false;
|
||||
authors: Array<BrowsePerson> = [];
|
||||
pagination: Pagination = {currentPage: 0, totalPages: 0, totalItems: 0, itemsPerPage: 0};
|
||||
refresh: EventEmitter<void> = new EventEmitter();
|
||||
jumpKeys: Array<JumpKey> = [];
|
||||
trackByIdentity = (index: number, item: BrowsePerson) => `${item.id}`;
|
||||
|
||||
ngOnInit() {
|
||||
this.isLoading = true;
|
||||
this.cdRef.markForCheck();
|
||||
this.personService.getAuthorsToBrowse(undefined, undefined).subscribe(d => {
|
||||
this.authors = d.result;
|
||||
this.pagination = d.pagination;
|
||||
this.jumpKeys = this.jumpbarService.getJumpKeys(this.authors, d => d.name);
|
||||
this.isLoading = false;
|
||||
this.cdRef.markForCheck();
|
||||
});
|
||||
}
|
||||
|
||||
goToPerson(person: BrowsePerson) {
|
||||
this.router.navigate(['person', person.name]);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
<div class="main-container container-fluid">
|
||||
<ng-container *transloco="let t; read:'browse-genres'" >
|
||||
<app-side-nav-companion-bar [hasFilter]="false">
|
||||
<h2 title>
|
||||
<span>{{t('title')}}</span>
|
||||
</h2>
|
||||
<h6 subtitle>{{t('genre-count', {num: pagination.totalItems | number})}} </h6>
|
||||
|
||||
</app-side-nav-companion-bar>
|
||||
|
||||
<app-card-detail-layout
|
||||
[isLoading]="isLoading"
|
||||
[items]="genres"
|
||||
[pagination]="pagination"
|
||||
[trackByIdentity]="trackByIdentity"
|
||||
[jumpBarKeys]="jumpKeys"
|
||||
[filteringDisabled]="true"
|
||||
[refresh]="refresh"
|
||||
>
|
||||
<ng-template #cardItem let-item let-position="idx">
|
||||
|
||||
<div class="tag-card" (click)="openFilter(FilterField.Genres, item.id)">
|
||||
<div class="tag-name">{{ item.title }}</div>
|
||||
<div class="tag-meta">
|
||||
<span>{{t('series-count', {num: item.seriesCount | compactNumber})}}</span>
|
||||
<span>{{t('issue-count', {num: item.chapterCount | compactNumber})}}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</ng-template>
|
||||
</app-card-detail-layout>
|
||||
|
||||
</ng-container>
|
||||
</div>
|
@ -0,0 +1 @@
|
||||
@use '../../../tag-card-common';
|
@ -0,0 +1,68 @@
|
||||
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, inject, OnInit} from '@angular/core';
|
||||
import {CardDetailLayoutComponent} from "../../cards/card-detail-layout/card-detail-layout.component";
|
||||
import {DecimalPipe} from "@angular/common";
|
||||
import {
|
||||
SideNavCompanionBarComponent
|
||||
} from "../../sidenav/_components/side-nav-companion-bar/side-nav-companion-bar.component";
|
||||
import {translate, TranslocoDirective} from "@jsverse/transloco";
|
||||
import {JumpbarService} from "../../_services/jumpbar.service";
|
||||
import {BrowsePerson} from "../../_models/metadata/browse/browse-person";
|
||||
import {Pagination} from "../../_models/pagination";
|
||||
import {JumpKey} from "../../_models/jumpbar/jump-key";
|
||||
import {MetadataService} from "../../_services/metadata.service";
|
||||
import {BrowseGenre} from "../../_models/metadata/browse/browse-genre";
|
||||
import {FilterField} from "../../_models/metadata/v2/filter-field";
|
||||
import {FilterComparison} from "../../_models/metadata/v2/filter-comparison";
|
||||
import {FilterUtilitiesService} from "../../shared/_services/filter-utilities.service";
|
||||
import {CompactNumberPipe} from "../../_pipes/compact-number.pipe";
|
||||
import {Title} from "@angular/platform-browser";
|
||||
|
||||
@Component({
|
||||
selector: 'app-browse-genres',
|
||||
imports: [
|
||||
CardDetailLayoutComponent,
|
||||
DecimalPipe,
|
||||
SideNavCompanionBarComponent,
|
||||
TranslocoDirective,
|
||||
CompactNumberPipe
|
||||
],
|
||||
templateUrl: './browse-genres.component.html',
|
||||
styleUrl: './browse-genres.component.scss',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class BrowseGenresComponent implements OnInit {
|
||||
|
||||
protected readonly FilterField = FilterField;
|
||||
|
||||
private readonly cdRef = inject(ChangeDetectorRef);
|
||||
private readonly metadataService = inject(MetadataService);
|
||||
private readonly jumpbarService = inject(JumpbarService);
|
||||
private readonly filterUtilityService = inject(FilterUtilitiesService);
|
||||
private readonly titleService = inject(Title);
|
||||
|
||||
isLoading = false;
|
||||
genres: Array<BrowseGenre> = [];
|
||||
pagination: Pagination = {currentPage: 0, totalPages: 0, totalItems: 0, itemsPerPage: 0};
|
||||
refresh: EventEmitter<void> = new EventEmitter();
|
||||
jumpKeys: Array<JumpKey> = [];
|
||||
trackByIdentity = (index: number, item: BrowsePerson) => `${item.id}`;
|
||||
|
||||
ngOnInit() {
|
||||
this.isLoading = true;
|
||||
this.cdRef.markForCheck();
|
||||
|
||||
this.titleService.setTitle('Kavita - ' + translate('browse-genres.title'));
|
||||
|
||||
this.metadataService.getGenreWithCounts(undefined, undefined).subscribe(d => {
|
||||
this.genres = d.result;
|
||||
this.pagination = d.pagination;
|
||||
this.jumpKeys = this.jumpbarService.getJumpKeys(this.genres, (d: BrowseGenre) => d.title);
|
||||
this.isLoading = false;
|
||||
this.cdRef.markForCheck();
|
||||
});
|
||||
}
|
||||
|
||||
openFilter(field: FilterField, value: string | number) {
|
||||
this.filterUtilityService.applyFilter(['all-series'], field, FilterComparison.Equal, `${value}`).subscribe();
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<div class="main-container container-fluid">
|
||||
<ng-container *transloco="let t; read:'browse-authors'" >
|
||||
<app-side-nav-companion-bar [hasFilter]="false">
|
||||
<ng-container *transloco="let t; read:'browse-people'" >
|
||||
<app-side-nav-companion-bar [hasFilter]="true" (filterOpen)="filterOpen.emit($event)" [filterActive]="filterActive">
|
||||
<h2 title>
|
||||
<span>{{t('title')}}</span>
|
||||
</h2>
|
||||
@ -16,13 +16,16 @@
|
||||
[jumpBarKeys]="jumpKeys"
|
||||
[filteringDisabled]="true"
|
||||
[refresh]="refresh"
|
||||
[filterSettings]="filterSettings"
|
||||
[filterOpen]="filterOpen"
|
||||
(applyFilter)="updateFilter($event)"
|
||||
>
|
||||
<ng-template #cardItem let-item let-position="idx">
|
||||
<app-person-card [entity]="item" [title]="item.name" [imageUrl]="imageService.getPersonImage(item.id)" (clicked)="goToPerson(item)">
|
||||
<ng-template #subtitle>
|
||||
<div class="d-flex justify-content-evenly">
|
||||
<div style="font-size: 12px">{{item.seriesCount | compactNumber}} series</div>
|
||||
<div style="font-size: 12px">{{item.issueCount | compactNumber}} issues</div>
|
||||
<div class="tag-meta">
|
||||
<div style="font-size: 12px">{{t('series-count', {num: item.seriesCount | compactNumber})}}</div>
|
||||
<div style="font-size: 12px">{{t('issue-count', {num: item.chapterCount | compactNumber})}}</div>
|
||||
</div>
|
||||
</ng-template>
|
||||
</app-person-card>
|
@ -1,3 +1,5 @@
|
||||
@use '../../../tag-card-common';
|
||||
|
||||
.main-container {
|
||||
margin-top: 10px;
|
||||
padding: 0 0 0 10px;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user