From a70b00ae14c4cf008a057fdcf2e56c3ce0dc0dc5 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 15 Aug 2024 17:04:06 +0200 Subject: [PATCH] Add Schem Download --- src/components/SchematicDownload.svelte | 17 +++++++++++++++++ src/components/repo/schem.ts | 4 ++-- src/pages/schematic.astro | 8 ++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 src/components/SchematicDownload.svelte create mode 100644 src/pages/schematic.astro diff --git a/src/components/SchematicDownload.svelte b/src/components/SchematicDownload.svelte new file mode 100644 index 0000000..dd31fe2 --- /dev/null +++ b/src/components/SchematicDownload.svelte @@ -0,0 +1,17 @@ + + +{#await schematic then schem} +

{schem.name}

+
+ Download +
+{:catch error} +

{error.message}

+{/await} diff --git a/src/components/repo/schem.ts b/src/components/repo/schem.ts index 3ec6846..e83edb4 100644 --- a/src/components/repo/schem.ts +++ b/src/components/repo/schem.ts @@ -39,11 +39,11 @@ export class SchematicRepo { } public async getSchematicCodeInfo(code: string): Promise { - return await fetchWithToken(this.token, `/schem/download/${code}/info`).then(value => value.json()).then(SchematicSchema.parse); + return await fetchWithToken(this.token, `/download/${code}/info`).then(value => value.json()).then(SchematicSchema.parse); } public getSchematicDownloadUrl(code: string): string { - return `/schem/download/${code}`; + return `${import.meta.env.PUBLIC_API_SERVER}/download/${code}`; } public async uploadSchematic(name: string, content: string) { diff --git a/src/pages/schematic.astro b/src/pages/schematic.astro new file mode 100644 index 0000000..710597b --- /dev/null +++ b/src/pages/schematic.astro @@ -0,0 +1,8 @@ +--- +import PageLayout from "../layouts/PageLayout.astro"; +import SchematicDownload from "@components/SchematicDownload.svelte"; +--- + + + + \ No newline at end of file