mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-03 00:06:46 +01:00
Update:Show RSS feed icon on collection card & update API endpoint for fetching collections
This commit is contained in:
parent
f806e4cce3
commit
8bbfee334c
@ -318,7 +318,7 @@ export default {
|
||||
|
||||
const entityPath = this.entityName === 'books' || this.entityName === 'series-books' ? 'items' : this.entityName
|
||||
const sfQueryString = this.currentSFQueryString ? this.currentSFQueryString + '&' : ''
|
||||
const fullQueryString = `?${sfQueryString}limit=${this.booksPerFetch}&page=${page}&minified=1`
|
||||
const fullQueryString = `?${sfQueryString}limit=${this.booksPerFetch}&page=${page}&minified=1&include=rssfeed`
|
||||
|
||||
const payload = await this.$axios.$get(`/api/libraries/${this.currentLibraryId}/${entityPath}${fullQueryString}`).catch((error) => {
|
||||
console.error('failed to fetch books', error)
|
||||
@ -340,7 +340,7 @@ export default {
|
||||
}
|
||||
|
||||
for (let i = 0; i < payload.results.length; i++) {
|
||||
var index = i + startIndex
|
||||
const index = i + startIndex
|
||||
this.entities[index] = payload.results[i]
|
||||
if (this.entityComponentRefs[index]) {
|
||||
this.entityComponentRefs[index].setEntity(this.entities[index])
|
||||
|
@ -9,6 +9,9 @@
|
||||
<span class="material-icons text-xl text-white text-opacity-75 hover:text-opacity-100">edit</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<span v-if="!isHovering && rssFeed" class="absolute z-10 material-icons text-success" :style="{ top: 0.5 * sizeMultiplier + 'rem', left: 0.5 * sizeMultiplier + 'rem', fontSize: 1.5 * sizeMultiplier + 'rem' }">rss_feed</span>
|
||||
|
||||
<div v-if="!isAlternativeBookshelfView" class="categoryPlacard absolute z-30 left-0 right-0 mx-auto -bottom-6 h-6 rounded-md font-book text-center" :style="{ width: Math.min(200, width) + 'px' }">
|
||||
<div class="w-full h-full shinyBlack flex items-center justify-center rounded-sm border" :style="{ padding: `0rem ${0.5 * sizeMultiplier}rem` }">
|
||||
<p class="truncate" :style="{ fontSize: labelFontSize + 'rem' }">{{ title }}</p>
|
||||
@ -72,6 +75,9 @@ export default {
|
||||
},
|
||||
userCanUpdate() {
|
||||
return this.store.getters['user/getUserCanUpdate']
|
||||
},
|
||||
rssFeed() {
|
||||
return this.collection ? this.collection.rssFeed : null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -124,7 +124,7 @@ export default {
|
||||
action: 'create-playlist'
|
||||
}
|
||||
]
|
||||
if (this.userIsAdminOrUp) {
|
||||
if (this.userIsAdminOrUp || this.rssFeed) {
|
||||
items.push({
|
||||
text: this.$strings.LabelOpenRSSFeed,
|
||||
action: 'open-rss-feed'
|
||||
|
@ -406,9 +406,11 @@ class LibraryController {
|
||||
|
||||
// api/libraries/:id/collections
|
||||
async getCollectionsForLibrary(req, res) {
|
||||
var libraryItems = req.libraryItems
|
||||
const libraryItems = req.libraryItems
|
||||
|
||||
var payload = {
|
||||
const include = (req.query.include || '').split(',').map(v => v.trim().toLowerCase()).filter(v => !!v)
|
||||
|
||||
const payload = {
|
||||
results: [],
|
||||
total: 0,
|
||||
limit: req.query.limit && !isNaN(req.query.limit) ? Number(req.query.limit) : 0,
|
||||
@ -416,20 +418,27 @@ class LibraryController {
|
||||
sortBy: req.query.sort,
|
||||
sortDesc: req.query.desc === '1',
|
||||
filterBy: req.query.filter,
|
||||
minified: req.query.minified === '1'
|
||||
minified: req.query.minified === '1',
|
||||
include: include.join(',')
|
||||
}
|
||||
|
||||
var collections = this.db.collections.filter(c => c.libraryId === req.library.id).map(c => {
|
||||
var expanded = c.toJSONExpanded(libraryItems, payload.minified)
|
||||
let collections = this.db.collections.filter(c => c.libraryId === req.library.id).map(c => {
|
||||
const expanded = c.toJSONExpanded(libraryItems, payload.minified)
|
||||
|
||||
// If all books restricted to user in this collection then hide this collection
|
||||
if (!expanded.books.length && c.books.length) return null
|
||||
|
||||
if (include.includes('rssfeed')) {
|
||||
expanded.rssFeed = this.rssFeedManager.findFeedForEntityId(c.id)
|
||||
}
|
||||
|
||||
return expanded
|
||||
}).filter(c => !!c)
|
||||
|
||||
payload.total = collections.length
|
||||
|
||||
if (payload.limit) {
|
||||
var startIndex = payload.page * payload.limit
|
||||
const startIndex = payload.page * payload.limit
|
||||
collections = collections.slice(startIndex, startIndex + payload.limit)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user