1
0

Compare commits

...

2 Commits

Author SHA1 Message Date
e9ea35a064 feat: Integrate
All checks were successful
Remote Deploy / deploy (push) Successful in 36s
2026-02-12 18:08:15 +01:00
cea8cdf4ee feat: Added viewer 2026-02-12 17:45:47 +01:00
49 changed files with 16148 additions and 11 deletions

View File

@@ -1,3 +1,6 @@
EMAIL=username@spsejecna.cz
PASSWORD=mojesupertajneheslo
SHAREPOINT_URL=https://spsejecnacz.sharepoint.com/:x:/s/nastenka/ESy19K245Y9BouR5ksciMvgBu3Pn_9EaT0fpP8R6MrkEmg
# For the viewer
API_URl=http://localhost:3000

1
output.json Normal file

File diff suppressed because one or more lines are too long

1863
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -9,22 +9,30 @@
"scripts": {
"test": "tsx tests/test.ts",
"start": "concurrently \"NODE_ENV=development tsx server.ts\" \"NODE_ENV=development tsx cron-runner.ts\"",
"build": "tsc && cd web && hugo --gc --minify",
"build": "tsc && cd web && hugo --gc --minify && cd ../viewer && npm run build",
"build-noweb": "tsc",
"serve": "concurrently \"node dist/server.js\" \"node dist/cron-runner.js\"",
"dev-web": "cd web && hugo serve"
"dev-web": "cd web && hugo serve",
"parse-timetable": "node scripts/load_static_schedule.js"
},
"dependencies": {
"axios": "^1.13.5",
"axios-cookiejar-support": "^6.0.5",
"body-parser": "^2.2.0",
"cheerio": "^1.1.2",
"cli-progress": "^3.12.0",
"concurrently": "^9.2.0",
"cors": "^2.8.6",
"dotenv": "^17.2.3",
"exceljs": "^4.4.0",
"express": "^5.1.0",
"inquirer": "^13.2.2",
"jszip": "^3.10.1",
"next": "^16.1.6",
"node-cron": "^4.2.1",
"password-prompt": "^1.1.3",
"puppeteer": "^24.10.0",
"tough-cookie": "^6.0.0",
"xml2js": "^0.6.2"
},
"devDependencies": {
@@ -32,6 +40,7 @@
"@types/cors": "^2.8.19",
"@types/express": "^5.0.6",
"@types/jszip": "^3.4.0",
"@types/next": "^8.0.7",
"@types/node": "^25.2.3",
"@types/node-cron": "^3.0.11",
"@types/xml2js": "^0.4.14",

View File

@@ -0,0 +1,216 @@
/*
* Copyright (C) 2025 Jakub Žitník
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
import axios from "axios";
import { CookieJar } from "tough-cookie";
import { wrapper } from "axios-cookiejar-support";
import * as cheerio from "cheerio";
import { URLSearchParams } from "url";
import fs from "fs";
import inquirer from "inquirer";
import cliProgress from "cli-progress";
const BASE = "https://www.spsejecna.cz";
const PATHS = {
SET_ROLE: "/user/role",
LOGIN: "/user/login",
TEACHERS: "/ucitel",
TEACHER: teacherCode => `/ucitel/${teacherCode}`
};
const jar = new CookieJar();
const client = wrapper(axios.create({
baseURL: BASE,
jar,
withCredentials: true,
headers: {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
}
}));
async function login(username, password) {
console.log("Logging in!");
await client.get("/");
await client.get(PATHS.SET_ROLE, {
params: { role: "student" }
});
const token3Res = await client.get("/");
const token3 = token3Res.data.match(/"token3"\s+value="(\d+)"/)[1];
const form = new URLSearchParams();
form.append('user', username);
form.append('pass', password);
form.append('token3', token3);
form.append('submit', 'Přihlásit+se');
try {
const response = await client.post(PATHS.LOGIN, form.toString(), {
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
maxRedirects: 0
});
if (response.status == 200) {
console.log("INVALID CREDENTIALS!");
process.exit(1);
}
} catch {}
}
async function getAllTeacherCodes() {
console.log("Fetching teacher list");
const list = new Set();
const response = await client.get(PATHS.TEACHERS);
const $ = cheerio.load(response.data);
$("main .contentLeftColumn li, main .contentRightColumn li").each((_, el) => {
const link = $(el).find("a");
const href = link.attr("href");
if (href) {
const key = href.split("/").pop().toLowerCase();
list.add(key);
}
});
return list;
}
async function constructSchedules(allTeachers) {
console.log("Fetching teachers");
const progressBar = new cliProgress.SingleBar({
format: 'Progress |{bar}| {percentage}% || {value}/{total} steps',
barCompleteChar: '\u2588',
barIncompleteChar: '\u2591',
hideCursor: true
});
progressBar.start(allTeachers.size, 0);
const classes = {};
function setupClass(className) {
function generateArray(width, height) {
return Array.from({ length: height }, () => Array.from({ length: width }, () => []));
}
classes[className.toLowerCase()] = generateArray(10, 5);
}
let idk = 0;
for (const key of allTeachers) {
idk++;
const response = await client.get(PATHS.TEACHER(key));
const $ = cheerio.load(response.data);
const tbody = $('table.timetable > tbody');
if (!tbody.length) {
console.log(`ERROR: ${key}`)
continue;
}
tbody.find('tr').slice(1).each((dayIndex, tr) => {
const $tr = $(tr);
let currentHour = 0;
$tr.find('td').each((_, td) => {
const $td = $(td);
const colspan = parseInt($td.attr('colspan') || '1', 10);
const $subject = $td.find('span.subject');
const $class = $td.find('span.class');
const $group = $td.find('span.group');
const $room = $td.find('a.room');
const $employee = $td.find('a.employee');
const hasData = $subject.length && $class.length && $room.length && $employee.length;
let cellData = null;
let classText = '';
if (hasData) {
classText = $class.text().trim().toLowerCase();
cellData = {
subject: $subject.text().trim(),
title: $subject.attr('title')?.trim() || '',
group: $group.length ? $group.text().trim() : null,
room: $room.text().trim(),
teacher: {
code: $employee.text().trim().toLowerCase(),
name: $employee.attr('title')?.trim() || ''
}
};
}
for (let i = 0; i < colspan; i++) {
if (currentHour >= 10) {
break;
}
if (hasData && cellData) {
if (classes[classText] === undefined) {
setupClass(classText);
}
classes[classText][dayIndex][currentHour].push(cellData);
}
currentHour++;
}
});
});
progressBar.update(idk);
}
progressBar.stop();
return classes;
}
const answers = await inquirer.prompt([
{
type: 'input',
name: 'username',
message: 'Enter your username:',
},
{
type: 'password',
name: 'password',
message: 'Enter your password:',
mask: '*',
},
{
type: 'input',
name: 'filePath',
message: 'Enter the file path to save:',
default: './output.json',
},
]);
await login(answers.username, answers.password);
const allTeachers = await getAllTeacherCodes();
const schedule = await constructSchedules(allTeachers)
const str = JSON.stringify(schedule);
fs.writeFileSync(answers.filePath, str, {
encoding: "utf8"
});
console.log("Done!");

View File

@@ -19,6 +19,8 @@ import fs from "fs/promises";
import { getCurrentInterval } from "./scheduleRules.js";
import bodyParser from "body-parser";
import cors from "cors";
import next from "next";
import { fileURLToPath } from "url";
const DB_FOLDER = path.join(process.cwd(), "volume", "db");
const WEB_FOLDER = path.join(process.cwd(), "web", "public");
@@ -82,6 +84,10 @@ app.get("/status", async (_: Request, res: Response) => {
}
})
app.get("/posts/viewer/redirect", (_: Request, res: Response) => {
res.redirect(302, "/viewer");
})
app.post("/report", async (req: Request, res: Response): Promise<any> => {
const { class: className, location, content } = req.body;
if (!className || !location || !content) {
@@ -121,10 +127,28 @@ app.post("/report", async (req: Request, res: Response): Promise<any> => {
});
if (SERVE_WEB) {
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const dev = process.env.NODE_ENV !== 'production'
// @ts-ignore
const nextApp = next({
dev,
dir: path.join(__dirname, '../viewer')
})
const handle = nextApp.getRequestHandler()
await nextApp.prepare()
app.all(/^\/viewer(?:$|\/.*)/, (req, res) => {
return handle(req, res)
})
app.use(express.static(path.join(process.cwd(), 'web/public'), {
index: 'index.html',
extensions: ['html'],
}));
}))
}
app.listen(PORT, () => {

View File

@@ -15,6 +15,7 @@
],
"exclude": [
"node_modules",
"web"
"web",
"viewer"
]
}

41
viewer/.gitignore vendored Normal file
View File

@@ -0,0 +1,41 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
# env files (can opt-in for committing if needed)
.env*
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts

36
viewer/README.md Normal file
View File

@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
## Getting Started
First, run the development server:
```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
## Learn More
To learn more about Next.js, take a look at the following resources:
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
## Deploy on Vercel
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.

8
viewer/app/all/page.tsx Normal file
View File

@@ -0,0 +1,8 @@
import { getData } from '@/lib/api';
import SubstitutionViewer from './substitution-viewer';
export default async function Page() {
const data = await getData();
return <SubstitutionViewer initialData={data} />;
}

View File

@@ -0,0 +1,202 @@
'use client';
import { useState, useEffect, useMemo } from 'react';
import { format, parseISO } from 'date-fns';
import { SubstitutionData, ChangeEntry } from '@/lib/types';
import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/select';
import { Label } from '@/components/ui/label';
import TakesPlace from '@/components/own/takes-place';
import { TeacherAbsenceItem } from '@/components/own/teacher-absence';
import UpdateStatus from '@/components/own/update-status';
interface SubstitutionViewerProps {
initialData: SubstitutionData | null;
}
export default function SubstitutionViewer({ initialData }: SubstitutionViewerProps) {
const data = initialData;
const [selectedDate, setSelectedDate] = useState<string>('');
useEffect(() => {
if (data?.schedule) {
const dates = Object.keys(data.schedule).sort();
if (dates.length > 0) {
if (!selectedDate || !data.schedule[selectedDate]) {
setSelectedDate(dates[0]);
}
}
}
}, [data, selectedDate]);
const currentDayData = data?.schedule?.[selectedDate];
const dates = data ? Object.keys(data.schedule).sort() : [];
if (!data) {
return (
<div className="flex flex-col items-center justify-center min-h-screen text-muted-foreground space-y-4">
<p>Nepodařilo se načíst data.</p>
<Button onClick={() => window.location.reload()}>Zkusit znovu</Button>
</div>
);
}
return (
<main className="flex-1 w-full max-w-[1920px] mx-auto p-4 md:p-6 space-y-6">
<UpdateStatus data={data} />
<div className="max-w-md">
<Label htmlFor="date-select" className="mb-2 block">Datum</Label>
<Select value={selectedDate} onValueChange={setSelectedDate}>
<SelectTrigger id="date-select" className="w-full">
<SelectValue placeholder="Vyberte datum" />
</SelectTrigger>
<SelectContent>
{dates.map((date) => {
const info = data.schedule[date];
const label = format(parseISO(date), 'd.M.yyyy');
const suffix = info.info.inWork ? ' (příprava)' : '';
return (
<SelectItem key={date} value={date}>
{label}{suffix}
</SelectItem>
);
})}
</SelectContent>
</Select>
</div>
{currentDayData ? (
<div className="grid grid-cols-1 xl:grid-cols-4 gap-6">
<div className="xl:col-span-3 space-y-6">
<div>
<h2 className="text-xl font-semibold mb-3">Změny v rozvrhu</h2>
<SubstitutionsTable changes={currentDayData.changes} />
</div>
<TakesPlace string={currentDayData.takesPlace} />
</div>
<div className="xl:col-span-1 space-y-6">
<div>
<h2 className="text-xl font-semibold mb-3 text-slate-900 dark:text-slate-100">Absence učitelů</h2>
{currentDayData.absence.length > 0 ? (
<div className="space-y-3">
{currentDayData.absence.map((entry, idx) => (
<TeacherAbsenceItem key={idx} entry={entry} />
))}
</div>
) : (
<div className="p-4 rounded-lg border border-dashed text-muted-foreground text-center bg-slate-50 dark:bg-slate-900/50">
Žádní učitelé nemají absenci
</div>
)}
</div>
</div>
</div>
) : (
<div className="flex flex-col items-center justify-center py-20 text-muted-foreground">
<p className="text-lg">Pro vybrané datum nejsou k dispozici žádná data.</p>
</div>
)}
</main>
);
}
function SubstitutionsTable({ changes }: { changes: Record<string, (ChangeEntry | null)[]> }) {
const sortedClasses = useMemo(() => {
return Object.keys(changes).sort((a, b) => {
const regex = /^([A-Z]+)(\d+)([a-z]*)$/;
const ma = a.match(regex);
const mb = b.match(regex);
if (ma && mb) {
const [, pa, na, sa] = ma;
const [, pb, nb, sb] = mb;
const numDiff = parseInt(na) - parseInt(nb);
if (numDiff !== 0) return numDiff;
const prefixDiff = pa.localeCompare(pb);
if (prefixDiff !== 0) return prefixDiff;
return sa.localeCompare(sb);
}
return a.localeCompare(b, undefined, { numeric: true, sensitivity: 'base' });
});
}, [changes]);
const maxHours = useMemo(() => {
let max = 0;
Object.values(changes).forEach(list => {
if (list.length > max) max = list.length;
});
return max;
}, [changes]);
const hours = Array.from({ length: maxHours }, (_, i) => i + 1);
return (
<Card className="overflow-hidden border p-0">
<div className="overflow-x-auto">
<table className="w-full text-sm text-left border-collapse">
<thead>
<tr>
<th className="p-3 font-semibold border-b border-r min-w-[80px] text-center sticky left-0 z-10">
</th>
{hours.map(h => (
<th key={h} className="p-3 font-semibold border-b border-r min-w-[60px] text-center w-[60px]">
{h}
</th>
))}
</tr>
</thead>
<tbody>
{sortedClasses.map((className) => (
<tr key={className} className="border-b last:border-0">
<td className="p-2 font-bold border-r sticky left-0 z-10 bg-card text-center">
{className}
</td>
{hours.map((_, idx) => {
const change = changes[className][idx];
return (
<td key={idx} className="p-[2px] border-r w-[70px] h-[70px] align-middle">
{change ? (
<div
className="w-full h-full min-h-[46px] flex items-center justify-center p-1 rounded-sm text-xs text-center truncate"
style={{
backgroundColor: change.backgroundColor || '#eee',
color: change.foregroundColor ? "#" +change.foregroundColor.substring(3, 6) : '#000'
}}
title={change.text}
>
{change.text}
</div>
) : (
<div className="w-full h-full min-h-[46px]"></div>
)}
</td>
);
})}
</tr>
))}
</tbody>
</table>
</div>
</Card>
);
}

127
viewer/app/globals.css Normal file
View File

@@ -0,0 +1,127 @@
@import "tailwindcss";
@import "tw-animate-css";
@custom-variant dark (&:is(.dark *));
@theme inline {
--color-background: var(--background);
--color-foreground: var(--foreground);
--font-sans: var(--font-geist-sans);
--font-mono: var(--font-geist-mono);
--color-sidebar-ring: var(--sidebar-ring);
--color-sidebar-border: var(--sidebar-border);
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
--color-sidebar-accent: var(--sidebar-accent);
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
--color-sidebar-primary: var(--sidebar-primary);
--color-sidebar-foreground: var(--sidebar-foreground);
--color-sidebar: var(--sidebar);
--color-chart-5: var(--chart-5);
--color-chart-4: var(--chart-4);
--color-chart-3: var(--chart-3);
--color-chart-2: var(--chart-2);
--color-chart-1: var(--chart-1);
--color-ring: var(--ring);
--color-input: var(--input);
--color-border: var(--border);
--color-destructive: var(--destructive);
--color-accent-foreground: var(--accent-foreground);
--color-accent: var(--accent);
--color-muted-foreground: var(--muted-foreground);
--color-muted: var(--muted);
--color-secondary-foreground: var(--secondary-foreground);
--color-secondary: var(--secondary);
--color-primary-foreground: var(--primary-foreground);
--color-primary: var(--primary);
--color-popover-foreground: var(--popover-foreground);
--color-popover: var(--popover);
--color-card-foreground: var(--card-foreground);
--color-card: var(--card);
--radius-sm: calc(var(--radius) - 4px);
--radius-md: calc(var(--radius) - 2px);
--radius-lg: var(--radius);
--radius-xl: calc(var(--radius) + 4px);
--radius-2xl: calc(var(--radius) + 8px);
--radius-3xl: calc(var(--radius) + 12px);
--radius-4xl: calc(var(--radius) + 16px);
}
:root {
--radius: 0.625rem;
--background: oklch(1 0 0);
--foreground: oklch(0.145 0 0);
--card: oklch(1 0 0);
--card-foreground: oklch(0.145 0 0);
--popover: oklch(1 0 0);
--popover-foreground: oklch(0.145 0 0);
--primary: oklch(0.205 0 0);
--primary-foreground: oklch(0.985 0 0);
--secondary: oklch(0.97 0 0);
--secondary-foreground: oklch(0.205 0 0);
--muted: oklch(0.97 0 0);
--muted-foreground: oklch(0.556 0 0);
--accent: oklch(0.97 0 0);
--accent-foreground: oklch(0.205 0 0);
--destructive: oklch(0.577 0.245 27.325);
--border: oklch(0.922 0 0);
--input: oklch(0.922 0 0);
--ring: oklch(0.708 0 0);
--chart-1: oklch(0.646 0.222 41.116);
--chart-2: oklch(0.6 0.118 184.704);
--chart-3: oklch(0.398 0.07 227.392);
--chart-4: oklch(0.828 0.189 84.429);
--chart-5: oklch(0.769 0.188 70.08);
--sidebar: oklch(0.985 0 0);
--sidebar-foreground: oklch(0.145 0 0);
--sidebar-primary: oklch(0.205 0 0);
--sidebar-primary-foreground: oklch(0.985 0 0);
--sidebar-accent: oklch(0.97 0 0);
--sidebar-accent-foreground: oklch(0.205 0 0);
--sidebar-border: oklch(0.922 0 0);
--sidebar-ring: oklch(0.708 0 0);
}
.dark {
--background: oklch(0.145 0 0);
--foreground: oklch(0.985 0 0);
--card: oklch(0.205 0 0);
--card-foreground: oklch(0.985 0 0);
--popover: oklch(0.205 0 0);
--popover-foreground: oklch(0.985 0 0);
--primary: oklch(0.922 0 0);
--primary-foreground: oklch(0.205 0 0);
--secondary: oklch(0.269 0 0);
--secondary-foreground: oklch(0.985 0 0);
--muted: oklch(0.269 0 0);
--muted-foreground: oklch(0.708 0 0);
--accent: oklch(0.269 0 0);
--accent-foreground: oklch(0.985 0 0);
--destructive: oklch(0.704 0.191 22.216);
--border: oklch(1 0 0 / 10%);
--input: oklch(1 0 0 / 15%);
--ring: oklch(0.556 0 0);
--chart-1: oklch(0.488 0.243 264.376);
--chart-2: oklch(0.696 0.17 162.48);
--chart-3: oklch(0.769 0.188 70.08);
--chart-4: oklch(0.627 0.265 303.9);
--chart-5: oklch(0.645 0.246 16.439);
--sidebar: oklch(0.205 0 0);
--sidebar-foreground: oklch(0.985 0 0);
--sidebar-primary: oklch(0.488 0.243 264.376);
--sidebar-primary-foreground: oklch(0.985 0 0);
--sidebar-accent: oklch(0.269 0 0);
--sidebar-accent-foreground: oklch(0.985 0 0);
--sidebar-border: oklch(1 0 0 / 10%);
--sidebar-ring: oklch(0.556 0 0);
}
@layer base {
* {
@apply border-border outline-ring/50;
@apply border-border outline-ring/50;
}
body {
@apply bg-background text-foreground;
@apply bg-background text-foreground;
}
}

64
viewer/app/layout.tsx Normal file
View File

@@ -0,0 +1,64 @@
import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";
import { ThemeProvider } from "@/components/theme-provider";
import { Toaster } from "@/components/ui/sonner";
import { SiteHeader } from "@/components/site-header";
import { InfoIcon } from 'lucide-react';
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
const geistSans = Geist({
variable: "--font-geist-sans",
subsets: ["latin"],
});
const geistMono = Geist_Mono({
variable: "--font-geist-mono",
subsets: ["latin"],
});
export const metadata: Metadata = {
title: "Mimořádný rozvrh SPŠE Ječná",
};
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en" suppressHydrationWarning>
<body
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
<ThemeProvider
attribute="class"
defaultTheme="system"
enableSystem
disableTransitionOnChange
>
<div className="flex flex-col min-h-screen">
<SiteHeader />
{children}
<div className="w-full flex justify-center pt-4 pb-8">
<Alert className="max-w-100 mx-auto">
<InfoIcon />
<AlertTitle>Pozor!</AlertTitle>
<AlertDescription>
Tento web není oficiální a není jakkoliv spojen se SPŠE Ječná.
</AlertDescription>
</Alert>
</div>
<footer className="text-center text-xs text-white/70 pb-4">
&copy; 2026{" "}
<a href="https://jzitnik.dev" target="_blank" className="underline hover:text-white/90">Jakub Žitník</a>{" "}
{" "}
<a href="https://www.gnu.org/licenses/gpl-3.0.html" target="_blank" className="underline hover:text-white/90">Licencováno pod GNU GPL v3.0</a>
</footer>
</div>
<Toaster />
</ThemeProvider>
</body>
</html>
);
}

8
viewer/app/page.tsx Normal file
View File

@@ -0,0 +1,8 @@
import { getData } from "@/lib/api";
import View from "./view";
export default async function Page() {
const data = await getData();
return <View data={data} />
}

167
viewer/app/view.tsx Normal file
View File

@@ -0,0 +1,167 @@
"use client";
import { useEffect, useState } from "react";
import { useForm } from "react-hook-form";
import { Button } from "@/components/ui/button";
import {
Form,
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import { SubstitutionData, LocalData } from "@/lib/types";
import { Card, CardContent } from "@/components/ui/card";
import ScheduleViewer from "@/components/own/schedule-viewer";
import { capitalizeFirstLetter } from "@/lib/utils";
import UpdateStatus from '@/components/own/update-status';
interface ViewProps {
data: SubstitutionData | null;
}
interface FormValues {
className: string;
jsonFile: FileList | null;
}
export default function View({ data }: ViewProps) {
const [loading, setLoading] = useState(true);
const [localData, setLocalData] = useState<LocalData | null>(null);
const [hideSubstitutions, setHideSubstitutions] = useState(false);
const form = useForm<FormValues>({
defaultValues: {
className: "",
jsonFile: null,
},
});
const onSubmit = async (values: FormValues) => {
const classNameProcessed = values.className.toLowerCase();
const file = values.jsonFile?.[0];
if (!file) {
alert("No file uploaded!");
return;
}
try {
const text = await file.text();
const jsonData = JSON.parse(text);
console.log(jsonData)
const foundKey = Object.keys(jsonData).find(k => k.toLowerCase() === classNameProcessed);
if (!foundKey) {
alert("Class not found in file!");
return;
}
const data = {
class: foundKey,
timetable: jsonData[foundKey]
};
setLocalData(data);
localStorage.setItem("data", JSON.stringify(data));
} catch (err) {
console.log(err)
alert("Invalid JSON file.");
}
};
useEffect(() => {
const saved = localStorage.getItem("data");
if (saved) {
setLocalData(JSON.parse(saved));
}
setLoading(false);
}, [data]);
if (loading) return <p>Loading...</p>;
if (!localData) {
return (
<div className="flex justify-center w-full">
<Card className="my-8 max-w-200">
<CardContent>
<Form {...form} >
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
<FormField
control={form.control}
name="className"
rules={{
required: "Třída je povinná",
pattern: {
value: /^[AEC][1-4][a-c]?$/i,
message: "Neplatný název třídy"
},
}}
render={({ field }) => (
<FormItem>
<FormLabel>Třída</FormLabel>
<FormControl>
<Input {...field} placeholder="C2c" />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="jsonFile"
rules={{ required: "Soubor je povinný" }}
render={({ field }) => (
<FormItem>
<FormLabel>Soubor</FormLabel>
<FormControl>
<input
type="file"
accept=".json"
onChange={(e) => field.onChange(e.target.files)}
className="cursor-pointer"
/>
</FormControl>
<FormDescription>
<a href="/posts/viewer/getting_file" target="_blank" className="hover:underline">
Jak získat soubor?
</a>
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
<Button type="submit" className="cursor-pointer">Odeslat</Button>
</form>
</Form>
</CardContent>
</Card>
</div>
);
}
return (
<div className="w-full max-w-[1920px] mx-auto p-4 space-y-6">
<div className="flex justify-between items-center">
<h1 className="text-2xl font-bold">Rozvrh třídy {capitalizeFirstLetter(localData.class)}</h1>
<div className="flex gap-2">
<Button variant="outline" onClick={() => setHideSubstitutions(!hideSubstitutions)}>
{hideSubstitutions ? "Zobrazit suplování" : "Skrýt suplování"}
</Button>
<Button variant="outline" onClick={() => setLocalData(null)}>Změnit třídu/soubor</Button>
</div>
</div>
<UpdateStatus data={data} />
<ScheduleViewer localData={localData} substitutionData={data} hideSubstitutions={hideSubstitutions} />
</div>
);
}

23
viewer/components.json Normal file
View File

@@ -0,0 +1,23 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "new-york",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "",
"css": "app/globals.css",
"baseColor": "neutral",
"cssVariables": true,
"prefix": ""
},
"iconLibrary": "lucide",
"rtl": false,
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"hooks": "@/hooks"
},
"registries": {}
}

View File

@@ -0,0 +1,184 @@
'use client';
import { useMemo } from 'react';
import { format, startOfWeek, addDays, parseISO } from 'date-fns';
import { cs } from 'date-fns/locale';
import { LocalData, SubstitutionData, ChangeEntry, Hour } from '@/lib/types';
import { Card } from '@/components/ui/card';
import { capitalizeFirstLetter } from '@/lib/utils';
interface ScheduleViewerProps {
localData: LocalData;
substitutionData: SubstitutionData | null;
hideSubstitutions?: boolean;
}
function getChangesForClass(changes: Record<string, (ChangeEntry | null)[]> | undefined, className: string): (ChangeEntry | null)[] {
if (!changes) return [];
if (changes[className]) return changes[className];
const key = Object.keys(changes).find(k => k.toLowerCase() === className.toLowerCase());
if (key) return changes[key];
return [];
}
export default function ScheduleViewer({ localData, substitutionData, hideSubstitutions = false }: ScheduleViewerProps) {
const referenceDate = useMemo(() => {
if (substitutionData?.schedule) {
const dates = Object.keys(substitutionData.schedule).sort();
if (dates.length > 0) {
return parseISO(dates[0]);
}
}
return new Date();
}, [substitutionData]);
const mondayDate = useMemo(() => {
return startOfWeek(referenceDate, { weekStartsOn: 1 });
}, [referenceDate]);
const weekDays = useMemo(() => {
return Array.from({ length: 5 }, (_, i) => addDays(mondayDate, i));
}, [mondayDate]);
const maxHours = useMemo(() => {
let max = 0;
localData.timetable.forEach(day => {
if (day.length > max) max = day.length;
});
return max;
}, [localData]);
const currentWeekMaxHours = useMemo(() => {
let max = maxHours;
if (!hideSubstitutions && substitutionData?.schedule) {
weekDays.forEach(date => {
const dateStr = format(date, 'yyyy-MM-dd');
const dayData = substitutionData.schedule[dateStr];
if (dayData && dayData.changes) {
const changes = getChangesForClass(dayData.changes, localData.class);
if (changes.length > max) max = changes.length;
}
});
}
return max;
}, [maxHours, substitutionData, weekDays, localData.class, hideSubstitutions]);
const hours = Array.from({ length: currentWeekMaxHours }, (_, i) => i + 1);
return (
<div className="space-y-6">
<div className="flex items-center justify-between">
<div className="text-sm text-muted-foreground">
Zobrazen týden od {format(mondayDate, 'd. M.', { locale: cs })} do {format(weekDays[4], 'd. M. yyyy', { locale: cs })}
</div>
</div>
<Card className="overflow-hidden border p-0">
<div className="overflow-x-auto">
<table className="w-full text-sm text-left border-collapse">
<thead>
<tr>
<th className="p-3 font-semibold border-b border-r min-w-[100px] text-center">
Den
</th>
{hours.map(h => (
<th key={h} className="p-3 font-semibold border-b border-r min-w-[120px] text-center">
{h}
</th>
))}
</tr>
</thead>
<tbody>
{weekDays.map((date, dayIndex) => {
const dateStr = format(date, 'yyyy-MM-dd');
const dayName = format(date, 'EEEE', { locale: cs });
const staticDay = localData.timetable[dayIndex] || [];
const dynamicDay = substitutionData?.schedule?.[dateStr];
const changes = getChangesForClass(dynamicDay?.changes, localData.class);
const has3 = hours.some((_, hourIndex) => staticDay[hourIndex].length == 3);
return (
<tr key={dateStr} className="border-b last:border-0 group hover:bg-muted/5" style={{height: has3 ? "120px" : "80px"}}>
<td className="p-3 font-medium border-r text-center">
<div className="capitalize">{dayName}</div>
<div className="text-xs text-muted-foreground">{format(date, 'd. M.')}</div>
</td>
{hours.map((_, hourIndex) => {
const change = changes[hourIndex];
const staticLessons = staticDay[hourIndex] || [];
return (
<td key={hourIndex} className="border-r min-w-[120px] h-full align-top relative p-0">
<CellContent
staticLessons={staticLessons}
change={hideSubstitutions ? null : change}
/>
</td>
);
})}
</tr>
);
})}
</tbody>
</table>
</div>
</Card>
</div>
);
}
function CellContent({ staticLessons, change }: { staticLessons: Hour[], change: ChangeEntry | null | undefined }) {
if (change) {
return (
<div
className="w-full h-full p-2 text-xs flex items-center justify-center text-center font-medium shadow-sm"
style={{
backgroundColor: change.backgroundColor || '#f0f0f0',
color: change.foregroundColor ? "#" + change.foregroundColor.substring(3, 6) : '#000',
}}
>
{change.text}
</div>
);
}
if (!staticLessons || staticLessons.length === 0) {
return null;
}
if (staticLessons.length > 1) {
return (
<div className="flex flex-col min-h-[80px] h-full">
{staticLessons.map((lesson, idx) => (
<div key={idx} className="flex-1 flex flex-col justify-between p-1 text-[10px] border-b min-h-[40px]">
<div className='flex justify-between'>
<div className="font-bold truncate">{lesson.subject}</div>
<span className="truncate opacity-70">{capitalizeFirstLetter(lesson.teacher.code)}</span>
</div>
<div className="flex justify-between">
<span className="truncate max-w-[40px]">{lesson.room}</span>
<span className="truncate opacity-70">{lesson.group}</span>
</div>
</div>
))}
</div>
);
}
const lesson = staticLessons[0];
return (
<div className="w-full min-h-[80px] h-full p-2 border-b flex flex-col justify-between text-xs hover:shadow-md transition-shadow">
<div className="font-bold text-lg text-primary">{lesson.subject}</div>
<div className="flex justify-between items-end mt-1">
<div className="font-mono font-medium">{lesson.room}</div>
<div className="text-[10px] opacity-80" title={lesson.teacher.name}>{capitalizeFirstLetter(lesson.teacher.code)}</div>
</div>
</div>
);
}

View File

@@ -0,0 +1,16 @@
import { Card, CardContent, CardHeader, CardTitle } from "../ui/card";
export default function TakesPlace({string}: {string: string}) {
return (
<Card>
<CardHeader>
<CardTitle>Koná se</CardTitle>
</CardHeader>
<CardContent>
<p className="text-sm text-slate-700 dark:text-slate-300">
{string}
</p>
</CardContent>
</Card>
);
}

View File

@@ -0,0 +1,34 @@
import { AbsenceEntry } from "@/lib/types";
import { Card, CardContent } from "../ui/card";
export function TeacherAbsenceItem({ entry }: { entry: AbsenceEntry }) {
const getTeacherName = (e: AbsenceEntry) => {
if (e.type === 'invalid') return null;
return e.teacher;
};
const teacherName = getTeacherName(entry) || 'Neznámý';
const getTypeDescription = (e: AbsenceEntry) => {
switch (e.type) {
case 'wholeDay': return 'Celý den';
case 'single': return `${e.hours}. hodinu`;
case 'range': return `${e.hours.from}-${e.hours.to} hodinu`;
case 'exkurze': return 'Na exkurzi';
case 'zastoupen': return `Zastoupen (${e.zastupuje.teacher || 'Neznámý'})`;
case 'invalid': return `Neplatný záznam: ${e.original}`;
default: return 'Neznámý';
}
};
return (
<Card>
<CardContent>
<div className="font-bold text-base text-slate-800 dark:text-slate-200">{teacherName}</div>
<div className="text-sm text-slate-500 dark:text-slate-400">
{getTypeDescription(entry)}
</div>
</CardContent>
</Card>
);
}

View File

@@ -0,0 +1,52 @@
"use client";
import { useTransition } from "react";
import { useRouter } from "next/navigation";
import { RefreshCw } from "lucide-react";
import { SubstitutionData } from "@/lib/types";
import { Button } from "@/components/ui/button";
interface UpdateStatusProps {
data: SubstitutionData | null;
}
export default function UpdateStatus({ data }: UpdateStatusProps) {
const router = useRouter();
const [isPending, startTransition] = useTransition();
if (!data) return null;
const handleRefresh = () => {
startTransition(() => {
router.refresh();
});
};
return (
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4 text-sm text-muted-foreground p-4 rounded-lg border">
<div>
<span className="font-medium">Poslední aktualizace:</span> {data.status.lastUpdated}
<span className="mx-2 hidden sm:inline"></span>
<br className="sm:hidden" />
<span>
Aktualizace každých{" "}
{data.status.currentUpdateSchedule < 60
? `${data.status.currentUpdateSchedule} min`
: `${data.status.currentUpdateSchedule / 60} hod`}
</span>
</div>
<Button
variant="outline"
size="sm"
onClick={handleRefresh}
disabled={isPending}
className="w-full sm:w-auto"
>
<RefreshCw
className={`h-4 w-4 mr-2 ${isPending ? "animate-spin" : ""}`}
/>
Aktualizovat
</Button>
</div>
);
}

View File

@@ -0,0 +1,103 @@
"use client";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { useState } from "react";
import { Menu, X, AlertTriangle, Home, List } from "lucide-react";
import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";
export function SiteHeader() {
const [isOpen, setIsOpen] = useState(false);
const pathname = usePathname();
const routes = [
{
href: "/",
label: "Třída",
active: pathname === "/",
icon: Home
},
{
href: "/all",
label: "Vše",
active: pathname === "/all",
icon: List
}
];
return (
<header className="sticky top-0 z-50 w-full border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60">
<div className="flex h-14 items-center px-4 md:px-8">
<Button
variant="ghost"
className="mr-2 px-0 text-base hover:bg-transparent focus-visible:bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 md:hidden"
onClick={() => setIsOpen(!isOpen)}
>
{isOpen ? <X className="h-6 w-6" /> : <Menu className="h-6 w-6" />}
<span className="sr-only">Toggle Menu</span>
</Button>
<div className="mr-4 hidden md:flex items-center">
<Link href="/" className="mr-6 flex items-center space-x-2">
<span className="hidden font-bold sm:inline-block">
Mimořádný rozvrh
</span>
</Link>
<nav className="flex items-center space-x-6 text-sm font-medium">
{routes.map((route) => (
<Link
key={route.href}
href={route.href}
className={cn(
"transition-colors hover:text-foreground/80 flex items-center gap-2",
route.active ? "text-foreground" : "text-foreground/60"
)}
>
<route.icon className="h-4 w-4" />
{route.label}
</Link>
))}
</nav>
</div>
<div className="flex flex-1 items-center justify-between space-x-2 md:justify-end hidden">
<div className="w-full flex-1 md:w-auto md:flex-none">
<span className="font-bold md:hidden">Mimořádný rozvrh</span>
</div>
<nav className="flex items-center">
<Button variant="ghost" size="icon" title="Nahlásit chybu" asChild>
<Link href="https://github.com/jzitnik/tablescraper/issues/new" target="_blank" rel="noreferrer">
<AlertTriangle className="h-5 w-5 text-amber-500" />
<span className="sr-only">Nahlásit chybu</span>
</Link>
</Button>
</nav>
</div>
</div>
{isOpen && (
<div className="md:hidden border-t p-4 space-y-4 bg-background animate-in slide-in-from-top-5">
<nav className="flex flex-col space-y-4">
{routes.map((route) => (
<Link
key={route.href}
href={route.href}
onClick={() => setIsOpen(false)}
className={cn(
"text-sm font-medium transition-colors hover:text-primary p-2 rounded-md hover:bg-muted",
route.active ? "bg-muted text-foreground" : "text-muted-foreground"
)}
>
<div className="flex items-center gap-3">
<route.icon className="h-5 w-5" />
{route.label}
</div>
</Link>
))}
</nav>
</div>
)}
</header>
);
}

View File

@@ -0,0 +1,11 @@
"use client"
import * as React from "react"
import { ThemeProvider as NextThemesProvider } from "next-themes"
export function ThemeProvider({
children,
...props
}: React.ComponentProps<typeof NextThemesProvider>) {
return <NextThemesProvider {...props}>{children}</NextThemesProvider>
}

View File

@@ -0,0 +1,66 @@
import * as React from "react"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "@/lib/utils"
const alertVariants = cva(
"relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",
{
variants: {
variant: {
default: "bg-card text-card-foreground",
destructive:
"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90",
},
},
defaultVariants: {
variant: "default",
},
}
)
function Alert({
className,
variant,
...props
}: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>) {
return (
<div
data-slot="alert"
role="alert"
className={cn(alertVariants({ variant }), className)}
{...props}
/>
)
}
function AlertTitle({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="alert-title"
className={cn(
"col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",
className
)}
{...props}
/>
)
}
function AlertDescription({
className,
...props
}: React.ComponentProps<"div">) {
return (
<div
data-slot="alert-description"
className={cn(
"text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",
className
)}
{...props}
/>
)
}
export { Alert, AlertTitle, AlertDescription }

View File

@@ -0,0 +1,64 @@
import * as React from "react"
import { cva, type VariantProps } from "class-variance-authority"
import { Slot } from "radix-ui"
import { cn } from "@/lib/utils"
const buttonVariants = cva(
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
{
variants: {
variant: {
default: "bg-primary text-primary-foreground hover:bg-primary/90",
destructive:
"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
outline:
"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
secondary:
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
ghost:
"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
link: "text-primary underline-offset-4 hover:underline",
},
size: {
default: "h-9 px-4 py-2 has-[>svg]:px-3",
xs: "h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
icon: "size-9",
"icon-xs": "size-6 rounded-md [&_svg:not([class*='size-'])]:size-3",
"icon-sm": "size-8",
"icon-lg": "size-10",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
}
)
function Button({
className,
variant = "default",
size = "default",
asChild = false,
...props
}: React.ComponentProps<"button"> &
VariantProps<typeof buttonVariants> & {
asChild?: boolean
}) {
const Comp = asChild ? Slot.Root : "button"
return (
<Comp
data-slot="button"
data-variant={variant}
data-size={size}
className={cn(buttonVariants({ variant, size, className }))}
{...props}
/>
)
}
export { Button, buttonVariants }

View File

@@ -0,0 +1,92 @@
import * as React from "react"
import { cn } from "@/lib/utils"
function Card({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card"
className={cn(
"bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",
className
)}
{...props}
/>
)
}
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-header"
className={cn(
"@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
className
)}
{...props}
/>
)
}
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-title"
className={cn("leading-none font-semibold", className)}
{...props}
/>
)
}
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-description"
className={cn("text-muted-foreground text-sm", className)}
{...props}
/>
)
}
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-action"
className={cn(
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
className
)}
{...props}
/>
)
}
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-content"
className={cn("px-6", className)}
{...props}
/>
)
}
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-footer"
className={cn("flex items-center px-6 [.border-t]:pt-6", className)}
{...props}
/>
)
}
export {
Card,
CardHeader,
CardFooter,
CardTitle,
CardAction,
CardDescription,
CardContent,
}

View File

@@ -0,0 +1,158 @@
"use client"
import * as React from "react"
import { XIcon } from "lucide-react"
import { Dialog as DialogPrimitive } from "radix-ui"
import { cn } from "@/lib/utils"
import { Button } from "@/components/ui/button"
function Dialog({
...props
}: React.ComponentProps<typeof DialogPrimitive.Root>) {
return <DialogPrimitive.Root data-slot="dialog" {...props} />
}
function DialogTrigger({
...props
}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
}
function DialogPortal({
...props
}: React.ComponentProps<typeof DialogPrimitive.Portal>) {
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
}
function DialogClose({
...props
}: React.ComponentProps<typeof DialogPrimitive.Close>) {
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
}
function DialogOverlay({
className,
...props
}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
return (
<DialogPrimitive.Overlay
data-slot="dialog-overlay"
className={cn(
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
className
)}
{...props}
/>
)
}
function DialogContent({
className,
children,
showCloseButton = true,
...props
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
showCloseButton?: boolean
}) {
return (
<DialogPortal data-slot="dialog-portal">
<DialogOverlay />
<DialogPrimitive.Content
data-slot="dialog-content"
className={cn(
"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg",
className
)}
{...props}
>
{children}
{showCloseButton && (
<DialogPrimitive.Close
data-slot="dialog-close"
className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
>
<XIcon />
<span className="sr-only">Close</span>
</DialogPrimitive.Close>
)}
</DialogPrimitive.Content>
</DialogPortal>
)
}
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="dialog-header"
className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
{...props}
/>
)
}
function DialogFooter({
className,
showCloseButton = false,
children,
...props
}: React.ComponentProps<"div"> & {
showCloseButton?: boolean
}) {
return (
<div
data-slot="dialog-footer"
className={cn(
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
className
)}
{...props}
>
{children}
{showCloseButton && (
<DialogPrimitive.Close asChild>
<Button variant="outline">Close</Button>
</DialogPrimitive.Close>
)}
</div>
)
}
function DialogTitle({
className,
...props
}: React.ComponentProps<typeof DialogPrimitive.Title>) {
return (
<DialogPrimitive.Title
data-slot="dialog-title"
className={cn("text-lg leading-none font-semibold", className)}
{...props}
/>
)
}
function DialogDescription({
className,
...props
}: React.ComponentProps<typeof DialogPrimitive.Description>) {
return (
<DialogPrimitive.Description
data-slot="dialog-description"
className={cn("text-muted-foreground text-sm", className)}
{...props}
/>
)
}
export {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogOverlay,
DialogPortal,
DialogTitle,
DialogTrigger,
}

View File

@@ -0,0 +1,167 @@
"use client"
import * as React from "react"
import type { Label as LabelPrimitive } from "radix-ui"
import { Slot } from "radix-ui"
import {
Controller,
FormProvider,
useFormContext,
useFormState,
type ControllerProps,
type FieldPath,
type FieldValues,
} from "react-hook-form"
import { cn } from "@/lib/utils"
import { Label } from "@/components/ui/label"
const Form = FormProvider
type FormFieldContextValue<
TFieldValues extends FieldValues = FieldValues,
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
> = {
name: TName
}
const FormFieldContext = React.createContext<FormFieldContextValue>(
{} as FormFieldContextValue
)
const FormField = <
TFieldValues extends FieldValues = FieldValues,
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
>({
...props
}: ControllerProps<TFieldValues, TName>) => {
return (
<FormFieldContext.Provider value={{ name: props.name }}>
<Controller {...props} />
</FormFieldContext.Provider>
)
}
const useFormField = () => {
const fieldContext = React.useContext(FormFieldContext)
const itemContext = React.useContext(FormItemContext)
const { getFieldState } = useFormContext()
const formState = useFormState({ name: fieldContext.name })
const fieldState = getFieldState(fieldContext.name, formState)
if (!fieldContext) {
throw new Error("useFormField should be used within <FormField>")
}
const { id } = itemContext
return {
id,
name: fieldContext.name,
formItemId: `${id}-form-item`,
formDescriptionId: `${id}-form-item-description`,
formMessageId: `${id}-form-item-message`,
...fieldState,
}
}
type FormItemContextValue = {
id: string
}
const FormItemContext = React.createContext<FormItemContextValue>(
{} as FormItemContextValue
)
function FormItem({ className, ...props }: React.ComponentProps<"div">) {
const id = React.useId()
return (
<FormItemContext.Provider value={{ id }}>
<div
data-slot="form-item"
className={cn("grid gap-2", className)}
{...props}
/>
</FormItemContext.Provider>
)
}
function FormLabel({
className,
...props
}: React.ComponentProps<typeof LabelPrimitive.Root>) {
const { error, formItemId } = useFormField()
return (
<Label
data-slot="form-label"
data-error={!!error}
className={cn("data-[error=true]:text-destructive", className)}
htmlFor={formItemId}
{...props}
/>
)
}
function FormControl({ ...props }: React.ComponentProps<typeof Slot.Root>) {
const { error, formItemId, formDescriptionId, formMessageId } = useFormField()
return (
<Slot.Root
data-slot="form-control"
id={formItemId}
aria-describedby={
!error
? `${formDescriptionId}`
: `${formDescriptionId} ${formMessageId}`
}
aria-invalid={!!error}
{...props}
/>
)
}
function FormDescription({ className, ...props }: React.ComponentProps<"p">) {
const { formDescriptionId } = useFormField()
return (
<p
data-slot="form-description"
id={formDescriptionId}
className={cn("text-muted-foreground text-sm", className)}
{...props}
/>
)
}
function FormMessage({ className, ...props }: React.ComponentProps<"p">) {
const { error, formMessageId } = useFormField()
const body = error ? String(error?.message ?? "") : props.children
if (!body) {
return null
}
return (
<p
data-slot="form-message"
id={formMessageId}
className={cn("text-destructive text-sm", className)}
{...props}
>
{body}
</p>
)
}
export {
useFormField,
Form,
FormItem,
FormLabel,
FormControl,
FormDescription,
FormMessage,
FormField,
}

View File

@@ -0,0 +1,21 @@
import * as React from "react"
import { cn } from "@/lib/utils"
function Input({ className, type, ...props }: React.ComponentProps<"input">) {
return (
<input
type={type}
data-slot="input"
className={cn(
"file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
className
)}
{...props}
/>
)
}
export { Input }

View File

@@ -0,0 +1,24 @@
"use client"
import * as React from "react"
import { Label as LabelPrimitive } from "radix-ui"
import { cn } from "@/lib/utils"
function Label({
className,
...props
}: React.ComponentProps<typeof LabelPrimitive.Root>) {
return (
<LabelPrimitive.Root
data-slot="label"
className={cn(
"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
className
)}
{...props}
/>
)
}
export { Label }

View File

@@ -0,0 +1,45 @@
"use client"
import * as React from "react"
import { CircleIcon } from "lucide-react"
import { RadioGroup as RadioGroupPrimitive } from "radix-ui"
import { cn } from "@/lib/utils"
function RadioGroup({
className,
...props
}: React.ComponentProps<typeof RadioGroupPrimitive.Root>) {
return (
<RadioGroupPrimitive.Root
data-slot="radio-group"
className={cn("grid gap-3", className)}
{...props}
/>
)
}
function RadioGroupItem({
className,
...props
}: React.ComponentProps<typeof RadioGroupPrimitive.Item>) {
return (
<RadioGroupPrimitive.Item
data-slot="radio-group-item"
className={cn(
"border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
className
)}
{...props}
>
<RadioGroupPrimitive.Indicator
data-slot="radio-group-indicator"
className="relative flex items-center justify-center"
>
<CircleIcon className="fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2" />
</RadioGroupPrimitive.Indicator>
</RadioGroupPrimitive.Item>
)
}
export { RadioGroup, RadioGroupItem }

View File

@@ -0,0 +1,190 @@
"use client"
import * as React from "react"
import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react"
import { Select as SelectPrimitive } from "radix-ui"
import { cn } from "@/lib/utils"
function Select({
...props
}: React.ComponentProps<typeof SelectPrimitive.Root>) {
return <SelectPrimitive.Root data-slot="select" {...props} />
}
function SelectGroup({
...props
}: React.ComponentProps<typeof SelectPrimitive.Group>) {
return <SelectPrimitive.Group data-slot="select-group" {...props} />
}
function SelectValue({
...props
}: React.ComponentProps<typeof SelectPrimitive.Value>) {
return <SelectPrimitive.Value data-slot="select-value" {...props} />
}
function SelectTrigger({
className,
size = "default",
children,
...props
}: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
size?: "sm" | "default"
}) {
return (
<SelectPrimitive.Trigger
data-slot="select-trigger"
data-size={size}
className={cn(
"border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
className
)}
{...props}
>
{children}
<SelectPrimitive.Icon asChild>
<ChevronDownIcon className="size-4 opacity-50" />
</SelectPrimitive.Icon>
</SelectPrimitive.Trigger>
)
}
function SelectContent({
className,
children,
position = "item-aligned",
align = "center",
...props
}: React.ComponentProps<typeof SelectPrimitive.Content>) {
return (
<SelectPrimitive.Portal>
<SelectPrimitive.Content
data-slot="select-content"
className={cn(
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",
position === "popper" &&
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
className
)}
position={position}
align={align}
{...props}
>
<SelectScrollUpButton />
<SelectPrimitive.Viewport
className={cn(
"p-1",
position === "popper" &&
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"
)}
>
{children}
</SelectPrimitive.Viewport>
<SelectScrollDownButton />
</SelectPrimitive.Content>
</SelectPrimitive.Portal>
)
}
function SelectLabel({
className,
...props
}: React.ComponentProps<typeof SelectPrimitive.Label>) {
return (
<SelectPrimitive.Label
data-slot="select-label"
className={cn("text-muted-foreground px-2 py-1.5 text-xs", className)}
{...props}
/>
)
}
function SelectItem({
className,
children,
...props
}: React.ComponentProps<typeof SelectPrimitive.Item>) {
return (
<SelectPrimitive.Item
data-slot="select-item"
className={cn(
"focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
className
)}
{...props}
>
<span
data-slot="select-item-indicator"
className="absolute right-2 flex size-3.5 items-center justify-center"
>
<SelectPrimitive.ItemIndicator>
<CheckIcon className="size-4" />
</SelectPrimitive.ItemIndicator>
</span>
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
</SelectPrimitive.Item>
)
}
function SelectSeparator({
className,
...props
}: React.ComponentProps<typeof SelectPrimitive.Separator>) {
return (
<SelectPrimitive.Separator
data-slot="select-separator"
className={cn("bg-border pointer-events-none -mx-1 my-1 h-px", className)}
{...props}
/>
)
}
function SelectScrollUpButton({
className,
...props
}: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>) {
return (
<SelectPrimitive.ScrollUpButton
data-slot="select-scroll-up-button"
className={cn(
"flex cursor-default items-center justify-center py-1",
className
)}
{...props}
>
<ChevronUpIcon className="size-4" />
</SelectPrimitive.ScrollUpButton>
)
}
function SelectScrollDownButton({
className,
...props
}: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>) {
return (
<SelectPrimitive.ScrollDownButton
data-slot="select-scroll-down-button"
className={cn(
"flex cursor-default items-center justify-center py-1",
className
)}
{...props}
>
<ChevronDownIcon className="size-4" />
</SelectPrimitive.ScrollDownButton>
)
}
export {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectLabel,
SelectScrollDownButton,
SelectScrollUpButton,
SelectSeparator,
SelectTrigger,
SelectValue,
}

View File

@@ -0,0 +1,40 @@
"use client"
import {
CircleCheckIcon,
InfoIcon,
Loader2Icon,
OctagonXIcon,
TriangleAlertIcon,
} from "lucide-react"
import { useTheme } from "next-themes"
import { Toaster as Sonner, type ToasterProps } from "sonner"
const Toaster = ({ ...props }: ToasterProps) => {
const { theme = "system" } = useTheme()
return (
<Sonner
theme={theme as ToasterProps["theme"]}
className="toaster group"
icons={{
success: <CircleCheckIcon className="size-4" />,
info: <InfoIcon className="size-4" />,
warning: <TriangleAlertIcon className="size-4" />,
error: <OctagonXIcon className="size-4" />,
loading: <Loader2Icon className="size-4 animate-spin" />,
}}
style={
{
"--normal-bg": "var(--popover)",
"--normal-text": "var(--popover-foreground)",
"--normal-border": "var(--border)",
"--border-radius": "var(--radius)",
} as React.CSSProperties
}
{...props}
/>
)
}
export { Toaster }

View File

@@ -0,0 +1,18 @@
import * as React from "react"
import { cn } from "@/lib/utils"
function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
return (
<textarea
data-slot="textarea"
className={cn(
"border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
className
)}
{...props}
/>
)
}
export { Textarea }

18
viewer/eslint.config.mjs Normal file
View File

@@ -0,0 +1,18 @@
import { defineConfig, globalIgnores } from "eslint/config";
import nextVitals from "eslint-config-next/core-web-vitals";
import nextTs from "eslint-config-next/typescript";
const eslintConfig = defineConfig([
...nextVitals,
...nextTs,
// Override default ignores of eslint-config-next.
globalIgnores([
// Default ignores of eslint-config-next:
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
]),
]);
export default eslintConfig;

18
viewer/lib/api.ts Normal file
View File

@@ -0,0 +1,18 @@
import { SubstitutionData } from "./types";
export async function getData(): Promise<SubstitutionData | null> {
const apiUrl = process.env.API_URL || 'http://localhost:3000';
try {
const res = await fetch(`${apiUrl}/versioned/v3`, {
next: { revalidate: 60 },
});
if (!res.ok) {
return null;
}
return res.json();
} catch {
return null;
}
}

49
viewer/lib/types.ts Normal file
View File

@@ -0,0 +1,49 @@
export interface TeacherReference {
name: string;
code: string;
}
export type AbsenceEntry =
| { type: 'wholeDay'; teacher: string; teacherCode: string }
| { type: 'single'; teacher: string; teacherCode: string; hours: string }
| { type: 'range'; teacher: string; teacherCode: string; hours: { from: string; to: string } }
| { type: 'exkurze'; teacher: string; teacherCode: string }
| { type: 'zastoupen'; teacher: string; teacherCode: string; zastupuje: { teacher: string | null } }
| { type: 'invalid'; original: string; teacher?: null; teacherCode?: null };
export interface ChangeEntry {
text: string;
backgroundColor?: string | null;
foregroundColor?: string | null;
}
export interface SubstitutionDayData {
info: { inWork: boolean };
takesPlace: string;
changes: Record<string, (ChangeEntry | null)[]>;
absence: AbsenceEntry[];
}
export interface SubstitutionData {
status: {
currentUpdateSchedule: number;
lastUpdated: string;
}
schedule: Record<string, SubstitutionDayData>;
}
export interface Hour {
subject: string;
title: string;
teacher: {
code: string;
name: string;
}
group?: string;
room: string;
}
export interface LocalData {
class: string;
timetable: Hour[][][];
}

11
viewer/lib/utils.ts Normal file
View File

@@ -0,0 +1,11 @@
import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
export function capitalizeFirstLetter(string: string) {
if (!string) return string;
return string.charAt(0).toUpperCase() + string.slice(1);
}

11
viewer/next.config.ts Normal file
View File

@@ -0,0 +1,11 @@
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
reactCompiler: true,
basePath: '/viewer',
turbopack: {
root: __dirname,
},
};
export default nextConfig;

11843
viewer/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

40
viewer/package.json Normal file
View File

@@ -0,0 +1,40 @@
{
"name": "viewer",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "eslint"
},
"dependencies": {
"@hookform/resolvers": "^5.2.2",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"date-fns": "^4.1.0",
"lucide-react": "^0.563.0",
"next": "16.1.6",
"next-themes": "^0.4.6",
"radix-ui": "^1.4.3",
"react": "19.2.3",
"react-dom": "19.2.3",
"react-hook-form": "^7.71.1",
"sonner": "^2.0.7",
"tailwind-merge": "^3.4.0",
"zod": "^4.3.6"
},
"devDependencies": {
"@tailwindcss/postcss": "^4",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"babel-plugin-react-compiler": "1.0.0",
"eslint": "^9",
"eslint-config-next": "16.1.6",
"shadcn": "^3.8.4",
"tailwindcss": "^4",
"tw-animate-css": "^1.4.0",
"typescript": "^5"
}
}

View File

@@ -0,0 +1,7 @@
const config = {
plugins: {
"@tailwindcss/postcss": {},
},
};
export default config;

1
viewer/public/file.svg Normal file
View File

@@ -0,0 +1 @@
<svg fill="none" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 13.5V5.41a1 1 0 0 0-.3-.7L9.8.29A1 1 0 0 0 9.08 0H1.5v13.5A2.5 2.5 0 0 0 4 16h8a2.5 2.5 0 0 0 2.5-2.5m-1.5 0v-7H8v-5H3v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1M9.5 5V2.12L12.38 5zM5.13 5h-.62v1.25h2.12V5zm-.62 3h7.12v1.25H4.5zm.62 3h-.62v1.25h7.12V11z" clip-rule="evenodd" fill="#666" fill-rule="evenodd"/></svg>

After

Width:  |  Height:  |  Size: 391 B

1
viewer/public/globe.svg Normal file
View File

@@ -0,0 +1 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

1
viewer/public/next.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

1
viewer/public/vercel.svg Normal file
View File

@@ -0,0 +1 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1155 1000"><path d="m577.3 0 577.4 1000H0z" fill="#fff"/></svg>

After

Width:  |  Height:  |  Size: 128 B

1
viewer/public/window.svg Normal file
View File

@@ -0,0 +1 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 2.5h13v10a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1zM0 1h16v11.5a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 12.5zm3.75 4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5M7 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m1.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5" fill="#666"/></svg>

After

Width:  |  Height:  |  Size: 385 B

34
viewer/tsconfig.json Normal file
View File

@@ -0,0 +1,34 @@
{
"compilerOptions": {
"target": "ES2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "react-jsx",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./*"]
}
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
".next/dev/types/**/*.ts",
"**/*.mts"
],
"exclude": ["node_modules"]
}

View File

@@ -0,0 +1,33 @@
---
title: "Získání statického souboru"
date: 2026-02-12
hiddenInHomelist: true
---
Pokud si chcete zobrazit stálý rozvrh zároveň s mimořádným rozvrhem ve webovém rozhraní musíte si získat statický rozvrh. Ten získáte pomocí Node.js scriptu.
## Požadavky
Před začátkem se ujistěte, že máte připravené následující:
- **Účet SPŠE Ječná**: Script vyžaduje platný školní účet a heslo.
- **Node.js 22+**
- **Git**
## Stažení projektu
```bash
git clone https://gitea.jzitnik.dev/jzitnik/jecnarozvrh
```
## Stažení knihoven a spuštění scriptu
```bash
npm i
npm run parse-timetable
```
Script se vás zeptá na username, password a output cestu k souboru.
Script projde všechny učitele a sestaví rozvrh všech tříd podle toho.

View File

@@ -0,0 +1,4 @@
---
title: "Online verze"
date: 2026-02-12
---