mirror of
https://github.com/gotson/komga.git
synced 2025-12-22 00:13:30 +01:00
parent
57cc6c48d3
commit
f5158197de
3 changed files with 47 additions and 15 deletions
|
|
@ -29,9 +29,15 @@ export default class KomgaReferentialService {
|
|||
}
|
||||
}
|
||||
|
||||
async getGenres (): Promise<string[]> {
|
||||
async getGenres (libraryId?: string): Promise<string[]> {
|
||||
try {
|
||||
return (await this.http.get('/api/v1/genres')).data
|
||||
const params = {} as any
|
||||
if (libraryId) params.library_id = libraryId
|
||||
|
||||
return (await this.http.get('/api/v1/genres', {
|
||||
params: params,
|
||||
paramsSerializer: params => qs.stringify(params, { indices: false }),
|
||||
})).data
|
||||
} catch (e) {
|
||||
let msg = 'An error occurred while trying to retrieve genres'
|
||||
if (e.response.data.message) {
|
||||
|
|
@ -41,9 +47,16 @@ export default class KomgaReferentialService {
|
|||
}
|
||||
}
|
||||
|
||||
async getTags (): Promise<string[]> {
|
||||
async getTags (libraryId?: string, seriesId?: string): Promise<string[]> {
|
||||
try {
|
||||
return (await this.http.get('/api/v1/tags')).data
|
||||
const params = {} as any
|
||||
if (libraryId) params.library_id = libraryId
|
||||
if (seriesId) params.series_id = seriesId
|
||||
|
||||
return (await this.http.get('/api/v1/tags', {
|
||||
params: params,
|
||||
paramsSerializer: params => qs.stringify(params, { indices: false }),
|
||||
})).data
|
||||
} catch (e) {
|
||||
let msg = 'An error occurred while trying to retrieve tags'
|
||||
if (e.response.data.message) {
|
||||
|
|
@ -53,9 +66,15 @@ export default class KomgaReferentialService {
|
|||
}
|
||||
}
|
||||
|
||||
async getPublishers (): Promise<string[]> {
|
||||
async getPublishers (libraryId?: string): Promise<string[]> {
|
||||
try {
|
||||
return (await this.http.get('/api/v1/publishers')).data
|
||||
const params = {} as any
|
||||
if (libraryId) params.library_id = libraryId
|
||||
|
||||
return (await this.http.get('/api/v1/publishers', {
|
||||
params: params,
|
||||
paramsSerializer: params => qs.stringify(params, { indices: false }),
|
||||
})).data
|
||||
} catch (e) {
|
||||
let msg = 'An error occurred while trying to retrieve publishers'
|
||||
if (e.response.data.message) {
|
||||
|
|
@ -65,9 +84,15 @@ export default class KomgaReferentialService {
|
|||
}
|
||||
}
|
||||
|
||||
async getLanguages (): Promise<NameValue[]> {
|
||||
async getLanguages (libraryId?: string): Promise<NameValue[]> {
|
||||
try {
|
||||
const data = (await this.http.get('/api/v1/languages')).data
|
||||
const params = {} as any
|
||||
if (libraryId) params.library_id = libraryId
|
||||
|
||||
const data = (await this.http.get('/api/v1/languages', {
|
||||
params: params,
|
||||
paramsSerializer: params => qs.stringify(params, { indices: false }),
|
||||
})).data
|
||||
const ret = [] as NameValue[]
|
||||
for (const code of data) {
|
||||
const tag = tags(code)
|
||||
|
|
|
|||
|
|
@ -188,11 +188,6 @@ export default Vue.extend({
|
|||
this.pageSize = Number(this.$cookies.get(cookiePageSize))
|
||||
}
|
||||
|
||||
this.filterOptionsPanel.genre.values.push(...toNameValue(await this.$komgaReferential.getGenres()))
|
||||
this.filterOptionsPanel.tag.values.push(...toNameValue(await this.$komgaReferential.getTags()))
|
||||
this.filterOptionsPanel.publisher.values.push(...toNameValue(await this.$komgaReferential.getPublishers()))
|
||||
this.filterOptionsPanel.language.values.push(...(await this.$komgaReferential.getLanguages()))
|
||||
|
||||
// restore from query param
|
||||
this.resetParams(this.$route)
|
||||
if (this.$route.query.page) this.page = Number(this.$route.query.page)
|
||||
|
|
@ -212,6 +207,10 @@ export default Vue.extend({
|
|||
this.totalPages = 1
|
||||
this.totalElements = null
|
||||
this.series = []
|
||||
this.filterOptionsPanel.genre.values = []
|
||||
this.filterOptionsPanel.tag.values = []
|
||||
this.filterOptionsPanel.publisher.values = []
|
||||
this.filterOptionsPanel.language.values = []
|
||||
|
||||
this.loadLibrary(to.params.libraryId)
|
||||
|
||||
|
|
@ -318,6 +317,12 @@ export default Vue.extend({
|
|||
async loadLibrary (libraryId: string) {
|
||||
this.library = this.getLibraryLazy(libraryId)
|
||||
|
||||
const requestLibraryId = libraryId !== LIBRARIES_ALL ? libraryId : undefined
|
||||
this.filterOptionsPanel.genre.values.push(...toNameValue(await this.$komgaReferential.getGenres(requestLibraryId)))
|
||||
this.filterOptionsPanel.tag.values.push(...toNameValue(await this.$komgaReferential.getTags(requestLibraryId)))
|
||||
this.filterOptionsPanel.publisher.values.push(...toNameValue(await this.$komgaReferential.getPublishers(requestLibraryId)))
|
||||
this.filterOptionsPanel.language.values.push(...(await this.$komgaReferential.getLanguages(requestLibraryId)))
|
||||
|
||||
await this.loadPage(libraryId, this.page, this.sortActive)
|
||||
},
|
||||
updateRoute () {
|
||||
|
|
|
|||
|
|
@ -333,8 +333,6 @@ export default Vue.extend({
|
|||
this.pageSize = Number(this.$cookies.get(cookiePageSize))
|
||||
}
|
||||
|
||||
this.filterOptionsPanel.tag.values.push(...toNameValue(await this.$komgaReferential.getTags()))
|
||||
|
||||
// restore from query param
|
||||
this.sortActive = this.parseQuerySortOrDefault(this.$route.query.sort)
|
||||
|
||||
|
|
@ -360,6 +358,7 @@ export default Vue.extend({
|
|||
this.totalElements = null
|
||||
this.books = []
|
||||
this.collections = []
|
||||
this.filterOptionsPanel.tag.values = []
|
||||
|
||||
this.loadSeries(to.params.seriesId)
|
||||
|
||||
|
|
@ -413,6 +412,9 @@ export default Vue.extend({
|
|||
async loadSeries (seriesId: string) {
|
||||
this.series = await this.$komgaSeries.getOneSeries(seriesId)
|
||||
this.collections = await this.$komgaSeries.getCollections(seriesId)
|
||||
|
||||
this.filterOptionsPanel.tag.values.push(...toNameValue(await this.$komgaReferential.getTags(undefined, this.seriesId)))
|
||||
|
||||
await this.loadPage(seriesId, this.page, this.sortActive)
|
||||
},
|
||||
parseQuerySortOrDefault (querySort: any): SortActive {
|
||||
|
|
|
|||
Loading…
Reference in a new issue