mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-02-03 16:59:41 +00:00
Add multi select dropdown with query from server
This commit is contained in:
parent
2a30cc428f
commit
f2be3bc95e
4 changed files with 275 additions and 25 deletions
|
|
@ -22,12 +22,11 @@ const PodcastFinder = require('./finders/PodcastFinder')
|
|||
const FileSystemController = require('./controllers/FileSystemController')
|
||||
|
||||
class ApiController {
|
||||
constructor(db, auth, scanner, streamManager, rssFeeds, downloadManager, coverController, backupManager, watcher, cacheManager, emitter, clientEmitter) {
|
||||
constructor(db, auth, scanner, streamManager, downloadManager, coverController, backupManager, watcher, cacheManager, emitter, clientEmitter) {
|
||||
this.db = db
|
||||
this.auth = auth
|
||||
this.scanner = scanner
|
||||
this.streamManager = streamManager
|
||||
this.rssFeeds = rssFeeds
|
||||
this.downloadManager = downloadManager
|
||||
this.backupManager = backupManager
|
||||
this.coverController = coverController
|
||||
|
|
@ -145,6 +144,7 @@ class ApiController {
|
|||
this.router.get('/search/covers', this.findCovers.bind(this))
|
||||
this.router.get('/search/books', this.findBooks.bind(this))
|
||||
this.router.get('/search/podcast', this.findPodcasts.bind(this))
|
||||
this.router.get('/search/authors', this.findAuthor.bind(this))
|
||||
|
||||
//
|
||||
// File System Routes
|
||||
|
|
@ -155,7 +155,7 @@ class ApiController {
|
|||
// Others
|
||||
//
|
||||
this.router.get('/authors', this.getAuthors.bind(this))
|
||||
this.router.get('/authors/search', this.searchAuthor.bind(this))
|
||||
this.router.get('/authors/search', this.searchAuthors.bind(this))
|
||||
this.router.get('/authors/:id', this.getAuthor.bind(this))
|
||||
this.router.post('/authors', this.createAuthor.bind(this))
|
||||
this.router.patch('/authors/:id', this.updateAuthor.bind(this))
|
||||
|
|
@ -165,8 +165,6 @@ class ApiController {
|
|||
|
||||
this.router.post('/authorize', this.authorize.bind(this))
|
||||
|
||||
this.router.post('/feed', this.openRssFeed.bind(this))
|
||||
|
||||
this.router.get('/download/:id', this.download.bind(this))
|
||||
|
||||
this.router.post('/syncUserAudiobookData', this.syncUserAudiobookData.bind(this))
|
||||
|
|
@ -201,6 +199,12 @@ class ApiController {
|
|||
res.json(results)
|
||||
}
|
||||
|
||||
async findAuthor(req, res) {
|
||||
var query = req.query.q
|
||||
var author = await this.authorFinder.findAuthorByName(query)
|
||||
res.json(author)
|
||||
}
|
||||
|
||||
authorize(req, res) {
|
||||
if (!req.user) {
|
||||
Logger.error('Invalid user in authorize')
|
||||
|
|
@ -209,20 +213,19 @@ class ApiController {
|
|||
res.json({ user: req.user })
|
||||
}
|
||||
|
||||
async openRssFeed(req, res) {
|
||||
var audiobookId = req.body.audiobookId
|
||||
var audiobook = this.db.audiobooks.find(ab => ab.id === audiobookId)
|
||||
if (!audiobook) return res.sendStatus(404)
|
||||
var feed = await this.rssFeeds.openFeed(audiobook)
|
||||
console.log('Feed open', feed)
|
||||
res.json(feed)
|
||||
}
|
||||
|
||||
async getAuthors(req, res) {
|
||||
var authors = this.db.authors.filter(p => p.isAuthor)
|
||||
res.json(authors)
|
||||
}
|
||||
|
||||
searchAuthors(req, res) {
|
||||
var query = req.query.q || ''
|
||||
var limit = req.query.limit && !isNaN(req.query.limit) ? Number(req.query.limit) : 100
|
||||
var authors = this.db.authors.filter(au => au.name.toLowerCase().includes(query.toLowerCase()))
|
||||
authors = authors.slice(0, limit)
|
||||
res.json(authors)
|
||||
}
|
||||
|
||||
async getAuthor(req, res) {
|
||||
var author = this.db.authors.find(p => p.id === req.params.id)
|
||||
if (!author) {
|
||||
|
|
@ -231,12 +234,6 @@ class ApiController {
|
|||
res.json(author.toJSON())
|
||||
}
|
||||
|
||||
async searchAuthor(req, res) {
|
||||
var query = req.query.q
|
||||
var author = await this.authorFinder.findAuthorByName(query)
|
||||
res.json(author)
|
||||
}
|
||||
|
||||
async createAuthor(req, res) {
|
||||
var author = await this.authorFinder.createAuthor(req.body)
|
||||
if (!author) {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ const LogManager = require('./LogManager')
|
|||
const ApiController = require('./ApiController')
|
||||
const HlsController = require('./HlsController')
|
||||
const StreamManager = require('./StreamManager')
|
||||
const RssFeeds = require('./RssFeeds')
|
||||
const DownloadManager = require('./DownloadManager')
|
||||
const CoverController = require('./CoverController')
|
||||
const CacheManager = require('./CacheManager')
|
||||
|
|
@ -62,9 +61,8 @@ class Server {
|
|||
this.scanner = new Scanner(this.db, this.coverController, this.emitter.bind(this))
|
||||
|
||||
this.streamManager = new StreamManager(this.db, this.emitter.bind(this), this.clientEmitter.bind(this))
|
||||
this.rssFeeds = new RssFeeds(this.Port, this.db)
|
||||
this.downloadManager = new DownloadManager(this.db, this.Uid, this.Gid)
|
||||
this.apiController = new ApiController(this.db, this.auth, this.scanner, this.streamManager, this.rssFeeds, this.downloadManager, this.coverController, this.backupManager, this.watcher, this.cacheManager, this.emitter.bind(this), this.clientEmitter.bind(this))
|
||||
this.apiController = new ApiController(this.db, this.auth, this.scanner, this.streamManager, this.downloadManager, this.coverController, this.backupManager, this.watcher, this.cacheManager, this.emitter.bind(this), this.clientEmitter.bind(this))
|
||||
this.hlsController = new HlsController(this.db, this.auth, this.streamManager, this.emitter.bind(this), this.streamManager.StreamsPath)
|
||||
|
||||
Logger.logManager = this.logManager
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue