mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-05-24 00:52:23 -04:00
* Added a reoccuring task to cleanup db entries that might be abandoned. On library page, the Library in question will be prepoulated. * Laid out the foundation for customized sorting. Added all series page to the UI when clicking on Libraries section header on home page so user can apply any filtering they like. * When filtering, the current library filter will now automatically filter out the options for people and genres. * Implemented Sorting controls * Clear now clears sorting and read progress. Sorting is disabled on deck and recently added. * Fixed an issue where all-series page couldn't click to open series * Don't let the user unselect the last read progress. Added new comicinfo v2.1 draft tags. * Hooked in Translator tag into backend and UI. * Fixed an issue where you could open multiple typeaheads at the same time * Integrated Translator and Tags ComicInfo extension fields. Started work on a badge expander. * Reworked a bit more on badge expander. Added the UI code for Age Rating and Tags * Integrated backend for Tags, Translator, and Age Rating * Metadata tags now collapse if more than 4 present * Some code cleanup * Made the not read badge slightly smaller
120 lines
3.8 KiB
C#
120 lines
3.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using API.Data;
|
|
using API.DTOs;
|
|
using API.DTOs.Filtering;
|
|
using API.DTOs.Metadata;
|
|
using API.Entities.Enums;
|
|
using Kavita.Common.Extensions;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace API.Controllers;
|
|
|
|
|
|
public class MetadataController : BaseApiController
|
|
{
|
|
private readonly IUnitOfWork _unitOfWork;
|
|
|
|
public MetadataController(IUnitOfWork unitOfWork)
|
|
{
|
|
_unitOfWork = unitOfWork;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Fetches genres from the instance
|
|
/// </summary>
|
|
/// <param name="libraryIds">String separated libraryIds or null for all genres</param>
|
|
/// <returns></returns>
|
|
[HttpGet("genres")]
|
|
public async Task<ActionResult<IList<GenreTagDto>>> GetAllGenres(string? libraryIds)
|
|
{
|
|
var ids = libraryIds?.Split(",").Select(int.Parse).ToList();
|
|
if (ids != null && ids.Count > 0)
|
|
{
|
|
return Ok(await _unitOfWork.GenreRepository.GetAllGenreDtosForLibrariesAsync(ids));
|
|
}
|
|
|
|
return Ok(await _unitOfWork.GenreRepository.GetAllGenreDtosAsync());
|
|
}
|
|
|
|
/// <summary>
|
|
/// Fetches people from the instance
|
|
/// </summary>
|
|
/// <param name="libraryIds">String separated libraryIds or null for all people</param>
|
|
/// <returns></returns>
|
|
[HttpGet("people")]
|
|
public async Task<ActionResult<IList<PersonDto>>> GetAllPeople(string? libraryIds)
|
|
{
|
|
var ids = libraryIds?.Split(",").Select(int.Parse).ToList();
|
|
if (ids != null && ids.Count > 0)
|
|
{
|
|
return Ok(await _unitOfWork.PersonRepository.GetAllPeopleDtosForLibrariesAsync(ids));
|
|
}
|
|
return Ok(await _unitOfWork.PersonRepository.GetAllPeople());
|
|
}
|
|
|
|
/// <summary>
|
|
/// Fetches all tags from the instance
|
|
/// </summary>
|
|
/// <param name="libraryIds">String separated libraryIds or null for all tags</param>
|
|
/// <returns></returns>
|
|
[HttpGet("tags")]
|
|
public async Task<ActionResult<IList<PersonDto>>> GetAllTags(string? libraryIds)
|
|
{
|
|
var ids = libraryIds?.Split(",").Select(int.Parse).ToList();
|
|
if (ids != null && ids.Count > 0)
|
|
{
|
|
return Ok(await _unitOfWork.TagRepository.GetAllTagDtosForLibrariesAsync(ids));
|
|
}
|
|
return Ok(await _unitOfWork.TagRepository.GetAllTagDtosAsync());
|
|
}
|
|
|
|
/// <summary>
|
|
/// Fetches all age ratings from the instance
|
|
/// </summary>
|
|
/// <param name="libraryIds">String separated libraryIds or null for all ratings</param>
|
|
/// <returns></returns>
|
|
[HttpGet("age-ratings")]
|
|
public async Task<ActionResult<IList<AgeRatingDto>>> GetAllAgeRatings(string? libraryIds)
|
|
{
|
|
var ids = libraryIds?.Split(",").Select(int.Parse).ToList();
|
|
if (ids != null && ids.Count > 0)
|
|
{
|
|
return Ok(await _unitOfWork.SeriesRepository.GetAllAgeRatingsDtosForLibrariesAsync(ids));
|
|
}
|
|
|
|
return Ok(Enum.GetValues<AgeRating>().Select(t => new AgeRatingDto()
|
|
{
|
|
Title = t.ToDescription(),
|
|
Value = t
|
|
}));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Fetches all age ratings from the instance
|
|
/// </summary>
|
|
/// <param name="libraryIds">String separated libraryIds or null for all ratings</param>
|
|
/// <returns></returns>
|
|
[HttpGet("languages")]
|
|
public async Task<ActionResult<IList<LanguageDto>>> GetAllLanguages(string? libraryIds)
|
|
{
|
|
var ids = libraryIds?.Split(",").Select(int.Parse).ToList();
|
|
if (ids != null && ids.Count > 0)
|
|
{
|
|
return Ok(await _unitOfWork.SeriesRepository.GetAllLanguagesForLibrariesAsync(ids));
|
|
}
|
|
|
|
return Ok(new List<LanguageDto>()
|
|
{
|
|
new ()
|
|
{
|
|
Title = CultureInfo.GetCultureInfo("en").DisplayName,
|
|
IsoCode = "en"
|
|
}
|
|
});
|
|
}
|
|
}
|