Add /tasks route to load all tasks.
Currently just a proof of concept. The data is pulled from the database and a few fields display in a table.
This commit is contained in:
parent
5fddf2f394
commit
136b58c44f
10
src/routes/tasks/+page.server.ts
Normal file
10
src/routes/tasks/+page.server.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import TasksService from "$lib/server/services/tasks";
|
||||||
|
import type { PageServerLoad } from "./$types";
|
||||||
|
|
||||||
|
export const load: PageServerLoad = async () => {
|
||||||
|
const tasks = new TasksService("internal");
|
||||||
|
return {
|
||||||
|
tasks: await tasks.getAll(),
|
||||||
|
test: "string",
|
||||||
|
};
|
||||||
|
};
|
||||||
32
src/routes/tasks/+page.svelte
Normal file
32
src/routes/tasks/+page.svelte
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { PageProps } from "./$types";
|
||||||
|
|
||||||
|
let { data }: PageProps = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if data.tasks}
|
||||||
|
<p>{data.tasks.length} total records.</p>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Id</strong></td>
|
||||||
|
<td><strong>Description</strong></td>
|
||||||
|
<td><strong>Status</strong></td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{#each data.tasks as task (task.id)}
|
||||||
|
<tr>
|
||||||
|
<td
|
||||||
|
>{task.type?.prefix +
|
||||||
|
task.taskId}</td
|
||||||
|
>
|
||||||
|
<td>{task.description}</td>
|
||||||
|
<td>{task.status}</td>
|
||||||
|
</tr>
|
||||||
|
{/each}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{:else}
|
||||||
|
<p>There was an error accessing the database.</p>
|
||||||
|
{/if}
|
||||||
Loading…
Reference in New Issue
Block a user