diff --git a/komga-webui/src/components/Dialogs.vue b/komga-webui/src/components/Dialogs.vue index 77fe6678a8..a0840746b4 100644 --- a/komga-webui/src/components/Dialogs.vue +++ b/komga-webui/src/components/Dialogs.vue @@ -19,6 +19,11 @@ @deleted="collectionDeleted" /> + + import CollectionAddToDialog from '@/components/dialogs/CollectionAddToDialog.vue' import CollectionDeleteDialog from '@/components/dialogs/CollectionDeleteDialog.vue' +import CollectionEditDialog from '@/components/dialogs/CollectionEditDialog.vue' +import EditBooksDialog from '@/components/dialogs/EditBooksDialog.vue' +import EditSeriesDialog from '@/components/dialogs/EditSeriesDialog.vue' import LibraryDeleteDialog from '@/components/dialogs/LibraryDeleteDialog.vue' +import LibraryEditDialog from '@/components/dialogs/LibraryEditDialog.vue' import { BOOK_CHANGED, bookToEventBookChanged, @@ -57,9 +66,6 @@ import { seriesToEventSeriesChanged, } from '@/types/events' import Vue from 'vue' -import EditBooksDialog from '@/components/dialogs/EditBooksDialog.vue' -import EditSeriesDialog from '@/components/dialogs/EditSeriesDialog.vue' -import CollectionEditDialog from '@/components/dialogs/CollectionEditDialog.vue' export default Vue.extend({ name: 'Dialogs', @@ -67,6 +73,7 @@ export default Vue.extend({ CollectionAddToDialog, CollectionEditDialog, CollectionDeleteDialog, + LibraryEditDialog, LibraryDeleteDialog, EditBooksDialog, EditSeriesDialog, @@ -105,6 +112,17 @@ export default Vue.extend({ deleteCollection (): CollectionDto { return this.$store.state.deleteCollection }, + editLibraryDialog: { + get (): boolean { + return this.$store.state.editLibraryDialog + }, + set (val) { + this.$store.dispatch('dialogEditLibraryDisplay', val) + }, + }, + editLibrary (): LibraryDto | undefined { + return this.$store.state.editLibrary + }, deleteLibraryDialog: { get (): boolean { return this.$store.state.deleteLibraryDialog diff --git a/komga-webui/src/components/dialogs/LibraryAddDialog.vue b/komga-webui/src/components/dialogs/LibraryAddDialog.vue deleted file mode 100644 index 44f2f8e7f3..0000000000 --- a/komga-webui/src/components/dialogs/LibraryAddDialog.vue +++ /dev/null @@ -1,170 +0,0 @@ - - - - - diff --git a/komga-webui/src/components/dialogs/LibraryEditDialog.vue b/komga-webui/src/components/dialogs/LibraryEditDialog.vue new file mode 100644 index 0000000000..715dcaf1f0 --- /dev/null +++ b/komga-webui/src/components/dialogs/LibraryEditDialog.vue @@ -0,0 +1,276 @@ + + + + + diff --git a/komga-webui/src/components/menus/LibraryActionsMenu.vue b/komga-webui/src/components/menus/LibraryActionsMenu.vue index 396e968e86..43bb828d57 100644 --- a/komga-webui/src/components/menus/LibraryActionsMenu.vue +++ b/komga-webui/src/components/menus/LibraryActionsMenu.vue @@ -16,6 +16,9 @@ Refresh metadata + + Edit + Delete @@ -50,6 +53,9 @@ export default Vue.extend({ refreshMetadata () { this.$komgaLibraries.refreshMetadata(this.library) }, + edit () { + this.$store.dispatch('dialogEditLibrary', this.library) + }, promptDeleteLibrary () { this.$store.dispatch('dialogDeleteLibrary', this.library) }, diff --git a/komga-webui/src/plugins/komga-libraries.plugin.ts b/komga-webui/src/plugins/komga-libraries.plugin.ts index 3658972942..04f120f6d1 100644 --- a/komga-webui/src/plugins/komga-libraries.plugin.ts +++ b/komga-webui/src/plugins/komga-libraries.plugin.ts @@ -25,11 +25,15 @@ const vuexModule: Module = { }, async postLibrary ({ dispatch }, library) { await service.postLibrary(library) - dispatch('getLibraries') + await dispatch('getLibraries') + }, + async updateLibrary ({ dispatch }, { libraryId, library }) { + await service.updateLibrary(libraryId, library) + await dispatch('getLibraries') }, async deleteLibrary ({ dispatch }, library) { await service.deleteLibrary(library) - dispatch('getLibraries') + await dispatch('getLibraries') }, }, } diff --git a/komga-webui/src/router.ts b/komga-webui/src/router.ts index 7ebaed8b60..8abbf56e5c 100644 --- a/komga-webui/src/router.ts +++ b/komga-webui/src/router.ts @@ -28,12 +28,6 @@ const router = new Router({ redirect: { name: 'dashboard' }, component: () => import(/* webpackChunkName: "home" */ './views/Home.vue'), children: [ - { - path: '/libraries/add', - name: 'addlibrary', - beforeEnter: adminGuard, - component: () => import(/* webpackChunkName: "addlibrary" */ './components/dialogs/LibraryAddDialog.vue'), - }, { path: '/welcome', name: 'welcome', diff --git a/komga-webui/src/services/komga-libraries.service.ts b/komga-webui/src/services/komga-libraries.service.ts index 4cd2f8532f..eec2d03afd 100644 --- a/komga-webui/src/services/komga-libraries.service.ts +++ b/komga-webui/src/services/komga-libraries.service.ts @@ -3,7 +3,7 @@ import { AxiosInstance } from 'axios' const API_LIBRARIES = '/api/v1/libraries' export default class KomgaLibrariesService { - private http: AxiosInstance; + private http: AxiosInstance constructor (http: AxiosInstance) { this.http = http @@ -45,6 +45,18 @@ export default class KomgaLibrariesService { } } + async updateLibrary (libraryId: number, library: LibraryUpdateDto) { + try { + await this.http.put(`${API_LIBRARIES}/${libraryId}`, library) + } catch (e) { + let msg = `An error occurred while trying to update library '${libraryId}'` + if (e.response.data.message) { + msg += `: ${e.response.data.message}` + } + throw new Error(msg) + } + } + async deleteLibrary (library: LibraryDto) { try { await this.http.delete(`${API_LIBRARIES}/${library.id}`) diff --git a/komga-webui/src/store.ts b/komga-webui/src/store.ts index 0be2e481eb..251dd7e459 100644 --- a/komga-webui/src/store.ts +++ b/komga-webui/src/store.ts @@ -11,6 +11,8 @@ export default new Vuex.Store({ editCollectionDialog: false, deleteCollection: {} as CollectionDto, deleteCollectionDialog: false, + editLibrary: {} as LibraryDto | undefined, + editLibraryDialog: false, deleteLibrary: {} as LibraryDto, deleteLibraryDialog: false, updateBooks: {} as BookDto | BookDto[], @@ -34,6 +36,12 @@ export default new Vuex.Store({ setDeleteCollection (state, collection) { state.deleteCollection = collection }, + setEditLibrary (state, library) { + state.editLibrary = library + }, + setEditLibraryDialog (state, dialog) { + state.editLibraryDialog = dialog + }, setDeleteCollectionDialog (state, dialog) { state.deleteCollectionDialog = dialog }, @@ -78,6 +86,17 @@ export default new Vuex.Store({ dialogDeleteCollectionDisplay ({ commit }, value) { commit('setDeleteCollectionDialog', value) }, + dialogAddLibrary ({ commit }) { + commit('setEditLibrary', undefined) + commit('setEditLibraryDialog', true) + }, + dialogEditLibrary ({ commit }, value) { + commit('setEditLibrary', value) + commit('setEditLibraryDialog', true) + }, + dialogEditLibraryDisplay ({ commit }, value) { + commit('setEditLibraryDialog', value) + }, dialogDeleteLibrary ({ commit }, library) { commit('setDeleteLibrary', library) commit('setDeleteLibraryDialog', true) diff --git a/komga-webui/src/types/events-payloads.ts b/komga-webui/src/types/events-payloads.ts index b5e3d88739..b321313598 100644 --- a/komga-webui/src/types/events-payloads.ts +++ b/komga-webui/src/types/events-payloads.ts @@ -16,6 +16,14 @@ interface EventCollectionDeleted { id: number } +interface EventLibraryAdded { + id: number +} + +interface EventLibraryChanged { + id: number +} + interface EventLibraryDeleted { id: number } diff --git a/komga-webui/src/types/events.ts b/komga-webui/src/types/events.ts index 2548af9767..f8bedb7ca0 100644 --- a/komga-webui/src/types/events.ts +++ b/komga-webui/src/types/events.ts @@ -2,6 +2,8 @@ export const BOOK_CHANGED = 'book-changed' export const SERIES_CHANGED = 'series-changed' export const COLLECTION_DELETED = 'collection-deleted' export const COLLECTION_CHANGED = 'collection-changed' +export const LIBRARY_ADDED = 'library-added' +export const LIBRARY_CHANGED = 'library-changed' export const LIBRARY_DELETED = 'library-deleted' export function bookToEventBookChanged (book: BookDto): EventBookChanged { @@ -30,6 +32,18 @@ export function collectionToEventCollectionDeleted (collection: CollectionDto): } as EventCollectionDeleted } +export function libraryToEventLibraryAdded (library: LibraryDto): EventLibraryAdded { + return { + id: library.id, + } as EventLibraryAdded +} + +export function libraryToEventLibraryChanged (library: LibraryDto): EventLibraryChanged { + return { + id: library.id, + } as EventLibraryChanged +} + export function libraryToEventLibraryDeleted (library: LibraryDto): EventLibraryDeleted { return { id: library.id, diff --git a/komga-webui/src/types/komga-libraries.ts b/komga-webui/src/types/komga-libraries.ts index 5abfead22f..6acd3e48db 100644 --- a/komga-webui/src/types/komga-libraries.ts +++ b/komga-webui/src/types/komga-libraries.ts @@ -1,10 +1,30 @@ interface LibraryCreationDto { name: string, - root: string + root: string, + importComicInfoBook: boolean, + importComicInfoSeries: boolean, + importComicInfoCollection: boolean, + importEpubBook: boolean, + importEpubSeries: boolean +} + +interface LibraryUpdateDto { + name: string, + root: string, + importComicInfoBook: boolean, + importComicInfoSeries: boolean, + importComicInfoCollection: boolean, + importEpubBook: boolean, + importEpubSeries: boolean } interface LibraryDto { id: number, name: string, - root: string + root: string, + importComicInfoBook: boolean, + importComicInfoSeries: boolean, + importComicInfoCollection: boolean, + importEpubBook: boolean, + importEpubSeries: boolean } diff --git a/komga-webui/src/views/BrowseCollections.vue b/komga-webui/src/views/BrowseCollections.vue index 3dd43871f1..f76c8ef289 100644 --- a/komga-webui/src/views/BrowseCollections.vue +++ b/komga-webui/src/views/BrowseCollections.vue @@ -38,12 +38,12 @@ diff --git a/komga-webui/src/views/Welcome.vue b/komga-webui/src/views/Welcome.vue index fe35556e13..b94c4e9453 100644 --- a/komga-webui/src/views/Welcome.vue +++ b/komga-webui/src/views/Welcome.vue @@ -9,13 +9,14 @@

Welcome to Komga

No libraries have been added yet!

- Add library + Add library