mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-17 21:25:39 -04:00
New: Show series info in author books table and book details
This commit is contained in:
@@ -71,7 +71,7 @@ class BookRow extends Component {
|
||||
statistics,
|
||||
releaseDate,
|
||||
title,
|
||||
position,
|
||||
seriesTitle,
|
||||
pageCount,
|
||||
ratings,
|
||||
isSaving,
|
||||
@@ -129,13 +129,13 @@ class BookRow extends Component {
|
||||
);
|
||||
}
|
||||
|
||||
if (name === 'position') {
|
||||
if (name === 'series') {
|
||||
return (
|
||||
<TableRowCell
|
||||
key={name}
|
||||
className={styles.title}
|
||||
>
|
||||
{position || ''}
|
||||
{seriesTitle || ''}
|
||||
</TableRowCell>
|
||||
);
|
||||
}
|
||||
@@ -215,7 +215,7 @@ BookRow.propTypes = {
|
||||
monitored: PropTypes.bool.isRequired,
|
||||
releaseDate: PropTypes.string,
|
||||
title: PropTypes.string.isRequired,
|
||||
position: PropTypes.string,
|
||||
seriesTitle: PropTypes.string.isRequired,
|
||||
pageCount: PropTypes.number,
|
||||
ratings: PropTypes.object.isRequired,
|
||||
titleSlug: PropTypes.string.isRequired,
|
||||
|
||||
@@ -143,6 +143,7 @@ class BookDetails extends Component {
|
||||
id,
|
||||
titleSlug,
|
||||
title,
|
||||
seriesTitle,
|
||||
pageCount,
|
||||
overview,
|
||||
statistics = {},
|
||||
@@ -301,6 +302,10 @@ class BookDetails extends Component {
|
||||
</div>
|
||||
|
||||
<div className={styles.details}>
|
||||
<div>
|
||||
{seriesTitle}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{
|
||||
!!pageCount &&
|
||||
@@ -510,6 +515,7 @@ BookDetails.propTypes = {
|
||||
id: PropTypes.number.isRequired,
|
||||
titleSlug: PropTypes.string.isRequired,
|
||||
title: PropTypes.string.isRequired,
|
||||
seriesTitle: PropTypes.string.isRequired,
|
||||
pageCount: PropTypes.number,
|
||||
overview: PropTypes.string,
|
||||
statistics: PropTypes.object.isRequired,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
|
||||
@@ -7,6 +8,7 @@ namespace NzbDrone.Core.Books
|
||||
public interface ISeriesBookLinkRepository : IBasicRepository<SeriesBookLink>
|
||||
{
|
||||
List<SeriesBookLink> GetLinksBySeries(int seriesId);
|
||||
List<SeriesBookLink> GetLinksByBook(List<int> bookIds);
|
||||
}
|
||||
|
||||
public class SeriesBookLinkRepository : BasicRepository<SeriesBookLink>, ISeriesBookLinkRepository
|
||||
@@ -20,5 +22,19 @@ namespace NzbDrone.Core.Books
|
||||
{
|
||||
return Query(x => x.SeriesId == seriesId);
|
||||
}
|
||||
|
||||
public List<SeriesBookLink> GetLinksByBook(List<int> bookIds)
|
||||
{
|
||||
return _database.QueryJoined<SeriesBookLink, Series>(
|
||||
Builder()
|
||||
.Join<SeriesBookLink, Series>((l, s) => l.SeriesId == s.Id)
|
||||
.Where<SeriesBookLink>(x => bookIds.Contains(x.BookId)),
|
||||
(link, series) =>
|
||||
{
|
||||
link.Series = series;
|
||||
return link;
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace NzbDrone.Core.Books
|
||||
public interface ISeriesBookLinkService
|
||||
{
|
||||
List<SeriesBookLink> GetLinksBySeries(int seriesId);
|
||||
List<SeriesBookLink> GetLinksByBook(List<int> bookIds);
|
||||
void InsertMany(List<SeriesBookLink> model);
|
||||
void UpdateMany(List<SeriesBookLink> model);
|
||||
void DeleteMany(List<SeriesBookLink> model);
|
||||
@@ -24,6 +25,11 @@ namespace NzbDrone.Core.Books
|
||||
return _repo.GetLinksBySeries(seriesId);
|
||||
}
|
||||
|
||||
public List<SeriesBookLink> GetLinksByBook(List<int> bookIds)
|
||||
{
|
||||
return _repo.GetLinksByBook(bookIds);
|
||||
}
|
||||
|
||||
public void InsertMany(List<SeriesBookLink> model)
|
||||
{
|
||||
_repo.InsertMany(model);
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace Readarr.Api.V1.Books
|
||||
IBookService bookService,
|
||||
IAddBookService addBookService,
|
||||
IEditionService editionService,
|
||||
ISeriesBookLinkService seriesBookLinkService,
|
||||
IAuthorStatisticsService authorStatisticsService,
|
||||
IMapCoversToLocal coverMapper,
|
||||
IUpgradableSpecification upgradableSpecification,
|
||||
@@ -44,7 +45,7 @@ namespace Readarr.Api.V1.Books
|
||||
QualityProfileExistsValidator qualityProfileExistsValidator,
|
||||
MetadataProfileExistsValidator metadataProfileExistsValidator)
|
||||
|
||||
: base(bookService, authorStatisticsService, coverMapper, upgradableSpecification, signalRBroadcaster)
|
||||
: base(bookService, seriesBookLinkService, authorStatisticsService, coverMapper, upgradableSpecification, signalRBroadcaster)
|
||||
{
|
||||
_authorService = authorService;
|
||||
_editionService = editionService;
|
||||
|
||||
@@ -14,18 +14,21 @@ namespace Readarr.Api.V1.Books
|
||||
public abstract class BookModuleWithSignalR : ReadarrRestModuleWithSignalR<BookResource, Book>
|
||||
{
|
||||
protected readonly IBookService _bookService;
|
||||
protected readonly ISeriesBookLinkService _seriesBookLinkService;
|
||||
protected readonly IAuthorStatisticsService _authorStatisticsService;
|
||||
protected readonly IUpgradableSpecification _qualityUpgradableSpecification;
|
||||
protected readonly IMapCoversToLocal _coverMapper;
|
||||
|
||||
protected BookModuleWithSignalR(IBookService bookService,
|
||||
IAuthorStatisticsService authorStatisticsService,
|
||||
IMapCoversToLocal coverMapper,
|
||||
IUpgradableSpecification qualityUpgradableSpecification,
|
||||
IBroadcastSignalRMessage signalRBroadcaster)
|
||||
ISeriesBookLinkService seriesBookLinkService,
|
||||
IAuthorStatisticsService authorStatisticsService,
|
||||
IMapCoversToLocal coverMapper,
|
||||
IUpgradableSpecification qualityUpgradableSpecification,
|
||||
IBroadcastSignalRMessage signalRBroadcaster)
|
||||
: base(signalRBroadcaster)
|
||||
{
|
||||
_bookService = bookService;
|
||||
_seriesBookLinkService = seriesBookLinkService;
|
||||
_authorStatisticsService = authorStatisticsService;
|
||||
_coverMapper = coverMapper;
|
||||
_qualityUpgradableSpecification = qualityUpgradableSpecification;
|
||||
@@ -75,6 +78,22 @@ namespace Readarr.Api.V1.Books
|
||||
|
||||
protected List<BookResource> MapToResource(List<Book> books, bool includeAuthor)
|
||||
{
|
||||
var seriesLinks = _seriesBookLinkService.GetLinksByBook(books.Select(x => x.Id).ToList())
|
||||
.GroupBy(x => x.BookId)
|
||||
.ToDictionary(x => x.Key, y => y.ToList());
|
||||
|
||||
foreach (var book in books)
|
||||
{
|
||||
if (seriesLinks.TryGetValue(book.Id, out var links))
|
||||
{
|
||||
book.SeriesLinks = links;
|
||||
}
|
||||
else
|
||||
{
|
||||
book.SeriesLinks = new List<SeriesBookLink>();
|
||||
}
|
||||
}
|
||||
|
||||
var result = books.ToResource();
|
||||
|
||||
if (includeAuthor)
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Books;
|
||||
using NzbDrone.Core.MediaCover;
|
||||
using Readarr.Api.V1.Author;
|
||||
@@ -13,6 +14,7 @@ namespace Readarr.Api.V1.Books
|
||||
public class BookResource : RestResource
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string SeriesTitle { get; set; }
|
||||
public string Disambiguation { get; set; }
|
||||
public string Overview { get; set; }
|
||||
public int AuthorId { get; set; }
|
||||
@@ -60,6 +62,7 @@ namespace Readarr.Api.V1.Books
|
||||
PageCount = selectedEdition?.PageCount ?? 0,
|
||||
Genres = model.Genres,
|
||||
Title = selectedEdition?.Title ?? model.Title,
|
||||
SeriesTitle = model.SeriesLinks.Value.Select(x => x.Series.Value.Title + (x.Position.IsNotNullOrWhiteSpace() ? $" #{x.Position}" : string.Empty)).ConcatToString("; "),
|
||||
Disambiguation = selectedEdition?.Disambiguation,
|
||||
Overview = selectedEdition?.Overview,
|
||||
Images = selectedEdition?.Images ?? new List<MediaCover>(),
|
||||
|
||||
Reference in New Issue
Block a user