Add:Library specific setting for use square covers and remove from server settings #387

This commit is contained in:
advplyr 2022-08-13 13:56:37 -05:00
parent be4f11a60e
commit d06c61b329
25 changed files with 69 additions and 74 deletions

View File

@ -33,7 +33,7 @@
<!-- Regular bookshelf view --> <!-- Regular bookshelf view -->
<div v-else class="w-full"> <div v-else class="w-full">
<template v-for="(shelf, index) in shelves"> <template v-for="(shelf, index) in shelves">
<app-book-shelf-row :key="index" :index="index" :shelf="shelf" :size-multiplier="sizeMultiplier" :book-cover-width="bookCoverWidth" :book-cover-aspect-ratio="bookCoverAspectRatio" /> <app-book-shelf-row :key="index" :index="index" :shelf="shelf" :size-multiplier="sizeMultiplier" :book-cover-width="bookCoverWidth" :book-cover-aspect-ratio="coverAspectRatio" />
</template> </template>
</div> </div>
</div> </div>
@ -82,13 +82,10 @@ export default {
return coverSize return coverSize
}, },
coverAspectRatio() { coverAspectRatio() {
return this.$store.getters['getServerSetting']('coverAspectRatio') return this.$store.getters['libraries/getBookCoverAspectRatio']
}, },
isCoverSquareAspectRatio() { isCoverSquareAspectRatio() {
return this.coverAspectRatio === this.$constants.BookCoverAspectRatio.SQUARE return this.coverAspectRatio == 1
},
bookCoverAspectRatio() {
return this.isCoverSquareAspectRatio ? 1 : 1.6
}, },
sizeMultiplier() { sizeMultiplier() {
var baseSize = this.isCoverSquareAspectRatio ? 192 : 120 var baseSize = this.isCoverSquareAspectRatio ? 192 : 120

View File

@ -110,7 +110,7 @@ export default {
return this.$store.getters['user/getUserSetting']('collapseSeries') return this.$store.getters['user/getUserSetting']('collapseSeries')
}, },
coverAspectRatio() { coverAspectRatio() {
return this.$store.getters['getServerSetting']('coverAspectRatio') return this.$store.getters['libraries/getBookCoverAspectRatio']
}, },
bookshelfView() { bookshelfView() {
return this.$store.getters['getServerSetting']('bookshelfView') return this.$store.getters['getServerSetting']('bookshelfView')
@ -119,15 +119,12 @@ export default {
return this.$store.getters['getServerSetting']('sortingIgnorePrefix') return this.$store.getters['getServerSetting']('sortingIgnorePrefix')
}, },
isCoverSquareAspectRatio() { isCoverSquareAspectRatio() {
return this.coverAspectRatio === this.$constants.BookCoverAspectRatio.SQUARE return this.coverAspectRatio == 1
}, },
isAlternativeBookshelfView() { isAlternativeBookshelfView() {
// if (!this.isEntityBook) return false // Only used for bookshelf showing books // if (!this.isEntityBook) return false // Only used for bookshelf showing books
return this.bookshelfView === this.$constants.BookshelfView.TITLES return this.bookshelfView === this.$constants.BookshelfView.TITLES
}, },
bookCoverAspectRatio() {
return this.isCoverSquareAspectRatio ? 1 : 1.6
},
hasFilter() { hasFilter() {
return this.filterBy && this.filterBy !== 'all' return this.filterBy && this.filterBy !== 'all'
}, },

View File

@ -2,7 +2,7 @@
<div v-if="streamLibraryItem" id="streamContainer" class="w-full fixed bottom-0 left-0 right-0 h-48 sm:h-44 md:h-40 z-40 bg-primary px-4 pb-1 md:pb-4 pt-2"> <div v-if="streamLibraryItem" id="streamContainer" class="w-full fixed bottom-0 left-0 right-0 h-48 sm:h-44 md:h-40 z-40 bg-primary px-4 pb-1 md:pb-4 pt-2">
<div id="videoDock" /> <div id="videoDock" />
<nuxt-link v-if="!playerHandler.isVideo" :to="`/item/${streamLibraryItem.id}`" class="absolute left-1 sm:left-4 cursor-pointer" :style="{ top: bookCoverPosTop + 'px' }"> <nuxt-link v-if="!playerHandler.isVideo" :to="`/item/${streamLibraryItem.id}`" class="absolute left-1 sm:left-4 cursor-pointer" :style="{ top: bookCoverPosTop + 'px' }">
<covers-book-cover :library-item="streamLibraryItem" :width="bookCoverWidth" :book-cover-aspect-ratio="bookCoverAspectRatio" /> <covers-book-cover :library-item="streamLibraryItem" :width="bookCoverWidth" :book-cover-aspect-ratio="coverAspectRatio" />
</nuxt-link> </nuxt-link>
<div class="flex items-start mb-6 md:mb-0" :class="playerHandler.isVideo ? 'ml-4 pl-96' : 'pl-20 sm:pl-24'"> <div class="flex items-start mb-6 md:mb-0" :class="playerHandler.isVideo ? 'ml-4 pl-96' : 'pl-20 sm:pl-24'">
<div> <div>
@ -77,16 +77,13 @@ export default {
}, },
computed: { computed: {
coverAspectRatio() { coverAspectRatio() {
return this.$store.getters['getServerSetting']('coverAspectRatio') return this.$store.getters['libraries/getBookCoverAspectRatio']
},
bookCoverAspectRatio() {
return this.coverAspectRatio === this.$constants.BookCoverAspectRatio.SQUARE ? 1 : 1.6
}, },
bookCoverWidth() { bookCoverWidth() {
return 88 return 88
}, },
bookCoverPosTop() { bookCoverPosTop() {
if (this.bookCoverAspectRatio === 1) return -10 if (this.coverAspectRatio == 1) return -10
return -64 return -64
}, },
cover() { cover() {

View File

@ -31,7 +31,7 @@ export default {
}, },
computed: { computed: {
bookCoverAspectRatio() { bookCoverAspectRatio() {
return this.$store.getters['getBookCoverAspectRatio'] return this.$store.getters['libraries/getBookCoverAspectRatio']
}, },
coverWidth() { coverWidth() {
if (this.bookCoverAspectRatio === 1) return 50 * 1.2 if (this.bookCoverAspectRatio === 1) return 50 * 1.2

View File

@ -24,7 +24,7 @@ export default {
}, },
computed: { computed: {
bookCoverAspectRatio() { bookCoverAspectRatio() {
return this.$store.getters['getBookCoverAspectRatio'] return this.$store.getters['libraries/getBookCoverAspectRatio']
}, },
name() { name() {
return this.series.name return this.series.name

View File

@ -75,7 +75,7 @@ export default {
} }
}, },
bookCoverAspectRatio() { bookCoverAspectRatio() {
return this.$store.getters['getBookCoverAspectRatio'] return this.$store.getters['libraries/getBookCoverAspectRatio']
}, },
collection() { collection() {
return this.$store.state.globals.selectedCollection || {} return this.$store.state.globals.selectedCollection || {}

View File

@ -70,7 +70,7 @@ export default {
return this.selectedLibraryItem ? this.selectedLibraryItem.media.metadata.title : '' return this.selectedLibraryItem ? this.selectedLibraryItem.media.metadata.title : ''
}, },
bookCoverAspectRatio() { bookCoverAspectRatio() {
return this.$store.getters['getBookCoverAspectRatio'] return this.$store.getters['libraries/getBookCoverAspectRatio']
}, },
selectedLibraryItem() { selectedLibraryItem() {
return this.$store.state.selectedLibraryItem return this.$store.state.selectedLibraryItem

View File

@ -129,11 +129,8 @@ export default {
else if (this.provider == 'itunes') return 'Search Term' else if (this.provider == 'itunes') return 'Search Term'
return 'Search Title' return 'Search Title'
}, },
coverAspectRatio() {
return this.$store.getters['getServerSetting']('coverAspectRatio')
},
bookCoverAspectRatio() { bookCoverAspectRatio() {
return this.coverAspectRatio === this.$constants.BookCoverAspectRatio.SQUARE ? 1 : 1.6 return this.$store.getters['libraries/getBookCoverAspectRatio']
}, },
libraryItemId() { libraryItemId() {
return this.libraryItem ? this.libraryItem.id : null return this.libraryItem ? this.libraryItem.id : null

View File

@ -246,7 +246,7 @@ export default {
} }
}, },
bookCoverAspectRatio() { bookCoverAspectRatio() {
return this.$store.getters['getBookCoverAspectRatio'] return this.$store.getters['libraries/getBookCoverAspectRatio']
}, },
providers() { providers() {
if (this.isPodcast) return this.$store.state.scanners.podcastProviders if (this.isPodcast) return this.$store.state.scanners.podcastProviders

View File

@ -1,5 +1,14 @@
<template> <template>
<div class="w-full h-full px-4 py-1 mb-4"> <div class="w-full h-full px-4 py-1 mb-4">
<div class="flex items-center py-2">
<ui-toggle-switch v-model="useSquareBookCovers" @input="formUpdated" />
<ui-tooltip :text="tooltips.coverAspectRatio">
<p class="pl-4 text-base">
Use square book covers
<span class="material-icons icon-text text-sm">info_outlined</span>
</p>
</ui-tooltip>
</div>
<div class="py-3"> <div class="py-3">
<div class="flex items-center"> <div class="flex items-center">
<ui-toggle-switch v-if="!globalWatcherDisabled" v-model="disableWatcher" @input="formUpdated" /> <ui-toggle-switch v-if="!globalWatcherDisabled" v-model="disableWatcher" @input="formUpdated" />
@ -35,9 +44,13 @@ export default {
data() { data() {
return { return {
provider: null, provider: null,
useSquareBookCovers: false,
disableWatcher: false, disableWatcher: false,
skipMatchingMediaWithAsin: false, skipMatchingMediaWithAsin: false,
skipMatchingMediaWithIsbn: false skipMatchingMediaWithIsbn: false,
tooltips: {
coverAspectRatio: 'Prefer to use square covers over standard 1.6:1 book covers'
}
} }
}, },
computed: { computed: {
@ -59,6 +72,7 @@ export default {
getLibraryData() { getLibraryData() {
return { return {
settings: { settings: {
coverAspectRatio: this.useSquareBookCovers ? this.$constants.BookCoverAspectRatio.SQUARE : this.$constants.BookCoverAspectRatio.STANDARD,
disableWatcher: !!this.disableWatcher, disableWatcher: !!this.disableWatcher,
skipMatchingMediaWithAsin: !!this.skipMatchingMediaWithAsin, skipMatchingMediaWithAsin: !!this.skipMatchingMediaWithAsin,
skipMatchingMediaWithIsbn: !!this.skipMatchingMediaWithIsbn skipMatchingMediaWithIsbn: !!this.skipMatchingMediaWithIsbn
@ -69,6 +83,7 @@ export default {
this.$emit('update', this.getLibraryData()) this.$emit('update', this.getLibraryData())
}, },
init() { init() {
this.useSquareBookCovers = this.librarySettings.coverAspectRatio === this.$constants.BookCoverAspectRatio.SQUARE
this.disableWatcher = !!this.librarySettings.disableWatcher this.disableWatcher = !!this.librarySettings.disableWatcher
this.skipMatchingMediaWithAsin = !!this.librarySettings.skipMatchingMediaWithAsin this.skipMatchingMediaWithAsin = !!this.librarySettings.skipMatchingMediaWithAsin
this.skipMatchingMediaWithIsbn = !!this.librarySettings.skipMatchingMediaWithIsbn this.skipMatchingMediaWithIsbn = !!this.librarySettings.skipMatchingMediaWithIsbn

View File

@ -66,7 +66,7 @@ export default {
return this.mediaMetadata.author return this.mediaMetadata.author
}, },
bookCoverAspectRatio() { bookCoverAspectRatio() {
return this.$store.getters['getBookCoverAspectRatio'] return this.$store.getters['libraries/getBookCoverAspectRatio']
} }
}, },
methods: {}, methods: {},

View File

@ -52,11 +52,8 @@ export default {
} }
}, },
computed: { computed: {
coverAspectRatio() {
return this.$store.getters['getServerSetting']('coverAspectRatio')
},
bookCoverAspectRatio() { bookCoverAspectRatio() {
return this.coverAspectRatio === this.$constants.BookCoverAspectRatio.SQUARE ? 1 : 1.6 return this.$store.getters['libraries/getBookCoverAspectRatio']
}, },
totalDuration() { totalDuration() {
var _total = 0 var _total = 0

View File

@ -46,7 +46,7 @@ export default {
}, },
computed: { computed: {
bookCoverAspectRatio() { bookCoverAspectRatio() {
return this.$store.getters['getBookCoverAspectRatio'] return this.$store.getters['libraries/getBookCoverAspectRatio']
}, },
cardScaleMulitiplier() { cardScaleMulitiplier() {
return this.height / 192 return this.height / 192

View File

@ -46,7 +46,7 @@ export default {
}, },
computed: { computed: {
bookCoverAspectRatio() { bookCoverAspectRatio() {
return this.$store.getters['getBookCoverAspectRatio'] return this.$store.getters['libraries/getBookCoverAspectRatio']
}, },
cardScaleMulitiplier() { cardScaleMulitiplier() {
return this.height / 192 return this.height / 192

View File

@ -46,7 +46,7 @@ export default {
}, },
computed: { computed: {
bookCoverAspectRatio() { bookCoverAspectRatio() {
return this.$store.getters['getBookCoverAspectRatio'] return this.$store.getters['libraries/getBookCoverAspectRatio']
}, },
cardScaleMulitiplier() { cardScaleMulitiplier() {
return this.height / 192 return this.height / 192

View File

@ -46,7 +46,7 @@ export default {
}, },
computed: { computed: {
bookCoverAspectRatio() { bookCoverAspectRatio() {
return this.$store.getters['getBookCoverAspectRatio'] return this.$store.getters['libraries/getBookCoverAspectRatio']
}, },
cardScaleMulitiplier() { cardScaleMulitiplier() {
return this.height / 192 return this.height / 192

View File

@ -51,7 +51,7 @@ export default {
index, index,
width: this.entityWidth, width: this.entityWidth,
height: this.entityHeight, height: this.entityHeight,
bookCoverAspectRatio: this.bookCoverAspectRatio, bookCoverAspectRatio: this.coverAspectRatio,
bookshelfView: this.bookshelfView, bookshelfView: this.bookshelfView,
sortingIgnorePrefix: !!this.sortingIgnorePrefix sortingIgnorePrefix: !!this.sortingIgnorePrefix
} }

View File

@ -144,12 +144,6 @@ export default {
isPodcastLibrary() { isPodcastLibrary() {
return this.mediaType === 'podcast' return this.mediaType === 'podcast'
}, },
coverAspectRatio() {
return this.$store.getters['getServerSetting']('coverAspectRatio')
},
bookCoverAspectRatio() {
return this.coverAspectRatio === this.$constants.BookCoverAspectRatio.SQUARE ? 1 : 1.6
},
streamLibraryItem() { streamLibraryItem() {
return this.$store.state.streamLibraryItem return this.$store.state.streamLibraryItem
}, },

View File

@ -65,7 +65,7 @@ export default {
}, },
computed: { computed: {
bookCoverAspectRatio() { bookCoverAspectRatio() {
return this.$store.getters['getBookCoverAspectRatio'] return this.$store.getters['libraries/getBookCoverAspectRatio']
}, },
streamLibraryItem() { streamLibraryItem() {
return this.$store.state.streamLibraryItem return this.$store.state.streamLibraryItem

View File

@ -52,7 +52,7 @@
<h2 class="font-semibold">Display</h2> <h2 class="font-semibold">Display</h2>
</div> </div>
<div class="flex items-center py-2"> <!-- <div class="flex items-center py-2">
<ui-toggle-switch v-model="useSquareBookCovers" :disabled="updatingServerSettings" @input="updateBookCoverAspectRatio" /> <ui-toggle-switch v-model="useSquareBookCovers" :disabled="updatingServerSettings" @input="updateBookCoverAspectRatio" />
<ui-tooltip :text="tooltips.coverAspectRatio"> <ui-tooltip :text="tooltips.coverAspectRatio">
<p class="pl-4"> <p class="pl-4">
@ -60,7 +60,7 @@
<span class="material-icons icon-text text-sm">info_outlined</span> <span class="material-icons icon-text text-sm">info_outlined</span>
</p> </p>
</ui-tooltip> </ui-tooltip>
</div> </div> -->
<div class="flex items-center py-2"> <div class="flex items-center py-2">
<ui-toggle-switch v-model="useAlternativeBookshelfView" :disabled="updatingServerSettings" @input="updateAlternativeBookshelfView" /> <ui-toggle-switch v-model="useAlternativeBookshelfView" :disabled="updatingServerSettings" @input="updateAlternativeBookshelfView" />

View File

@ -105,11 +105,8 @@ export default {
userToken() { userToken() {
return this.user.token return this.user.token
}, },
coverAspectRatio() {
return this.$store.getters['getServerSetting']('coverAspectRatio')
},
bookCoverAspectRatio() { bookCoverAspectRatio() {
return this.coverAspectRatio === this.$constants.BookCoverAspectRatio.SQUARE ? 1 : 1.6 return this.$store.getters['libraries/getBookCoverAspectRatio']
}, },
username() { username() {
return this.user.username return this.user.username

View File

@ -246,11 +246,8 @@ export default {
isFile() { isFile() {
return this.libraryItem.isFile return this.libraryItem.isFile
}, },
coverAspectRatio() {
return this.$store.getters['getServerSetting']('coverAspectRatio')
},
bookCoverAspectRatio() { bookCoverAspectRatio() {
return this.coverAspectRatio === this.$constants.BookCoverAspectRatio.SQUARE ? 1 : 1.6 return this.$store.getters['libraries/getBookCoverAspectRatio']
}, },
bookCoverWidth() { bookCoverWidth() {
return 208 return 208

View File

@ -42,6 +42,14 @@ export const getters = {
}) })
if (!librariesSorted.length) return null if (!librariesSorted.length) return null
return librariesSorted[0] return librariesSorted[0]
},
getCurrentLibrarySettings: (state, getters) => {
if (!getters.getCurrentLibrary) return null
return getters.getCurrentLibrary.settings
},
getBookCoverAspectRatio: (state, getters) => {
if (!getters.getCurrentLibrarySettings || isNaN(getters.getCurrentLibrarySettings.coverAspectRatio)) return 1
return getters.getCurrentLibrarySettings.coverAspectRatio === 0 ? 1.6 : 1
} }
} }

View File

@ -121,7 +121,7 @@ class Db {
async init() { async init() {
await this.load() await this.load()
if (!this.serverSettings) { if (!this.serverSettings) { // Create first load server settings
this.serverSettings = new ServerSettings() this.serverSettings = new ServerSettings()
await this.insertEntity('settings', this.serverSettings) await this.insertEntity('settings', this.serverSettings)
} }
@ -142,7 +142,7 @@ class Db {
this.libraries.sort((a, b) => a.displayOrder - b.displayOrder) this.libraries.sort((a, b) => a.displayOrder - b.displayOrder)
Logger.info(`[DB] ${this.libraries.length} Libraries Loaded`) Logger.info(`[DB] ${this.libraries.length} Libraries Loaded`)
}) })
var p4 = this.settingsDb.select(() => true).then((results) => { var p4 = this.settingsDb.select(() => true).then(async (results) => {
if (results.data && results.data.length) { if (results.data && results.data.length) {
this.settings = results.data this.settings = results.data
var serverSettings = this.settings.find(s => s.id === 'server-settings') var serverSettings = this.settings.find(s => s.id === 'server-settings')
@ -152,6 +152,18 @@ class Db {
// Check if server was upgraded // Check if server was upgraded
if (!this.serverSettings.version || this.serverSettings.version !== version) { if (!this.serverSettings.version || this.serverSettings.version !== version) {
this.previousVersion = this.serverSettings.version || '1.0.0' this.previousVersion = this.serverSettings.version || '1.0.0'
// Library settings and server settings updated in 2.1.3 - run migration
if (this.previousVersion.localeCompare('2.1.3') < 0) {
Logger.info(`[Db] Running servers & library settings migration`)
for (const library of this.libraries) {
if (library.settings.coverAspectRatio !== serverSettings.coverAspectRatio) {
library.settings.coverAspectRatio = serverSettings.coverAspectRatio
await this.updateEntity('library', library)
Logger.debug(`[Db] Library ${library.name} migrated`)
}
}
}
} }
} }
} }
@ -357,22 +369,7 @@ class Db {
} }
return entityDb.update((record) => record.id === entity.id, () => jsonEntity).then((results) => { return entityDb.update((record) => record.id === entity.id, () => jsonEntity).then((results) => {
if (process.env.NODE_ENV !== 'production') {
Logger.debug(`[DB] Updated ${entityName}: ${results.updated} | Selected: ${results.selected}`)
if (!results.selected) {
entityDb.select(match => match.id == jsonEntity.id).then((results) => {
if (results.data.length) {
console.log('Said selected 0 but found it right here...', results.data[0].id)
} else {
console.log('Said selected 0 and no results for json entity id', jsonEntity.id)
}
})
}
} else {
Logger.debug(`[DB] Updated ${entityName}: ${results.updated}`) Logger.debug(`[DB] Updated ${entityName}: ${results.updated}`)
}
var arrayKey = this.getEntityArrayKey(entityName) var arrayKey = this.getEntityArrayKey(entityName)
if (this[arrayKey]) { if (this[arrayKey]) {
this[arrayKey] = this[arrayKey].map(e => { this[arrayKey] = this[arrayKey].map(e => {

View File

@ -1,8 +1,8 @@
const { BookCoverAspectRatio } = require('../../utils/constants') const { BookCoverAspectRatio } = require('../../utils/constants')
const Logger = require('../../Logger')
class LibrarySettings { class LibrarySettings {
constructor(settings) { constructor(settings) {
this.coverAspectRatio = BookCoverAspectRatio.SQUARE
this.disableWatcher = false this.disableWatcher = false
this.skipMatchingMediaWithAsin = false this.skipMatchingMediaWithAsin = false
this.skipMatchingMediaWithIsbn = false this.skipMatchingMediaWithIsbn = false
@ -13,6 +13,7 @@ class LibrarySettings {
} }
construct(settings) { construct(settings) {
this.coverAspectRatio = !isNaN(settings.coverAspectRatio) ? settings.coverAspectRatio : BookCoverAspectRatio.SQUARE
this.disableWatcher = !!settings.disableWatcher this.disableWatcher = !!settings.disableWatcher
this.skipMatchingMediaWithAsin = !!settings.skipMatchingMediaWithAsin this.skipMatchingMediaWithAsin = !!settings.skipMatchingMediaWithAsin
this.skipMatchingMediaWithIsbn = !!settings.skipMatchingMediaWithIsbn this.skipMatchingMediaWithIsbn = !!settings.skipMatchingMediaWithIsbn
@ -20,6 +21,7 @@ class LibrarySettings {
toJSON() { toJSON() {
return { return {
coverAspectRatio: this.coverAspectRatio,
disableWatcher: this.disableWatcher, disableWatcher: this.disableWatcher,
skipMatchingMediaWithAsin: this.skipMatchingMediaWithAsin, skipMatchingMediaWithAsin: this.skipMatchingMediaWithAsin,
skipMatchingMediaWithIsbn: this.skipMatchingMediaWithIsbn skipMatchingMediaWithIsbn: this.skipMatchingMediaWithIsbn