2021-11-29 02:36:44 +01:00
|
|
|
<template>
|
2021-12-18 03:52:11 +01:00
|
|
|
<div ref="card" :id="`book-card-${index}`" :style="{ minWidth: width + 'px', maxWidth: width + 'px', height: height + 'px' }" class="rounded-sm z-10 bg-primary cursor-pointer box-shadow-book" @mousedown.prevent @mouseup.prevent @mousemove.prevent @mouseover="mouseover" @mouseleave="mouseleave" @click="clickCard">
|
2021-12-02 22:49:03 +01:00
|
|
|
<!-- When cover image does not fill -->
|
2021-12-04 00:05:13 +01:00
|
|
|
<div v-show="showCoverBg" class="absolute top-0 left-0 w-full h-full overflow-hidden rounded-sm bg-primary">
|
|
|
|
<div class="absolute cover-bg" ref="coverBg" />
|
|
|
|
</div>
|
2021-12-02 22:49:03 +01:00
|
|
|
|
2022-02-28 01:18:38 +01:00
|
|
|
<!-- Alternative bookshelf title/author/sort -->
|
2022-05-09 01:54:41 +02:00
|
|
|
<div v-if="isAlternativeBookshelfView || isAuthorBookshelfView" class="absolute left-0 z-50 w-full" :style="{ bottom: `-${titleDisplayBottomOffset}rem` }">
|
2022-01-09 01:05:38 +01:00
|
|
|
<p class="truncate" :style="{ fontSize: 0.9 * sizeMultiplier + 'rem' }">
|
2022-03-11 01:45:02 +01:00
|
|
|
{{ displayTitle }}
|
2022-01-09 01:05:38 +01:00
|
|
|
</p>
|
2022-05-09 01:54:41 +02:00
|
|
|
<p class="truncate text-gray-400" :style="{ fontSize: 0.8 * sizeMultiplier + 'rem' }">{{ displayLineTwo || ' ' }}</p>
|
2022-02-14 23:01:53 +01:00
|
|
|
<p v-if="displaySortLine" class="truncate text-gray-400" :style="{ fontSize: 0.8 * sizeMultiplier + 'rem' }">{{ displaySortLine }}</p>
|
2021-12-28 22:50:17 +01:00
|
|
|
</div>
|
|
|
|
|
2022-01-25 01:03:54 +01:00
|
|
|
<div v-if="booksInSeries" class="absolute z-20 top-1.5 right-1.5 rounded-md leading-3 text-sm p-1 font-semibold text-white flex items-center justify-center" style="background-color: #cd9d49dd">{{ booksInSeries }}</div>
|
|
|
|
|
2021-12-02 02:07:03 +01:00
|
|
|
<div class="w-full h-full absolute top-0 left-0 rounded overflow-hidden z-10">
|
2022-03-26 17:59:34 +01:00
|
|
|
<div v-show="libraryItem && !imageReady" class="absolute top-0 left-0 w-full h-full flex items-center justify-center" :style="{ padding: sizeMultiplier * 0.5 + 'rem' }">
|
2021-12-01 03:02:40 +01:00
|
|
|
<p :style="{ fontSize: sizeMultiplier * 0.8 + 'rem' }" class="font-book text-gray-300 text-center">{{ title }}</p>
|
|
|
|
</div>
|
2021-12-02 02:07:03 +01:00
|
|
|
|
2022-03-26 17:59:34 +01:00
|
|
|
<!-- Cover Image -->
|
|
|
|
<img v-show="libraryItem" ref="cover" :src="bookCoverSrc" class="w-full h-full transition-opacity duration-300" :class="showCoverBg ? 'object-contain' : 'object-fill'" @load="imageLoaded" :style="{ opacity: imageReady ? 1 : 0 }" />
|
2021-12-02 02:07:03 +01:00
|
|
|
|
|
|
|
<!-- Placeholder Cover Title & Author -->
|
|
|
|
<div v-if="!hasCover" class="absolute top-0 left-0 right-0 bottom-0 w-full h-full flex items-center justify-center" :style="{ padding: placeholderCoverPadding + 'rem' }">
|
|
|
|
<div>
|
|
|
|
<p class="text-center font-book" style="color: rgb(247 223 187)" :style="{ fontSize: titleFontSize + 'rem' }">{{ titleCleaned }}</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div v-if="!hasCover" class="absolute left-0 right-0 w-full flex items-center justify-center" :style="{ padding: placeholderCoverPadding + 'rem', bottom: authorBottom + 'rem' }">
|
|
|
|
<p class="text-center font-book" style="color: rgb(247 223 187); opacity: 0.75" :style="{ fontSize: authorFontSize + 'rem' }">{{ authorCleaned }}</p>
|
|
|
|
</div>
|
2021-12-01 03:02:40 +01:00
|
|
|
</div>
|
|
|
|
|
2022-04-23 02:31:11 +02:00
|
|
|
<!-- No progress shown for collapsed series in library and podcasts (unless showing podcast episode) -->
|
|
|
|
<div v-if="!booksInSeries && (!isPodcast || episodeProgress)" class="absolute bottom-0 left-0 h-1 shadow-sm max-w-full z-10 rounded-b" :class="itemIsFinished ? 'bg-success' : 'bg-yellow-400'" :style="{ width: width * userProgressPercent + 'px' }"></div>
|
2021-12-01 03:02:40 +01:00
|
|
|
|
2022-01-31 23:01:49 +01:00
|
|
|
<!-- Overlay is not shown if collapsing series in library -->
|
2022-03-26 17:59:34 +01:00
|
|
|
<div v-show="!booksInSeries && libraryItem && (isHovering || isSelectionMode || isMoreMenuOpen)" class="w-full h-full absolute top-0 left-0 z-10 bg-black rounded hidden md:block" :class="overlayWrapperClasslist">
|
2021-12-01 03:02:40 +01:00
|
|
|
<div v-show="showPlayButton" class="h-full flex items-center justify-center pointer-events-none">
|
2022-02-15 21:38:06 +01:00
|
|
|
<div class="hover:text-white text-gray-200 hover:scale-110 transform duration-200 pointer-events-auto" @click.stop.prevent="play">
|
2021-12-01 03:02:40 +01:00
|
|
|
<span class="material-icons" :style="{ fontSize: playIconFontSize + 'rem' }">play_circle_filled</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div v-show="showReadButton" class="h-full flex items-center justify-center pointer-events-none">
|
2022-02-15 21:38:06 +01:00
|
|
|
<div class="hover:text-white text-gray-200 hover:scale-110 transform duration-200 pointer-events-auto" @click.stop.prevent="clickReadEBook">
|
2021-12-01 03:02:40 +01:00
|
|
|
<span class="material-icons" :style="{ fontSize: playIconFontSize + 'rem' }">auto_stories</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2022-05-10 01:23:23 +02:00
|
|
|
<div v-if="userCanUpdate" v-show="!isSelectionMode" class="absolute cursor-pointer hover:text-yellow-300 hover:scale-125 transform duration-150 top-0 right-0" :style="{ padding: 0.375 * sizeMultiplier + 'rem' }" @click.stop.prevent="editClick">
|
2021-12-01 03:02:40 +01:00
|
|
|
<span class="material-icons" :style="{ fontSize: sizeMultiplier + 'rem' }">edit</span>
|
|
|
|
</div>
|
|
|
|
|
2022-01-31 23:01:49 +01:00
|
|
|
<div class="absolute cursor-pointer hover:text-yellow-300 hover:scale-125 transform duration-100" :style="{ top: 0.375 * sizeMultiplier + 'rem', left: 0.375 * sizeMultiplier + 'rem' }" @click.stop.prevent="selectBtnClick">
|
2021-12-01 03:02:40 +01:00
|
|
|
<span class="material-icons" :class="selected ? 'text-yellow-400' : ''" :style="{ fontSize: 1.25 * sizeMultiplier + 'rem' }">{{ selected ? 'radio_button_checked' : 'radio_button_unchecked' }}</span>
|
|
|
|
</div>
|
|
|
|
|
2022-05-04 00:21:22 +02:00
|
|
|
<!-- More Menu Icon -->
|
2022-05-10 01:23:23 +02:00
|
|
|
<div ref="moreIcon" v-show="!isSelectionMode" class="hidden md:block absolute cursor-pointer hover:text-yellow-300 300 hover:scale-125 transform duration-150" :style="{ bottom: 0.375 * sizeMultiplier + 'rem', right: 0.375 * sizeMultiplier + 'rem' }" @click.stop.prevent="clickShowMore">
|
2021-12-01 03:02:40 +01:00
|
|
|
<span class="material-icons" :style="{ fontSize: 1.2 * sizeMultiplier + 'rem' }">more_vert</span>
|
2021-11-29 02:36:44 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-02-28 01:18:38 +01:00
|
|
|
|
|
|
|
<!-- Series name overlay -->
|
2022-03-26 17:59:34 +01:00
|
|
|
<div v-if="booksInSeries && libraryItem && isHovering" class="w-full h-full absolute top-0 left-0 z-10 bg-black bg-opacity-60 rounded flex items-center justify-center" :style="{ padding: sizeMultiplier + 'rem' }">
|
2022-01-31 23:01:49 +01:00
|
|
|
<p class="text-gray-200 text-center" :style="{ fontSize: 1.1 * sizeMultiplier + 'rem' }">{{ series }}</p>
|
|
|
|
</div>
|
|
|
|
|
2022-02-28 01:18:38 +01:00
|
|
|
<!-- Error widget -->
|
2021-12-02 02:07:03 +01:00
|
|
|
<ui-tooltip v-if="showError" :text="errorText" class="absolute bottom-4 left-0 z-10">
|
|
|
|
<div :style="{ height: 1.5 * sizeMultiplier + 'rem', width: 2.5 * sizeMultiplier + 'rem' }" class="bg-error rounded-r-full shadow-md flex items-center justify-end border-r border-b border-red-300">
|
|
|
|
<span class="material-icons text-red-100 pr-1" :style="{ fontSize: 0.875 * sizeMultiplier + 'rem' }">priority_high</span>
|
|
|
|
</div>
|
|
|
|
</ui-tooltip>
|
2021-11-29 02:36:44 +01:00
|
|
|
|
2022-04-23 02:31:11 +02:00
|
|
|
<!-- Series sequence -->
|
2022-04-30 19:24:48 +02:00
|
|
|
<div v-if="seriesSequence && !isHovering && !isSelectionMode" class="absolute rounded-lg bg-black bg-opacity-90 box-shadow-md z-10" :style="{ top: 0.375 * sizeMultiplier + 'rem', right: 0.375 * sizeMultiplier + 'rem', padding: `${0.1 * sizeMultiplier}rem ${0.25 * sizeMultiplier}rem` }">
|
2022-04-10 02:44:46 +02:00
|
|
|
<p :style="{ fontSize: sizeMultiplier * 0.8 + 'rem' }">#{{ seriesSequence }}</p>
|
|
|
|
</div>
|
|
|
|
|
2022-04-23 02:31:11 +02:00
|
|
|
<!-- Podcast Episode # -->
|
|
|
|
<div v-if="recentEpisodeNumber && !isHovering && !isSelectionMode" class="absolute rounded-lg bg-black bg-opacity-90 box-shadow-md z-10" :style="{ top: 0.375 * sizeMultiplier + 'rem', right: 0.375 * sizeMultiplier + 'rem', padding: `${0.1 * sizeMultiplier}rem ${0.25 * sizeMultiplier}rem` }">
|
|
|
|
<p :style="{ fontSize: sizeMultiplier * 0.8 + 'rem' }">Episode #{{ recentEpisodeNumber }}</p>
|
|
|
|
</div>
|
|
|
|
|
2022-04-10 02:44:46 +02:00
|
|
|
<!-- Podcast Num Episodes -->
|
2022-04-23 02:31:11 +02:00
|
|
|
<div v-else-if="numEpisodes && !isHovering && !isSelectionMode" class="absolute rounded-full bg-black bg-opacity-90 box-shadow-md z-10 flex items-center justify-center" :style="{ top: 0.375 * sizeMultiplier + 'rem', right: 0.375 * sizeMultiplier + 'rem', width: 1.25 * sizeMultiplier + 'rem', height: 1.25 * sizeMultiplier + 'rem' }">
|
2022-04-10 02:44:46 +02:00
|
|
|
<p :style="{ fontSize: sizeMultiplier * 0.8 + 'rem' }">{{ numEpisodes }}</p>
|
2021-12-02 02:07:03 +01:00
|
|
|
</div>
|
2021-11-29 02:36:44 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-12-01 03:02:40 +01:00
|
|
|
import Vue from 'vue'
|
|
|
|
import MoreMenu from '@/components/widgets/MoreMenu'
|
|
|
|
|
2021-11-29 02:36:44 +01:00
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
index: Number,
|
2021-12-01 03:02:40 +01:00
|
|
|
width: {
|
2021-11-29 02:36:44 +01:00
|
|
|
type: Number,
|
|
|
|
default: 120
|
2021-12-02 02:07:03 +01:00
|
|
|
},
|
2021-12-02 22:49:03 +01:00
|
|
|
height: {
|
|
|
|
type: Number,
|
|
|
|
default: 192
|
|
|
|
},
|
|
|
|
bookCoverAspectRatio: Number,
|
2021-12-28 22:50:17 +01:00
|
|
|
bookshelfView: Number,
|
2021-12-18 03:52:11 +01:00
|
|
|
bookMount: {
|
|
|
|
// Book can be passed as prop or set with setEntity()
|
|
|
|
type: Object,
|
|
|
|
default: () => null
|
2022-02-14 23:01:53 +01:00
|
|
|
},
|
|
|
|
orderBy: String,
|
|
|
|
filterBy: String,
|
|
|
|
sortingIgnorePrefix: Boolean
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isHovering: false,
|
|
|
|
isMoreMenuOpen: false,
|
|
|
|
isProcessingReadUpdate: false,
|
2022-03-26 17:59:34 +01:00
|
|
|
libraryItem: null,
|
2021-12-01 03:02:40 +01:00
|
|
|
imageReady: false,
|
|
|
|
rescanning: false,
|
|
|
|
selected: false,
|
2021-12-02 02:07:03 +01:00
|
|
|
isSelectionMode: false,
|
|
|
|
showCoverBg: false
|
2021-11-29 02:36:44 +01:00
|
|
|
}
|
|
|
|
},
|
2022-02-15 19:57:56 +01:00
|
|
|
watch: {
|
|
|
|
bookMount: {
|
|
|
|
handler(newVal) {
|
|
|
|
if (newVal) {
|
2022-03-26 17:59:34 +01:00
|
|
|
this.libraryItem = newVal
|
2022-02-15 19:57:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2021-11-29 02:36:44 +01:00
|
|
|
computed: {
|
2022-06-17 10:35:24 +02:00
|
|
|
dateFormat() {
|
|
|
|
return this.store.state.serverSettings.dateFormat
|
|
|
|
},
|
2021-12-02 02:07:03 +01:00
|
|
|
showExperimentalFeatures() {
|
|
|
|
return this.store.state.showExperimentalFeatures
|
|
|
|
},
|
2022-05-20 23:34:51 +02:00
|
|
|
enableEReader() {
|
|
|
|
return this.store.getters['getServerSetting']('enableEReader')
|
|
|
|
},
|
2022-03-11 01:45:02 +01:00
|
|
|
_libraryItem() {
|
2022-03-26 17:59:34 +01:00
|
|
|
return this.libraryItem || {}
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
2022-04-28 02:42:34 +02:00
|
|
|
isFile() {
|
|
|
|
// Library item is not in a folder
|
|
|
|
return this._libraryItem.isFile
|
|
|
|
},
|
2022-03-11 01:45:02 +01:00
|
|
|
media() {
|
|
|
|
return this._libraryItem.media || {}
|
|
|
|
},
|
|
|
|
mediaMetadata() {
|
|
|
|
return this.media.metadata || {}
|
2022-01-25 01:03:54 +01:00
|
|
|
},
|
2022-03-26 21:23:25 +01:00
|
|
|
mediaType() {
|
|
|
|
return this._libraryItem.mediaType
|
|
|
|
},
|
|
|
|
isPodcast() {
|
|
|
|
return this.mediaType === 'podcast'
|
|
|
|
},
|
2021-12-02 02:07:03 +01:00
|
|
|
placeholderUrl() {
|
|
|
|
return '/book_placeholder.jpg'
|
|
|
|
},
|
2021-11-29 02:36:44 +01:00
|
|
|
bookCoverSrc() {
|
2022-03-14 01:34:31 +01:00
|
|
|
return this.store.getters['globals/getLibraryItemCoverSrc'](this._libraryItem, this.placeholderUrl)
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
2022-03-11 01:45:02 +01:00
|
|
|
libraryItemId() {
|
|
|
|
return this._libraryItem.id
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
2022-01-25 01:03:54 +01:00
|
|
|
series() {
|
2022-04-30 19:24:48 +02:00
|
|
|
// Only included when filtering by series or collapse series or Continue Series shelf on home page
|
2022-03-11 01:45:02 +01:00
|
|
|
return this.mediaMetadata.series
|
2022-01-25 01:03:54 +01:00
|
|
|
},
|
2022-04-10 02:44:46 +02:00
|
|
|
seriesSequence() {
|
|
|
|
return this.series ? this.series.sequence : null
|
|
|
|
},
|
2022-01-25 01:03:54 +01:00
|
|
|
libraryId() {
|
2022-03-11 01:45:02 +01:00
|
|
|
return this._libraryItem.libraryId
|
2022-01-25 01:03:54 +01:00
|
|
|
},
|
2021-11-29 02:36:44 +01:00
|
|
|
hasEbook() {
|
2022-04-13 15:26:43 +02:00
|
|
|
return this.media.ebookFormat
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
2022-03-26 17:59:34 +01:00
|
|
|
numTracks() {
|
|
|
|
if (this.media.tracks) return this.media.tracks.length
|
|
|
|
return this.media.numTracks || 0 // toJSONMinified
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
2022-04-10 02:44:46 +02:00
|
|
|
numEpisodes() {
|
|
|
|
if (!this.isPodcast) return 0
|
|
|
|
return this.media.numEpisodes || 0
|
|
|
|
},
|
2021-11-29 02:36:44 +01:00
|
|
|
processingBatch() {
|
|
|
|
return this.store.state.processingBatch
|
|
|
|
},
|
2022-04-23 02:31:11 +02:00
|
|
|
recentEpisode() {
|
|
|
|
// Only added to item when getting currently listening podcasts
|
|
|
|
return this._libraryItem.recentEpisode
|
|
|
|
},
|
|
|
|
recentEpisodeNumber() {
|
|
|
|
if (!this.recentEpisode) return null
|
|
|
|
if (this.recentEpisode.episode) {
|
|
|
|
return this.recentEpisode.episode.replace(/^#/, '')
|
|
|
|
}
|
|
|
|
return this.recentEpisode.index
|
|
|
|
},
|
2022-04-10 02:44:46 +02:00
|
|
|
collapsedSeries() {
|
|
|
|
// Only added to item object when collapseSeries is enabled
|
|
|
|
return this._libraryItem.collapsedSeries
|
|
|
|
},
|
2022-01-25 01:03:54 +01:00
|
|
|
booksInSeries() {
|
2022-03-26 17:59:34 +01:00
|
|
|
// Only added to item object when collapseSeries is enabled
|
2022-04-10 02:44:46 +02:00
|
|
|
return this.collapsedSeries ? this.collapsedSeries.numBooks : 0
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
2021-12-02 02:07:03 +01:00
|
|
|
hasCover() {
|
2022-03-11 01:45:02 +01:00
|
|
|
return !!this.media.coverPath
|
2021-12-02 02:07:03 +01:00
|
|
|
},
|
2021-12-02 22:49:03 +01:00
|
|
|
squareAspectRatio() {
|
|
|
|
return this.bookCoverAspectRatio === 1
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
|
|
|
sizeMultiplier() {
|
2021-12-02 22:49:03 +01:00
|
|
|
var baseSize = this.squareAspectRatio ? 192 : 120
|
|
|
|
return this.width / baseSize
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
|
|
|
title() {
|
2022-03-11 01:45:02 +01:00
|
|
|
return this.mediaMetadata.title || ''
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
|
|
|
playIconFontSize() {
|
|
|
|
return Math.max(2, 3 * this.sizeMultiplier)
|
|
|
|
},
|
2022-03-11 01:45:02 +01:00
|
|
|
author() {
|
2022-03-26 21:23:25 +01:00
|
|
|
if (this.isPodcast) return this.mediaMetadata.author
|
2022-03-31 22:07:50 +02:00
|
|
|
return this.mediaMetadata.authorName
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
|
|
|
authorLF() {
|
2022-03-31 22:07:50 +02:00
|
|
|
return this.mediaMetadata.authorNameLF
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
2022-02-14 23:01:53 +01:00
|
|
|
displayTitle() {
|
2022-07-03 02:15:23 +02:00
|
|
|
if (this.recentEpisode) return this.recentEpisode.title
|
2022-03-31 22:07:50 +02:00
|
|
|
if (this.orderBy === 'media.metadata.title' && this.sortingIgnorePrefix) {
|
|
|
|
return this.mediaMetadata.titleIgnorePrefix
|
2022-02-14 23:01:53 +01:00
|
|
|
}
|
|
|
|
return this.title
|
|
|
|
},
|
2022-05-09 01:54:41 +02:00
|
|
|
displayLineTwo() {
|
2022-07-03 02:15:23 +02:00
|
|
|
if (this.recentEpisode) return this.title
|
2022-03-26 21:23:25 +01:00
|
|
|
if (this.isPodcast) return this.author
|
2022-05-09 01:54:41 +02:00
|
|
|
if (this.isAuthorBookshelfView) {
|
|
|
|
return this.mediaMetadata.publishedYear || ''
|
|
|
|
}
|
2022-03-17 18:25:12 +01:00
|
|
|
if (this.orderBy === 'media.metadata.authorNameLF') return this.authorLF
|
2022-03-11 01:45:02 +01:00
|
|
|
return this.author
|
2022-02-14 23:01:53 +01:00
|
|
|
},
|
|
|
|
displaySortLine() {
|
2022-06-17 10:35:24 +02:00
|
|
|
if (this.orderBy === 'mtimeMs') return 'Modified ' + this.$formatDate(this._libraryItem.mtimeMs, this.dateFormat)
|
|
|
|
if (this.orderBy === 'birthtimeMs') return 'Born ' + this.$formatDate(this._libraryItem.birthtimeMs, this.dateFormat)
|
|
|
|
if (this.orderBy === 'addedAt') return 'Added ' + this.$formatDate(this._libraryItem.addedAt, this.dateFormat)
|
2022-05-04 00:50:19 +02:00
|
|
|
if (this.orderBy === 'media.duration') return 'Duration: ' + this.$elapsedPrettyExtended(this.media.duration, false)
|
2022-03-11 01:45:02 +01:00
|
|
|
if (this.orderBy === 'size') return 'Size: ' + this.$bytesPretty(this._libraryItem.size)
|
2022-05-04 00:50:19 +02:00
|
|
|
if (this.orderBy === 'media.numTracks') return `${this.numEpisodes} Episodes`
|
2022-02-14 23:01:53 +01:00
|
|
|
return null
|
|
|
|
},
|
2022-04-23 02:31:11 +02:00
|
|
|
episodeProgress() {
|
|
|
|
// Only used on home page currently listening podcast shelf
|
|
|
|
if (!this.recentEpisode) return null
|
|
|
|
return this.store.getters['user/getUserMediaProgress'](this.libraryItemId, this.recentEpisode.id)
|
|
|
|
},
|
2021-11-29 02:36:44 +01:00
|
|
|
userProgress() {
|
2022-04-23 02:31:11 +02:00
|
|
|
if (this.episodeProgress) return this.episodeProgress
|
2022-03-26 17:59:34 +01:00
|
|
|
return this.store.getters['user/getUserMediaProgress'](this.libraryItemId)
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
|
|
|
userProgressPercent() {
|
|
|
|
return this.userProgress ? this.userProgress.progress || 0 : 0
|
|
|
|
},
|
2022-03-17 18:25:12 +01:00
|
|
|
itemIsFinished() {
|
|
|
|
return this.userProgress ? !!this.userProgress.isFinished : false
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
|
|
|
showError() {
|
2022-04-25 00:03:43 +02:00
|
|
|
if (this.recentEpisode) return false // Dont show podcast error on episode card
|
2022-04-25 01:05:15 +02:00
|
|
|
return this.numInvalidAudioFiles || this.numMissingParts || this.isMissing || this.isInvalid
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
|
|
|
isStreaming() {
|
2022-03-11 01:45:02 +01:00
|
|
|
return this.store.getters['getlibraryItemIdStreaming'] === this.libraryItemId
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
|
|
|
showReadButton() {
|
2022-05-20 23:34:51 +02:00
|
|
|
return !this.isSelectionMode && !this.showPlayButton && this.hasEbook && (this.showExperimentalFeatures || this.enableEReader)
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
|
|
|
showPlayButton() {
|
2022-04-23 02:31:11 +02:00
|
|
|
return !this.isSelectionMode && !this.isMissing && !this.isInvalid && !this.isStreaming && (this.numTracks || this.recentEpisode)
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
|
|
|
showSmallEBookIcon() {
|
2022-05-20 23:34:51 +02:00
|
|
|
return !this.isSelectionMode && this.hasEbook && (this.showExperimentalFeatures || this.enableEReader)
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
|
|
|
isMissing() {
|
2022-03-11 01:45:02 +01:00
|
|
|
return this._libraryItem.isMissing
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
2021-12-02 02:07:03 +01:00
|
|
|
isInvalid() {
|
2022-03-11 01:45:02 +01:00
|
|
|
return this._libraryItem.isInvalid
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
2022-04-24 02:41:06 +02:00
|
|
|
numMissingParts() {
|
|
|
|
if (this.isPodcast) return 0
|
|
|
|
return this.media.numMissingParts
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
2022-04-25 01:05:15 +02:00
|
|
|
numInvalidAudioFiles() {
|
|
|
|
if (this.isPodcast) return 0
|
|
|
|
return this.media.numInvalidAudioFiles
|
|
|
|
},
|
2021-11-29 02:36:44 +01:00
|
|
|
errorText() {
|
2022-03-26 17:59:34 +01:00
|
|
|
if (this.isMissing) return 'Item directory is missing!'
|
2022-04-24 02:41:06 +02:00
|
|
|
else if (this.isInvalid) {
|
|
|
|
if (this.isPodcast) return 'Podcast has no episodes'
|
|
|
|
return 'Item has no audio tracks & ebook'
|
2021-11-29 02:36:44 +01:00
|
|
|
}
|
2022-04-24 02:41:06 +02:00
|
|
|
var txt = ''
|
|
|
|
if (this.numMissingParts) {
|
2022-04-25 01:05:15 +02:00
|
|
|
txt += `${this.numMissingParts} missing parts.`
|
|
|
|
}
|
|
|
|
if (this.numInvalidAudioFiles) {
|
|
|
|
if (txt) txt += ' '
|
|
|
|
txt += `${this.numInvalidAudioFiles} invalid audio files.`
|
2021-11-29 02:36:44 +01:00
|
|
|
}
|
|
|
|
return txt || 'Unknown Error'
|
|
|
|
},
|
|
|
|
overlayWrapperClasslist() {
|
|
|
|
var classes = []
|
|
|
|
if (this.isSelectionMode) classes.push('bg-opacity-60')
|
|
|
|
else classes.push('bg-opacity-40')
|
|
|
|
if (this.selected) {
|
|
|
|
classes.push('border-2 border-yellow-400')
|
|
|
|
}
|
|
|
|
return classes
|
|
|
|
},
|
|
|
|
store() {
|
|
|
|
return this.$store || this.$nuxt.$store
|
|
|
|
},
|
|
|
|
userCanUpdate() {
|
|
|
|
return this.store.getters['user/getUserCanUpdate']
|
|
|
|
},
|
|
|
|
userCanDelete() {
|
|
|
|
return this.store.getters['user/getUserCanDelete']
|
|
|
|
},
|
|
|
|
userCanDownload() {
|
|
|
|
return this.store.getters['user/getUserCanDownload']
|
|
|
|
},
|
2022-05-04 02:16:16 +02:00
|
|
|
userIsAdminOrUp() {
|
2022-05-06 01:12:27 +02:00
|
|
|
return this.store.getters['user/getIsAdminOrUp']
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
|
|
|
moreMenuItems() {
|
2022-05-04 00:21:22 +02:00
|
|
|
if (this.recentEpisode) {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
func: 'editPodcast',
|
|
|
|
text: 'Edit Podcast'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
func: 'toggleFinished',
|
|
|
|
text: `Mark as ${this.itemIsFinished ? 'Not Finished' : 'Finished'}`
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2022-03-26 21:23:25 +01:00
|
|
|
var items = []
|
|
|
|
if (!this.isPodcast) {
|
|
|
|
items = [
|
|
|
|
{
|
|
|
|
func: 'toggleFinished',
|
|
|
|
text: `Mark as ${this.itemIsFinished ? 'Not Finished' : 'Finished'}`
|
|
|
|
},
|
|
|
|
{
|
|
|
|
func: 'openCollections',
|
|
|
|
text: 'Add to Collection'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2021-11-29 02:36:44 +01:00
|
|
|
if (this.userCanUpdate) {
|
2022-03-26 21:23:25 +01:00
|
|
|
items.push({
|
2022-03-27 01:00:55 +01:00
|
|
|
func: 'showEditModalFiles',
|
2022-03-26 21:23:25 +01:00
|
|
|
text: 'Files'
|
|
|
|
})
|
2021-11-29 02:36:44 +01:00
|
|
|
items.push({
|
|
|
|
func: 'showEditModalMatch',
|
|
|
|
text: 'Match'
|
|
|
|
})
|
|
|
|
}
|
2022-05-04 02:16:16 +02:00
|
|
|
if (this.userIsAdminOrUp && !this.isFile) {
|
2021-11-29 02:36:44 +01:00
|
|
|
items.push({
|
|
|
|
func: 'rescan',
|
|
|
|
text: 'Re-Scan'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
return items
|
2021-12-02 02:07:03 +01:00
|
|
|
},
|
|
|
|
_socket() {
|
|
|
|
return this.$root.socket || this.$nuxt.$root.socket
|
|
|
|
},
|
|
|
|
titleFontSize() {
|
|
|
|
return 0.75 * this.sizeMultiplier
|
|
|
|
},
|
|
|
|
authorFontSize() {
|
|
|
|
return 0.6 * this.sizeMultiplier
|
|
|
|
},
|
|
|
|
placeholderCoverPadding() {
|
|
|
|
return 0.8 * this.sizeMultiplier
|
|
|
|
},
|
|
|
|
authorBottom() {
|
|
|
|
return 0.75 * this.sizeMultiplier
|
|
|
|
},
|
|
|
|
titleCleaned() {
|
|
|
|
if (!this.title) return ''
|
|
|
|
if (this.title.length > 60) {
|
|
|
|
return this.title.slice(0, 57) + '...'
|
|
|
|
}
|
|
|
|
return this.title
|
|
|
|
},
|
|
|
|
authorCleaned() {
|
2022-03-11 01:45:02 +01:00
|
|
|
if (!this.author) return ''
|
|
|
|
if (this.author.length > 30) {
|
|
|
|
return this.author.slice(0, 27) + '...'
|
2021-12-02 02:07:03 +01:00
|
|
|
}
|
2022-03-11 01:45:02 +01:00
|
|
|
return this.author
|
2021-12-28 22:50:17 +01:00
|
|
|
},
|
|
|
|
isAlternativeBookshelfView() {
|
|
|
|
var constants = this.$constants || this.$nuxt.$constants
|
|
|
|
return this.bookshelfView === constants.BookshelfView.TITLES
|
2022-02-14 23:01:53 +01:00
|
|
|
},
|
2022-05-09 01:54:41 +02:00
|
|
|
isAuthorBookshelfView() {
|
|
|
|
var constants = this.$constants || this.$nuxt.$constants
|
|
|
|
return this.bookshelfView === constants.BookshelfView.AUTHOR
|
|
|
|
},
|
2022-02-14 23:01:53 +01:00
|
|
|
titleDisplayBottomOffset() {
|
2022-05-09 01:54:41 +02:00
|
|
|
if (!this.isAlternativeBookshelfView && !this.isAuthorBookshelfView) return 0
|
2022-02-14 23:01:53 +01:00
|
|
|
else if (!this.displaySortLine) return 3 * this.sizeMultiplier
|
|
|
|
return 4.25 * this.sizeMultiplier
|
2021-11-29 02:36:44 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2021-12-01 03:02:40 +01:00
|
|
|
setSelectionMode(val) {
|
|
|
|
this.isSelectionMode = val
|
|
|
|
if (!val) this.selected = false
|
|
|
|
},
|
2022-05-13 23:26:34 +02:00
|
|
|
setEntity(_libraryItem) {
|
|
|
|
var libraryItem = _libraryItem
|
|
|
|
|
|
|
|
// this code block is only necessary when showing a selected series with sequence #
|
|
|
|
// it will update the selected series so we get realtime updates for series sequence changes
|
|
|
|
if (this.series) {
|
|
|
|
// i know.. but the libraryItem passed to this func cannot be modified so we need to create a copy
|
|
|
|
libraryItem = {
|
|
|
|
..._libraryItem,
|
|
|
|
media: {
|
|
|
|
..._libraryItem.media,
|
|
|
|
metadata: {
|
|
|
|
..._libraryItem.media.metadata
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var mediaMetadata = libraryItem.media.metadata
|
|
|
|
if (mediaMetadata.series) {
|
|
|
|
var newSeries = mediaMetadata.series.find((se) => se.id === this.series.id)
|
|
|
|
if (newSeries) {
|
|
|
|
// update selected series
|
|
|
|
libraryItem.media.metadata.series = newSeries
|
|
|
|
this.libraryItem = libraryItem
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-26 17:59:34 +01:00
|
|
|
this.libraryItem = libraryItem
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
|
|
|
clickCard(e) {
|
|
|
|
if (this.isSelectionMode) {
|
|
|
|
e.stopPropagation()
|
|
|
|
e.preventDefault()
|
|
|
|
this.selectBtnClick()
|
2021-12-01 03:02:40 +01:00
|
|
|
} else {
|
|
|
|
var router = this.$router || this.$nuxt.$router
|
2022-01-25 01:03:54 +01:00
|
|
|
if (router) {
|
2022-04-10 02:44:46 +02:00
|
|
|
if (this.collapsedSeries) router.push(`/library/${this.libraryId}/series/${this.collapsedSeries.id}`)
|
2022-03-11 01:45:02 +01:00
|
|
|
else router.push(`/item/${this.libraryItemId}`)
|
2022-01-25 01:03:54 +01:00
|
|
|
}
|
2021-11-29 02:36:44 +01:00
|
|
|
}
|
|
|
|
},
|
2021-12-01 03:02:40 +01:00
|
|
|
editClick() {
|
2022-04-23 02:31:11 +02:00
|
|
|
if (this.recentEpisode) {
|
|
|
|
return this.$emit('edit', { libraryItem: this.libraryItem, episode: this.recentEpisode })
|
|
|
|
}
|
2022-03-26 17:59:34 +01:00
|
|
|
this.$emit('edit', this.libraryItem)
|
2021-12-01 03:02:40 +01:00
|
|
|
},
|
2022-03-17 19:33:22 +01:00
|
|
|
toggleFinished() {
|
2021-12-01 03:02:40 +01:00
|
|
|
var updatePayload = {
|
2022-03-17 18:25:12 +01:00
|
|
|
isFinished: !this.itemIsFinished
|
2021-12-01 03:02:40 +01:00
|
|
|
}
|
|
|
|
this.isProcessingReadUpdate = true
|
2022-05-04 00:21:22 +02:00
|
|
|
|
|
|
|
var apiEndpoint = `/api/me/progress/${this.libraryItemId}`
|
|
|
|
if (this.recentEpisode) apiEndpoint += `/${this.recentEpisode.id}`
|
|
|
|
|
2021-12-01 03:02:40 +01:00
|
|
|
var toast = this.$toast || this.$nuxt.$toast
|
|
|
|
var axios = this.$axios || this.$nuxt.$axios
|
|
|
|
axios
|
2022-05-04 00:21:22 +02:00
|
|
|
.$patch(apiEndpoint, updatePayload)
|
2021-12-01 03:02:40 +01:00
|
|
|
.then(() => {
|
|
|
|
this.isProcessingReadUpdate = false
|
2022-03-17 19:33:22 +01:00
|
|
|
toast.success(`Item marked as ${updatePayload.isFinished ? 'Finished' : 'Not Finished'}`)
|
2021-12-01 03:02:40 +01:00
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
console.error('Failed', error)
|
|
|
|
this.isProcessingReadUpdate = false
|
2022-03-17 19:33:22 +01:00
|
|
|
toast.error(`Failed to mark as ${updatePayload.isFinished ? 'Finished' : 'Not Finished'}`)
|
2021-12-01 03:02:40 +01:00
|
|
|
})
|
|
|
|
},
|
2022-05-04 00:21:22 +02:00
|
|
|
editPodcast() {
|
|
|
|
this.$emit('editPodcast', this.libraryItem)
|
|
|
|
},
|
2021-12-01 03:02:40 +01:00
|
|
|
rescan() {
|
|
|
|
this.rescanning = true
|
2022-03-18 17:51:55 +01:00
|
|
|
this.$axios
|
|
|
|
.$get(`/api/items/${this.libraryItemId}/scan`)
|
|
|
|
.then((data) => {
|
|
|
|
this.rescanning = false
|
|
|
|
var result = data.result
|
|
|
|
if (!result) {
|
|
|
|
this.$toast.error(`Re-Scan Failed for "${this.title}"`)
|
|
|
|
} else if (result === 'UPDATED') {
|
|
|
|
this.$toast.success(`Re-Scan complete item was updated`)
|
|
|
|
} else if (result === 'UPTODATE') {
|
|
|
|
this.$toast.success(`Re-Scan complete item was up to date`)
|
|
|
|
} else if (result === 'REMOVED') {
|
|
|
|
this.$toast.error(`Re-Scan complete item was removed`)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
console.error('Failed to scan library item', error)
|
|
|
|
this.$toast.error('Failed to scan library item')
|
|
|
|
this.rescanning = false
|
|
|
|
})
|
2021-12-01 03:02:40 +01:00
|
|
|
},
|
2022-03-27 01:00:55 +01:00
|
|
|
showEditModalFiles() {
|
2021-12-01 03:02:40 +01:00
|
|
|
// More menu func
|
2022-03-27 01:00:55 +01:00
|
|
|
this.store.commit('showEditModalOnTab', { libraryItem: this.libraryItem, tab: 'files' })
|
2021-12-01 03:02:40 +01:00
|
|
|
},
|
|
|
|
showEditModalMatch() {
|
|
|
|
// More menu func
|
2022-03-26 17:59:34 +01:00
|
|
|
this.store.commit('showEditModalOnTab', { libraryItem: this.libraryItem, tab: 'match' })
|
2021-12-01 03:02:40 +01:00
|
|
|
},
|
|
|
|
openCollections() {
|
2022-03-26 17:59:34 +01:00
|
|
|
this.store.commit('setSelectedLibraryItem', this.libraryItem)
|
2021-12-01 03:02:40 +01:00
|
|
|
this.store.commit('globals/setShowUserCollectionsModal', true)
|
|
|
|
},
|
|
|
|
createMoreMenu() {
|
|
|
|
if (!this.$refs.moreIcon) return
|
|
|
|
|
|
|
|
var ComponentClass = Vue.extend(MoreMenu)
|
|
|
|
|
|
|
|
var _this = this
|
|
|
|
var instance = new ComponentClass({
|
|
|
|
propsData: {
|
|
|
|
items: this.moreMenuItems
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.$on('action', (func) => {
|
|
|
|
if (_this[func]) _this[func]()
|
|
|
|
})
|
|
|
|
this.$on('close', () => {
|
|
|
|
_this.isMoreMenuOpen = false
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
instance.$mount()
|
|
|
|
|
|
|
|
var wrapperBox = this.$refs.moreIcon.getBoundingClientRect()
|
|
|
|
var el = instance.$el
|
|
|
|
|
|
|
|
var elHeight = this.moreMenuItems.length * 28 + 2
|
|
|
|
var elWidth = 130
|
|
|
|
|
|
|
|
var bottomOfIcon = wrapperBox.top + wrapperBox.height
|
|
|
|
var rightOfIcon = wrapperBox.left + wrapperBox.width
|
|
|
|
|
|
|
|
var elTop = bottomOfIcon
|
|
|
|
var elLeft = rightOfIcon
|
|
|
|
if (bottomOfIcon + elHeight > window.innerHeight - 100) {
|
|
|
|
elTop = wrapperBox.top - elHeight
|
|
|
|
elLeft = wrapperBox.left
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rightOfIcon + elWidth > window.innerWidth - 100) {
|
|
|
|
elLeft = rightOfIcon - elWidth
|
|
|
|
}
|
|
|
|
|
|
|
|
el.style.top = elTop + 'px'
|
|
|
|
el.style.left = elLeft + 'px'
|
|
|
|
|
|
|
|
this.isMoreMenuOpen = true
|
|
|
|
document.body.appendChild(el)
|
|
|
|
},
|
|
|
|
clickShowMore() {
|
|
|
|
this.createMoreMenu()
|
|
|
|
},
|
2022-04-13 15:26:43 +02:00
|
|
|
async clickReadEBook() {
|
|
|
|
var libraryItem = await this.$axios.$get(`/api/items/${this.libraryItemId}?expanded=1`).catch((error) => {
|
|
|
|
console.error('Failed to get lirbary item', this.libraryItemId)
|
|
|
|
return null
|
|
|
|
})
|
|
|
|
if (!libraryItem) return
|
|
|
|
console.log('Got library itemn', libraryItem)
|
|
|
|
this.store.commit('showEReader', libraryItem)
|
2021-12-02 02:07:03 +01:00
|
|
|
},
|
2021-11-29 02:36:44 +01:00
|
|
|
selectBtnClick() {
|
|
|
|
if (this.processingBatch) return
|
2021-12-01 03:02:40 +01:00
|
|
|
this.selected = !this.selected
|
2022-03-26 17:59:34 +01:00
|
|
|
this.$emit('select', this.libraryItem)
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
2021-12-02 02:07:03 +01:00
|
|
|
play() {
|
2022-02-23 00:33:55 +01:00
|
|
|
var eventBus = this.$eventBus || this.$nuxt.$eventBus
|
2022-03-26 23:41:26 +01:00
|
|
|
eventBus.$emit('play-item', {
|
2022-04-23 02:31:11 +02:00
|
|
|
libraryItemId: this.libraryItemId,
|
|
|
|
episodeId: this.recentEpisode ? this.recentEpisode.id : null
|
2022-03-26 23:41:26 +01:00
|
|
|
})
|
2021-11-29 02:36:44 +01:00
|
|
|
},
|
|
|
|
mouseover() {
|
|
|
|
this.isHovering = true
|
|
|
|
},
|
2021-12-01 03:02:40 +01:00
|
|
|
mouseleave() {
|
|
|
|
this.isHovering = false
|
|
|
|
},
|
2021-11-29 02:36:44 +01:00
|
|
|
destroy() {
|
|
|
|
// destroy the vue listeners, etc
|
|
|
|
this.$destroy()
|
|
|
|
|
|
|
|
// remove the element from the DOM
|
2021-12-01 03:02:40 +01:00
|
|
|
if (this.$el && this.$el.parentNode) {
|
|
|
|
this.$el.parentNode.removeChild(this.$el)
|
|
|
|
} else if (this.$el && this.$el.remove) {
|
|
|
|
this.$el.remove()
|
|
|
|
}
|
|
|
|
},
|
2021-12-02 02:07:03 +01:00
|
|
|
setCoverBg() {
|
|
|
|
if (this.$refs.coverBg) {
|
|
|
|
this.$refs.coverBg.style.backgroundImage = `url("${this.bookCoverSrc}")`
|
|
|
|
}
|
|
|
|
},
|
2021-12-01 03:02:40 +01:00
|
|
|
imageLoaded() {
|
|
|
|
this.imageReady = true
|
2021-12-02 02:07:03 +01:00
|
|
|
|
|
|
|
if (this.$refs.cover && this.bookCoverSrc !== this.placeholderUrl) {
|
|
|
|
var { naturalWidth, naturalHeight } = this.$refs.cover
|
|
|
|
var aspectRatio = naturalHeight / naturalWidth
|
2021-12-02 22:49:03 +01:00
|
|
|
var arDiff = Math.abs(aspectRatio - this.bookCoverAspectRatio)
|
2021-12-02 02:07:03 +01:00
|
|
|
|
|
|
|
// If image aspect ratio is <= 1.45 or >= 1.75 then use cover bg, otherwise stretch to fit
|
|
|
|
if (arDiff > 0.15) {
|
|
|
|
this.showCoverBg = true
|
|
|
|
this.$nextTick(this.setCoverBg)
|
|
|
|
} else {
|
|
|
|
this.showCoverBg = false
|
|
|
|
}
|
|
|
|
}
|
2021-11-29 02:36:44 +01:00
|
|
|
}
|
2021-12-18 03:52:11 +01:00
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
if (this.bookMount) {
|
|
|
|
this.setEntity(this.bookMount)
|
|
|
|
}
|
2021-12-04 00:05:13 +01:00
|
|
|
}
|
2021-11-29 02:36:44 +01:00
|
|
|
}
|
2021-12-04 00:05:13 +01:00
|
|
|
</script>
|