mirror of
https://github.com/gotson/komga.git
synced 2026-05-01 03:11:32 +02:00
parent
449a27e136
commit
50b516d0c5
5 changed files with 111 additions and 20 deletions
|
|
@ -106,7 +106,7 @@ export default Vue.extend({
|
||||||
this.modal = val
|
this.modal = val
|
||||||
if (val) {
|
if (val) {
|
||||||
this.newCollection = ''
|
this.newCollection = ''
|
||||||
this.collections = await this.$komgaCollections.getCollections()
|
this.collections = (await this.$komgaCollections.getCollections(undefined, undefined, true)).content
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
modal (val) {
|
modal (val) {
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ export default Vue.extend({
|
||||||
async dialogReset (collection: CollectionDto) {
|
async dialogReset (collection: CollectionDto) {
|
||||||
this.form.name = collection.name
|
this.form.name = collection.name
|
||||||
this.form.ordered = collection.ordered
|
this.form.ordered = collection.ordered
|
||||||
this.collections = await this.$komgaCollections.getCollections()
|
this.collections = (await this.$komgaCollections.getCollections(undefined, undefined, true)).content
|
||||||
},
|
},
|
||||||
dialogCancel () {
|
dialogCancel () {
|
||||||
this.$emit('input', false)
|
this.$emit('input', false)
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,13 @@ export default class KomgaCollectionsService {
|
||||||
this.http = http
|
this.http = http
|
||||||
}
|
}
|
||||||
|
|
||||||
async getCollections (libraryIds?: number[]): Promise<CollectionDto[]> {
|
async getCollections (libraryIds?: number[], pageRequest?: PageRequest, unpaged?: boolean, search?: string): Promise<Page<CollectionDto>> {
|
||||||
try {
|
try {
|
||||||
const params = {} as any
|
const params = { ...pageRequest } as any
|
||||||
if (libraryIds) {
|
if (libraryIds) params.library_id = libraryIds
|
||||||
params.library_id = libraryIds
|
if (unpaged) params.unpaged = unpaged
|
||||||
}
|
if (search) params.search = search
|
||||||
|
|
||||||
return (await this.http.get(API_COLLECTIONS, {
|
return (await this.http.get(API_COLLECTIONS, {
|
||||||
params: params,
|
params: params,
|
||||||
paramsSerializer: params => qs.stringify(params, { indices: false }),
|
paramsSerializer: params => qs.stringify(params, { indices: false }),
|
||||||
|
|
|
||||||
|
|
@ -9,15 +9,25 @@
|
||||||
<span>{{ library ? library.name : 'All libraries' }}</span>
|
<span>{{ library ? library.name : 'All libraries' }}</span>
|
||||||
<badge class="ml-4">{{ collections.length }}</badge>
|
<badge class="ml-4">{{ collections.length }}</badge>
|
||||||
</v-toolbar-title>
|
</v-toolbar-title>
|
||||||
|
|
||||||
|
<v-spacer/>
|
||||||
|
|
||||||
|
<page-size-select v-model="pageSize"/>
|
||||||
</toolbar-sticky>
|
</toolbar-sticky>
|
||||||
|
|
||||||
<library-navigation :libraryId="libraryId"/>
|
<library-navigation :libraryId="libraryId"/>
|
||||||
|
|
||||||
<v-container fluid class="px-6">
|
<v-container fluid>
|
||||||
|
<v-pagination
|
||||||
|
v-if="totalPages > 1"
|
||||||
|
v-model="page"
|
||||||
|
:total-visible="paginationVisible"
|
||||||
|
:length="totalPages"
|
||||||
|
/>
|
||||||
|
|
||||||
<item-browser
|
<item-browser
|
||||||
:items="collections"
|
:items="collections"
|
||||||
:selectable="false"
|
:selectable="false"
|
||||||
class="px-4"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</v-container>
|
</v-container>
|
||||||
|
|
@ -30,6 +40,7 @@ import Badge from '@/components/Badge.vue'
|
||||||
import ItemBrowser from '@/components/ItemBrowser.vue'
|
import ItemBrowser from '@/components/ItemBrowser.vue'
|
||||||
import LibraryActionsMenu from '@/components/LibraryActionsMenu.vue'
|
import LibraryActionsMenu from '@/components/LibraryActionsMenu.vue'
|
||||||
import LibraryNavigation from '@/components/LibraryNavigation.vue'
|
import LibraryNavigation from '@/components/LibraryNavigation.vue'
|
||||||
|
import PageSizeSelect from '@/components/PageSizeSelect.vue'
|
||||||
import ToolbarSticky from '@/components/ToolbarSticky.vue'
|
import ToolbarSticky from '@/components/ToolbarSticky.vue'
|
||||||
import { COLLECTION_CHANGED } from '@/types/events'
|
import { COLLECTION_CHANGED } from '@/types/events'
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
|
@ -44,11 +55,18 @@ export default Vue.extend({
|
||||||
LibraryNavigation,
|
LibraryNavigation,
|
||||||
ItemBrowser,
|
ItemBrowser,
|
||||||
Badge,
|
Badge,
|
||||||
|
PageSizeSelect,
|
||||||
},
|
},
|
||||||
data: () => {
|
data: () => {
|
||||||
return {
|
return {
|
||||||
library: undefined as LibraryDto | undefined,
|
library: undefined as LibraryDto | undefined,
|
||||||
collections: [] as CollectionDto[],
|
collections: [] as CollectionDto[],
|
||||||
|
page: 1,
|
||||||
|
pageSize: 20,
|
||||||
|
totalPages: 1,
|
||||||
|
totalElements: null as number | null,
|
||||||
|
pageUnwatch: null as any,
|
||||||
|
pageSizeUnwatch: null as any,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
|
@ -64,11 +82,24 @@ export default Vue.extend({
|
||||||
this.$eventHub.$off(COLLECTION_CHANGED, this.reloadCollections)
|
this.$eventHub.$off(COLLECTION_CHANGED, this.reloadCollections)
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
|
if (this.$cookies.isKey(cookiePageSize)) {
|
||||||
|
this.pageSize = Number(this.$cookies.get(cookiePageSize))
|
||||||
|
}
|
||||||
|
|
||||||
|
// restore from query param
|
||||||
|
if (this.$route.query.page) this.page = Number(this.$route.query.page)
|
||||||
|
if (this.$route.query.pageSize) this.pageSize = Number(this.$route.query.pageSize)
|
||||||
|
|
||||||
this.loadLibrary(this.libraryId)
|
this.loadLibrary(this.libraryId)
|
||||||
|
|
||||||
|
this.setWatches()
|
||||||
},
|
},
|
||||||
beforeRouteUpdate (to, from, next) {
|
beforeRouteUpdate (to, from, next) {
|
||||||
if (to.params.libraryId !== from.params.libraryId) {
|
if (to.params.libraryId !== from.params.libraryId) {
|
||||||
// reset
|
// reset
|
||||||
|
this.page = 1
|
||||||
|
this.totalPages = 1
|
||||||
|
this.totalElements = null
|
||||||
this.collections = []
|
this.collections = []
|
||||||
|
|
||||||
this.loadLibrary(Number(to.params.libraryId))
|
this.loadLibrary(Number(to.params.libraryId))
|
||||||
|
|
@ -80,19 +111,81 @@ export default Vue.extend({
|
||||||
isAdmin (): boolean {
|
isAdmin (): boolean {
|
||||||
return this.$store.getters.meAdmin
|
return this.$store.getters.meAdmin
|
||||||
},
|
},
|
||||||
|
paginationVisible (): number {
|
||||||
|
switch (this.$vuetify.breakpoint.name) {
|
||||||
|
case 'xs':
|
||||||
|
return 5
|
||||||
|
case 'sm':
|
||||||
|
case 'md':
|
||||||
|
return 10
|
||||||
|
case 'lg':
|
||||||
|
case 'xl':
|
||||||
|
default:
|
||||||
|
return 15
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
setWatches () {
|
||||||
|
this.pageSizeUnwatch = this.$watch('pageSize', (val) => {
|
||||||
|
this.$cookies.set(cookiePageSize, val, Infinity)
|
||||||
|
this.updateRouteAndReload()
|
||||||
|
})
|
||||||
|
|
||||||
|
this.pageUnwatch = this.$watch('page', (val) => {
|
||||||
|
this.updateRoute()
|
||||||
|
this.loadPage(this.libraryId, val)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
unsetWatches () {
|
||||||
|
this.pageUnwatch()
|
||||||
|
this.pageSizeUnwatch()
|
||||||
|
},
|
||||||
|
updateRouteAndReload () {
|
||||||
|
this.unsetWatches()
|
||||||
|
|
||||||
|
this.page = 1
|
||||||
|
|
||||||
|
this.updateRoute()
|
||||||
|
this.loadPage(this.libraryId, this.page)
|
||||||
|
|
||||||
|
this.setWatches()
|
||||||
|
},
|
||||||
|
updateRoute () {
|
||||||
|
this.$router.replace({
|
||||||
|
name: this.$route.name,
|
||||||
|
params: { libraryId: this.$route.params.libraryId },
|
||||||
|
query: {
|
||||||
|
page: `${this.page}`,
|
||||||
|
pageSize: `${this.pageSize}`,
|
||||||
|
},
|
||||||
|
}).catch(_ => {
|
||||||
|
})
|
||||||
|
},
|
||||||
reloadCollections () {
|
reloadCollections () {
|
||||||
this.loadLibrary(this.libraryId)
|
this.loadLibrary(this.libraryId)
|
||||||
},
|
},
|
||||||
async loadLibrary (libraryId: number) {
|
async loadLibrary (libraryId: number) {
|
||||||
this.library = this.getLibraryLazy(libraryId)
|
this.library = this.getLibraryLazy(libraryId)
|
||||||
const lib = libraryId !== 0 ? [libraryId] : undefined
|
await this.loadPage(libraryId, this.page)
|
||||||
this.collections = await this.$komgaCollections.getCollections(lib)
|
|
||||||
if (this.collections.length === 0) {
|
if (this.totalElements === 0) {
|
||||||
await this.$router.push({ name: 'browse-libraries', params: { libraryId: libraryId.toString() } })
|
await this.$router.push({ name: 'browse-libraries', params: { libraryId: libraryId.toString() } })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async loadPage (libraryId: number, page: number) {
|
||||||
|
const pageRequest = {
|
||||||
|
page: page - 1,
|
||||||
|
size: this.pageSize,
|
||||||
|
} as PageRequest
|
||||||
|
|
||||||
|
const lib = libraryId !== 0 ? [libraryId] : undefined
|
||||||
|
const collectionsPage = await this.$komgaCollections.getCollections(lib, pageRequest)
|
||||||
|
|
||||||
|
this.totalPages = collectionsPage.totalPages
|
||||||
|
this.totalElements = collectionsPage.totalElements
|
||||||
|
this.collections = collectionsPage.content
|
||||||
|
},
|
||||||
getLibraryLazy (libraryId: any): LibraryDto | undefined {
|
getLibraryLazy (libraryId: any): LibraryDto | undefined {
|
||||||
if (libraryId !== 0) {
|
if (libraryId !== 0) {
|
||||||
return this.$store.getters.getLibraryById(libraryId)
|
return this.$store.getters.getLibraryById(libraryId)
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@
|
||||||
</toolbar-sticky>
|
</toolbar-sticky>
|
||||||
</v-scroll-y-transition>
|
</v-scroll-y-transition>
|
||||||
|
|
||||||
<library-navigation v-if="collections.length > 0"
|
<library-navigation v-if="collectionsCount > 0"
|
||||||
:libraryId="libraryId"
|
:libraryId="libraryId"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
@ -178,7 +178,7 @@ export default Vue.extend({
|
||||||
dialogEdit: false,
|
dialogEdit: false,
|
||||||
dialogEditSingle: false,
|
dialogEditSingle: false,
|
||||||
dialogAddToCollection: false,
|
dialogAddToCollection: false,
|
||||||
collections: [] as CollectionDto[],
|
collectionsCount: 0,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
|
@ -245,7 +245,7 @@ export default Vue.extend({
|
||||||
this.totalPages = 1
|
this.totalPages = 1
|
||||||
this.totalElements = null
|
this.totalElements = null
|
||||||
this.series = []
|
this.series = []
|
||||||
this.collections = []
|
this.collectionsCount = 0
|
||||||
|
|
||||||
this.loadLibrary(Number(to.params.libraryId))
|
this.loadLibrary(Number(to.params.libraryId))
|
||||||
|
|
||||||
|
|
@ -322,7 +322,7 @@ export default Vue.extend({
|
||||||
this.library = this.getLibraryLazy(libraryId)
|
this.library = this.getLibraryLazy(libraryId)
|
||||||
|
|
||||||
const lib = libraryId !== 0 ? [libraryId] : undefined
|
const lib = libraryId !== 0 ? [libraryId] : undefined
|
||||||
this.collections = await this.$komgaCollections.getCollections(lib)
|
this.collectionsCount = (await this.$komgaCollections.getCollections(lib, { size: 1 })).totalElements
|
||||||
|
|
||||||
await this.loadPage(libraryId, this.page, this.sortActive)
|
await this.loadPage(libraryId, this.page, this.sortActive)
|
||||||
},
|
},
|
||||||
|
|
@ -353,10 +353,7 @@ export default Vue.extend({
|
||||||
pageRequest.sort = [`${sort.key},${sort.order}`]
|
pageRequest.sort = [`${sort.key},${sort.order}`]
|
||||||
}
|
}
|
||||||
|
|
||||||
let requestLibraryId
|
const requestLibraryId = libraryId !== 0 ? libraryId : undefined
|
||||||
if (libraryId !== 0) {
|
|
||||||
requestLibraryId = libraryId
|
|
||||||
}
|
|
||||||
const seriesPage = await this.$komgaSeries.getSeries(requestLibraryId, pageRequest, undefined, this.filters[1], this.filters[0])
|
const seriesPage = await this.$komgaSeries.getSeries(requestLibraryId, pageRequest, undefined, this.filters[1], this.filters[0])
|
||||||
|
|
||||||
this.totalPages = seriesPage.totalPages
|
this.totalPages = seriesPage.totalPages
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue