From 58e1ffa9effc92f5ddebee4068d5931be12201b0 Mon Sep 17 00:00:00 2001 From: Maksymilian Jopek Date: Thu, 10 Mar 2022 15:39:25 +0100 Subject: Initial commit w/ v1.0.0 --- frontend/src/AddBook.svelte | 103 +++++++++++++++++++++++++ frontend/src/App.svelte | 32 ++++++++ frontend/src/Books.svelte | 165 +++++++++++++++++++++++++++++++++++++++++ frontend/src/DBInput.svelte | 60 +++++++++++++++ frontend/src/Login.svelte | 74 ++++++++++++++++++ frontend/src/Search.svelte | 92 +++++++++++++++++++++++ frontend/src/assets/svelte.png | Bin 0 -> 5185 bytes frontend/src/main.ts | 7 ++ frontend/src/utils.ts | 22 ++++++ frontend/src/vite-env.d.ts | 2 + 10 files changed, 557 insertions(+) create mode 100644 frontend/src/AddBook.svelte create mode 100644 frontend/src/App.svelte create mode 100644 frontend/src/Books.svelte create mode 100644 frontend/src/DBInput.svelte create mode 100644 frontend/src/Login.svelte create mode 100644 frontend/src/Search.svelte create mode 100644 frontend/src/assets/svelte.png create mode 100644 frontend/src/main.ts create mode 100644 frontend/src/utils.ts create mode 100644 frontend/src/vite-env.d.ts (limited to 'frontend/src') diff --git a/frontend/src/AddBook.svelte b/frontend/src/AddBook.svelte new file mode 100644 index 0000000..9352808 --- /dev/null +++ b/frontend/src/AddBook.svelte @@ -0,0 +1,103 @@ + + +
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + diff --git a/frontend/src/App.svelte b/frontend/src/App.svelte new file mode 100644 index 0000000..ee4d894 --- /dev/null +++ b/frontend/src/App.svelte @@ -0,0 +1,32 @@ + + +{#if whereami === "check-db"} + +{:else if whereami === "login"} + +{:else if whereami === "books"} + +{:else if whereami === "add-book"} + +{:else if whereami === "edit-book"} + +{/if} + + diff --git a/frontend/src/Books.svelte b/frontend/src/Books.svelte new file mode 100644 index 0000000..db1c10b --- /dev/null +++ b/frontend/src/Books.svelte @@ -0,0 +1,165 @@ + + +
+ + + + + {#if showSearch} + + {/if} + + + + + + + + + + + + + + + + {#each books as book} + + + + + + + + + + + + + + {/each} + +
IdAuthorTitleYear of
publication
PublisherIsbnFormatPagesDescription + +
{book.id}{book.author}{book.title}{book.year}{book.publisher}{book.isbn}{book.format}{book.pages}{book.description} + + + +
+
+ + diff --git a/frontend/src/DBInput.svelte b/frontend/src/DBInput.svelte new file mode 100644 index 0000000..f520014 --- /dev/null +++ b/frontend/src/DBInput.svelte @@ -0,0 +1,60 @@ + + +
+ +

+ +

+ +

+ +

+ +

+ +

+

+ + diff --git a/frontend/src/Login.svelte b/frontend/src/Login.svelte new file mode 100644 index 0000000..674ca47 --- /dev/null +++ b/frontend/src/Login.svelte @@ -0,0 +1,74 @@ + + +
+ {#if mode === "register"} + +

+ {/if} + +

+ +

+

+ + (mode = mode === "login" ? "register" : "login")} + /> +

{pt}

+
+ + diff --git a/frontend/src/Search.svelte b/frontend/src/Search.svelte new file mode 100644 index 0000000..2f192eb --- /dev/null +++ b/frontend/src/Search.svelte @@ -0,0 +1,92 @@ + + +
+ +
+ +
+ +
+ +
+ +
+ + +
+ +
+ +
+ +
+ +
+ + diff --git a/frontend/src/assets/svelte.png b/frontend/src/assets/svelte.png new file mode 100644 index 0000000..e673c91 Binary files /dev/null and b/frontend/src/assets/svelte.png differ diff --git a/frontend/src/main.ts b/frontend/src/main.ts new file mode 100644 index 0000000..d8200ac --- /dev/null +++ b/frontend/src/main.ts @@ -0,0 +1,7 @@ +import App from './App.svelte' + +const app = new App({ + target: document.getElementById('app') +}) + +export default app diff --git a/frontend/src/utils.ts b/frontend/src/utils.ts new file mode 100644 index 0000000..0bf115a --- /dev/null +++ b/frontend/src/utils.ts @@ -0,0 +1,22 @@ +export const url = "http://localhost:8000"; +export async function postToServer(path: string, body: object, asText = false) { + const res = await fetch(url + path, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(body), + }); + if (asText) return await res.text() + return res.json(); +} +export async function fetchFromServer(path: string, asText = false) { + const res = await fetch(url + path); + if (asText) return await res.text() + return res.json(); +} +export async function deleteOnServer(path: string, asText = false) { + const res = await fetch(url + path, { method: "DELETE" }); + if (asText) return await res.text() + return res.json(); +} diff --git a/frontend/src/vite-env.d.ts b/frontend/src/vite-env.d.ts new file mode 100644 index 0000000..4078e74 --- /dev/null +++ b/frontend/src/vite-env.d.ts @@ -0,0 +1,2 @@ +/// +/// -- cgit v1.3.1