Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat : add cover display option #2643

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

charles7668
Copy link
Contributor

Added


Note : this PR will update Database (config/kavita.db)


Currently, there are three display options available:

  1. Default: Shows the default display (usually Volume 1).

  2. Random: Displays a random volume cover.

  3. LatestVolume: Shows the cover of the latest volume.

Random:
firefox_hdcoFp2tJS

LatestVolume:
firefox_jcUDrL3c3I

This option determines how the series cover will be displayed.
Currently, there are three display options available:

1. Default: Shows the default display (usually Volume 1).

2. Random: Displays a random volume cover.

3. LatestVolume: Shows the cover of the latest volume.
Copy link
Member

@majora2007 majora2007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sold on including this into Kavita. I need feedback from users on how this should work as well.

I don't want to dissuade you from contributing, but not everything in discussions or that you raise will be merged. Feel free to join discord and ask me before you spend time working on something.

@@ -30,6 +30,7 @@ export interface SeriesMetadata {
language: string;
publicationStatus: PublicationStatus;
webLinks: string;
coverDisplayOption: number;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an enum.

@@ -96,6 +96,10 @@ export class MetadataService {
return this.httpClient.get<Array<Person>>(this.baseUrl + 'metadata/people-by-role?role=' + role);
}

getCoverDisplayOptions(){
return this.httpClient.get<Array<string>>(this.baseUrl + 'metadata/cover-display-options');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return an Array of enums

<form [formGroup]="coverOptionForm" style="margin-bottom: 15px">
<label for="cover-display-option-port" class="form-label">Cover Display Options</label>
<select id="cover-display-option-port" class="form-select" formControlName="coverDisplayOptionSelected">
<option *ngFor="let option of coverDisplayOptions" [ngValue]="option">{{ option | titlecase }}</option>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a pipe to localize the enum value -> string

@@ -358,6 +358,12 @@ <h4 class="modal-title">
<li [ngbNavItem]="tabs[TabID.CoverImage]">
<a ngbNavLink>{{t(tabs[TabID.CoverImage])}}</a>
<ng-template ngbNavContent>
<form [formGroup]="coverOptionForm" style="margin-bottom: 15px">
<label for="cover-display-option-port" class="form-label">Cover Display Options</label>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to use localization on any new strings. You need a tooltip to explain how this works.

@@ -157,6 +157,9 @@ export class EditSeriesModalComponent implements OnInit {
selectedCover: string = '';
coverImageReset = false;

coverDisplayOptions : Array<string> = [];
coverOptionForm! : FormGroup;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this not go in the existing Form?

var path = Path.Join(_directoryService.CoverImageDirectory, await _unitOfWork.SeriesRepository.GetSeriesCoverImageAsync(seriesId));
if (string.IsNullOrEmpty(path) || !_directoryService.FileSystem.File.Exists(path)) return BadRequest(await _localizationService.Translate(userId, "no-cover-image"));
var format = _directoryService.FileSystem.Path.GetExtension(path);
var seriesMetadata = await _unitOfWork.SeriesRepository.GetSeriesMetadata(seriesId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to use a dedicated repo method to get the CoverImageOption for a given series. No need to load the whole SeriesMetadata in for one field.


namespace API.Entities.Enums;

public enum CoverDisplayOption
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Option doesn't leave a good impression on an enum.

CoverGenerationSelector works a bit better. I'm open to opinion on a better name.

if (volumes.Count < 1)
return BadRequest(await _localizationService.Translate(userId, "no-cover-image"));
var latestVolumeNumber = volumes.Max(x => x.Number);
var latestId = volumes.First(v => v.Number == latestVolumeNumber).Id;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need latestVolumeNumber? You can just do:
var latestId = volumes.OrderByDescending(v => v.Number).First().Id;

string path;
switch (seriesMetadata.CoverDisplayOption)
{
case CoverDisplayOption.Random:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of supporting this. I'd need to see a use case to adding it in. I would remove for now.

/// <summary>
/// Series cover display option
/// </summary>
public CoverDisplayOption CoverDisplayOption { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this belongs on the Series.

It is likely this is used for Magazines, which are likely to be in their own library, rather than on a series. Plus if a user has a lot of magazines, it is quite painful to update this for all those series. Maybe @lyingloverr, @MortenCB, or @raub21 can comment on their opinion.

@majora2007 majora2007 added enhancement New feature or request db-migration This story needs a DB Migration labels Jan 22, 2024
@charles7668
Copy link
Contributor Author

I'm not 100% sold on including this into Kavita. I need feedback from users on how this should work as well.

I don't want to dissuade you from contributing, but not everything in discussions or that you raise will be merged. Feel free to join discord and ask me before you spend time working on something.

Sorry, maybe I missed some of the rules for feature requests.

Should I close this PR before the discussion(#2629) is concluded?

@majora2007
Copy link
Member

I'm not 100% sold on including this into Kavita. I need feedback from users on how this should work as well.
I don't want to dissuade you from contributing, but not everything in discussions or that you raise will be merged. Feel free to join discord and ask me before you spend time working on something.

Sorry, maybe I missed some of the rules for feature requests.

Should I close this PR before the discussion(#2629) is concluded?

The way the feature request works is that users open discussions, I gather feedback and upvotes. I label the discussion as accepted then move to brainstorming on the feature in the discord with Kavita+ members to flesh out the feature further and integrate it well in Kavita before going to implementation.

I appreciate all the PRs, but I don't want to setup the expectation just because someone requested it and someone else coded it that it will be pulled in. It needs to fit well with Kavita and the maintenance needs to be worthwhile.

Again, if you have discord, reach out to me in the Kavita server. It's much easier to just ping me when you want to work on something before doing it and me rejecting it.

As for this PR, more information is needed. I can see this feature as being beneficial to Magazine users, but personally I don't see a huge need to add the complexity into Kavita. I'm waiting to see how much feedback and upvotes we get on the discussion before bringing into consideration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
db-migration This story needs a DB Migration enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants