Compare commits

10 Commits
Author SHA1 Message Date
robin 811277d149 feat: display per categorie informations 2026-08-03 17:13:54 +02:00
robin adf4446f8a feat: display categories on events 2026-08-03 16:48:56 +02:00
robin 0712cf2f5f update version number 2026-08-03 16:47:06 +02:00
robin 0b71bdd348 chore: remove unnecessary comment 2026-08-03 16:44:36 +02:00
robin ade29ee5a8 fix: small issues 2026-08-03 13:01:48 +02:00
robin 176602d9bb feat: accept amount of days to fetch 2026-08-03 12:57:58 +02:00
robin e3072755e7 feat: fetch and read calendar 2026-08-03 12:52:33 +02:00
robin 1b2df1912a update version number 2026-08-03 12:22:32 +02:00
robin c8a66d8471 feat: preparing evaluation 2026-08-03 12:21:11 +02:00
robin fedab30e35 remove NextJS content
Deploy Next.js via Docker / deploy (push) Successful in 48s
2026-08-03 12:10:55 +02:00
4 changed files with 174 additions and 60 deletions

No files matched your search

@@ -0,0 +1,134 @@
import ical, { VEvent } from 'node-ical';
interface PageProps {
params: Promise<{
'days': string;
'ical-link': string[];
}>;
}
function getIcalText(field: any): string {
if (!field) return '';
if (typeof field === 'string') return field;
if (typeof field === 'object' && 'val' in field) return field.val as string;
return String(field);
}
function getIcalDate(dateValue: any): Date {
if (!dateValue) return new Date(0); // Fallback: 01.01.1970, falls kein Datum da ist
if (dateValue instanceof Date) return dateValue;
return new Date(dateValue);
}
function getCategories(categoriesField: any): string[] {
if (!categoriesField) return [];
if (Array.isArray(categoriesField)) {
return categoriesField.map((cat) => getIcalText(cat));
}
return [getIcalText(categoriesField)];
}
type TimeMap = Record<string, number>
export default async function EvaluationPage({ params }: PageProps) {
let times: TimeMap = {};
// get all params
const resolvedParams = await params;
// get amount of days to fetch
const daysToFetch = Number(resolvedParams['days']) || 7; //fallback to 7 days
// get the URL from the own URL (/evaluation/<ics-link>)
const pathSegments = resolvedParams['ical-link'];
let rawUrl = pathSegments.join('/');
rawUrl = decodeURIComponent(rawUrl);
const icalUrl = rawUrl.replace(/^(https?):\/+/, '$1://');
// fetch the file
const response = await fetch(icalUrl, { next: { revalidate: 3600 } });
if (!response.ok) {
return <div>Fehler beim Laden der Kalenderdaten. Status: {response.status}</div>;
}
const icalData = await response.text();
const parsedData = ical.sync.parseICS(icalData);
// calculate range of time
const now = new Date();
const cutoffDate = new Date();
cutoffDate.setDate(now.getDate() - daysToFetch);
// filter and sort data (needed: "VEVENT"; time range)
const events = Object.values(parsedData)
.filter((item): item is VEvent => item !== undefined && item.type === 'VEVENT')
.filter((event) => {
const startDate = getIcalDate(event.start);
return startDate >= cutoffDate && startDate <= now;
})
.sort((a, b) => getIcalDate(b.start).getTime() - getIcalDate(a.start).getTime()); // newest first
// read time per categorie
events.map((event, index) => {
const startDate = getIcalDate(event.start);
const endDate = getIcalDate(event.end);
const durationInMs = endDate.getTime() - startDate.getTime();
const durationInMinutes = durationInMs / (1000 * 60);
const categories = getCategories(event.categories);
categories.forEach((cat) => {
times[cat] = (times[cat] || 0) + durationInMinutes
})
})
return (
<main>
<h1>Meine Kalender-Events</h1>
<section>
<h2>Gesamtdauer pro Kategorie</h2>
{Object.keys(times).length === 0 ? (
<p>Keine Zeiten erfasst.</p>
) : (
<ul>
{Object.entries(times).map(([category, minutes]) => (
<li key={category}>
<strong>{category}:</strong> {Math.floor(minutes / 60)} Std. {minutes % 60} Min. ({minutes} Min. gesamt)
</li>
))}
</ul>
)}
</section>
{events.length === 0 ? (
<p>Keine Termine gefunden.</p>
) : (
<ul style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
{events.map((event, index) => {
const startDate = getIcalDate(event.start);
const endDate = getIcalDate(event.end);
return (
<li key={event.uid || index} style={{ border: '1px solid #ccc', padding: '1rem', borderRadius: '8px' }}>
<h2>{getIcalText(event.summary)}</h2>
<p>
<strong>Start:</strong> {startDate.toLocaleString('de-DE')} <br />
<strong>Ende:</strong> {endDate.toLocaleString('de-DE')}
</p>
{event.location && (
<p><strong>Ort:</strong> {getIcalText(event.location)}</p>
)}
{event.description && (
<p><strong>Beschreibung:</strong> {getIcalText(event.description)}</p>
)}
{event.categories && (
<p><strong>Kategorien:</strong> {getIcalText(event.categories)}</p>
)}
</li>
);
})}
</ul>
)}
</main>
);
}
+1 -59
View File
@@ -2,64 +2,6 @@ import Image from "next/image";
export default function Home() { export default function Home() {
return ( return (
<div className="flex flex-col flex-1 items-center justify-center bg-zinc-50 font-sans dark:bg-black"> <p>hi</p>
<main className="flex flex-1 w-full max-w-3xl flex-col items-center justify-between py-32 px-16 bg-white dark:bg-black sm:items-start">
<Image
className="dark:invert"
src="/next.svg"
alt="Next.js logo"
width={100}
height={20}
priority
/>
<div className="flex flex-col items-center gap-6 text-center sm:items-start sm:text-left">
<h1 className="max-w-xs text-3xl font-semibold leading-10 tracking-tight text-black dark:text-zinc-50">
To get started, edit the page.tsx file.
</h1>
<p className="max-w-md text-lg leading-8 text-zinc-600 dark:text-zinc-400">
Looking for a starting point or more instructions? Head over to{" "}
<a
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
className="font-medium text-zinc-950 dark:text-zinc-50"
>
Templates
</a>{" "}
or the{" "}
<a
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
className="font-medium text-zinc-950 dark:text-zinc-50"
>
Learning
</a>{" "}
center.
</p>
</div>
<div className="flex flex-col gap-4 text-base font-medium sm:flex-row">
<a
className="flex h-12 w-full items-center justify-center gap-2 rounded-full bg-foreground px-5 text-background transition-colors hover:bg-[#383838] dark:hover:bg-[#ccc] md:w-[158px]"
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<Image
className="dark:invert"
src="/vercel.svg"
alt="Vercel logomark"
width={16}
height={16}
/>
Deploy Now
</a>
<a
className="flex h-12 w-full items-center justify-center rounded-full border border-solid border-black/[.08] px-5 transition-colors hover:border-transparent hover:bg-black/[.04] dark:border-white/[.145] dark:hover:bg-[#1a1a1a] md:w-[158px]"
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
Documentation
</a>
</div>
</main>
</div>
); );
} }
+2 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "temp-next", "name": "temp-next",
"version": "0.1.0", "version": "0.3.0",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",
@@ -10,6 +10,7 @@
}, },
"dependencies": { "dependencies": {
"next": "16.2.12", "next": "16.2.12",
"node-ical": "^0.27.1",
"react": "19.2.4", "react": "19.2.4",
"react-dom": "19.2.4" "react-dom": "19.2.4"
}, },
+37
View File
@@ -11,6 +11,9 @@ importers:
next: next:
specifier: 16.2.12 specifier: 16.2.12
version: 16.2.12(@babel/core@7.29.7(supports-color@7.2.0))(react-dom@19.2.4(react@19.2.4))(react@19.2.4) version: 16.2.12(@babel/core@7.29.7(supports-color@7.2.0))(react-dom@19.2.4(react@19.2.4))(react@19.2.4)
node-ical:
specifier: ^0.27.1
version: 0.27.1
react: react:
specifier: 19.2.4 specifier: 19.2.4
version: 19.2.4 version: 19.2.4
@@ -1598,6 +1601,10 @@ packages:
resolution: {integrity: sha512-kXs9Go0cah0qHVV2v389IXQLdLCeE1xfFtjOAF+iobu0OIoG1pje8At2vMHyaPMiPMnG/LWP50twML21eMcAag==} resolution: {integrity: sha512-kXs9Go0cah0qHVV2v389IXQLdLCeE1xfFtjOAF+iobu0OIoG1pje8At2vMHyaPMiPMnG/LWP50twML21eMcAag==}
engines: {node: '>= 0.4'} engines: {node: '>= 0.4'}
node-ical@0.27.1:
resolution: {integrity: sha512-5fiKuh/h2HrWKzFt20LtRQdjtjdGfijGfDnCfdAEc++SFX9gA6sa7xwj7/BJmRfWtW/NJWBenN4tOJhg0vM3pg==}
engines: {node: '>=22'}
node-releases@2.0.51: node-releases@2.0.51:
resolution: {integrity: sha512-wRNIrw4DmVLKQlbgOMdkMx27Wrpzes2hh5Jtbi2bjPd+4wJstWIqP5A+lscnqbm0xxmT5Bpg8Lec5ItEBwx6BQ==} resolution: {integrity: sha512-wRNIrw4DmVLKQlbgOMdkMx27Wrpzes2hh5Jtbi2bjPd+4wJstWIqP5A+lscnqbm0xxmT5Bpg8Lec5ItEBwx6BQ==}
engines: {node: '>=18'} engines: {node: '>=18'}
@@ -1738,6 +1745,9 @@ packages:
resolution: {integrity: sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==} resolution: {integrity: sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==}
engines: {iojs: '>=1.0.0', node: '>=0.10.0'} engines: {iojs: '>=1.0.0', node: '>=0.10.0'}
rrule-temporal@2.0.2:
resolution: {integrity: sha512-pwe7+pWXKUotQgdudN8W36tFHWf8eH+FbcB5Tl4Zftb4RYpl1hnqMRapizv0s8QlOlC6GEKcVSmITurpSOVZfQ==}
run-parallel@1.2.0: run-parallel@1.2.0:
resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==}
@@ -1875,6 +1885,15 @@ packages:
resolution: {integrity: sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==} resolution: {integrity: sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==}
engines: {node: '>=6'} engines: {node: '>=6'}
temporal-polyfill@1.0.2:
resolution: {integrity: sha512-pTyp/7kfStJQbJ8YOHmcJItkxvOGCZHu3PaVgLvLnxFS7O12EPiWLElnRre/rw77z4TGZX/gvdqMXWn6ispQvA==}
temporal-spec@1.0.1:
resolution: {integrity: sha512-wxVoanmDeavXie1vu2JaQ3WIc3JZnWAOYFBsJyATaVsXsycKYUflGsyBmrRSnoCpZJpwPyr38VpgSUlQ8CbFxg==}
temporal-utils@1.0.1:
resolution: {integrity: sha512-HAixuesxFQIUaQk3ptX2jhfO/FsOkgVkDDMawvp6n/fkB1q6BKfs3lURw9I+pK/2e2e/q/vrLrxmeqauBoyGMQ==}
tinyglobby@0.2.17: tinyglobby@0.2.17:
resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==} resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==}
engines: {node: '>=12.0.0'} engines: {node: '>=12.0.0'}
@@ -3618,6 +3637,11 @@ snapshots:
object.entries: 1.1.9 object.entries: 1.1.9
semver: 6.3.1 semver: 6.3.1
node-ical@0.27.1:
dependencies:
rrule-temporal: 2.0.2
temporal-polyfill: 1.0.2
node-releases@2.0.51: {} node-releases@2.0.51: {}
object-assign@4.1.1: {} object-assign@4.1.1: {}
@@ -3772,6 +3796,10 @@ snapshots:
reusify@1.1.0: {} reusify@1.1.0: {}
rrule-temporal@2.0.2:
dependencies:
temporal-spec: 1.0.1
run-parallel@1.2.0: run-parallel@1.2.0:
dependencies: dependencies:
queue-microtask: 1.2.3 queue-microtask: 1.2.3
@@ -3970,6 +3998,15 @@ snapshots:
tapable@2.3.3: {} tapable@2.3.3: {}
temporal-polyfill@1.0.2:
dependencies:
temporal-spec: 1.0.1
temporal-utils: 1.0.1
temporal-spec@1.0.1: {}
temporal-utils@1.0.1: {}
tinyglobby@0.2.17: tinyglobby@0.2.17:
dependencies: dependencies:
fdir: 6.5.0(picomatch@4.0.5) fdir: 6.5.0(picomatch@4.0.5)