mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-04-20 01:17:45 +02:00
Fix experimental e-reader with new data model
This commit is contained in:
parent
88354de495
commit
a90cfc4d04
@ -1,7 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="w-full border-b border-gray-700 pb-2">
|
<div class="w-full border-b border-gray-700 pb-2">
|
||||||
<div class="flex py-1 hover:bg-gray-300 hover:bg-opacity-10 cursor-pointer" @click="selectMatch">
|
<div class="flex py-1 hover:bg-gray-300 hover:bg-opacity-10 cursor-pointer" @click="selectMatch">
|
||||||
<img :src="selectedCover || '/book_placeholder.jpg'" class="h-24 object-cover" :style="{ width: 96 / bookCoverAspectRatio + 'px' }" />
|
<div class="h-24 bg-primary" :style="{ minWidth: 96 / bookCoverAspectRatio + 'px' }">
|
||||||
|
<img v-if="selectedCover" :src="selectedCover" class="h-full w-full object-contain" />
|
||||||
|
</div>
|
||||||
<div class="px-4 flex-grow">
|
<div class="px-4 flex-grow">
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<h1>{{ book.title }}</h1>
|
<h1>{{ book.title }}</h1>
|
||||||
|
@ -177,7 +177,7 @@ export default {
|
|||||||
return this._libraryItem.libraryId
|
return this._libraryItem.libraryId
|
||||||
},
|
},
|
||||||
hasEbook() {
|
hasEbook() {
|
||||||
return this.media.ebookFile
|
return this.media.ebookFormat
|
||||||
},
|
},
|
||||||
numTracks() {
|
numTracks() {
|
||||||
if (this.media.tracks) return this.media.tracks.length
|
if (this.media.tracks) return this.media.tracks.length
|
||||||
@ -522,8 +522,14 @@ export default {
|
|||||||
clickShowMore() {
|
clickShowMore() {
|
||||||
this.createMoreMenu()
|
this.createMoreMenu()
|
||||||
},
|
},
|
||||||
clickReadEBook() {
|
async clickReadEBook() {
|
||||||
this.store.commit('showEReader', this.media.ebookFile)
|
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)
|
||||||
},
|
},
|
||||||
selectBtnClick() {
|
selectBtnClick() {
|
||||||
if (this.processingBatch) return
|
if (this.processingBatch) return
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<tables-tracks-table :key="audiobook.id" :title="`Audiobook Tracks (${audiobook.name})`" :audiobook-id="audiobook.id" :tracks="audiobook.tracks" class="mb-4" />
|
<tables-tracks-table :key="audiobook.id" :title="`Audiobook Tracks (${audiobook.name})`" :audiobook-id="audiobook.id" :tracks="audiobook.tracks" class="mb-4" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<tables-library-files-table :files="libraryFiles" :library-item-id="libraryItem.id" :is-missing="isMissing" />
|
<tables-library-files-table expanded :files="libraryFiles" :library-item-id="libraryItem.id" :is-missing="isMissing" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -18,10 +18,7 @@
|
|||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {}
|
||||||
ebookType: '',
|
|
||||||
ebookUrl: ''
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
show(newVal) {
|
show(newVal) {
|
||||||
@ -47,13 +44,19 @@ export default {
|
|||||||
return null
|
return null
|
||||||
},
|
},
|
||||||
abTitle() {
|
abTitle() {
|
||||||
return this.selectedLibraryItem.media.metadata.title
|
return this.mediaMetadata.title
|
||||||
},
|
},
|
||||||
abAuthor() {
|
abAuthor() {
|
||||||
return this.selectedLibraryItem.media.metadata.authorName
|
return this.mediaMetadata.authorName
|
||||||
},
|
},
|
||||||
selectedLibraryItem() {
|
selectedLibraryItem() {
|
||||||
return this.$store.state.selectedLibraryItem
|
return this.$store.state.selectedLibraryItem || {}
|
||||||
|
},
|
||||||
|
media() {
|
||||||
|
return this.selectedLibraryItem.media || {}
|
||||||
|
},
|
||||||
|
mediaMetadata() {
|
||||||
|
return this.media.metadata || {}
|
||||||
},
|
},
|
||||||
libraryId() {
|
libraryId() {
|
||||||
return this.selectedLibraryItem.libraryId
|
return this.selectedLibraryItem.libraryId
|
||||||
@ -61,32 +64,45 @@ export default {
|
|||||||
folderId() {
|
folderId() {
|
||||||
return this.selectedLibraryItem.folderId
|
return this.selectedLibraryItem.folderId
|
||||||
},
|
},
|
||||||
ebooks() {
|
ebookFile() {
|
||||||
return this.selectedLibraryItem.media.ebooks || []
|
return this.media.ebookFile
|
||||||
},
|
},
|
||||||
epubEbook() {
|
ebookFormat() {
|
||||||
return this.ebooks.find((eb) => eb.ext === '.epub')
|
if (!this.ebookFile) return null
|
||||||
|
return this.ebookFile.ebookFormat
|
||||||
},
|
},
|
||||||
mobiEbook() {
|
ebookType() {
|
||||||
return this.ebooks.find((eb) => eb.ext === '.mobi' || eb.ext === '.azw3')
|
if (this.isMobi) return 'mobi'
|
||||||
|
else if (this.isEpub) return 'epub'
|
||||||
|
else if (this.isPdf) return 'pdf'
|
||||||
|
else if (this.isComic) return 'comic'
|
||||||
|
return null
|
||||||
},
|
},
|
||||||
pdfEbook() {
|
isEpub() {
|
||||||
return this.ebooks.find((eb) => eb.ext === '.pdf')
|
return this.ebookFormat == 'epub'
|
||||||
},
|
},
|
||||||
comicEbook() {
|
isMobi() {
|
||||||
return this.ebooks.find((eb) => eb.ext === '.cbz' || eb.ext === '.cbr')
|
return this.ebookFormat == 'mobi' || this.ebookFormat == 'azw3'
|
||||||
|
},
|
||||||
|
isPdf() {
|
||||||
|
return this.ebookFormat == 'pdf'
|
||||||
|
},
|
||||||
|
isComic() {
|
||||||
|
return this.ebookFormat == 'cbz' || this.ebookFormat == 'cbr'
|
||||||
|
},
|
||||||
|
ebookUrl() {
|
||||||
|
if (!this.ebookFile) return null
|
||||||
|
var itemRelPath = this.selectedLibraryItem.relPath
|
||||||
|
if (itemRelPath.startsWith('/')) itemRelPath = itemRelPath.slice(1)
|
||||||
|
var relPath = this.ebookFile.metadata.relPath
|
||||||
|
if (relPath.startsWith('/')) relPath = relPath.slice(1)
|
||||||
|
return `/ebook/${this.libraryId}/${this.folderId}/${itemRelPath}/${relPath}`
|
||||||
},
|
},
|
||||||
userToken() {
|
userToken() {
|
||||||
return this.$store.getters['user/getToken']
|
return this.$store.getters['user/getToken']
|
||||||
},
|
|
||||||
selectedAudiobookFile() {
|
|
||||||
return this.$store.state.selectedAudiobookFile
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getEbookUrl(path) {
|
|
||||||
return `/ebook/${this.libraryId}/${this.folderId}/${path}`
|
|
||||||
},
|
|
||||||
hotkey(action) {
|
hotkey(action) {
|
||||||
console.log('Reader hotkey', action)
|
console.log('Reader hotkey', action)
|
||||||
if (!this.$refs.readerComponent) return
|
if (!this.$refs.readerComponent) return
|
||||||
@ -107,31 +123,6 @@ export default {
|
|||||||
},
|
},
|
||||||
init() {
|
init() {
|
||||||
this.registerListeners()
|
this.registerListeners()
|
||||||
|
|
||||||
if (this.selectedAudiobookFile) {
|
|
||||||
this.ebookUrl = this.getEbookUrl(this.selectedAudiobookFile.path)
|
|
||||||
if (this.selectedAudiobookFile.ext === '.pdf') {
|
|
||||||
this.ebookType = 'pdf'
|
|
||||||
} else if (this.selectedAudiobookFile.ext === '.mobi' || this.selectedAudiobookFile.ext === '.azw3') {
|
|
||||||
this.ebookType = 'mobi'
|
|
||||||
} else if (this.selectedAudiobookFile.ext === '.epub') {
|
|
||||||
this.ebookType = 'epub'
|
|
||||||
} else if (this.selectedAudiobookFile.ext === '.cbr' || this.selectedAudiobookFile.ext === '.cbz') {
|
|
||||||
this.ebookType = 'comic'
|
|
||||||
}
|
|
||||||
} else if (this.epubEbook) {
|
|
||||||
this.ebookType = 'epub'
|
|
||||||
this.ebookUrl = this.getEbookUrl(this.epubEbook.path)
|
|
||||||
} else if (this.mobiEbook) {
|
|
||||||
this.ebookType = 'mobi'
|
|
||||||
this.ebookUrl = this.getEbookUrl(this.mobiEbook.path)
|
|
||||||
} else if (this.pdfEbook) {
|
|
||||||
this.ebookType = 'pdf'
|
|
||||||
this.ebookUrl = this.getEbookUrl(this.pdfEbook.path)
|
|
||||||
} else if (this.comicEbook) {
|
|
||||||
this.ebookType = 'comic'
|
|
||||||
this.ebookUrl = this.getEbookUrl(this.comicEbook.path)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
close() {
|
close() {
|
||||||
this.unregisterListeners()
|
this.unregisterListeners()
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
</td>
|
</td>
|
||||||
<td class="text-xs">
|
<td class="text-xs">
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<span v-if="file.filetype === 'ebook'" class="material-icons text-base mr-1 cursor-pointer text-white text-opacity-60 hover:text-opacity-100" @click="readEbookClick(file)">auto_stories </span>
|
|
||||||
<p>{{ file.fileType }}</p>
|
<p>{{ file.fileType }}</p>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@ -53,7 +52,8 @@ export default {
|
|||||||
default: () => []
|
default: () => []
|
||||||
},
|
},
|
||||||
libraryItemId: String,
|
libraryItemId: String,
|
||||||
isMissing: Boolean
|
isMissing: Boolean,
|
||||||
|
expanded: Boolean // start expanded
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -70,13 +70,12 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
readEbookClick(file) {
|
|
||||||
// this.$store.commit('showEReaderForFile', { audiobook: this.audiobook, file })
|
|
||||||
},
|
|
||||||
clickBar() {
|
clickBar() {
|
||||||
this.showFiles = !this.showFiles
|
this.showFiles = !this.showFiles
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {}
|
mounted() {
|
||||||
|
this.showFiles = this.expanded
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
@ -118,7 +118,7 @@
|
|||||||
{{ isMissing ? 'Missing' : 'Incomplete' }}
|
{{ isMissing ? 'Missing' : 'Incomplete' }}
|
||||||
</ui-btn>
|
</ui-btn>
|
||||||
|
|
||||||
<ui-btn v-if="showExperimentalFeatures && ebooks.length" color="info" :padding-x="4" small class="flex items-center h-9 mr-2" @click="openEbook">
|
<ui-btn v-if="showExperimentalFeatures && ebookFile" color="info" :padding-x="4" small class="flex items-center h-9 mr-2" @click="openEbook">
|
||||||
<span class="material-icons -ml-2 pr-2 text-white">auto_stories</span>
|
<span class="material-icons -ml-2 pr-2 text-white">auto_stories</span>
|
||||||
Read
|
Read
|
||||||
</ui-btn>
|
</ui-btn>
|
||||||
@ -291,11 +291,11 @@ export default {
|
|||||||
libraryFiles() {
|
libraryFiles() {
|
||||||
return this.libraryItem.libraryFiles || []
|
return this.libraryItem.libraryFiles || []
|
||||||
},
|
},
|
||||||
ebooks() {
|
ebookFile() {
|
||||||
return this.media.ebooks || []
|
return this.media.ebookFile
|
||||||
},
|
},
|
||||||
showExperimentalReadAlert() {
|
showExperimentalReadAlert() {
|
||||||
return !this.tracks.length && this.ebooks.length && !this.showExperimentalFeatures
|
return !this.tracks.length && this.ebookFile && !this.showExperimentalFeatures
|
||||||
},
|
},
|
||||||
description() {
|
description() {
|
||||||
return this.mediaMetadata.description || ''
|
return this.mediaMetadata.description || ''
|
||||||
|
@ -11,7 +11,6 @@ export const state = () => ({
|
|||||||
showEditModal: false,
|
showEditModal: false,
|
||||||
showEReader: false,
|
showEReader: false,
|
||||||
selectedLibraryItem: null,
|
selectedLibraryItem: null,
|
||||||
selectedAudiobookFile: null,
|
|
||||||
developerMode: false,
|
developerMode: false,
|
||||||
selectedLibraryItems: [],
|
selectedLibraryItems: [],
|
||||||
processingBatch: false,
|
processingBatch: false,
|
||||||
@ -141,13 +140,6 @@ export const mutations = {
|
|||||||
state.showEditModal = val
|
state.showEditModal = val
|
||||||
},
|
},
|
||||||
showEReader(state, libraryItem) {
|
showEReader(state, libraryItem) {
|
||||||
state.selectedAudiobookFile = null
|
|
||||||
state.selectedLibraryItem = libraryItem
|
|
||||||
|
|
||||||
state.showEReader = true
|
|
||||||
},
|
|
||||||
showEReaderForFile(state, { libraryItem, file }) {
|
|
||||||
state.selectedAudiobookFile = file
|
|
||||||
state.selectedLibraryItem = libraryItem
|
state.selectedLibraryItem = libraryItem
|
||||||
|
|
||||||
state.showEReader = true
|
state.showEReader = true
|
||||||
|
Loading…
Reference in New Issue
Block a user