From 61612c8e1861ac704bbe592a623a41f12ebc9c11 Mon Sep 17 00:00:00 2001
From: Mitchell Riedstra
Date: Tue, 3 Jan 2023 22:41:20 -0500
Subject: Add a messy but mostly working UI
---
ui/src/routes/+layout.svelte | 14 ++++++++----
ui/src/routes/+page.svelte | 4 ++--
ui/src/routes/list/+page.js | 26 ++++++++++++++--------
ui/src/routes/list/+page.svelte | 42 ++++++++++++++++++++++++++++++------
ui/src/routes/view/[id]/+page.js | 6 +-----
ui/src/routes/view/[id]/+page.svelte | 4 ++--
6 files changed, 67 insertions(+), 29 deletions(-)
(limited to 'ui/src')
diff --git a/ui/src/routes/+layout.svelte b/ui/src/routes/+layout.svelte
index e9fd192..4f83f18 100644
--- a/ui/src/routes/+layout.svelte
+++ b/ui/src/routes/+layout.svelte
@@ -1,11 +1,17 @@
+
@@ -139,4 +145,4 @@ h1,h2,h3 {
}
-
\ No newline at end of file
+
diff --git a/ui/src/routes/+page.svelte b/ui/src/routes/+page.svelte
index fae229e..4cf6b97 100644
--- a/ui/src/routes/+page.svelte
+++ b/ui/src/routes/+page.svelte
@@ -1,5 +1,5 @@
@@ -11,4 +11,4 @@
Below is a listing of recent pastes:
-
\ No newline at end of file
+
diff --git a/ui/src/routes/list/+page.js b/ui/src/routes/list/+page.js
index 1c0c1d5..85435b1 100644
--- a/ui/src/routes/list/+page.js
+++ b/ui/src/routes/list/+page.js
@@ -1,14 +1,22 @@
+/** @type {import('./$types').PageLoad} */
+// export async function load({ fetch, params }) {
+// const res = await fetch(`/api/v1/list`);
+// const item = await res.json();
+//
+// return { item };
+// }
+
/** @type {import('./$types').PageLoad} */
-export async function load({ params }) {
- const req = await fetch(`http://localhost:6130/api/v1/list`)
- const reqJson = await req.json();
-
- return {
- req: req,
- reqJson: reqJson,
- };
-}
+// export async function load({ params }) {
+// const req = await fetch(`http://localhost:6130/api/v1/list`)
+// const reqJson = await req.json();
+//
+// return {
+// req: req,
+// reqJson: reqJson,
+// };
+// }
diff --git a/ui/src/routes/list/+page.svelte b/ui/src/routes/list/+page.svelte
index 3b463b5..1986665 100644
--- a/ui/src/routes/list/+page.svelte
+++ b/ui/src/routes/list/+page.svelte
@@ -1,17 +1,43 @@
-
{#if data}
{#each data as paste (paste.id)}
@@ -22,6 +48,8 @@
{/each}
+{:else if Err}
+{Err}
{:else}
Loading....
{/if}
diff --git a/ui/src/routes/view/[id]/+page.js b/ui/src/routes/view/[id]/+page.js
index a7af895..a457936 100644
--- a/ui/src/routes/view/[id]/+page.js
+++ b/ui/src/routes/view/[id]/+page.js
@@ -1,7 +1,3 @@
-
-
-
-
/** @type {import('./$types').PageLoad} */
export async function load({ params }) {
const req = await fetch(`/api/v1/view/${params.id}`)
@@ -12,4 +8,4 @@ export async function load({ params }) {
req: req,
reqJson: reqJson,
};
-}
\ No newline at end of file
+}
diff --git a/ui/src/routes/view/[id]/+page.svelte b/ui/src/routes/view/[id]/+page.svelte
index f621dbf..1a7377c 100644
--- a/ui/src/routes/view/[id]/+page.svelte
+++ b/ui/src/routes/view/[id]/+page.svelte
@@ -12,7 +12,7 @@
let timer = 0;
function copy() {
- copyPromise = navigator.clipboard.writeText(data.reqJson.Content);
+ copyPromise = navigator.clipboard.writeText(data.reqJson.Data.Content);
timer = 3;
setTimeout(function() {
for (; timer >= 0 ; timer --);
@@ -55,7 +55,7 @@
-{data.reqJson.Content}
+{data.reqJson.Data.Content}