From 93b9dcb68a6a6212561f6c84cc9b19ee018c0288 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Wed, 19 Apr 2023 21:14:07 +0100 Subject: [PATCH] Starts working on template page --- src/routes/[slug]/+page.server.ts | 19 +++ src/routes/[slug]/+page.svelte | 216 ++++++++++++++++++++++++++++++ 2 files changed, 235 insertions(+) create mode 100644 src/routes/[slug]/+page.server.ts create mode 100644 src/routes/[slug]/+page.svelte diff --git a/src/routes/[slug]/+page.server.ts b/src/routes/[slug]/+page.server.ts new file mode 100644 index 0000000..1679860 --- /dev/null +++ b/src/routes/[slug]/+page.server.ts @@ -0,0 +1,19 @@ +import { get } from 'svelte/store'; + +import { templatesUrl } from '$src/constants'; +import { templates } from '$src/store'; + +export const load = async () => { + if (get(templates) && get(templates).length > 0) { + return { + templates: get(templates), + } + } else { + const data = await fetch(templatesUrl).then((res) => res.json()); + templates.set(data.templates); + + return { + templates: data.templates, + } + } +}; \ No newline at end of file diff --git a/src/routes/[slug]/+page.svelte b/src/routes/[slug]/+page.svelte new file mode 100644 index 0000000..cd61842 --- /dev/null +++ b/src/routes/[slug]/+page.svelte @@ -0,0 +1,216 @@ + + +
+ + +

Portainer Templates

+
+ +
+ +{#if template} +
+

{template.title}{template.title}

+ {#if template.categories} +

+ {#each (template.categories) as tag} + {tag} + {/each} +

+ {/if} +
+

{template.description}

+
+ {#if template.type} +
+ Type + {#if template.type === 1} + Container + {:else if template.type === 2} + Swarm + {:else if template.type === 3} + Kubernetes + {:else} + Unknown + {/if} +
+ {/if} + {#if template.platform} +
+ Platform + {template.platform} +
+ {/if} + {#if template.image} +
+ Image + {template.image} +
+ {/if} + {#if template.command} +
+ Command + {template.command} +
+ {/if} + {#if typeof template.interactive === 'boolean'} +
+ Interactive + {template.interactive ? 'Yes' : 'No'} +
+ {/if} + {#if template.ports} +
+ Ports +

+ {#each template.ports as port}{port}{/each} +

+
+ {/if} + {#if template.volumes} +
+ Volumes +

+ {#each template.volumes as volume}{volume.container}{/each} +

+
+ {/if} +
+
+
+{:else} + +{/if} + + \ No newline at end of file