-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from greybaron/feat/blockplan-tile
add blockplan tile
- Loading branch information
Showing
7 changed files
with
139 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<script lang="ts"> | ||
import DashboardTile from '$lib/DashboardTile.svelte'; | ||
import { onMount } from 'svelte'; | ||
let timeline: Timeline; | ||
import { createEventDispatcher } from 'svelte'; | ||
import { ToastPayloadClass, type Timeline, type ToastPayload } from '$lib/types'; | ||
import { Accordion, AccordionItem } from '@skeletonlabs/skeleton'; | ||
const dispatch = createEventDispatcher(); | ||
onMount(async () => { | ||
console.log('Fetching timeline...'); | ||
const res = await fetch('/api/timeline'); | ||
if (!res.ok) { | ||
let error = await res.text(); | ||
let payload: ToastPayload = { | ||
text: error, | ||
class: ToastPayloadClass.error | ||
}; | ||
dispatch('showToast', payload); | ||
return; | ||
} else { | ||
timeline = await res.json(); | ||
} | ||
}); | ||
</script> | ||
|
||
<DashboardTile title="Blockplan" clickable={false} ready={Boolean(timeline)}> | ||
<Accordion> | ||
{#if timeline.fachsemester.length > 0} | ||
<AccordionItem> | ||
<svelte:fragment slot="summary">Fachsemester</svelte:fragment> | ||
<svelte:fragment slot="content"> | ||
<ul class="list-disc list-inside text-left"> | ||
{#each timeline.fachsemester as fsevent} | ||
<li class="text-xs">{fsevent.description}</li> | ||
{/each} | ||
</ul> | ||
</svelte:fragment> | ||
</AccordionItem> | ||
{/if} | ||
|
||
{#if timeline.theoriesemester.length > 0} | ||
<AccordionItem> | ||
<svelte:fragment slot="summary">Theoriesemester</svelte:fragment> | ||
<svelte:fragment slot="content"> | ||
<ul class="list-disc list-inside text-left"> | ||
{#each timeline.theoriesemester as tsevent} | ||
<li class="text-xs">{tsevent.description}</li> | ||
{/each} | ||
</ul> | ||
</svelte:fragment> | ||
</AccordionItem> | ||
{/if} | ||
|
||
{#if timeline.praxissemester.length > 0} | ||
<AccordionItem> | ||
<svelte:fragment slot="summary">Praxissemester</svelte:fragment> | ||
<svelte:fragment slot="content"> | ||
<ul class="list-disc list-inside text-left"> | ||
{#each timeline.praxissemester as psevent} | ||
<li class="text-xs">{psevent.description}</li> | ||
{/each} | ||
</ul> | ||
</svelte:fragment> | ||
</AccordionItem> | ||
{/if} | ||
|
||
{#if timeline.specials.length > 0} | ||
<AccordionItem> | ||
<svelte:fragment slot="summary">Spezielles</svelte:fragment> | ||
<svelte:fragment slot="content"> | ||
<ul class="list-disc list-inside text-left"> | ||
{#each timeline.specials as spevent} | ||
<li class="text-xs">{spevent.description}</li> | ||
{/each} | ||
</ul> | ||
</svelte:fragment> | ||
</AccordionItem> | ||
{/if} | ||
</Accordion> | ||
</DashboardTile> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { json } from '@sveltejs/kit'; | ||
import { env } from '$env/dynamic/private'; | ||
|
||
export async function GET({ cookies }) { | ||
const token = cookies.get('jwt'); | ||
|
||
if (!token) { | ||
return json({ error: 'Unauthorized' }, { status: 401 }); | ||
} | ||
|
||
try { | ||
const response = await fetch(`${env.CD_API_URL}/get_timeline`, { | ||
headers: { | ||
Authorization: `Bearer ${token}` | ||
} | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error(); | ||
} | ||
|
||
return response; | ||
} catch (error) { | ||
console.error('Error at blockplan:'); | ||
if (error instanceof Error) { | ||
console.error(error.message); | ||
} | ||
return new Response('CaDu: Blockplan-Abfrage ist fehlgeschlagen', { status: 500 }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters