mirror of
https://github.com/gotson/komga.git
synced 2026-02-15 20:02:40 +01:00
parent
7f3c49280b
commit
7984cef066
7 changed files with 77 additions and 53 deletions
|
|
@ -90,7 +90,7 @@
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { getReadProgress, getReadProgressPercentage } from '@/functions/book-progress'
|
import { getReadProgress, getReadProgressPercentage } from '@/functions/book-progress'
|
||||||
import { ReadProgress } from '@/types/enum-books'
|
import { ReadStatus } from '@/types/enum-books'
|
||||||
import { createItem, Item } from '@/types/items'
|
import { createItem, Item } from '@/types/items'
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
|
||||||
|
|
@ -165,11 +165,11 @@ export default Vue.extend({
|
||||||
return this.computedItem.body()
|
return this.computedItem.body()
|
||||||
},
|
},
|
||||||
isInProgress (): boolean {
|
isInProgress (): boolean {
|
||||||
if ('seriesId' in this.item) return getReadProgress(this.item) === ReadProgress.IN_PROGRESS
|
if ('seriesId' in this.item) return getReadProgress(this.item) === ReadStatus.IN_PROGRESS
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
isUnread (): boolean {
|
isUnread (): boolean {
|
||||||
if ('seriesId' in this.item) return getReadProgress(this.item) === ReadProgress.UNREAD
|
if ('seriesId' in this.item) return getReadProgress(this.item) === ReadStatus.UNREAD
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
unreadCount (): number | undefined {
|
unreadCount (): number | undefined {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import { ReadProgress } from '@/types/enum-books'
|
import { ReadStatus } from '@/types/enum-books'
|
||||||
|
|
||||||
export function getReadProgress (book: BookDto): ReadProgress {
|
export function getReadProgress (book: BookDto): ReadStatus {
|
||||||
if (book.readProgress?.completed) return ReadProgress.READ
|
if (book.readProgress?.completed) return ReadStatus.READ
|
||||||
if (book.readProgress?.completed === false) return ReadProgress.IN_PROGRESS
|
if (book.readProgress?.completed === false) return ReadStatus.IN_PROGRESS
|
||||||
return ReadProgress.UNREAD
|
return ReadStatus.UNREAD
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getReadProgressPercentage (book: BookDto): number {
|
export function getReadProgressPercentage (book: BookDto): number {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ export default class KomgaBooksService {
|
||||||
this.http = http
|
this.http = http
|
||||||
}
|
}
|
||||||
|
|
||||||
async getBooks (libraryId?: number, pageRequest?: PageRequest, search?: string, mediaStatus?: string[]): Promise<Page<BookDto>> {
|
async getBooks (libraryId?: number, pageRequest?: PageRequest, search?: string, mediaStatus?: string[], readStatus?: string[]): Promise<Page<BookDto>> {
|
||||||
try {
|
try {
|
||||||
const params = { ...pageRequest } as any
|
const params = { ...pageRequest } as any
|
||||||
if (libraryId) {
|
if (libraryId) {
|
||||||
|
|
@ -23,6 +23,9 @@ export default class KomgaBooksService {
|
||||||
if (mediaStatus) {
|
if (mediaStatus) {
|
||||||
params.media_status = mediaStatus
|
params.media_status = mediaStatus
|
||||||
}
|
}
|
||||||
|
if (readStatus) {
|
||||||
|
params.read_status = readStatus
|
||||||
|
}
|
||||||
return (await this.http.get(API_BOOKS, {
|
return (await this.http.get(API_BOOKS, {
|
||||||
params: params,
|
params: params,
|
||||||
paramsSerializer: params => qs.stringify(params, { indices: false }),
|
paramsSerializer: params => qs.stringify(params, { indices: false }),
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ export default class KomgaSeriesService {
|
||||||
params: params,
|
params: params,
|
||||||
})).data
|
})).data
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
let msg = 'An error occurred while trying to retrieve new series'
|
let msg = 'An error occurred while trying to retrieve updated series'
|
||||||
if (e.response.data.message) {
|
if (e.response.data.message) {
|
||||||
msg += `: ${e.response.data.message}`
|
msg += `: ${e.response.data.message}`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ export enum MediaStatus {
|
||||||
OUTDATED = 'OUTDATED'
|
OUTDATED = 'OUTDATED'
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ReadProgress {
|
export enum ReadStatus {
|
||||||
UNREAD = 'UNREAD',
|
UNREAD = 'UNREAD',
|
||||||
READ = 'READ',
|
READ = 'READ',
|
||||||
IN_PROGRESS = 'IN_PROGRESS'
|
IN_PROGRESS = 'IN_PROGRESS'
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,7 @@ import { getBookFormatFromMediaType } from '@/functions/book-format'
|
||||||
import { getReadProgress, getReadProgressPercentage } from '@/functions/book-progress'
|
import { getReadProgress, getReadProgressPercentage } from '@/functions/book-progress'
|
||||||
import { getBookTitleCompact } from '@/functions/book-title'
|
import { getBookTitleCompact } from '@/functions/book-title'
|
||||||
import { bookFileUrl, bookThumbnailUrl } from '@/functions/urls'
|
import { bookFileUrl, bookThumbnailUrl } from '@/functions/urls'
|
||||||
import { ReadProgress } from '@/types/enum-books'
|
import { ReadStatus } from '@/types/enum-books'
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
|
|
@ -229,13 +229,13 @@ export default Vue.extend({
|
||||||
return groupAuthorsByRolePlural(this.book.metadata.authors)
|
return groupAuthorsByRolePlural(this.book.metadata.authors)
|
||||||
},
|
},
|
||||||
isRead (): boolean {
|
isRead (): boolean {
|
||||||
return getReadProgress(this.book) === ReadProgress.READ
|
return getReadProgress(this.book) === ReadStatus.READ
|
||||||
},
|
},
|
||||||
isUnread (): boolean {
|
isUnread (): boolean {
|
||||||
return getReadProgress(this.book) === ReadProgress.UNREAD
|
return getReadProgress(this.book) === ReadStatus.UNREAD
|
||||||
},
|
},
|
||||||
isInProgress (): boolean {
|
isInProgress (): boolean {
|
||||||
return getReadProgress(this.book) === ReadProgress.IN_PROGRESS
|
return getReadProgress(this.book) === ReadStatus.IN_PROGRESS
|
||||||
},
|
},
|
||||||
readProgressPercentage (): number {
|
readProgressPercentage (): number {
|
||||||
return getReadProgressPercentage(this.book)
|
return getReadProgressPercentage(this.book)
|
||||||
|
|
|
||||||
|
|
@ -9,64 +9,65 @@
|
||||||
:books.sync="editBookSingle"
|
:books.sync="editBookSingle"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<horizontal-scroller>
|
<empty-state v-if="allEmpty"
|
||||||
|
title="Nothing to show"
|
||||||
|
icon="mdi-help-circle"
|
||||||
|
icon-color="secondary"
|
||||||
|
>
|
||||||
|
</empty-state>
|
||||||
|
|
||||||
|
<horizontal-scroller v-if="inProgressBooks.length !== 0">
|
||||||
|
<template v-slot:prepend>
|
||||||
|
<div class="title">Keep Reading</div>
|
||||||
|
</template>
|
||||||
|
<template v-slot:content>
|
||||||
|
<div v-for="(b, i) in inProgressBooks"
|
||||||
|
:key="i"
|
||||||
|
>
|
||||||
|
<item-card class="ma-2 card" :item="b" :on-edit="singleEditBook"/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</horizontal-scroller>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<horizontal-scroller v-if="newSeries.length !== 0">
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<div class="title">Recently Added Series</div>
|
<div class="title">Recently Added Series</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:content>
|
<template v-slot:content>
|
||||||
<div v-for="(s, i) in newSeries"
|
<div v-for="(s, i) in newSeries"
|
||||||
:key="i">
|
:key="i">
|
||||||
<v-skeleton-loader v-if="s === null"
|
<item-card class="ma-2 card" :item="s" :on-edit="singleEditSeries"/>
|
||||||
:loading="s === null"
|
|
||||||
type="card, text"
|
|
||||||
width="150"
|
|
||||||
height="306.14"
|
|
||||||
class="ma-2 card"
|
|
||||||
/>
|
|
||||||
<item-card v-else class="ma-2 card" :item="s" :on-edit="singleEditSeries"/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</horizontal-scroller>
|
</horizontal-scroller>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<horizontal-scroller>
|
<horizontal-scroller v-if="updatedSeries.length !== 0">
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<div class="title">Recently Updated Series</div>
|
<div class="title">Recently Updated Series</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:content>
|
<template v-slot:content>
|
||||||
<div v-for="(s, i) in updatedSeries"
|
<div v-for="(s, i) in updatedSeries"
|
||||||
:key="i">
|
:key="i">
|
||||||
<v-skeleton-loader v-if="s === null"
|
<item-card class="ma-2 card" :item="s" :on-edit="singleEditSeries"/>
|
||||||
:loading="s === null"
|
|
||||||
type="card, text"
|
|
||||||
width="150"
|
|
||||||
height="306.14"
|
|
||||||
class="ma-2 card"
|
|
||||||
/>
|
|
||||||
<item-card v-else class="ma-2 card" :item="s" :on-edit="singleEditSeries"/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</horizontal-scroller>
|
</horizontal-scroller>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<horizontal-scroller>
|
<horizontal-scroller v-if="latestBooks.length !== 0">
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<div class="title">Recently Added Books</div>
|
<div class="title">Recently Added Books</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:content>
|
<template v-slot:content>
|
||||||
<div v-for="(b, i) in books"
|
<div v-for="(b, i) in latestBooks"
|
||||||
:key="i"
|
:key="i"
|
||||||
>
|
>
|
||||||
<v-skeleton-loader v-if="b === null"
|
<item-card class="ma-2 card" :item="b" :on-edit="singleEditBook"/>
|
||||||
:loading="b === null"
|
|
||||||
type="card, text"
|
|
||||||
width="150"
|
|
||||||
height="328.13"
|
|
||||||
class="ma-2 card"
|
|
||||||
/>
|
|
||||||
<item-card v-else class="ma-2 card" :item="b" :on-edit="singleEditBook"/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</horizontal-scroller>
|
</horizontal-scroller>
|
||||||
|
|
@ -77,20 +78,21 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import EditBooksDialog from '@/components/EditBooksDialog.vue'
|
import EditBooksDialog from '@/components/EditBooksDialog.vue'
|
||||||
import EditSeriesDialog from '@/components/EditSeriesDialog.vue'
|
import EditSeriesDialog from '@/components/EditSeriesDialog.vue'
|
||||||
|
import EmptyState from '@/components/EmptyState.vue'
|
||||||
import HorizontalScroller from '@/components/HorizontalScroller.vue'
|
import HorizontalScroller from '@/components/HorizontalScroller.vue'
|
||||||
import ItemCard from '@/components/ItemCard.vue'
|
import ItemCard from '@/components/ItemCard.vue'
|
||||||
|
import { ReadStatus } from '@/types/enum-books'
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
name: 'Dashboard',
|
name: 'Dashboard',
|
||||||
components: { ItemCard, HorizontalScroller, EditSeriesDialog, EditBooksDialog },
|
components: { ItemCard, HorizontalScroller, EditSeriesDialog, EditBooksDialog, EmptyState },
|
||||||
data: () => {
|
data: () => {
|
||||||
const pageSize = 20
|
|
||||||
return {
|
return {
|
||||||
newSeries: Array(pageSize).fill(null) as SeriesDto[],
|
newSeries: [] as SeriesDto[],
|
||||||
updatedSeries: Array(pageSize).fill(null) as SeriesDto[],
|
updatedSeries: [] as SeriesDto[],
|
||||||
books: Array(pageSize).fill(null) as BookDto[],
|
latestBooks: [] as BookDto[],
|
||||||
pageSize: pageSize,
|
inProgressBooks: [] as BookDto[],
|
||||||
editSeriesSingle: {} as SeriesDto,
|
editSeriesSingle: {} as SeriesDto,
|
||||||
dialogEditSeriesSingle: false,
|
dialogEditSeriesSingle: false,
|
||||||
editBookSingle: {} as BookDto,
|
editBookSingle: {} as BookDto,
|
||||||
|
|
@ -101,6 +103,7 @@ export default Vue.extend({
|
||||||
this.loadNewSeries()
|
this.loadNewSeries()
|
||||||
this.loadUpdatedSeries()
|
this.loadUpdatedSeries()
|
||||||
this.loadLatestBooks()
|
this.loadLatestBooks()
|
||||||
|
this.loadInProgressBooks()
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
editSeriesSingle (val: SeriesDto) {
|
editSeriesSingle (val: SeriesDto) {
|
||||||
|
|
@ -114,10 +117,22 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
editBookSingle (val: BookDto) {
|
editBookSingle (val: BookDto) {
|
||||||
let index = this.books.findIndex(x => x.id === val.id)
|
let index = this.latestBooks.findIndex(x => x.id === val.id)
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
this.books.splice(index, 1, val)
|
this.latestBooks.splice(index, 1, val)
|
||||||
}
|
}
|
||||||
|
index = this.inProgressBooks.findIndex(x => x.id === val.id)
|
||||||
|
if (index !== -1) {
|
||||||
|
this.inProgressBooks.splice(index, 1, val)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
allEmpty (): boolean {
|
||||||
|
return this.newSeries.length === 0 &&
|
||||||
|
this.updatedSeries.length === 0 &&
|
||||||
|
this.latestBooks.length === 0 &&
|
||||||
|
this.inProgressBooks.length === 0
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -129,11 +144,17 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
async loadLatestBooks () {
|
async loadLatestBooks () {
|
||||||
const pageRequest = {
|
const pageRequest = {
|
||||||
size: this.pageSize,
|
|
||||||
sort: ['createdDate,desc'],
|
sort: ['createdDate,desc'],
|
||||||
} as PageRequest
|
} as PageRequest
|
||||||
|
|
||||||
this.books = (await this.$komgaBooks.getBooks(undefined, pageRequest)).content
|
this.latestBooks = (await this.$komgaBooks.getBooks(undefined, pageRequest)).content
|
||||||
|
},
|
||||||
|
async loadInProgressBooks () {
|
||||||
|
const pageRequest = {
|
||||||
|
sort: ['readProgress.lastModified,desc'],
|
||||||
|
} as PageRequest
|
||||||
|
|
||||||
|
this.inProgressBooks = (await this.$komgaBooks.getBooks(undefined, pageRequest, undefined, undefined, [ReadStatus.IN_PROGRESS])).content
|
||||||
},
|
},
|
||||||
singleEditSeries (series: SeriesDto) {
|
singleEditSeries (series: SeriesDto) {
|
||||||
this.editSeriesSingle = series
|
this.editSeriesSingle = series
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue