Skip to content

Commit

Permalink
fix(webui): show empty state if there's not books to import
Browse files Browse the repository at this point in the history
  • Loading branch information
gotson committed Jul 5, 2021
1 parent 403ab0a commit 7ddbac9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion komga-webui/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"field_import_path": "Import from folder",
"info_part1": "This screen lets you import files that are outside your existing libraries. You can only import files into existing Series, in which case Komga will move or copy the files into the directory of the chosen Series.",
"info_part2": "If you choose a number for a book, and a book already exists with that number, then you will be able to compare the 2 books. If you decide to import the book, Komga will upgrade the existing book with the new one, effectively replacing the old file with the new.",
"no_files_found": "No files found",
"notification": {
"go_to_book": "Go to book",
"import_failure": "Failed to import book: {file}",
Expand All @@ -69,7 +70,8 @@
"number": "Number",
"series": "Series"
},
"title": "Import"
"title": "Import",
"try_another_directory": "Try searching another directory"
},
"bookreader": {
"beginning_of_book": "You're at the beginning of the book.",
Expand Down
14 changes: 13 additions & 1 deletion komga-webui/src/views/BookImport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
</v-col>
</v-row>

<empty-state
v-if="scanned && transientBooks.length === 0"
:title="$t('book_import.no_files_found')"
:sub-title="$t('book_import.try_another_directory')"
icon-color="secondary"
icon="mdi-book-search"
/>

<template v-if="transientBooks.length > 0">
<v-divider/>

Expand Down Expand Up @@ -104,17 +112,19 @@ import {BookImportBatchDto, BookImportDto} from "@/types/komga-books";
import {CopyMode} from "@/types/enum-books";
import {convertErrorCodes} from "@/functions/error-codes";
import {ERROR} from "@/types/events";
import EmptyState from "@/components/EmptyState.vue";
export default Vue.extend({
name: 'BookImport',
components: {FileBrowserDialog, FileImportRow, SeriesPickerDialog},
components: {EmptyState, FileBrowserDialog, FileImportRow, SeriesPickerDialog},
data: () => ({
modalFileBrowser: false,
modalSeriesPicker: false,
selected: [] as number[],
selectedSeries: undefined as SeriesDto | undefined,
payloads: [] as BookImportDto[],
transientBooks: [] as TransientBookDto[],
scanned: false,
copyMode: CopyMode.HARDLINK,
importFinished: false,
}),
Expand Down Expand Up @@ -161,8 +171,10 @@ export default Vue.extend({
methods: {
async scanBooks() {
this.transientBooks = []
this.scanned = false
try {
this.transientBooks = await this.$komgaTransientBooks.scanForTransientBooks(this.importPath)
this.scanned = true
} catch (e) {
this.$eventHub.$emit(ERROR, {message: convertErrorCodes(e.message)} as ErrorEvent)
}
Expand Down

0 comments on commit 7ddbac9

Please sign in to comment.