Massive UI Cleanup (#4466)

Co-authored-by: KindlyFire <10267586+kindlyfire@users.noreply.github.com>
Co-authored-by: Hosted Weblate <hosted@weblate.org>
Co-authored-by: Adam Havránek <adamhavra@seznam.cz>
Co-authored-by: Aindriú Mac Giolla Eoin <aindriu80@gmail.com>
Co-authored-by: Alexey <lewadedun@gmail.com>
Co-authored-by: Anon Bitardov <timurvolga23+weblate@gmail.com>
Co-authored-by: Ferran <ferrancette@gmail.com>
Co-authored-by: Gneb <goozi12345@gmail.com>
Co-authored-by: Robin Stolpe <robinstolpe@slashmad.com>
Co-authored-by: 안세훈 <on9686@gmail.com>
Co-authored-by: Tijl Van den Brugghen <contact@tijlvdb.me>
This commit is contained in:
Joe Milazzo
2026-02-28 13:19:00 -06:00
committed by GitHub
parent faae7fe402
commit 0bbb0ff28f
596 changed files with 14339 additions and 12501 deletions
+8 -6
View File
@@ -66,10 +66,12 @@ public class CollectionController : BaseApiController
/// <param name="collectionId"></param>
/// <returns></returns>
[HttpGet("single")]
public async Task<ActionResult<IEnumerable<AppUserCollectionDto>>> GetTag(int collectionId)
public async Task<ActionResult<AppUserCollectionDto>> GetTag(int collectionId)
{
var collections = await _unitOfWork.CollectionTagRepository.GetCollectionDtosAsync(UserId, false);
return Ok(collections.FirstOrDefault(c => c.Id == collectionId));
var result = await _unitOfWork.CollectionTagRepository.GetCollectionDtoAsync(collectionId, UserId);
if (result == null) return NotFound(); // TODO: Figure out how to best handle restrictions/not found across the codebase
return Ok(result);
}
/// <summary>
@@ -101,10 +103,10 @@ public class CollectionController : BaseApiController
/// <remarks>UI does not contain controls to update title</remarks>
/// </summary>
/// <param name="updatedTag"></param>
/// <returns></returns>
/// <returns>The updated tag entity</returns>
[HttpPost("update")]
[DisallowRole(PolicyConstants.ReadOnlyRole)]
public async Task<ActionResult> UpdateTag(AppUserCollectionDto updatedTag)
public async Task<ActionResult<AppUserCollectionDto>> UpdateTag(AppUserCollectionDto updatedTag)
{
try
{
@@ -112,7 +114,7 @@ public class CollectionController : BaseApiController
{
await _eventHub.SendMessageAsync(MessageFactory.CollectionUpdated,
MessageFactory.CollectionUpdatedEvent(updatedTag.Id), false);
return Ok(await _localizationService.Translate(UserId, "collection-updated-successfully"));
return Ok(await _unitOfWork.CollectionTagRepository.GetCollectionDtoAsync(updatedTag.Id, UserId));
}
}
catch (KavitaException ex)
+14 -15
View File
@@ -24,6 +24,7 @@ using EasyCaching.Core;
using Hangfire;
using Kavita.Common;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
@@ -68,10 +69,10 @@ public class LibraryController : BaseApiController
/// Creates a new Library. Upon library creation, adds new library to all Admin accounts.
/// </summary>
/// <param name="dto"></param>
/// <returns></returns>
/// <returns>Created Library</returns>
[Authorize(Policy = PolicyGroups.AdminPolicy)]
[HttpPost("create")]
public async Task<ActionResult> AddLibrary(UpdateLibraryDto dto)
public async Task<ActionResult<LibraryDto?>> AddLibrary(UpdateLibraryDto dto)
{
if (await _unitOfWork.LibraryRepository.LibraryExists(dto.Name))
{
@@ -161,7 +162,7 @@ public class LibraryController : BaseApiController
await _eventHub.SendMessageAsync(MessageFactory.SideNavUpdate,
MessageFactory.SideNavUpdateEvent(UserId), false);
return Ok();
return Ok(await _unitOfWork.LibraryRepository.GetLibraryDtoByIdAsync(library.Id));
}
/// <summary>
@@ -207,17 +208,18 @@ public class LibraryController : BaseApiController
/// <summary>
/// Return a specific library
/// </summary>
/// <remarks>If the user is not an admin, only id, type, and name will be returned</remarks>
/// <returns></returns>
[Authorize(Policy = PolicyGroups.AdminPolicy)]
[ProducesResponseType<LibraryDto>(StatusCodes.Status200OK)]
[ProducesResponseType<LiteLibraryDto>(StatusCodes.Status200OK)]
[HttpGet]
public async Task<ActionResult<LibraryDto?>> GetLibrary(int libraryId)
{
var username = Username!;
if (string.IsNullOrEmpty(username)) return Unauthorized();
var libraries = await GetLibrariesForUser(username);
return Ok(libraries.FirstOrDefault(l => l.Id == libraryId));
if (User.IsInRole(PolicyConstants.AdminRole))
{
return Ok(await _unitOfWork.LibraryRepository.GetLibraryDtoByIdAsync(libraryId));
}
return Ok(await _unitOfWork.LibraryRepository.GetLiteLibraryDtoByIdAsync(libraryId));
}
/// <summary>
@@ -227,10 +229,7 @@ public class LibraryController : BaseApiController
[HttpGet("libraries")]
public async Task<ActionResult<IEnumerable<LibraryDto>>> GetLibraries()
{
var username = Username!;
if (string.IsNullOrEmpty(username)) return Unauthorized();
return Ok(await GetLibrariesForUser(username));
return Ok(await GetLibrariesForUser(Username!));
}
/// <summary>
@@ -674,7 +673,7 @@ public class LibraryController : BaseApiController
await _libraryCacheProvider.RemoveByPrefixAsync(CacheKey);
return Ok();
return Ok(await _unitOfWork.LibraryRepository.GetLibraryDtoByIdAsync(library.Id));
}
+4 -4
View File
@@ -159,9 +159,9 @@ public class SeriesController : BaseApiController
/// Updates the Series
/// </summary>
/// <param name="updateSeries"></param>
/// <returns></returns>
/// <returns>Updated Series</returns>
[HttpPost("update")]
public async Task<ActionResult> UpdateSeries(UpdateSeriesDto updateSeries)
public async Task<ActionResult<SeriesDto>> UpdateSeries(UpdateSeriesDto updateSeries)
{
var series = await _unitOfWork.SeriesRepository.GetSeriesByIdAsync(updateSeries.Id);
if (series == null)
@@ -206,7 +206,7 @@ public class SeriesController : BaseApiController
await _taskScheduler.RefreshSeriesMetadata(series.LibraryId, series.Id);
}
return Ok();
return Ok(await _unitOfWork.SeriesRepository.GetSeriesDtoByIdAsync(series.Id, UserId));
}
/// <summary>
@@ -233,7 +233,7 @@ public class SeriesController : BaseApiController
/// <param name="userParams">Page size and offset</param>
/// <returns></returns>
[HttpPost("recently-updated-series")]
public async Task<ActionResult<IList<RecentlyAddedItemDto>>> GetRecentlyAddedChapters([FromQuery] UserParams? userParams)
public async Task<ActionResult<IList<GroupedSeriesDto>>> GetRecentlyAddedChapters([FromQuery] UserParams? userParams)
{
userParams ??= UserParams.Default;
return Ok(await _unitOfWork.SeriesRepository.GetRecentlyUpdatedSeries(UserId, userParams));