Skip to content

Commit

Permalink
Fixing scanner inodes, select all fix, starting ebook reader
Browse files Browse the repository at this point in the history
  • Loading branch information
advplyr committed Sep 27, 2021
1 parent 01fdca4 commit 3e5338e
Show file tree
Hide file tree
Showing 21 changed files with 662 additions and 67 deletions.
7 changes: 5 additions & 2 deletions client/components/app/Appbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@

<div v-show="numAudiobooksSelected" class="absolute top-0 left-0 w-full h-full px-4 bg-primary flex items-center">
<h1 class="text-2xl px-4">{{ numAudiobooksSelected }} Selected</h1>
<ui-btn small class="text-sm mx-2" @click="toggleSelectAll">{{ isAllSelected ? 'Select None' : 'Select All' }}</ui-btn>
<ui-btn small class="text-sm mx-2" @click="toggleSelectAll"
>{{ isAllSelected ? 'Select None' : 'Select All' }}<span class="pl-2">({{ audiobooksShowing.length }})</span></ui-btn
>

<div class="flex-grow" />

Expand Down Expand Up @@ -87,7 +89,8 @@ export default {
return this.$store.state.user.user.audiobooks || {}
},
audiobooksShowing() {
return this.$store.getters['audiobooks/getFiltered']()
// return this.$store.getters['audiobooks/getFiltered']()
return this.$store.getters['audiobooks/getEntitiesShowing']()
},
userCanUpdate() {
return this.$store.getters['user/getUserCanUpdate']
Expand Down
2 changes: 1 addition & 1 deletion client/components/app/BookShelf.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<template v-for="entity in shelf">
<cards-group-card v-if="showGroups" :key="entity.id" :width="bookCoverWidth" :group="entity" @click="clickGroup" />
<!-- <cards-book-3d :key="entity.id" v-else :width="100" :src="$store.getters['audiobooks/getBookCoverSrc'](entity.book)" /> -->
<cards-book-card v-else :key="entity.id" :show-volume-number="selectedSeries" :width="bookCoverWidth" :user-progress="userAudiobooks[entity.id]" :audiobook="entity" />
<cards-book-card v-else :key="entity.id" :show-volume-number="!!selectedSeries" :width="bookCoverWidth" :user-progress="userAudiobooks[entity.id]" :audiobook="entity" />
</template>
</div>
<div class="bookshelfDivider h-4 w-full absolute bottom-0 left-0 right-0 z-10" />
Expand Down
7 changes: 7 additions & 0 deletions client/components/cards/BookCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
<p :style="{ fontSize: sizeMultiplier * 0.8 + 'rem' }">#{{ volumeNumber }}</p>
</div>

<!-- <div v-if="true && hasEbook" class="absolute rounded-lg bg-black bg-opacity-90 box-shadow-md" :style="{ bottom: 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' }">EBook</p>
</div> -->

<div v-show="!isSelectionMode" class="absolute bottom-0 left-0 h-1 shadow-sm max-w-full" :class="userIsRead ? 'bg-success' : 'bg-yellow-400'" :style="{ width: width * userProgressPercent + 'px' }"></div>

<ui-tooltip v-if="showError" :text="errorText" class="absolute bottom-4 left-0">
Expand Down Expand Up @@ -78,6 +82,9 @@ export default {
audiobookId() {
return this.audiobook.id
},
hasEbook() {
return this.audiobook.numEbooks
},
isSelectionMode() {
return this.$store.getters['getNumAudiobooksSelected']
},
Expand Down
2 changes: 1 addition & 1 deletion client/components/tables/AudioFilesTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<template v-for="track in files">
<tr :key="track.path">
<td class="font-book pl-2">
{{ track.filename }}
{{ track.filename }}<span class="text-white text-opacity-50 pl-4">({{ track.ino }})</span>
</td>
<td class="font-mono">
{{ $bytesPretty(track.size) }}
Expand Down
2 changes: 1 addition & 1 deletion client/components/tables/OtherFilesTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<template v-for="file in files">
<tr :key="file.path">
<td class="font-book pl-2">
{{ file.path }}
{{ file.path }}<span class="text-white text-opacity-50 pl-4">({{ file.ino }})</span>
</td>
<td class="text-xs">
<p>{{ file.filetype }}</p>
Expand Down
2 changes: 1 addition & 1 deletion client/components/tables/TracksTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<p>{{ track.index }}</p>
</td>
<td class="font-book">
{{ track.filename }}
{{ track.filename }}<span class="text-white text-opacity-50 pl-4">({{ track.ino }})</span>
</td>
<td class="font-mono">
{{ $bytesPretty(track.size) }}
Expand Down
2 changes: 1 addition & 1 deletion client/middleware/authenticated.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default function ({ store, redirect, route, app }) {
// If the user is not authenticated
if (!store.state.user.user) {
if (route.name === 'batch') return redirect('/login')
if (route.name === 'batch' || route.name === 'index') return redirect('/login')
return redirect(`/login?redirect=${route.fullPath}`)
}
}
2 changes: 1 addition & 1 deletion client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "audiobookshelf-client",
"version": "1.2.4",
"version": "1.2.5",
"description": "Audiobook manager and player",
"main": "index.js",
"scripts": {
Expand Down
22 changes: 22 additions & 0 deletions client/pages/audiobook/_id/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
Missing
</ui-btn>

<!-- <ui-btn v-if="ebooks.length" 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>
Read
</ui-btn> -->

<ui-tooltip v-if="userCanUpdate" text="Edit" direction="top">
<ui-icon-btn icon="edit" class="mx-0.5" @click="editClick" />
</ui-tooltip>
Expand Down Expand Up @@ -86,6 +91,8 @@
<tables-other-files-table v-if="otherFiles.length" :audiobook-id="audiobook.id" :files="otherFiles" class="mt-6" />
</div>
</div>

<div id="area"></div>
</div>
</div>
</template>
Expand Down Expand Up @@ -223,6 +230,9 @@ export default {
audioFiles() {
return this.audiobook.audioFiles || []
},
ebooks() {
return this.audiobook.ebooks
},
description() {
return this.book.description || ''
},
Expand Down Expand Up @@ -261,6 +271,18 @@ export default {
}
},
methods: {
openEbook() {
var ebook = this.ebooks[0]
console.log('Ebook', ebook)
this.$axios
.$get(`/ebook/open/${this.audiobookId}/${ebook.ino}`)
.then(() => {
console.log('opened')
})
.catch((error) => {
console.error('failed', error)
})
},
toggleRead() {
var updatePayload = {
isRead: !this.isRead
Expand Down
10 changes: 8 additions & 2 deletions client/pages/library/_id.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@ export default {
console.error('Search error', error)
return []
})
store.commit('audiobooks/setSearchResults', searchResults)
}
var selectedSeries = query.series ? app.$decode(query.series) : null
store.commit('audiobooks/setSelectedSeries', selectedSeries)
var libraryPage = params.id || ''
store.commit('audiobooks/setLibraryPage', libraryPage)
return {
id: params.id,
id: libraryPage,
searchQuery,
searchResults,
selectedSeries: query.series ? app.$decode(query.series) : null
selectedSeries
}
},
data() {
Expand Down
1 change: 0 additions & 1 deletion client/pages/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export default {
if (token) {
this.processing = true
console.log('Authorize', token)
this.$axios
.$post('/api/authorize', null, {
headers: {
Expand Down
30 changes: 29 additions & 1 deletion client/store/audiobooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,32 @@ export const state = () => ({
genres: [...STANDARD_GENRES],
tags: [],
series: [],
keywordFilter: null
keywordFilter: null,
selectedSeries: null,
libraryPage: null,
searchResults: []
})

export const getters = {
getAudiobook: (state) => id => {
return state.audiobooks.find(ab => ab.id === id)
},
getEntitiesShowing: (state, getters, rootState, rootGetters) => () => {
if (!state.libraryPage) {
return getters.getFiltered()
} else if (state.libraryPage === 'search') {
return state.searchResults
} else if (state.libraryPage === 'series') {
var series = getters.getSeriesGroups()
if (state.selectedSeries) {
var _series = series.find(__series => __series.name === state.selectedSeries)
if (!_series) return []
return _series.books || []
}
return series
}
return []
},
getFiltered: (state, getters, rootState, rootGetters) => () => {
var filtered = state.audiobooks
var settings = rootState.user.settings || {}
Expand Down Expand Up @@ -159,6 +178,15 @@ export const mutations = {
setKeywordFilter(state, val) {
state.keywordFilter = val
},
setSelectedSeries(state, val) {
state.selectedSeries = val
},
setLibraryPage(state, val) {
state.libraryPage = val
},
setSearchResults(state, val) {
state.searchResults = val
},
set(state, audiobooks) {
// GENRES
var genres = [...state.genres]
Expand Down
Loading

0 comments on commit 3e5338e

Please sign in to comment.