Skip to content

Commit

Permalink
feat(webui): filter series by age rating
Browse files Browse the repository at this point in the history
  • Loading branch information
gotson committed Aug 28, 2020
1 parent f51d575 commit 01eef83
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
18 changes: 18 additions & 0 deletions komga-webui/src/services/komga-referential.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion komga-webui/src/services/komga-series.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion komga-webui/src/views/BrowseLibraries.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
},
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 01eef83

Please sign in to comment.