5 changed files with 105 additions and 30 deletions
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
<script> |
||||
import { onMount } from 'svelte'; |
||||
|
||||
import { api } from '../../urls.svelte.js'; |
||||
import { t } from '../../translations.svelte.js'; |
||||
|
||||
let error = $state(null); |
||||
let tasks = $state(null); |
||||
|
||||
async function load(){ |
||||
const url = api('task'); |
||||
const resp = await fetch(url,{credentials:'include'}); |
||||
let project_ids = {}; |
||||
if (resp.ok){ |
||||
tasks = await resp.json(); |
||||
for (let task of (Object.values(tasks))) project_ids[task.project_id] = true; |
||||
} else { |
||||
error = await resp.text(); |
||||
} |
||||
project_ids = Object.keys(project_ids); |
||||
console.log(project_ids); |
||||
} |
||||
|
||||
onMount(load); |
||||
</script> |
||||
|
||||
<fieldsett> |
||||
<legend>{t('task_list')}</legend> |
||||
{#if error} |
||||
<soan class="error">{error}</soan> |
||||
{/if} |
||||
{#if tasks} |
||||
<table> |
||||
<thead> |
||||
<tr> |
||||
<th>{t('title')}</th> |
||||
<th>{t('project')} / {t('parent_task')}</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
{#each Object.entries(tasks) as [tid,task]} |
||||
<tr> |
||||
<td>{task.name}</td> |
||||
<td>{task.project_id} {task.parent_task_id?tasks[task.parent_task_id]?.name:''}</td> |
||||
<td>TODO: load projects</td> |
||||
</tr> |
||||
{/each} |
||||
</tbody> |
||||
</table> |
||||
{/if} |
||||
</fieldsett> |
||||
Loading…
Reference in new issue