Author SHA1 Message Date
robin 966554e615 feat: sort table by time 2026-08-25 13:38:22 +02:00
robin c5e351cec3 style: switch to Pie diagramm 2026-08-04 12:16:06 +02:00
robin b3e8b1209a chore: remove unnecessary comments 2026-08-04 12:09:39 +02:00
robin e5e66b2953 feat: create index page 2026-08-04 12:06:21 +02:00
robin 19d2d191d0 refactor: switch arguments to query parameters 2026-08-04 11:50:37 +02:00
robin 9935be7a25 Merge branch 'main' into feat/evaluation 2026-08-04 09:36:23 +00:00
robin f19babaa68 style: adjust formats in UI 2026-08-04 11:30:18 +02:00
robin fc8142a131 feat: display total percentage 2026-08-04 11:24:38 +02:00
3 changed files with 128 additions and 19 deletions

No files matched your search

@@ -2,9 +2,9 @@ import ical, { VEvent } from 'node-ical';
import CategoryChart from '@/components/CategoryChart';
interface PageProps {
params: Promise<{
'days': string;
'ical-link': string[];
searchParams: Promise<{
'days'?: string;
'ical-link'?: string | string[];
}>;
}
@@ -31,17 +31,25 @@ function getCategories(categoriesField: any): string[] {
type TimeMap = Record<string, number>;
export default async function EvaluationPage({ params }: PageProps) {
export default async function EvaluationPage({ searchParams }: PageProps) {
const times: TimeMap = {};
let total = 0;
const resolvedParams = await params;
const daysToFetch = Number(resolvedParams['days']) || 7;
const resolvedSearchParams = await searchParams;
const daysToFetch = Number(resolvedSearchParams['days']) || 7;
const pathSegments = resolvedParams['ical-link'];
let rawUrl = pathSegments.join('/');
rawUrl = decodeURIComponent(rawUrl);
const icalUrl = rawUrl.replace(/^(https?):\/+/, '$1://');
const rawUrl = resolvedSearchParams['ical-link'];
if (!rawUrl) {
return (
<div style={{ padding: '1rem', color: '#dc2626', fontFamily: 'system-ui, sans-serif' }}>
Fehler: Kein iCal-Link übergeben. Bitte verwende den Query-Parameter ?ical-link=...
</div>
);
}
const singleUrl = Array.isArray(rawUrl) ? rawUrl[0] : rawUrl;
const icalUrl = decodeURIComponent(singleUrl);
const response = await fetch(icalUrl, { next: { revalidate: 3600 } });
if (!response.ok) {
@@ -108,28 +116,38 @@ export default async function EvaluationPage({ params }: PageProps) {
<th style={{ padding: '0.5rem' }}>Kategorie</th>
<th style={{ padding: '0.5rem' }}>Dauer</th>
<th style={{ padding: '0.5rem' }}>Anteil</th>
<th style={{ padding: '0.5rem' }}>Insg. Anteil</th>
</tr>
</thead>
<tbody>
{Object.entries(times).map(([category, minutes]) => (
{Object.entries(times)
.sort(([, minutesA], [, minutesB]) => minutesB - minutesA)
.map(([category, minutes]) => (
<tr key={category} style={{ borderBottom: '1px solid #e5e7eb' }}>
<td style={{ padding: '0.5rem' }}>{category}</td>
<td style={{ padding: '0.5rem', whiteSpace: 'nowrap' }}>
{Math.floor(minutes / 60)} Std. {Math.round(minutes % 60)} Min. ({Math.round(minutes)} Min. gesamt)
{Math.floor(minutes / 60)}:{Math.round(minutes % 60).toString().padStart(2, '0')}h (={Math.round(minutes)} min)
</td>
<td style={{ padding: '0.5rem' }}>
{total > 0 ? Math.round((minutes / total) * 1000) / 10 : 0}%
</td>
<td style={{ padding: '0.5rem' }}>
{total > 0 ? Math.round((minutes / (daysToFetch * 24 * 60)) * 1000) / 10 : 0}%
</td>
</tr>
))}
))
}
</tbody>
<tfoot>
<tr style={{ fontWeight: 'bold' }}>
<td style={{ padding: '0.5rem' }}>Total</td>
<td style={{ padding: '0.5rem', whiteSpace: 'nowrap' }}>
{Math.floor(total / 60)} Std. {Math.round(total % 60)} Min. ({Math.round(total)} Min. gesamt)
{Math.floor(total / 60)}:{Math.round(total % 60)}h (={Math.round(total)} min)
</td>
<td style={{ padding: '0.5rem' }}>100%</td>
<td style={{ padding: '0.5rem' }}>
{total > 0 ? Math.round((total / (daysToFetch * 24 * 60)) * 1000) / 10 : 0}%
</td>
</tr>
</tfoot>
</table>
@@ -190,7 +208,6 @@ export default async function EvaluationPage({ params }: PageProps) {
display: 'inline-block',
background: '#white',
border: '1px solid #e5e7eb',
color: 'black',
padding: '2px 8px',
borderRadius: '4px',
fontSize: '0.85rem',
+94 -2
View File
@@ -1,7 +1,99 @@
import Image from "next/image";
"use client"
import { useState } from 'react';
import { useRouter } from 'next/navigation';
export default function Home() {
const [icalLink, setIcalLink] = useState('');
const [days, setDays] = useState<number | string>(7) // standart: 7 days
const router = useRouter();
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault(); // website won't reload
if (!icalLink) {
return;
}
router.push(`/evaluation?days=${days}&ical-link=${icalLink}`);
};
return (
<p>hi</p>
<main
style={{
width: '100%',
maxWidth: '800px',
margin: '0 auto',
padding: '1rem',
boxSizing: 'border-box',
fontFamily: 'system-ui, sans-serif',
}}
>
<section style={{ marginBottom: '2.5rem' }}>
<form
onSubmit={handleSubmit}
style={{ display: 'flex', flexDirection: 'column', gap: '1rem', maxWidth: '400px' }}
>
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.3rem' }}>
<label htmlFor="ical-link-input" style={{ fontWeight: 600 }}>
iCal-Link
</label>
<input
type="url"
id="ical-link-input"
value={icalLink}
onChange={(e) => setIcalLink(e.target.value)}
placeholder="https://example.com/calendar.ics"
required
style={{
padding: '0.5rem',
borderRadius: '4px',
border: '1px solid #ccc',
fontSize: '1rem',
}}
/>
</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.3rem' }}>
<label htmlFor="days-input" style={{ fontWeight: 600 }}>
Anzahl der betrachteten Tage
</label>
<input
type="number"
id="days-input"
min={1}
value={days}
onChange={(e) => setDays(Number(e.target.value) || '')}
placeholder="7"
required
style={{
padding: '0.5rem',
borderRadius: '4px',
border: '1px solid #ccc',
fontSize: '1rem',
}}
/>
</div>
<button
type="submit"
style={{
marginTop: '0.5rem',
padding: '0.75rem',
backgroundColor: '#3b82f6',
color: 'white',
border: 'none',
borderRadius: '4px',
fontSize: '1rem',
fontWeight: 600,
cursor: 'pointer',
}}
>
Zu den Diagrammen
</button>
</form>
</section>
</main>
);
}
+2 -2
View File
@@ -1,7 +1,7 @@
'use client';
import { Chart as ChartJS, ArcElement, Tooltip, Legend } from 'chart.js';
import { Doughnut } from 'react-chartjs-2';
import { Pie } from 'react-chartjs-2';
// Chart.js Module registrieren (wichtig in v3/v4)
ChartJS.register(ArcElement, Tooltip, Legend);
@@ -56,7 +56,7 @@ export default function CategoryChart({ times }: CategoryChartProps) {
return (
<div style={{ maxWidth: '360px', margin: '1.5rem auto' }}>
<Doughnut data={data} options={options} />
<Pie data={data} options={options} />
</div>
);
}