feat(webui): display book links

closes #750
This commit is contained in:
Gauthier Roebroeck 2021-12-28 18:58:36 +08:00
parent 1c32273268
commit ff38516b11
6 changed files with 67 additions and 9 deletions

View file

@ -152,6 +152,7 @@
"file": "FILE",
"format": "FORMAT",
"isbn": "ISBN",
"links": "LINKS",
"navigation_within_readlist": "Navigation within the readlist: {name}",
"outdated_tooltip": "The file for this book has changed, this book must be re-analyzed",
"read_book": "Read book",
@ -306,12 +307,6 @@
"warning_html": "The read list <b>{name}</b> will be removed from this server. Your media files will not be affected. This <b>cannot</b> be undone. Continue?",
"warning_multiple_html": "{count} read lists will be removed from this server. Your media files will not be affected. This <b>cannot</b> be undone. Continue?"
},
"delete_user": {
"button_confirm": "Delete",
"confirm_delete": "Yes, delete the user \"{name}\"",
"dialog_title": "Delete User",
"warning_html": "The user <b>{name}</b> will be deleted from this server. This <b>cannot</b> be undone. Continue?"
},
"delete_series": {
"button_confirm": "Delete",
"confirm_delete": "Yes, delete series \"{name}\" and its files",
@ -320,6 +315,12 @@
"warning_html": "The Series <b>{name}</b> will be removed from this server alongside with stored media files. This <b>cannot</b> be undone. Continue?",
"warning_multiple_html": "{count} series will be removed from this server alongside with stored media files. This <b>cannot</b> be undone. Continue?"
},
"delete_user": {
"button_confirm": "Delete",
"confirm_delete": "Yes, delete the user \"{name}\"",
"dialog_title": "Delete User",
"warning_html": "The user <b>{name}</b> will be deleted from this server. This <b>cannot</b> be undone. Continue?"
},
"edit_books": {
"authors_notice_multiple_edit": "You are editing authors for multiple books. This will override existing authors of each book.",
"button_cancel": "Cancel",

View file

@ -63,6 +63,8 @@ export interface BookMetadataDto {
tagsLock: boolean,
isbn: string,
isbnLock: boolean
links?: WebLinkDto[],
linksLock?: boolean
}
export interface ReadProgressDto {
@ -100,6 +102,11 @@ export interface AuthorDto {
role: string
}
export interface WebLinkDto {
label: string,
url: string
}
export interface ReadProgressUpdateDto {
page?: number,
completed?: boolean

View file

@ -250,7 +250,9 @@
:key="role"
class="align-center text-caption"
>
<v-col cols="4" sm="3" md="2" xl="1" class="py-1 text-uppercase">{{ $te(`author_roles.${role}`) ? $t(`author_roles.${role}`) : role }}</v-col>
<v-col cols="4" sm="3" md="2" xl="1" class="py-1 text-uppercase">
{{ $te(`author_roles.${role}`) ? $t(`author_roles.${role}`) : role }}
</v-col>
<v-col cols="8" sm="9" md="10" xl="11" class="py-1">
<vue-horizontal>
<template v-slot:btn-prev>
@ -315,6 +317,32 @@
</v-col>
</v-row>
<v-row v-if="book.metadata.links.length > 0" class="align-center text-caption">
<v-col class="py-1" cols="4" sm="3" md="2" xl="1">{{ $t('browse_book.links') }}</v-col>
<v-col class="py-1" cols="8" sm="9" md="10" xl="11">
<v-chip
v-for="(link, i) in book.metadata.links"
:href="link.url"
target="_blank"
class="me-2"
label
small
outlined
link
:key="i"
>
{{ link.label }}
<v-icon
x-small
color="grey"
class="ps-1"
>
mdi-open-in-new
</v-icon>
</v-chip>
</v-col>
</v-row>
<v-row class="align-center text-caption">
<v-col class="py-1" cols="4" sm="3" md="2" xl="1">{{ $t('browse_book.size') }}</v-col>
<v-col class="py-1" cols="8" sm="9" md="10" xl="11">{{ book.size }}</v-col>

View file

@ -12,6 +12,7 @@ import org.gotson.komga.interfaces.api.rest.dto.BookDto
import org.gotson.komga.interfaces.api.rest.dto.BookMetadataDto
import org.gotson.komga.interfaces.api.rest.dto.MediaDto
import org.gotson.komga.interfaces.api.rest.dto.ReadProgressDto
import org.gotson.komga.interfaces.api.rest.dto.WebLinkDto
import org.gotson.komga.jooq.Tables
import org.gotson.komga.jooq.tables.records.BookMetadataRecord
import org.gotson.komga.jooq.tables.records.BookRecord
@ -49,6 +50,7 @@ class BookDtoDao(
private val s = Tables.SERIES
private val rlb = Tables.READLIST_BOOK
private val bt = Tables.BOOK_METADATA_TAG
private val bl = Tables.BOOK_METADATA_LINK
private val countUnread: AggregateFunction<BigDecimal> = DSL.sum(DSL.`when`(r.COMPLETED.isNull, 1).otherwise(0))
private val countRead: AggregateFunction<BigDecimal> = DSL.sum(DSL.`when`(r.COMPLETED.isTrue, 1).otherwise(0))
@ -281,7 +283,13 @@ class BookDtoDao(
.where(bt.BOOK_ID.eq(br.id))
.fetchSet(bt.TAG)
br.toDto(mr.toDto(), dr.toDto(authors, tags), if (rr.userId != null) rr.toDto() else null)
val links = dsl.select(bl.LABEL, bl.URL)
.from(bl)
.where(bl.BOOK_ID.eq(br.id))
.fetchInto(bl)
.map { WebLinkDto(it.label, it.url) }
br.toDto(mr.toDto(), dr.toDto(authors, tags, links), if (rr.userId != null) rr.toDto() else null)
}
private fun BookSearchWithReadProgress.toCondition(): Condition {
@ -356,7 +364,7 @@ class BookDtoDao(
comment = comment ?: ""
)
private fun BookMetadataRecord.toDto(authors: List<AuthorDto>, tags: Set<String>) =
private fun BookMetadataRecord.toDto(authors: List<AuthorDto>, tags: Set<String>, links: List<WebLinkDto>) =
BookMetadataDto(
title = title,
titleLock = titleLock,
@ -374,6 +382,8 @@ class BookDtoDao(
tagsLock = tagsLock,
isbn = isbn,
isbnLock = isbnLock,
links = links,
linksLock = linksLock,
created = createdDate,
lastModified = lastModifiedDate
)

View file

@ -55,6 +55,8 @@ data class BookMetadataDto(
val tagsLock: Boolean,
val isbn: String,
val isbnLock: Boolean,
val links: List<WebLinkDto>,
val linksLock: Boolean,
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
val created: LocalDateTime,

View file

@ -0,0 +1,10 @@
package org.gotson.komga.interfaces.api.rest.dto
import org.gotson.komga.domain.model.WebLink
data class WebLinkDto(
val label: String,
val url: String,
)
fun WebLink.toDto() = WebLinkDto(label, url.toString())