mirror of
https://github.com/C9Glax/tranga-website.git
synced 2025-10-16 18:30:47 +02:00
Add Kavita setting
This commit is contained in:
@@ -9,9 +9,18 @@
|
||||
<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
|
||||
>
|
||||
<UButton
|
||||
:icon="komgaConnected ? 'i-lucide-unlink' : 'i-lucide-link'"
|
||||
class="w-fit"
|
||||
label="Komga"
|
||||
@click="onKomgaClick" />
|
||||
</UTooltip>
|
||||
<UTooltip :text="kavitaConnected ? 'Disconnect Kavita' : 'Connect Kavita'">
|
||||
<UButton
|
||||
:icon="kavitaConnected ? 'i-lucide-unlink' : 'i-lucide-link'"
|
||||
class="w-fit"
|
||||
label="Kavita"
|
||||
@click="onKavitaClick" />
|
||||
</UTooltip>
|
||||
</div>
|
||||
</template>
|
||||
@@ -34,7 +43,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { LazyAddLibraryModal, LazyKomgaModal } from '#components';
|
||||
import { LazyAddLibraryModal, LazyKavitaModal, LazyKomgaModal } from '#components';
|
||||
import FileLibraries from '~/components/FileLibraries.vue';
|
||||
import { refreshNuxtData } from '#app';
|
||||
const overlay = useOverlay();
|
||||
@@ -42,6 +51,7 @@ const { $api } = useNuxtApp();
|
||||
|
||||
const addLibraryModal = overlay.create(LazyAddLibraryModal);
|
||||
const komgaModal = overlay.create(LazyKomgaModal);
|
||||
const kavitaModal = overlay.create(LazyKavitaModal);
|
||||
|
||||
const config = useRuntimeConfig();
|
||||
const apiUrl = ref(config.public.openFetch.api.baseURL);
|
||||
@@ -62,12 +72,21 @@ const cleanUpDatabase = async () => {
|
||||
};
|
||||
|
||||
const { data: libraries } = useApi('/v2/LibraryConnector', { key: FetchKeys.Libraries.All });
|
||||
const komgaConnected = computed(() => libraries.value?.find((l) => l.type === "Komga")?.key);
|
||||
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 } });
|
||||
} else {
|
||||
await $api('/v2/LibraryConnector/{LibraryConnectorId}', { method: 'DELETE', path: { LibraryConnectorId: komgaConnected.value } });
|
||||
await refreshNuxtData(FetchKeys.Libraries.All);
|
||||
}
|
||||
};
|
||||
const kavitaConnected = computed(() => libraries.value?.find((l) => l.type === 'Kavita')?.key);
|
||||
const onKavitaClick = async () => {
|
||||
if (!kavitaConnected.value) {
|
||||
kavitaModal.open();
|
||||
} else {
|
||||
await $api('/v2/LibraryConnector/{LibraryConnectorId}', { method: 'DELETE', path: { LibraryConnectorId: kavitaConnected.value } });
|
||||
await refreshNuxtData(FetchKeys.Libraries.All);
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user