Switch from open library API to Inventaire API

This commit is contained in:
2026-01-16 16:12:59 +01:00
parent 1bb841332c
commit a04aff6056
22 changed files with 338 additions and 108 deletions

View File

@@ -107,6 +107,7 @@
<h3 class="subtitle">{{data.author}}</h3>
<p>{{data.summary}}</p>
<div class="my-5" v-if="data.isbn">ISBN: {{data.isbn}}</div>
<div class="my-5" v-if="data.inventaireid">Inventaire ID: {{data.inventaireid}}</div>
<div class="my-5" v-if="data.openlibraryid">OLID: {{data.openlibraryid}}</div>
</div>
<div class="column">

View File

@@ -7,7 +7,7 @@
const props = defineProps({
id: Number,
openlibraryid: String,
inventaireid: String,
title: String,
author: String,
rating: Number,
@@ -31,7 +31,7 @@ function openBook() {
if (props.id != 0) {
router.push(`/book/${props.id}`);
} else {
router.push(`/importopenlibrary/${props.openlibraryid}`)
router.push(`/importinventaire/${props.inventaireid}`)
}
}

View File

@@ -6,13 +6,13 @@
const router = useRouter();
const props = defineProps({
openlibraryid: String
inventaireid: String
});
const error = ref(null);
const data = ref(null);
async function importOpenLibraryId() {
const res = await postImportBook(props.openlibraryid);
async function importInventaireId() {
const res = await postImportBook(props.inventaireid, navigator.language.substring(0,2));
const json = await res.json();
if (res.ok) {
router.push(`/book/${json.id}`);
@@ -21,12 +21,12 @@
}
}
importOpenLibraryId();
importInventaireId();
</script>
<template>
<div v-if="error">Importing {{props.openlibraryid}}...</div>
<div v-else-if="!data">Importing {{props.openlibraryid}}...</div>
<div v-if="error">{{error}}</div>
<div v-else-if="!data">Importing {{props.inventaireid}}...</div>
</template>
<style scoped></style>

View File

@@ -9,7 +9,7 @@
if (typeof searchterm.value === "undefined" || searchterm.value === "") {
return
}
router.push('/search/' + encodeURIComponent(searchterm.value));
router.push('/search/' + searchterm.value);
}
</script>

View File

@@ -62,8 +62,8 @@ export function postBook(book) {
return genericPayloadCall('/book', book.value, 'POST')
}
export async function postImportBook(id) {
return genericPayloadCall('/importbook', {openlibraryid: id}, 'POST');
export async function postImportBook(id, language) {
return genericPayloadCall('/importbook', {inventaireid: id, lang: language}, 'POST');
}
export async function putReadBook(bookId) {

View File

@@ -8,14 +8,14 @@ import SignUp from './SignUp.vue'
import LogIn from './LogIn.vue'
import Home from './Home.vue'
import SearchBook from './SearchBook.vue'
import OpenLibraryImport from './OpenLibraryImport.vue'
import InventaireImport from './InventaireImport.vue'
import { useAuthStore } from './auth.store'
const routes = [
{ path: '/', component: Home },
{ path: '/books', component: BooksBrowser },
{ path: '/book/:id', component: BookForm, props: true },
{ path: '/importopenlibrary/:openlibraryid', component: OpenLibraryImport, props: true },
{ path: '/importinventaire/:inventaireid', component: InventaireImport, props: true },
{ path: '/author/:id', component: AuthorForm, props: true },
{ path: '/search/:searchterm', component: SearchBook, props: true },
{ path: '/add', component: AddBook },