mirror of
https://github.com/C9Glax/tranga-website.git
synced 2025-10-16 18:30:47 +02:00
Add Komga connection setting
This commit is contained in:
@@ -6,7 +6,14 @@
|
||||
<h1>Libraries</h1>
|
||||
</template>
|
||||
<template #footer>
|
||||
<UButton icon="i-lucide-plus" class="w-fit" @click="addLibraryModal.open()">Add</UButton>
|
||||
<div class="flex flex-row gap-2">
|
||||
<UButton icon="i-lucide-plus" class="w-fit" @click="addLibraryModal.open()">Add</UButton>
|
||||
<UTooltip :text="komgaConnected ? 'Disconnect Komga' : 'Connect Komga'">
|
||||
<UButton :icon="komgaConnected ? 'i-lucide-unlink' : 'i-lucide-link'" class="w-fit" @click="onKomgaClick"
|
||||
>Komga</UButton
|
||||
>
|
||||
</UTooltip>
|
||||
</div>
|
||||
</template>
|
||||
<FileLibraries />
|
||||
</UCard>
|
||||
@@ -27,12 +34,14 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { LazyAddLibraryModal } from '#components';
|
||||
import { LazyAddLibraryModal, LazyKomgaModal } from '#components';
|
||||
import FileLibraries from '~/components/FileLibraries.vue';
|
||||
import { refreshNuxtData } from '#app';
|
||||
const overlay = useOverlay();
|
||||
const { $api } = useNuxtApp();
|
||||
|
||||
const addLibraryModal = overlay.create(LazyAddLibraryModal);
|
||||
const komgaModal = overlay.create(LazyKomgaModal);
|
||||
|
||||
const config = useRuntimeConfig();
|
||||
const apiUrl = ref(config.public.openFetch.api.baseURL);
|
||||
@@ -52,5 +61,16 @@ const cleanUpDatabase = async () => {
|
||||
cleanUpDatabaseBusy.value = false;
|
||||
};
|
||||
|
||||
const { data: libraries } = useApi('/v2/LibraryConnector', { key: FetchKeys.Libraries.All });
|
||||
const komgaConnected = computed(() => libraries.value?.find((l) => l.type === "Komga")?.key);
|
||||
const onKomgaClick = async () => {
|
||||
if (!komgaConnected.value) {
|
||||
komgaModal.open();
|
||||
}else{
|
||||
await $api("/v2/LibraryConnector/{LibraryConnectorId}", { method: "DELETE", path: { LibraryConnectorId: komgaConnected.value } });
|
||||
await refreshNuxtData(FetchKeys.Libraries.All);
|
||||
}
|
||||
};
|
||||
|
||||
useHead({ title: 'Settings' });
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user