working on task index

This commit is contained in:
2025-08-04 08:50:40 +02:00
parent 8eef37eb1a
commit 983f1bac49
5 changed files with 105 additions and 30 deletions

View File

@@ -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>