diff --git a/komga-webui/src/services/komga-referential.service.ts b/komga-webui/src/services/komga-referential.service.ts index 17509a51..6fca117a 100644 --- a/komga-webui/src/services/komga-referential.service.ts +++ b/komga-webui/src/services/komga-referential.service.ts @@ -1,5 +1,6 @@ import {AxiosInstance} from 'axios' import {AuthorDto} from '@/types/komga-books' +import {NameValue} from '@/types/filter' const qs = require('qs') const tags = require('language-tags') @@ -11,12 +12,12 @@ export default class KomgaReferentialService { this.http = http } - async getAuthors(search?: string, role?: string, libraryId?: string, collectionId?: string, seriesId?: string, readListId?: string): Promise> { + async getAuthors(search?: string, role?: string, libraryIds?: string[], collectionId?: string, seriesId?: string, readListId?: string): Promise> { try { const params = {} as any if (search) params.search = search if (role) params.role = role - if (libraryId) params.library_id = libraryId + if (libraryIds) params.library_id = libraryIds if (collectionId) params.collection_id = collectionId if (seriesId) params.series_id = seriesId if (readListId) params.readlist_id = readListId @@ -53,10 +54,10 @@ export default class KomgaReferentialService { } } - async getGenres(libraryId?: string, collectionId?: string): Promise { + async getGenres(libraryIds?: string[], collectionId?: string): Promise { try { const params = {} as any - if (libraryId) params.library_id = libraryId + if (libraryIds) params.library_id = libraryIds if (collectionId) params.collection_id = collectionId return (await this.http.get('/api/v1/genres', { @@ -84,10 +85,10 @@ export default class KomgaReferentialService { } } - async getSharingLabels(libraryId?: string, collectionId?: string): Promise { + async getSharingLabels(libraryIds?: string[], collectionId?: string): Promise { try { const params = {} as any - if (libraryId) params.library_id = libraryId + if (libraryIds) params.library_id = libraryIds if (collectionId) params.collection_id = collectionId return (await this.http.get('/api/v1/sharing-labels', { @@ -103,10 +104,10 @@ export default class KomgaReferentialService { } } - async getSeriesAndBookTags(libraryId?: string, collectionId?: string): Promise { + async getSeriesAndBookTags(libraryIds?: string[], collectionId?: string): Promise { try { const params = {} as any - if (libraryId) params.library_id = libraryId + if (libraryIds) params.library_id = libraryIds if (collectionId) params.collection_id = collectionId return (await this.http.get('/api/v1/tags', { @@ -141,10 +142,10 @@ export default class KomgaReferentialService { } } - async getPublishers(libraryId?: string, collectionId?: string): Promise { + async getPublishers(libraryIds?: string[], collectionId?: string): Promise { try { const params = {} as any - if (libraryId) params.library_id = libraryId + if (libraryIds) params.library_id = libraryIds if (collectionId) params.collection_id = collectionId return (await this.http.get('/api/v1/publishers', { @@ -160,10 +161,10 @@ export default class KomgaReferentialService { } } - async getAgeRatings(libraryId?: string, collectionId?: string): Promise { + async getAgeRatings(libraryIds?: string[], collectionId?: string): Promise { try { const params = {} as any - if (libraryId) params.library_id = libraryId + if (libraryIds) params.library_id = libraryIds if (collectionId) params.collection_id = collectionId return (await this.http.get('/api/v1/age-ratings', { @@ -179,10 +180,10 @@ export default class KomgaReferentialService { } } - async getSeriesReleaseDates(libraryId?: string, collectionId?: string): Promise { + async getSeriesReleaseDates(libraryIds?: string[], collectionId?: string): Promise { try { const params = {} as any - if (libraryId) params.library_id = libraryId + if (libraryIds) params.library_id = libraryIds if (collectionId) params.collection_id = collectionId return (await this.http.get('/api/v1/series/release-dates', { @@ -198,10 +199,10 @@ export default class KomgaReferentialService { } } - async getLanguages(libraryId?: string, collectionId?: string): Promise { + async getLanguages(libraryIds?: string[], collectionId?: string): Promise { try { const params = {} as any - if (libraryId) params.library_id = libraryId + if (libraryIds) params.library_id = libraryIds if (collectionId) params.collection_id = collectionId const data = (await this.http.get('/api/v1/languages', { diff --git a/komga-webui/src/views/BrowseLibraries.vue b/komga-webui/src/views/BrowseLibraries.vue index bb44c8eb..136fa3b3 100644 --- a/komga-webui/src/views/BrowseLibraries.vue +++ b/komga-webui/src/views/BrowseLibraries.vue @@ -342,6 +342,9 @@ export default Vue.extend({ library(): LibraryDto | undefined { return this.getLibraryLazy(this.libraryId) }, + requestLibraryIds(): string[] { + return this.libraryId !== LIBRARIES_ALL ? [this.libraryId] : this.$store.getters.getLibrariesPinned.map((it: LibraryDto) => it.id) + }, toolbarTitle(): string { if (this.library) return this.library.name else if (this.$store.getters.getLibrariesPinned.length > 0) return this.$t('common.pinned_libraries').toString() @@ -441,7 +444,7 @@ export default Vue.extend({ r[role] = { name: this.$t(`author_roles.${role}`).toString(), search: async search => { - return (await this.$komgaReferential.getAuthors(search, role, this.libraryId !== LIBRARIES_ALL ? this.libraryId : undefined)) + return (await this.$komgaReferential.getAuthors(search, role, this.requestLibraryIds)) .content .map(x => x.name) }, @@ -501,17 +504,17 @@ export default Vue.extend({ this.$store.getters.getLibrarySort(route.params.libraryId) || this.$_.clone(this.sortDefault) - const requestLibraryId = libraryId !== LIBRARIES_ALL ? libraryId : undefined + const requestLibraryIds = libraryId !== LIBRARIES_ALL ? [libraryId] : this.$store.getters.getLibrariesPinned.map((it: LibraryDto) => it.id) // load dynamic filters const [genres, tags, publishers, languages, ageRatings, releaseDates, sharingLabels] = await Promise.all([ - this.$komgaReferential.getGenres(requestLibraryId), - this.$komgaReferential.getSeriesAndBookTags(requestLibraryId), - this.$komgaReferential.getPublishers(requestLibraryId), - this.$komgaReferential.getLanguages(requestLibraryId), - this.$komgaReferential.getAgeRatings(requestLibraryId), - this.$komgaReferential.getSeriesReleaseDates(requestLibraryId), - this.$komgaReferential.getSharingLabels(requestLibraryId), + this.$komgaReferential.getGenres(requestLibraryIds), + this.$komgaReferential.getSeriesAndBookTags(requestLibraryIds), + this.$komgaReferential.getPublishers(requestLibraryIds), + this.$komgaReferential.getLanguages(requestLibraryIds), + this.$komgaReferential.getAgeRatings(requestLibraryIds), + this.$komgaReferential.getSeriesReleaseDates(requestLibraryIds), + this.$komgaReferential.getSharingLabels(requestLibraryIds), ]) this.$set(this.filterOptions, 'genre', toNameValueCondition(genres, x => new SearchConditionGenre(new SearchOperatorIs(x)), x => new SearchConditionGenre(new SearchOperatorIsNot(x)))) this.$set(this.filterOptions, 'tag', toNameValueCondition(tags, x => new SearchConditionTag(new SearchOperatorIs(x)), x => new SearchConditionTag(new SearchOperatorIsNot(x))))