diff --git a/komga-webui/src/components/LibraryNavigation.vue b/komga-webui/src/components/LibraryNavigation.vue index fca907de..5d4820a4 100644 --- a/komga-webui/src/components/LibraryNavigation.vue +++ b/komga-webui/src/components/LibraryNavigation.vue @@ -1,31 +1,78 @@ diff --git a/komga-webui/src/views/Home.vue b/komga-webui/src/views/Home.vue index 7018d5dd..3b0a3142 100644 --- a/komga-webui/src/views/Home.vue +++ b/komga-webui/src/views/Home.vue @@ -25,7 +25,7 @@ - + mdi-home @@ -34,7 +34,7 @@ - + mdi-book-multiple @@ -51,7 +51,7 @@ @@ -158,12 +158,14 @@ import LibraryActionsMenu from '@/components/menus/LibraryActionsMenu.vue' import SearchBox from '@/components/SearchBox.vue' import {Theme} from '@/types/themes' import Vue from 'vue' +import {LIBRARIES_ALL} from "@/types/library"; export default Vue.extend({ name: 'home', components: {LibraryActionsMenu, SearchBox, Dialogs}, data: function () { return { + LIBRARIES_ALL, drawerVisible: this.$vuetify.breakpoint.lgAndUp, info: {} as ActuatorInfo, locales: this.$i18n.availableLocales.map((x: any) => ({text: this.$i18n.t('common.locale_name', x), value: x})), diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/BookDtoDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/BookDtoDao.kt index c1168b86..f7acc311 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/BookDtoDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/BookDtoDao.kt @@ -144,14 +144,12 @@ class BookDtoDao( ): BookDto? = findSiblingReadList(readListId, bookId, userId, filterOnLibraryIds, next = true) - override fun findOnDeck(libraryIds: Collection, userId: String, pageable: Pageable): Page { - val conditions = if (libraryIds.isEmpty()) DSL.trueCondition() else s.LIBRARY_ID.`in`(libraryIds) - + override fun findOnDeck(userId: String, filterOnLibraryIds: Collection?, pageable: Pageable): Page { val seriesIds = dsl.select(s.ID) .from(s) .leftJoin(b).on(s.ID.eq(b.SERIES_ID)) .leftJoin(r).on(b.ID.eq(r.BOOK_ID)).and(readProgressCondition(userId)) - .where(conditions) + .apply { filterOnLibraryIds?.let { where(s.LIBRARY_ID.`in`(it)) } } .groupBy(s.ID) .having(SeriesDtoDao.countUnread.ge(inline(1.toBigDecimal()))) .and(SeriesDtoDao.countRead.ge(inline(1.toBigDecimal()))) diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/BookController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/BookController.kt index 3cf54f2d..ad003eb8 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/BookController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/BookController.kt @@ -153,16 +153,14 @@ class BookController( @GetMapping("api/v1/books/ondeck") fun getBooksOnDeck( @AuthenticationPrincipal principal: KomgaPrincipal, + @RequestParam(name = "library_id", required = false) libraryIds: List?, @Parameter(hidden = true) page: Pageable - ): Page { - val libraryIds = if (principal.user.sharedAllLibraries) emptySet() else principal.user.sharedLibrariesIds - - return bookDtoRepository.findOnDeck( - libraryIds, + ): Page = + bookDtoRepository.findOnDeck( principal.user.id, + principal.user.getAuthorizedLibraryIds(libraryIds), page ).map { it.restrictUrl(!principal.user.roleAdmin) } - } @GetMapping("api/v1/books/{bookId}") fun getOneBook( @@ -289,7 +287,10 @@ class BookController( val media = mediaRepository.findById(book.id) when (media.status) { Media.Status.UNKNOWN -> throw ResponseStatusException(HttpStatus.NOT_FOUND, "Book has not been analyzed yet") - Media.Status.OUTDATED -> throw ResponseStatusException(HttpStatus.NOT_FOUND, "Book is outdated and must be re-analyzed") + Media.Status.OUTDATED -> throw ResponseStatusException( + HttpStatus.NOT_FOUND, + "Book is outdated and must be re-analyzed" + ) Media.Status.ERROR -> throw ResponseStatusException(HttpStatus.NOT_FOUND, "Book analysis failed") Media.Status.UNSUPPORTED -> throw ResponseStatusException(HttpStatus.NOT_FOUND, "Book format is not supported") Media.Status.READY -> media.pages.mapIndexed { index, s -> @@ -319,7 +320,10 @@ class BookController( request: WebRequest, @PathVariable bookId: String, @PathVariable pageNumber: Int, - @Parameter(description = "Convert the image to the provided format.", schema = Schema(allowableValues = ["jpeg", "png"])) + @Parameter( + description = "Convert the image to the provided format.", + schema = Schema(allowableValues = ["jpeg", "png"]) + ) @RequestParam(value = "convert", required = false) convertTo: String?, @Parameter(description = "If set to true, pages will start at index 0. If set to false, pages will start at index 1.") @RequestParam(value = "zero_based", defaultValue = "false") zeroBasedIndex: Boolean diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/persistence/BookDtoRepository.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/persistence/BookDtoRepository.kt index d626375a..3762932e 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/persistence/BookDtoRepository.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/persistence/BookDtoRepository.kt @@ -37,5 +37,5 @@ interface BookDtoRepository { filterOnLibraryIds: Collection? ): BookDto? - fun findOnDeck(libraryIds: Collection, userId: String, pageable: Pageable): Page + fun findOnDeck(userId: String, filterOnLibraryIds: Collection?, pageable: Pageable): Page } diff --git a/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/BookDtoDaoTest.kt b/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/BookDtoDaoTest.kt index 7ca2335d..2d23fcd9 100644 --- a/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/BookDtoDaoTest.kt +++ b/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/BookDtoDaoTest.kt @@ -231,8 +231,8 @@ class BookDtoDaoTest( // when val found = bookDtoDao.findOnDeck( - emptyList(), user.id, + null, PageRequest.of(0, 20) ) @@ -252,8 +252,8 @@ class BookDtoDaoTest( // when val found = bookDtoDao.findOnDeck( - emptyList(), user.id, + null, PageRequest.of(0, 20) ) @@ -276,8 +276,8 @@ class BookDtoDaoTest( // when val found = bookDtoDao.findOnDeck( - emptyList(), user.id, + null, PageRequest.of(0, 20) )