Add Kavita setting

This commit is contained in:
2025-10-16 00:08:47 +02:00
parent d987dd0ebb
commit 35ca5b9550
4 changed files with 126 additions and 32 deletions

View File

@@ -10,7 +10,14 @@
<UFormField label="Password">
<UInput v-model="requestData.password" type="password" class="w-full" :disabled="busy" />
</UFormField>
<UButton icon="i-lucide-link" :class="['mt-2 float-right', success == false ? 'animate-[shake_0.2s] bg-error' : '' ]" :loading="busy" :disabled="busy || !allowSend" @click="connect">Connect</UButton>
<UButton
icon="i-lucide-link"
:class="['mt-2 float-right', success == false ? 'animate-[shake_0.2s] bg-error' : '']"
:loading="busy"
:disabled="busy || !allowSend"
@click="connect"
>Connect</UButton
>
</template>
</UModal>
</template>
@@ -20,30 +27,25 @@ import type { components } from '#open-fetch-schemas/api';
type CreateLibraryConnectorRecord = components['schemas']['CreateLibraryConnectorRecord'];
const { $api } = useNuxtApp();
const requestData = ref<CreateLibraryConnectorRecord>({
libraryType: 'Komga',
url: '',
username: '',
password: ''
});
const requestData = ref<CreateLibraryConnectorRecord>({ libraryType: 'Komga', url: '', username: '', password: '' });
const allowSend = computed(() => requestData.value.url && requestData.value.username && requestData.value.password);
const busy = ref<boolean>(false);
const success = ref<boolean | undefined>(undefined);
const emit = defineEmits<{ close: [boolean] }>()
const emit = defineEmits<{ close: [boolean] }>();
const connect = async () => {
busy.value = true;
try {
await $api("/v2/LibraryConnector", { method: "PUT", body: requestData.value });
await $api('/v2/LibraryConnector', { method: 'PUT', body: requestData.value });
await refreshNuxtData(FetchKeys.Libraries.All);
emit('close', false);
success.value = true;
}catch {
} catch {
success.value = false;
setTimeout(() => success.value = undefined, 200);
}finally {
setTimeout(() => (success.value = undefined), 200);
} finally {
busy.value = false;
}
}
};
</script>