mirror of
https://github.com/gotson/komga.git
synced 2025-12-22 00:13:30 +01:00
feat(webui): filter series by age rating
This commit is contained in:
parent
f51d575bda
commit
01eef838a2
3 changed files with 26 additions and 2 deletions
|
|
@ -84,6 +84,24 @@ export default class KomgaReferentialService {
|
|||
}
|
||||
}
|
||||
|
||||
async getAgeRatings (libraryId?: string): Promise<string[]> {
|
||||
try {
|
||||
const params = {} as any
|
||||
if (libraryId) params.library_id = libraryId
|
||||
|
||||
return (await this.http.get('/api/v1/age-ratings', {
|
||||
params: params,
|
||||
paramsSerializer: params => qs.stringify(params, { indices: false }),
|
||||
})).data
|
||||
} catch (e) {
|
||||
let msg = 'An error occurred while trying to retrieve age ratings'
|
||||
if (e.response.data.message) {
|
||||
msg += `: ${e.response.data.message}`
|
||||
}
|
||||
throw new Error(msg)
|
||||
}
|
||||
}
|
||||
|
||||
async getLanguages (libraryId?: string): Promise<NameValue[]> {
|
||||
try {
|
||||
const params = {} as any
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ export default class KomgaSeriesService {
|
|||
this.http = http
|
||||
}
|
||||
|
||||
async getSeries (libraryId?: string, pageRequest?: PageRequest, search?: string, status?: string[], readStatus?: string[], genre?: string[], tag?: string[], language?: string[], publisher?: string[]): Promise<Page<SeriesDto>> {
|
||||
async getSeries (libraryId?: string, pageRequest?: PageRequest, search?: string, status?: string[],
|
||||
readStatus?: string[], genre?: string[], tag?: string[], language?: string[],
|
||||
publisher?: string[], ageRating?: string[]): Promise<Page<SeriesDto>> {
|
||||
try {
|
||||
const params = { ...pageRequest } as any
|
||||
if (libraryId) params.library_id = libraryId
|
||||
|
|
@ -22,6 +24,7 @@ export default class KomgaSeriesService {
|
|||
if (tag) params.tag = tag
|
||||
if (language) params.language = language
|
||||
if (publisher) params.publisher = publisher
|
||||
if (ageRating) params.age_rating = ageRating
|
||||
|
||||
return (await this.http.get(API_SERIES, {
|
||||
params: params,
|
||||
|
|
|
|||
|
|
@ -148,6 +148,7 @@ export default Vue.extend({
|
|||
tag: { name: 'TAG', values: [] },
|
||||
publisher: { name: 'PUBLISHER', values: [] },
|
||||
language: { name: 'LANGUAGE', values: [] },
|
||||
ageRating: { name: 'AGE RATING', values: [] },
|
||||
} as FiltersOptions,
|
||||
filters: {} as FiltersActive,
|
||||
sortUnwatch: null as any,
|
||||
|
|
@ -211,6 +212,7 @@ export default Vue.extend({
|
|||
this.filterOptionsPanel.tag.values = []
|
||||
this.filterOptionsPanel.publisher.values = []
|
||||
this.filterOptionsPanel.language.values = []
|
||||
this.filterOptionsPanel.ageRating.values = []
|
||||
|
||||
this.loadLibrary(to.params.libraryId)
|
||||
|
||||
|
|
@ -322,6 +324,7 @@ export default Vue.extend({
|
|||
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)))
|
||||
this.filterOptionsPanel.ageRating.values.push(...toNameValue(await this.$komgaReferential.getAgeRatings(requestLibraryId)))
|
||||
|
||||
await this.loadPage(libraryId, this.page, this.sortActive)
|
||||
},
|
||||
|
|
@ -350,7 +353,7 @@ export default Vue.extend({
|
|||
}
|
||||
|
||||
const requestLibraryId = libraryId !== LIBRARIES_ALL ? libraryId : undefined
|
||||
const seriesPage = await this.$komgaSeries.getSeries(requestLibraryId, pageRequest, undefined, this.filters.status, this.filters.readStatus, this.filters.genre, this.filters.tag, this.filters.language, this.filters.publisher)
|
||||
const seriesPage = await this.$komgaSeries.getSeries(requestLibraryId, pageRequest, undefined, this.filters.status, this.filters.readStatus, this.filters.genre, this.filters.tag, this.filters.language, this.filters.publisher, this.filters.ageRating)
|
||||
|
||||
this.totalPages = seriesPage.totalPages
|
||||
this.totalElements = seriesPage.totalElements
|
||||
|
|
|
|||
Loading…
Reference in a new issue