Skip to content

Commit cfde4b1

Browse files
committed
F: Add kanban cards to for today overview (DEMO)
1 parent 1ce59fd commit cfde4b1

File tree

2 files changed

+32
-14
lines changed

2 files changed

+32
-14
lines changed

src/routes/+layout.svelte

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
} from "@davidnet/svelte-ui";
1717
import favicon from "$lib/assets/favicon.svg";
1818
import { onMount } from "svelte";
19-
import type { Card, SessionInfo } from "$lib/types";
19+
import type { SessionInfo } from "$lib/types";
2020
import { page } from "$app/state";
21-
import { authapiurl, kanbanapiurl } from "$lib/config";
21+
import { authapiurl } from "$lib/config";
2222
2323
let { children } = $props();
2424
@@ -34,15 +34,6 @@
3434
fontsLoaded = true;
3535
});
3636
}
37-
38-
let cards_due_today: Card[] = $state([]);
39-
40-
async function LoadDaily() {
41-
const cards_due_today_res = await authFetch(`${kanbanapiurl}boards/recent`, correlationID, { method: "GET" });
42-
cards_due_today = await cards_due_today_res.json();
43-
console.log("Cards due today:", cards_due_today);
44-
}
45-
4637
onMount(async () => {
4738
const initloader = document.getElementById("initloader");
4839
if (initloader) initloader.remove();
@@ -77,7 +68,6 @@
7768
}
7869
7970
authed = true;
80-
await LoadDaily();
8171
setInterval(
8272
() => {
8373
refreshAccessToken(correlationID, true, false);

src/routes/+page.svelte

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script lang="ts">
22
import Weather from "$lib/components/Weather.svelte";
3-
import type { SessionInfo } from "$lib/types";
3+
import { kanbanapiurl } from "$lib/config";
4+
import type { Card, SessionInfo } from "$lib/types";
45
import {
56
FlexWrapper,
67
Icon,
@@ -11,7 +12,10 @@
1112
refreshAccessToken,
1213
formatDate_PREFERREDTIME,
1314
BlockNote,
14-
isMachineTimeSameAsPreferred
15+
isMachineTimeSameAsPreferred,
16+
17+
authFetch
18+
1519
} from "@davidnet/svelte-ui";
1620
import { sign } from "crypto";
1721
import { onMount, onDestroy } from "svelte";
@@ -105,6 +109,7 @@
105109
}, 1000);
106110
107111
goodtime = await isMachineTimeSameAsPreferred(correlationID);
112+
await LoadDaily();
108113
});
109114
110115
let width = $state(window.innerWidth);
@@ -162,6 +167,14 @@
162167
if (!url) return;
163168
edit_custom_link(link.id, name, url);
164169
}
170+
171+
let cards_due_today: Card[] = $state([]);
172+
async function LoadDaily() {
173+
const cards_due_today_res = await authFetch(`${kanbanapiurl}boards/recent`, correlationID, { method: "GET" });
174+
cards_due_today = await cards_due_today_res.json();
175+
console.log("Cards due today:", cards_due_today);
176+
}
177+
165178
</script>
166179

167180
<FlexWrapper direction="column" width="100%">
@@ -406,7 +419,20 @@
406419

407420
<FlexWrapper alignitems="flex-start" width="80%">
408421
<h2>Today:</h2>
422+
{#if cards_due_today.length > 0}
423+
<FlexWrapper gap="var(--token-space-3)" justifycontent={width > 600 ? "flex-start" : "space-evenly"} direction="row" wrap="wrap">
424+
{#each cards_due_today as card (card.id)}
425+
<a class="option" href={"https://kanban.davidnet.net"}>
426+
<FlexWrapper width="100%" height="100%" gap="var(--token-space-2)">
427+
<Icon size="4rem" icon="task_alt" />
428+
<p class="option-text">{card.name}</p>
429+
</FlexWrapper>
430+
</a>
431+
{/each}
432+
</FlexWrapper>
433+
{:else}
409434
<span style="color: var(--token-color-text-secondary); margin-left: var(--token-space-3);">No activity for today.</span>
435+
{/if}
410436
</FlexWrapper>
411437

412438
<Space height="var(--token-space-4)" />
@@ -432,6 +458,8 @@
432458
</a>
433459
{/each}
434460
<!-- Button to add a new link -->
461+
<!-- svelte-ignore a11y_click_events_have_key_events -->
462+
<!-- svelte-ignore a11y_no_static_element_interactions -->
435463
<div class="option" onclick={addLinkPrompt}>
436464
<FlexWrapper width="100%" height="100%" justifycontent="center" alignitems="center">
437465
<Icon icon="add" size="5rem"/>

0 commit comments

Comments
 (0)