mirror of
https://github.com/gotson/komga.git
synced 2025-12-20 15:34:17 +01:00
parent
f6dc546fd9
commit
320450a750
3 changed files with 53 additions and 20 deletions
|
|
@ -213,6 +213,7 @@
|
|||
"on_deck": "On Deck",
|
||||
"recently_added_books": "Recently Added Books",
|
||||
"recently_added_series": "Recently Added Series",
|
||||
"recently_released_books": "Recently Released Books",
|
||||
"recently_updated_series": "Recently Updated Series"
|
||||
},
|
||||
"data_import": {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import {AxiosInstance} from 'axios'
|
||||
import {BookDto, BookImportBatchDto, BookMetadataUpdateDto, PageDto, ReadProgressUpdateDto} from '@/types/komga-books'
|
||||
import {formatISO} from "date-fns";
|
||||
|
||||
const qs = require('qs')
|
||||
|
||||
|
|
@ -8,13 +9,13 @@ const API_BOOKS = '/api/v1/books'
|
|||
export default class KomgaBooksService {
|
||||
private http: AxiosInstance;
|
||||
|
||||
constructor (http: AxiosInstance) {
|
||||
constructor(http: AxiosInstance) {
|
||||
this.http = http
|
||||
}
|
||||
|
||||
async getBooks (libraryId?: string, pageRequest?: PageRequest, search?: string, mediaStatus?: string[], readStatus?: string[]): Promise<Page<BookDto>> {
|
||||
async getBooks(libraryId?: string, pageRequest?: PageRequest, search?: string, mediaStatus?: string[], readStatus?: string[], releasedAfter?: Date): Promise<Page<BookDto>> {
|
||||
try {
|
||||
const params = { ...pageRequest } as any
|
||||
const params = {...pageRequest} as any
|
||||
if (libraryId) {
|
||||
params.library_id = libraryId
|
||||
}
|
||||
|
|
@ -27,9 +28,12 @@ export default class KomgaBooksService {
|
|||
if (readStatus) {
|
||||
params.read_status = readStatus
|
||||
}
|
||||
if (releasedAfter) {
|
||||
params.released_after = formatISO(releasedAfter, { representation: 'date' })
|
||||
}
|
||||
return (await this.http.get(API_BOOKS, {
|
||||
params: params,
|
||||
paramsSerializer: params => qs.stringify(params, { indices: false }),
|
||||
paramsSerializer: params => qs.stringify(params, {indices: false}),
|
||||
})).data
|
||||
} catch (e) {
|
||||
let msg = 'An error occurred while trying to retrieve books'
|
||||
|
|
@ -40,9 +44,9 @@ export default class KomgaBooksService {
|
|||
}
|
||||
}
|
||||
|
||||
async getBooksOnDeck (libraryId?: string, pageRequest?: PageRequest): Promise<Page<BookDto>> {
|
||||
async getBooksOnDeck(libraryId?: string, pageRequest?: PageRequest): Promise<Page<BookDto>> {
|
||||
try {
|
||||
const params = { ...pageRequest } as any
|
||||
const params = {...pageRequest} as any
|
||||
if (libraryId) {
|
||||
params.library_id = libraryId
|
||||
}
|
||||
|
|
@ -58,7 +62,7 @@ export default class KomgaBooksService {
|
|||
}
|
||||
}
|
||||
|
||||
async getBook (bookId: string): Promise<BookDto> {
|
||||
async getBook(bookId: string): Promise<BookDto> {
|
||||
try {
|
||||
return (await this.http.get(`${API_BOOKS}/${bookId}`)).data
|
||||
} catch (e) {
|
||||
|
|
@ -70,7 +74,7 @@ export default class KomgaBooksService {
|
|||
}
|
||||
}
|
||||
|
||||
async getBookSiblingNext (bookId: string): Promise<BookDto> {
|
||||
async getBookSiblingNext(bookId: string): Promise<BookDto> {
|
||||
try {
|
||||
return (await this.http.get(`${API_BOOKS}/${bookId}/next`)).data
|
||||
} catch (e) {
|
||||
|
|
@ -82,7 +86,7 @@ export default class KomgaBooksService {
|
|||
}
|
||||
}
|
||||
|
||||
async getBookSiblingPrevious (bookId: string): Promise<BookDto> {
|
||||
async getBookSiblingPrevious(bookId: string): Promise<BookDto> {
|
||||
try {
|
||||
return (await this.http.get(`${API_BOOKS}/${bookId}/previous`)).data
|
||||
} catch (e) {
|
||||
|
|
@ -94,7 +98,7 @@ export default class KomgaBooksService {
|
|||
}
|
||||
}
|
||||
|
||||
async getBookPages (bookId: string): Promise<PageDto[]> {
|
||||
async getBookPages(bookId: string): Promise<PageDto[]> {
|
||||
try {
|
||||
return (await this.http.get(`${API_BOOKS}/${bookId}/pages`)).data
|
||||
} catch (e) {
|
||||
|
|
@ -106,7 +110,7 @@ export default class KomgaBooksService {
|
|||
}
|
||||
}
|
||||
|
||||
async getReadLists (bookId: string): Promise<ReadListDto[]> {
|
||||
async getReadLists(bookId: string): Promise<ReadListDto[]> {
|
||||
try {
|
||||
return (await this.http.get(`${API_BOOKS}/${bookId}/readlists`)).data
|
||||
} catch (e) {
|
||||
|
|
@ -118,7 +122,7 @@ export default class KomgaBooksService {
|
|||
}
|
||||
}
|
||||
|
||||
async analyzeBook (book: BookDto) {
|
||||
async analyzeBook(book: BookDto) {
|
||||
try {
|
||||
await this.http.post(`${API_BOOKS}/${book.id}/analyze`)
|
||||
} catch (e) {
|
||||
|
|
@ -130,7 +134,7 @@ export default class KomgaBooksService {
|
|||
}
|
||||
}
|
||||
|
||||
async refreshMetadata (book: BookDto) {
|
||||
async refreshMetadata(book: BookDto) {
|
||||
try {
|
||||
await this.http.post(`${API_BOOKS}/${book.id}/metadata/refresh`)
|
||||
} catch (e) {
|
||||
|
|
@ -142,7 +146,7 @@ export default class KomgaBooksService {
|
|||
}
|
||||
}
|
||||
|
||||
async updateMetadata (bookId: string, metadata: BookMetadataUpdateDto) {
|
||||
async updateMetadata(bookId: string, metadata: BookMetadataUpdateDto) {
|
||||
try {
|
||||
await this.http.patch(`${API_BOOKS}/${bookId}/metadata`, metadata)
|
||||
} catch (e) {
|
||||
|
|
@ -154,7 +158,7 @@ export default class KomgaBooksService {
|
|||
}
|
||||
}
|
||||
|
||||
async updateReadProgress (bookId: string, readProgress: ReadProgressUpdateDto) {
|
||||
async updateReadProgress(bookId: string, readProgress: ReadProgressUpdateDto) {
|
||||
try {
|
||||
await this.http.patch(`${API_BOOKS}/${bookId}/read-progress`, readProgress)
|
||||
} catch (e) {
|
||||
|
|
@ -166,7 +170,7 @@ export default class KomgaBooksService {
|
|||
}
|
||||
}
|
||||
|
||||
async deleteReadProgress (bookId: string) {
|
||||
async deleteReadProgress(bookId: string) {
|
||||
try {
|
||||
await this.http.delete(`${API_BOOKS}/${bookId}/read-progress`)
|
||||
} catch (e) {
|
||||
|
|
|
|||
|
|
@ -78,6 +78,21 @@
|
|||
</template>
|
||||
</horizontal-scroller>
|
||||
|
||||
<horizontal-scroller v-if="recentlyReleasedBooks.length !== 0" class="mb-4">
|
||||
<template v-slot:prepend>
|
||||
<div class="title">{{ $t('dashboard.recently_released_books') }}</div>
|
||||
</template>
|
||||
<template v-slot:content>
|
||||
<item-browser :items="recentlyReleasedBooks"
|
||||
nowrap
|
||||
:edit-function="isAdmin ? singleEditBook : undefined"
|
||||
:selected.sync="selectedBooks"
|
||||
:selectable="selectedSeries.length === 0"
|
||||
:fixed-item-width="fixedCardWidth"
|
||||
/>
|
||||
</template>
|
||||
</horizontal-scroller>
|
||||
|
||||
<horizontal-scroller v-if="latestBooks.length !== 0" class="mb-4">
|
||||
<template v-slot:prepend>
|
||||
<div class="title">{{ $t('dashboard.recently_added_books') }}</div>
|
||||
|
|
@ -147,10 +162,11 @@ import {
|
|||
SERIES_DELETED,
|
||||
} from '@/types/events'
|
||||
import Vue from 'vue'
|
||||
import {SeriesDto} from "@/types/komga-series";
|
||||
import {LIBRARIES_ALL, LIBRARY_ROUTE} from "@/types/library";
|
||||
import {SeriesDto} from "@/types/komga-series"
|
||||
import {LIBRARIES_ALL, LIBRARY_ROUTE} from "@/types/library"
|
||||
import {throttle} from 'lodash'
|
||||
import {BookSseDto, ReadProgressSseDto, SeriesSseDto} from "@/types/komga-sse";
|
||||
import {subMonths} from 'date-fns'
|
||||
import {BookSseDto, ReadProgressSseDto, SeriesSseDto} from "@/types/komga-sse"
|
||||
|
||||
export default Vue.extend({
|
||||
name: 'Dashboard',
|
||||
|
|
@ -171,6 +187,7 @@ export default Vue.extend({
|
|||
latestBooks: [] as BookDto[],
|
||||
inProgressBooks: [] as BookDto[],
|
||||
onDeckBooks: [] as BookDto[],
|
||||
recentlyReleasedBooks: [] as BookDto[],
|
||||
selectedSeries: [] as SeriesDto[],
|
||||
selectedBooks: [] as BookDto[],
|
||||
}
|
||||
|
|
@ -231,7 +248,8 @@ export default Vue.extend({
|
|||
this.updatedSeries.length === 0 &&
|
||||
this.latestBooks.length === 0 &&
|
||||
this.inProgressBooks.length === 0 &&
|
||||
this.onDeckBooks.length === 0
|
||||
this.onDeckBooks.length === 0 &&
|
||||
this.recentlyReleasedBooks.length === 0
|
||||
},
|
||||
individualLibrary(): boolean {
|
||||
return this.libraryId !== LIBRARIES_ALL
|
||||
|
|
@ -255,6 +273,7 @@ export default Vue.extend({
|
|||
if (this.inProgressBooks.some(b => b.id === event.bookId)) this.reload()
|
||||
else if (this.latestBooks.some(b => b.id === event.bookId)) this.reload()
|
||||
else if (this.onDeckBooks.some(b => b.id === event.bookId)) this.reload()
|
||||
else if (this.recentlyReleasedBooks.some(b => b.id === event.bookId)) this.reload()
|
||||
},
|
||||
reload: throttle(function(this: any) {
|
||||
this.loadAll(this.libraryId)
|
||||
|
|
@ -265,6 +284,7 @@ export default Vue.extend({
|
|||
this.selectedBooks = []
|
||||
this.loadInProgressBooks(libraryId)
|
||||
this.loadOnDeckBooks(libraryId)
|
||||
this.loadRecentlyReleasedBooks(libraryId)
|
||||
this.loadLatestBooks(libraryId)
|
||||
this.loadNewSeries(libraryId)
|
||||
this.loadUpdatedSeries(libraryId)
|
||||
|
|
@ -282,6 +302,14 @@ export default Vue.extend({
|
|||
|
||||
this.latestBooks = (await this.$komgaBooks.getBooks(this.getRequestLibraryId(libraryId), pageRequest)).content
|
||||
},
|
||||
async loadRecentlyReleasedBooks(libraryId: string) {
|
||||
const pageRequest = {
|
||||
sort: ['metadata.releaseDate,desc'],
|
||||
} as PageRequest
|
||||
|
||||
const releasedAfter = subMonths(new Date(), 1)
|
||||
this.recentlyReleasedBooks = (await this.$komgaBooks.getBooks(this.getRequestLibraryId(libraryId), pageRequest, undefined, undefined, undefined, releasedAfter)).content
|
||||
},
|
||||
async loadInProgressBooks(libraryId: string) {
|
||||
const pageRequest = {
|
||||
sort: ['readProgress.lastModified,desc'],
|
||||
|
|
|
|||
Loading…
Reference in a new issue