2021-08-18 00:01:11 +02:00
|
|
|
<template>
|
2021-08-26 16:47:51 +02:00
|
|
|
<div id="page-wrapper" class="bg-bg page overflow-hidden" :class="streamAudiobook ? 'streaming' : ''">
|
2021-11-04 23:35:59 +01:00
|
|
|
<div class="w-full h-full overflow-y-auto px-2 py-6 md:p-8">
|
2022-02-09 18:19:02 +01:00
|
|
|
<div class="flex flex-col md:flex-row max-w-6xl mx-auto">
|
|
|
|
<div class="w-full flex justify-center md:block md:w-52" style="min-width: 208px">
|
2021-11-04 23:35:59 +01:00
|
|
|
<div class="relative" style="height: fit-content">
|
2021-12-03 02:02:38 +01:00
|
|
|
<covers-book-cover :audiobook="audiobook" :width="bookCoverWidth" :book-cover-aspect-ratio="bookCoverAspectRatio" />
|
2022-01-02 19:20:39 +01:00
|
|
|
<div class="absolute bottom-0 left-0 h-1.5 bg-yellow-400 shadow-sm z-10" :class="userIsRead ? 'bg-success' : 'bg-yellow-400'" :style="{ width: 208 * progressPercent + 'px' }"></div>
|
2021-08-18 00:01:11 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-11-04 23:35:59 +01:00
|
|
|
<div class="flex-grow px-2 py-6 md:py-0 md:px-10">
|
2022-02-09 18:19:02 +01:00
|
|
|
<div class="flex justify-center">
|
2021-10-07 04:08:52 +02:00
|
|
|
<div class="mb-4">
|
2021-11-04 23:35:59 +01:00
|
|
|
<div class="flex sm:items-end flex-col sm:flex-row">
|
|
|
|
<h1 class="text-2xl md:text-3xl font-sans">
|
2021-10-31 02:12:36 +01:00
|
|
|
{{ title }}
|
2021-10-07 04:08:52 +02:00
|
|
|
</h1>
|
2021-11-04 23:35:59 +01:00
|
|
|
<p v-if="subtitle" class="sm:ml-4 text-gray-400 text-xl md:text-2xl">{{ subtitle }}</p>
|
2021-10-07 04:08:52 +02:00
|
|
|
</div>
|
2021-11-04 23:35:59 +01:00
|
|
|
<!-- <p v-if="subtitle" class="ml-4 text-gray-400 text-2xl block sm:hidden">{{ subtitle }}</p> -->
|
|
|
|
|
|
|
|
<p v-if="authorFL" class="mb-2 mt-0.5 text-gray-200 text-lg md:text-xl">
|
2021-10-31 22:40:27 +01:00
|
|
|
by <nuxt-link v-for="(author, index) in authorsList" :key="index" :to="`/library/${libraryId}/bookshelf?filter=authors.${$encode(author)}`" class="hover:underline">{{ author }}<span v-if="index < authorsList.length - 1">, </span></nuxt-link>
|
2021-10-07 04:08:52 +02:00
|
|
|
</p>
|
2021-10-31 22:40:27 +01:00
|
|
|
<p v-else class="mb-2 mt-0.5 text-gray-200 text-xl">by Unknown</p>
|
2021-12-04 01:07:42 +01:00
|
|
|
<nuxt-link v-if="series" :to="`/library/${libraryId}/series/${$encode(series)}`" class="hover:underline font-sans text-gray-300 text-lg leading-7"> {{ seriesText }}</nuxt-link>
|
2021-10-07 04:08:52 +02:00
|
|
|
|
2021-11-04 23:35:59 +01:00
|
|
|
<div v-if="narrator" class="flex py-0.5 mt-4">
|
2021-10-07 04:08:52 +02:00
|
|
|
<div class="w-32">
|
|
|
|
<span class="text-white text-opacity-60 uppercase text-sm">Narrated By</span>
|
|
|
|
</div>
|
|
|
|
<div>
|
2021-11-17 23:13:16 +01:00
|
|
|
<template v-for="(narrator, index) in narrators">
|
|
|
|
<nuxt-link :key="narrator" :to="`/library/${libraryId}/bookshelf?filter=narrators.${$encode(narrator)}`" class="hover:underline">{{ narrator }}</nuxt-link
|
|
|
|
><span :key="index" v-if="index < narrators.length - 1">, </span>
|
|
|
|
</template>
|
|
|
|
<!-- <nuxt-link :to="`/library/${libraryId}/bookshelf?filter=narrators.${$encode(narrator)}`" class="hover:underline">{{ narrator }}</nuxt-link> -->
|
2021-10-07 04:08:52 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div v-if="publishYear" class="flex py-0.5">
|
|
|
|
<div class="w-32">
|
|
|
|
<span class="text-white text-opacity-60 uppercase text-sm">Publish Year</span>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
{{ publishYear }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="flex py-0.5" v-if="genres.length">
|
|
|
|
<div class="w-32">
|
|
|
|
<span class="text-white text-opacity-60 uppercase text-sm">Genres</span>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<template v-for="(genre, index) in genres">
|
|
|
|
<nuxt-link :key="genre" :to="`/library/${libraryId}/bookshelf?filter=genres.${$encode(genre)}`" class="hover:underline">{{ genre }}</nuxt-link
|
|
|
|
><span :key="index" v-if="index < genres.length - 1">, </span>
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-10-10 23:36:21 +02:00
|
|
|
<div v-if="tracks.length" class="flex py-0.5">
|
2021-10-07 04:08:52 +02:00
|
|
|
<div class="w-32">
|
|
|
|
<span class="text-white text-opacity-60 uppercase text-sm">Duration</span>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
{{ durationPretty }}
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-10-10 23:36:21 +02:00
|
|
|
<div v-if="tracks.length" class="flex py-0.5">
|
2021-10-07 04:08:52 +02:00
|
|
|
<div class="w-32">
|
|
|
|
<span class="text-white text-opacity-60 uppercase text-sm">Size</span>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
{{ sizePretty }}
|
|
|
|
</div>
|
2021-09-18 19:45:34 +02:00
|
|
|
</div>
|
2021-08-25 03:24:40 +02:00
|
|
|
</div>
|
2022-02-09 18:19:02 +01:00
|
|
|
<div class="hidden md:block flex-grow" />
|
2021-08-18 00:01:11 +02:00
|
|
|
</div>
|
2021-10-10 23:36:21 +02:00
|
|
|
|
|
|
|
<!-- Alerts -->
|
|
|
|
<div v-show="showExperimentalReadAlert" class="bg-error p-4 rounded-xl flex items-center">
|
|
|
|
<span class="material-icons text-2xl">warning_amber</span>
|
|
|
|
<p class="ml-4">Book has no audio tracks but has valid ebook files. The e-reader is experimental and can be turned on in config.</p>
|
|
|
|
</div>
|
|
|
|
|
2022-02-09 18:19:02 +01:00
|
|
|
<div v-if="progressPercent > 0 && progressPercent < 1" class="px-4 py-2 mt-4 bg-primary text-sm font-semibold rounded-md text-gray-200 relative max-w-max mx-auto md:mx-0" :class="resettingProgress ? 'opacity-25' : ''">
|
2021-09-06 21:13:01 +02:00
|
|
|
<p class="leading-6">Your Progress: {{ Math.round(progressPercent * 100) }}%</p>
|
|
|
|
<p class="text-gray-400 text-xs">{{ $elapsedPretty(userTimeRemaining) }} remaining</p>
|
|
|
|
<div v-if="!resettingProgress" class="absolute -top-1.5 -right-1.5 p-1 w-5 h-5 rounded-full bg-bg hover:bg-error border border-primary flex items-center justify-center cursor-pointer" @click.stop="clearProgressClick">
|
|
|
|
<span class="material-icons text-sm">close</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2022-02-09 18:19:02 +01:00
|
|
|
<div class="flex items-center justify-center md:justify-start pt-4">
|
2021-10-10 23:36:21 +02:00
|
|
|
<ui-btn v-if="showPlayButton" :disabled="streaming" color="success" :padding-x="4" small class="flex items-center h-9 mr-2" @click="startStream">
|
2021-09-04 21:17:26 +02:00
|
|
|
<span v-show="!streaming" class="material-icons -ml-2 pr-1 text-white">play_arrow</span>
|
|
|
|
{{ streaming ? 'Streaming' : 'Play' }}
|
2021-08-18 00:01:11 +02:00
|
|
|
</ui-btn>
|
2021-12-02 02:07:03 +01:00
|
|
|
<ui-btn v-else-if="isMissing || isInvalid" color="error" :padding-x="4" small class="flex items-center h-9 mr-2">
|
2021-09-18 01:40:30 +02:00
|
|
|
<span v-show="!streaming" class="material-icons -ml-2 pr-1 text-white">error</span>
|
2021-10-10 23:36:21 +02:00
|
|
|
{{ isMissing ? 'Missing' : 'Incomplete' }}
|
2021-09-18 01:40:30 +02:00
|
|
|
</ui-btn>
|
2021-09-06 21:13:01 +02:00
|
|
|
|
2021-10-17 03:33:49 +02:00
|
|
|
<ui-btn v-if="showExperimentalFeatures && numEbooks" color="info" :padding-x="4" small class="flex items-center h-9 mr-2" @click="openEbook">
|
2021-09-27 13:52:21 +02:00
|
|
|
<span class="material-icons -ml-2 pr-2 text-white">auto_stories</span>
|
|
|
|
Read
|
2021-10-02 20:50:39 +02:00
|
|
|
</ui-btn>
|
2021-09-27 13:52:21 +02:00
|
|
|
|
2021-09-07 00:42:15 +02:00
|
|
|
<ui-tooltip v-if="userCanUpdate" text="Edit" direction="top">
|
2021-09-06 21:13:01 +02:00
|
|
|
<ui-icon-btn icon="edit" class="mx-0.5" @click="editClick" />
|
|
|
|
</ui-tooltip>
|
|
|
|
|
2021-09-18 01:40:30 +02:00
|
|
|
<ui-tooltip v-if="userCanDownload" :disabled="isMissing" text="Download" direction="top">
|
|
|
|
<ui-icon-btn icon="download" :disabled="isMissing" class="mx-0.5" @click="downloadClick" />
|
2021-09-06 21:13:01 +02:00
|
|
|
</ui-tooltip>
|
|
|
|
|
|
|
|
<ui-tooltip :text="isRead ? 'Mark as Not Read' : 'Mark as Read'" direction="top">
|
|
|
|
<ui-read-icon-btn :disabled="isProcessingReadUpdate" :is-read="isRead" class="mx-0.5" @click="toggleRead" />
|
|
|
|
</ui-tooltip>
|
2021-08-18 00:01:11 +02:00
|
|
|
|
2021-11-13 23:06:32 +01:00
|
|
|
<ui-tooltip text="Collections" direction="top">
|
2021-11-06 02:24:02 +01:00
|
|
|
<ui-icon-btn icon="collections_bookmark" class="mx-0.5" outlined @click="collectionsClick" />
|
|
|
|
</ui-tooltip>
|
|
|
|
|
2021-08-23 21:08:54 +02:00
|
|
|
<ui-btn v-if="isDeveloperMode" class="mx-2" @click="openRssFeed">Open RSS Feed</ui-btn>
|
2021-09-06 21:13:01 +02:00
|
|
|
</div>
|
|
|
|
|
2021-10-07 04:08:52 +02:00
|
|
|
<div class="my-4 max-w-2xl">
|
2022-01-06 11:50:33 +01:00
|
|
|
<p class="text-base text-gray-100 whitespace-pre-line">{{ description }}</p>
|
2021-08-18 00:01:11 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div v-if="missingParts.length" class="bg-error border-red-800 shadow-md p-4">
|
|
|
|
<p class="text-sm mb-2">
|
|
|
|
Missing Parts <span class="text-sm">({{ missingParts.length }})</span>
|
|
|
|
</p>
|
|
|
|
<p class="text-sm font-mono">{{ missingPartChunks.join(', ') }}</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div v-if="invalidParts.length" class="bg-error border-red-800 shadow-md p-4">
|
|
|
|
<p class="text-sm mb-2">
|
|
|
|
Invalid Parts <span class="text-sm">({{ invalidParts.length }})</span>
|
|
|
|
</p>
|
2021-08-26 14:09:23 +02:00
|
|
|
<div>
|
2021-09-16 15:37:09 +02:00
|
|
|
<p v-for="part in invalidParts" :key="part.filename" class="text-sm font-mono">{{ part.filename }}: {{ part.error }}</p>
|
2021-08-26 14:09:23 +02:00
|
|
|
</div>
|
2021-08-18 00:01:11 +02:00
|
|
|
</div>
|
|
|
|
|
2021-10-10 23:36:21 +02:00
|
|
|
<tables-tracks-table v-if="tracks.length" :tracks="tracks" :audiobook="audiobook" class="mt-6" />
|
2021-08-19 01:31:19 +02:00
|
|
|
|
|
|
|
<tables-audio-files-table v-if="otherAudioFiles.length" :audiobook-id="audiobook.id" :files="otherAudioFiles" class="mt-6" />
|
|
|
|
|
2021-10-09 00:30:20 +02:00
|
|
|
<tables-other-files-table v-if="otherFiles.length" :audiobook="audiobook" :files="otherFiles" class="mt-6" />
|
2021-08-18 00:01:11 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
async asyncData({ store, params, app, redirect, route }) {
|
2021-08-24 01:31:04 +02:00
|
|
|
if (!store.state.user.user) {
|
2021-08-18 00:01:11 +02:00
|
|
|
return redirect(`/login?redirect=${route.path}`)
|
|
|
|
}
|
2021-11-22 03:00:40 +01:00
|
|
|
var audiobook = await app.$axios.$get(`/api/books/${params.id}`).catch((error) => {
|
2021-08-18 00:01:11 +02:00
|
|
|
console.error('Failed', error)
|
|
|
|
return false
|
|
|
|
})
|
|
|
|
if (!audiobook) {
|
|
|
|
console.error('No audiobook...', params.id)
|
|
|
|
return redirect('/')
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
audiobook
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2021-09-06 21:13:01 +02:00
|
|
|
isRead: false,
|
|
|
|
resettingProgress: false,
|
2022-02-09 18:19:02 +01:00
|
|
|
isProcessingReadUpdate: false
|
2021-09-06 21:13:01 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
userIsRead: {
|
|
|
|
immediate: true,
|
|
|
|
handler(newVal) {
|
|
|
|
this.isRead = newVal
|
|
|
|
}
|
2021-08-18 00:01:11 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2021-12-03 02:02:38 +01:00
|
|
|
coverAspectRatio() {
|
|
|
|
return this.$store.getters['getServerSetting']('coverAspectRatio')
|
|
|
|
},
|
|
|
|
bookCoverAspectRatio() {
|
|
|
|
return this.coverAspectRatio === this.$constants.BookCoverAspectRatio.SQUARE ? 1 : 1.6
|
|
|
|
},
|
2021-11-04 23:35:59 +01:00
|
|
|
bookCoverWidth() {
|
2022-02-09 18:19:02 +01:00
|
|
|
return 208
|
2021-11-04 23:35:59 +01:00
|
|
|
},
|
2021-08-23 21:08:54 +02:00
|
|
|
isDeveloperMode() {
|
|
|
|
return this.$store.state.developerMode
|
|
|
|
},
|
2021-10-02 20:50:39 +02:00
|
|
|
showExperimentalFeatures() {
|
|
|
|
return this.$store.state.showExperimentalFeatures
|
|
|
|
},
|
2021-08-18 00:01:11 +02:00
|
|
|
missingPartChunks() {
|
|
|
|
if (this.missingParts === 1) return this.missingParts[0]
|
|
|
|
var chunks = []
|
|
|
|
|
|
|
|
var currentIndex = this.missingParts[0]
|
|
|
|
var currentChunk = [this.missingParts[0]]
|
|
|
|
|
|
|
|
for (let i = 1; i < this.missingParts.length; i++) {
|
|
|
|
var partIndex = this.missingParts[i]
|
|
|
|
if (currentIndex === partIndex - 1) {
|
|
|
|
currentChunk.push(partIndex)
|
|
|
|
currentIndex = partIndex
|
|
|
|
} else {
|
|
|
|
// console.log('Chunk ended', currentChunk.join(', '), currentIndex, partIndex)
|
|
|
|
if (currentChunk.length === 0) {
|
|
|
|
console.error('How is current chunk 0?', currentChunk.join(', '))
|
|
|
|
}
|
|
|
|
chunks.push(currentChunk)
|
|
|
|
currentChunk = [partIndex]
|
|
|
|
currentIndex = partIndex
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (currentChunk.length) {
|
|
|
|
chunks.push(currentChunk)
|
|
|
|
}
|
|
|
|
chunks = chunks.map((chunk) => {
|
|
|
|
if (chunk.length === 1) return chunk[0]
|
|
|
|
else return `${chunk[0]}-${chunk[chunk.length - 1]}`
|
|
|
|
})
|
|
|
|
return chunks
|
|
|
|
},
|
2021-09-18 01:40:30 +02:00
|
|
|
isMissing() {
|
|
|
|
return this.audiobook.isMissing
|
|
|
|
},
|
2021-12-02 02:07:03 +01:00
|
|
|
isInvalid() {
|
|
|
|
return this.audiobook.isInvalid
|
2021-10-10 23:36:21 +02:00
|
|
|
},
|
|
|
|
showPlayButton() {
|
2021-12-02 02:07:03 +01:00
|
|
|
return !this.isMissing && !this.isInvalid && this.tracks.length
|
2021-10-10 23:36:21 +02:00
|
|
|
},
|
2021-08-18 00:01:11 +02:00
|
|
|
missingParts() {
|
|
|
|
return this.audiobook.missingParts || []
|
|
|
|
},
|
|
|
|
invalidParts() {
|
|
|
|
return this.audiobook.invalidParts || []
|
|
|
|
},
|
2021-10-07 04:08:52 +02:00
|
|
|
libraryId() {
|
|
|
|
return this.audiobook.libraryId
|
|
|
|
},
|
2021-10-09 00:30:20 +02:00
|
|
|
folderId() {
|
|
|
|
return this.audiobook.folderId
|
|
|
|
},
|
2021-08-18 00:01:11 +02:00
|
|
|
audiobookId() {
|
|
|
|
return this.audiobook.id
|
|
|
|
},
|
|
|
|
title() {
|
|
|
|
return this.book.title || 'No Title'
|
|
|
|
},
|
2021-10-07 04:08:52 +02:00
|
|
|
publishYear() {
|
|
|
|
return this.book.publishYear
|
|
|
|
},
|
|
|
|
narrator() {
|
|
|
|
return this.book.narrator
|
|
|
|
},
|
|
|
|
subtitle() {
|
|
|
|
return this.book.subtitle
|
|
|
|
},
|
|
|
|
genres() {
|
|
|
|
return this.book.genres || []
|
|
|
|
},
|
2021-08-18 00:01:11 +02:00
|
|
|
author() {
|
|
|
|
return this.book.author || 'Unknown'
|
|
|
|
},
|
2021-08-25 13:38:32 +02:00
|
|
|
authorFL() {
|
|
|
|
return this.book.authorFL
|
|
|
|
},
|
2021-10-31 22:40:27 +01:00
|
|
|
authorsList() {
|
|
|
|
return this.authorFL ? this.authorFL.split(', ') : []
|
|
|
|
},
|
2021-08-25 13:38:32 +02:00
|
|
|
authorLF() {
|
|
|
|
return this.book.authorLF
|
|
|
|
},
|
2021-11-17 23:13:16 +01:00
|
|
|
narrators() {
|
|
|
|
if (!this.book.narratorFL) return []
|
|
|
|
return this.book.narratorFL.split(', ') || []
|
|
|
|
},
|
2021-08-25 13:38:32 +02:00
|
|
|
authorTooltipText() {
|
|
|
|
var txt = ['FL: ' + this.authorFL || 'Not Set', 'LF: ' + this.authorLF || 'Not Set']
|
2021-09-06 21:13:01 +02:00
|
|
|
return txt.join('<br>')
|
2021-08-25 13:38:32 +02:00
|
|
|
},
|
2021-08-25 03:24:40 +02:00
|
|
|
series() {
|
|
|
|
return this.book.series || null
|
|
|
|
},
|
|
|
|
volumeNumber() {
|
|
|
|
return this.book.volumeNumber || null
|
|
|
|
},
|
|
|
|
seriesText() {
|
|
|
|
if (!this.series) return ''
|
|
|
|
if (!this.volumeNumber) return this.series
|
|
|
|
return `${this.series} #${this.volumeNumber}`
|
|
|
|
},
|
2021-08-18 00:01:11 +02:00
|
|
|
durationPretty() {
|
|
|
|
return this.audiobook.durationPretty
|
|
|
|
},
|
|
|
|
duration() {
|
|
|
|
return this.audiobook.duration
|
|
|
|
},
|
|
|
|
sizePretty() {
|
|
|
|
return this.audiobook.sizePretty
|
|
|
|
},
|
|
|
|
book() {
|
|
|
|
return this.audiobook.book || {}
|
|
|
|
},
|
2021-08-19 01:31:19 +02:00
|
|
|
otherFiles() {
|
|
|
|
return this.audiobook.otherFiles || []
|
|
|
|
},
|
|
|
|
otherAudioFiles() {
|
|
|
|
return this.audioFiles.filter((af) => {
|
|
|
|
return !this.tracks.find((t) => t.path === af.path)
|
|
|
|
})
|
|
|
|
},
|
2021-08-18 00:01:11 +02:00
|
|
|
tracks() {
|
|
|
|
return this.audiobook.tracks || []
|
|
|
|
},
|
2021-08-19 01:31:19 +02:00
|
|
|
audioFiles() {
|
|
|
|
return this.audiobook.audioFiles || []
|
|
|
|
},
|
2021-09-27 13:52:21 +02:00
|
|
|
ebooks() {
|
|
|
|
return this.audiobook.ebooks
|
|
|
|
},
|
2021-10-10 23:36:21 +02:00
|
|
|
showExperimentalReadAlert() {
|
|
|
|
return !this.tracks.length && this.ebooks.length && !this.showExperimentalFeatures
|
2021-10-02 20:50:39 +02:00
|
|
|
},
|
2021-10-17 03:33:49 +02:00
|
|
|
numEbooks() {
|
|
|
|
return this.audiobook.numEbooks
|
2021-10-09 00:30:20 +02:00
|
|
|
},
|
2021-08-18 00:01:11 +02:00
|
|
|
description() {
|
2021-09-06 21:13:01 +02:00
|
|
|
return this.book.description || ''
|
2021-08-18 00:01:11 +02:00
|
|
|
},
|
|
|
|
userAudiobooks() {
|
2021-08-24 01:31:04 +02:00
|
|
|
return this.$store.state.user.user ? this.$store.state.user.user.audiobooks || {} : {}
|
2021-08-18 00:01:11 +02:00
|
|
|
},
|
|
|
|
userAudiobook() {
|
|
|
|
return this.userAudiobooks[this.audiobookId] || null
|
|
|
|
},
|
|
|
|
userCurrentTime() {
|
|
|
|
return this.userAudiobook ? this.userAudiobook.currentTime : 0
|
|
|
|
},
|
2021-09-06 21:13:01 +02:00
|
|
|
userIsRead() {
|
|
|
|
return this.userAudiobook ? !!this.userAudiobook.isRead : false
|
|
|
|
},
|
2021-08-18 00:01:11 +02:00
|
|
|
userTimeRemaining() {
|
|
|
|
return this.duration - this.userCurrentTime
|
|
|
|
},
|
|
|
|
progressPercent() {
|
|
|
|
return this.userAudiobook ? this.userAudiobook.progress : 0
|
|
|
|
},
|
|
|
|
streamAudiobook() {
|
|
|
|
return this.$store.state.streamAudiobook
|
|
|
|
},
|
2021-09-05 01:02:42 +02:00
|
|
|
streaming() {
|
2021-08-18 00:01:11 +02:00
|
|
|
return this.streamAudiobook && this.streamAudiobook.id === this.audiobookId
|
2021-09-07 00:42:15 +02:00
|
|
|
},
|
|
|
|
userCanUpdate() {
|
|
|
|
return this.$store.getters['user/getUserCanUpdate']
|
|
|
|
},
|
|
|
|
userCanDelete() {
|
|
|
|
return this.$store.getters['user/getUserCanDelete']
|
|
|
|
},
|
|
|
|
userCanDownload() {
|
|
|
|
return this.$store.getters['user/getUserCanDownload']
|
2021-08-18 00:01:11 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2021-09-27 13:52:21 +02:00
|
|
|
openEbook() {
|
2021-10-10 23:36:21 +02:00
|
|
|
this.$store.commit('showEReader', this.audiobook)
|
2021-09-27 13:52:21 +02:00
|
|
|
},
|
2021-09-06 21:13:01 +02:00
|
|
|
toggleRead() {
|
|
|
|
var updatePayload = {
|
|
|
|
isRead: !this.isRead
|
|
|
|
}
|
|
|
|
this.isProcessingReadUpdate = true
|
|
|
|
this.$axios
|
2021-11-22 03:00:40 +01:00
|
|
|
.$patch(`/api/me/audiobook/${this.audiobookId}`, updatePayload)
|
2021-09-06 21:13:01 +02:00
|
|
|
.then(() => {
|
|
|
|
this.isProcessingReadUpdate = false
|
|
|
|
this.$toast.success(`"${this.title}" Marked as ${updatePayload.isRead ? 'Read' : 'Not Read'}`)
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
console.error('Failed', error)
|
|
|
|
this.isProcessingReadUpdate = false
|
|
|
|
this.$toast.error(`Failed to mark as ${updatePayload.isRead ? 'Read' : 'Not Read'}`)
|
|
|
|
})
|
|
|
|
},
|
2021-08-23 21:08:54 +02:00
|
|
|
openRssFeed() {
|
|
|
|
this.$axios
|
|
|
|
.$post('/api/feed', { audiobookId: this.audiobook.id })
|
|
|
|
.then((res) => {
|
|
|
|
console.log('Feed open', res)
|
|
|
|
this.$toast.success('RSS Feed Open')
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
console.error('Failed', error)
|
|
|
|
this.$toast.error('Failed to open feed')
|
|
|
|
})
|
|
|
|
},
|
2021-08-18 00:01:11 +02:00
|
|
|
startStream() {
|
|
|
|
this.$store.commit('setStreamAudiobook', this.audiobook)
|
|
|
|
this.$root.socket.emit('open_stream', this.audiobook.id)
|
|
|
|
},
|
|
|
|
editClick() {
|
2021-10-16 03:31:00 +02:00
|
|
|
this.$store.commit('setBookshelfBookIds', [])
|
2021-08-18 00:01:11 +02:00
|
|
|
this.$store.commit('showEditModal', this.audiobook)
|
|
|
|
},
|
|
|
|
audiobookUpdated() {
|
|
|
|
console.log('Audiobook Updated - Fetch full audiobook')
|
|
|
|
this.$axios
|
2021-11-22 03:00:40 +01:00
|
|
|
.$get(`/api/books/${this.audiobookId}`)
|
2021-08-18 00:01:11 +02:00
|
|
|
.then((audiobook) => {
|
2021-10-07 04:08:52 +02:00
|
|
|
console.log('Updated audiobook', audiobook)
|
2021-08-18 00:01:11 +02:00
|
|
|
this.audiobook = audiobook
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
console.error('Failed', error)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
clearProgressClick() {
|
|
|
|
if (confirm(`Are you sure you want to reset your progress?`)) {
|
|
|
|
this.resettingProgress = true
|
|
|
|
this.$axios
|
2021-11-22 03:00:40 +01:00
|
|
|
.$patch(`/api/me/audiobook/${this.audiobookId}/reset-progress`)
|
2021-08-18 00:01:11 +02:00
|
|
|
.then(() => {
|
|
|
|
console.log('Progress reset complete')
|
|
|
|
this.$toast.success(`Your progress was reset`)
|
|
|
|
this.resettingProgress = false
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
console.error('Progress reset failed', error)
|
|
|
|
this.resettingProgress = false
|
|
|
|
})
|
|
|
|
}
|
2021-09-06 21:13:01 +02:00
|
|
|
},
|
|
|
|
downloadClick() {
|
|
|
|
this.$store.commit('showEditModalOnTab', { audiobook: this.audiobook, tab: 'download' })
|
2021-11-04 23:35:59 +01:00
|
|
|
},
|
2021-11-06 02:24:02 +01:00
|
|
|
collectionsClick() {
|
|
|
|
this.$store.commit('setSelectedAudiobook', this.audiobook)
|
|
|
|
this.$store.commit('globals/setShowUserCollectionsModal', true)
|
2021-08-18 00:01:11 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.$store.commit('audiobooks/addListener', { id: 'audiobook', audiobookId: this.audiobookId, meth: this.audiobookUpdated })
|
2021-10-11 23:59:41 +02:00
|
|
|
|
2021-12-02 02:07:03 +01:00
|
|
|
// use this audiobooks library id as the current
|
|
|
|
if (this.libraryId) {
|
2021-10-11 23:59:41 +02:00
|
|
|
this.$store.commit('libraries/setCurrentLibrary', this.libraryId)
|
|
|
|
}
|
2021-08-18 00:01:11 +02:00
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
this.$store.commit('audiobooks/removeListener', 'audiobook')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|