Skip to content

Commit

Permalink
Merge pull request #31 from tsmooth3:4th
Browse files Browse the repository at this point in the history
slide
  • Loading branch information
tsmooth3 authored Jul 5, 2024
2 parents 1324529 + eda244d commit 3524d14
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 31 deletions.
8 changes: 6 additions & 2 deletions src/routes/slide/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ import { invalidateAll } from "$app/navigation";
export const load: PageServerLoad = async ({ fetch }) => {
const dbSlidesResponse = await fetch('/api/slides')
const dbSlides: prismaSlide[] = await dbSlidesResponse.json()

return { dbSlides }
if (dbSlides) {
return { dbSlides }
}
else {
return { }
}
};

export const actions: Actions = {
Expand Down
67 changes: 38 additions & 29 deletions src/routes/slide/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
let tableSimple: TableSource
$: tableSimple = {
$: if (data.dbSlides) {
tableSimple = {
// A list of heading labels.
head: ['TimeStamp', 'Slider', 'Speed (FPS)', 'Speed (MPH)'],
// The data visibly shown in your table body UI.
Expand All @@ -41,42 +43,49 @@
// meta: tableMapperValues(sourceData, ['position', 'name', 'symbol', 'weight']),
// Optional: A list of footer labels.
// foot: ['Total', '', '<code class="code">5</code>']
};
};
} else {
tableSimple = {
head: ['TimeStamp', 'Slider', 'Speed (FPS)', 'Speed (MPH)'],
body: tableMapperValues([], ['timeStamp', 'sliderName', 'sliderFPS', 'sliderMPH']),
}
}
</script>

<!-- {#await data}
{#await data}
<p>loading...</p>
{:then data }
{/await} -->
<form method="POST" action="?/submitSpeed" use:enhance>
<div class="flex my-auto p-5 min-w-[390px] max-w-6xl mx-auto">
<div class="p-3">
<div class="flex-col">
<div>
<label for="slider">Slider: </label>
</div>
<div>
<input class="input" type="text" name="slider" bind:value={inputName} />
<div class="flex my-auto p-5 min-w-[390px] max-w-6xl mx-auto">
<div class="p-3">
<div class="flex-col">
<div>
<label for="slider">Slider: </label>
</div>
<div>
<input class="input" type="text" name="slider" bind:value={inputName} />
</div>
</div>
</div>
</div>
<div class="p-3">
<div class="flex-col">
<div>
<label for="speed">Speed: </label>
</div>
<div>
<input class="input" type="number" name="speed" bind:value={inputSpeed} />
<div class="p-3">
<div class="flex-col">
<div>
<label for="speed">Speed: </label>
</div>
<div>
<input class="input" type="number" name="speed" bind:value={inputSpeed} />
</div>
</div>
</div>
<div class="m-3 p-3">
<button type="submit" formaction="?/submitSpeed" class="btn w-full variant-outline-primary variant-ghost-primary">Submit</button>
</div>
</div>
<div class="m-3 p-3">
<button type="submit" formaction="?/submitSpeed" class="btn w-full variant-outline-primary variant-ghost-primary">Submit</button>
</div>
</form>
<div class="flex my-auto p-5 min-w-[390px] max-w-6xl mx-auto">
<Table source={tableSimple} interactive={true} regionHeadCell="text-right" regionCell="text-right"/>
</div>
</form>
<div class="flex my-auto p-5 min-w-[390px] max-w-6xl mx-auto">
<Table source={tableSimple} interactive={true} regionHeadCell="text-right" regionCell="text-right"/>
</div>

{/await}

0 comments on commit 3524d14

Please sign in to comment.