diff --git a/.gitignore b/.gitignore index 68bd285..f8b367e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ vendor/ node_modules/ data/*.json -.direnv/ \ No newline at end of file +.direnv/ +cypress/screenshots/ +cypress/videos/ \ No newline at end of file diff --git a/app/View/ViewController.php b/app/View/ViewController.php index 4fd8d84..efe322b 100644 --- a/app/View/ViewController.php +++ b/app/View/ViewController.php @@ -38,6 +38,16 @@ class ViewController return $response; } + public function today(Response $response): Response + { + $html = file_get_contents( + __DIR__ . '/../../views/templates/today.php' + ); + $response->getBody()->write($html); + + return $response; + } + public function login(Response $response): Response { $html = file_get_contents( diff --git a/bootstrap/app.php b/bootstrap/app.php index c05dc0f..c2150e0 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -27,6 +27,7 @@ $app->post('/api/auth/register', [AuthController::class, 'register']); // Authenticated routes (any logged-in user) $app->group('', function (RouteCollectorProxy $group) { $group->get('/home', [ViewController::class, 'home']); + $group->get('/today', [ViewController::class, 'today']); $group->post('/api/auth/logout', [AuthController::class, 'logout']); $group->get('/api/auth/me', [AuthController::class, 'me']); diff --git a/public/js/today.js b/public/js/today.js new file mode 100644 index 0000000..6f14627 --- /dev/null +++ b/public/js/today.js @@ -0,0 +1,33 @@ +document.addEventListener('DOMContentLoaded', () => { + const scheduledNodesList = document.getElementById( + 'scheduled-nodes-list' + ); + + function todayDateString() { + const today = new Date(); + const year = today.getFullYear(); + const month = String(today.getMonth() + 1).padStart(2, '0'); + const day = String(today.getDate()).padStart(2, '0'); + return year + '-' + month + '-' + day; + } + + async function loadScheduledNodes() { + const date = todayDateString(); + const response = await fetch( + '/api/scheduled-nodes?date=' + date, + { credentials: 'same-origin' } + ); + if (!response.ok) { + return; + } + const scheduledNodes = await response.json(); + scheduledNodesList.innerHTML = scheduledNodes + .map((scheduledNode) => + '