working on task index
This commit is contained in:
51
frontend/src/routes/task/Index.svelte
Normal file
51
frontend/src/routes/task/Index.svelte
Normal 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>
|
||||
Reference in New Issue
Block a user