-
-
Notifications
You must be signed in to change notification settings - Fork 341
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
base: develop
Are you sure you want to change the base?
Feat : add cover display option #2643
Conversation
This option determines how the series cover will be displayed.
…for cover display
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.
There was a problem hiding this 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; |
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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; } |
There was a problem hiding this comment.
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.
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. |
Added
Note : this PR will update Database (config/kavita.db)
Currently, there are three display options available:
Default: Shows the default display (usually Volume 1).
Random: Displays a random volume cover.
LatestVolume: Shows the cover of the latest volume.
Random:
LatestVolume: