From 749ca32489a2bfb4a601cb0fb3e4187dd6c50ea4 Mon Sep 17 00:00:00 2001 From: Joren de Graaf Date: Tue, 25 Aug 2026 11:25:55 +0200 Subject: [PATCH] ui touch ups --- assets/styles/app.scss | 34 ++++++++++++-- src/Controller/TaskController.php | 24 ++++++++-- src/Service/WeatherEvaluator.php | 29 ++++++++++-- templates/task/_task_composer.html.twig | 30 +++++++------ templates/task/index.html.twig | 60 ++++++++++++++----------- 5 files changed, 130 insertions(+), 47 deletions(-) diff --git a/assets/styles/app.scss b/assets/styles/app.scss index 9485958..d77e683 100644 --- a/assets/styles/app.scss +++ b/assets/styles/app.scss @@ -56,12 +56,13 @@ header { display: flex; gap: 10px; } + .day-picker { display: flex; align-items: center; justify-content: center; gap: 1rem; - margin-bottom: 1.5rem; + margin-bottom: 0; color: #fff; text-align: center; } @@ -184,11 +185,12 @@ header { .weather-forecast { font-size: 2em; - margin-bottom: 50px; + // margin-bottom: 50px; color: #fff; display: flex; gap: 10px; - > span { + + >span { line-height: 2; font-size: 25px; } @@ -199,9 +201,11 @@ header { border-radius: 10px; margin-bottom: 50px; flex-direction: column; + &__submit { display: flex; } + form.task-composer__form { width: 100%; max-width: unset; @@ -217,9 +221,22 @@ header { &__main { width: 100%; } + &__heading { + padding: 25px; + h2 { + font-size: 2em; + font-weight: bold; + } + } + &__row { + display: flex; + gap: 10px; + width: 100%; + } &__details { display: flex; + flex-direction: column; gap: 25px; input[type=checkbox] { @@ -288,6 +305,13 @@ header { flex: 1; align-items: center; gap: .75rem; + color: #000; + a.task-list__title:focus, + a.task-list__title:active, + a.task-list__title:visited + { + color: inherit; + } } .task-list__checkbox, @@ -512,4 +536,8 @@ header { opacity: 1; } +} +.weather-refresh { + box-shadow: unset; + border: unset; } \ No newline at end of file diff --git a/src/Controller/TaskController.php b/src/Controller/TaskController.php index e2311d3..8ac571a 100644 --- a/src/Controller/TaskController.php +++ b/src/Controller/TaskController.php @@ -14,6 +14,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; +use Symfony\Component\Process\Process; #[Route('/task')] final class TaskController extends AbstractController @@ -116,7 +117,7 @@ final class TaskController extends AbstractController #[Route('/{id}/completion', name: 'app_task_toggle_completion', methods: ['POST'])] public function toggleCompletion(Request $request, Task $task, EntityManagerInterface $entityManager, TaskRepository $taskRepository, TaskRecommendationService $taskRecommendationService): Response { - if (!$this->isCsrfTokenValid('completion'.$task->getId(), $request->getPayload()->getString('_token'))) { + if (!$this->isCsrfTokenValid('completion' . $task->getId(), $request->getPayload()->getString('_token'))) { throw $this->createAccessDeniedException('Invalid CSRF token.'); } @@ -134,7 +135,7 @@ final class TaskController extends AbstractController #[Route('/{id}', name: 'app_task_delete', methods: ['POST'])] public function delete(Request $request, Task $task, EntityManagerInterface $entityManager): Response { - if ($this->isCsrfTokenValid('delete'.$task->getId(), $request->getPayload()->getString('_token'))) { + if ($this->isCsrfTokenValid('delete' . $task->getId(), $request->getPayload()->getString('_token'))) { $entityManager->remove($task); $entityManager->flush(); } @@ -183,6 +184,23 @@ final class TaskController extends AbstractController return $user instanceof User ? $user->getSettings() : null; } + #[Route('/task/refresh/weather', name: 'weather_refresh', methods: ['POST'])] + public function refresh(): Response + { + $process = new Process([ + 'frankenphp', + 'php-cli', + $this->getParameter('kernel.project_dir') . '/bin/console', + 'app:weather:refresh', + ]); + $process->run(); + + if (!$process->isSuccessful()) { + throw new \RuntimeException($process->getErrorOutput()); + } + + return $this->redirectToRoute('app_task_index'); } - +} + diff --git a/src/Service/WeatherEvaluator.php b/src/Service/WeatherEvaluator.php index 1256af4..519e4b6 100644 --- a/src/Service/WeatherEvaluator.php +++ b/src/Service/WeatherEvaluator.php @@ -7,8 +7,16 @@ use App\Entity\WeatherForecast; final class WeatherEvaluator { + /** + * Summary of scoreAdjustment + * @param Task $task + * @param mixed $forecast + * @param mixed $previousDay + * @return int + */ public function scoreAdjustment(Task $task, ?WeatherForecast $forecast, ?WeatherForecast $previousDay = null): int { + if (!$task->isOutdoor() || null === $forecast) { return 0; } @@ -27,7 +35,11 @@ final class WeatherEvaluator return $this->isWet($forecast) ? -45 : 0; } - + /** + * Summary of isWet + * @param mixed $forecast + * @return bool + */ public function isWet(?WeatherForecast $forecast): bool { return null !== $forecast @@ -35,12 +47,23 @@ final class WeatherEvaluator || ($forecast->getPrecipitationSum() ?? 0) >= 1.0 || ($forecast->getRainSum() ?? 0) >= 1.0); } - + /** + * Summary of isDryForecast + * @param mixed $forecast + * @return bool + */ public function isDryForecast(?WeatherForecast $forecast): bool { return null !== $forecast && !$this->isWet($forecast); } - + /** + * Summary of shouldCarryForward + * @param Task $task + * @param \DateTimeImmutable $selectedDay + * @param mixed $previousDay + * @param mixed $currentDay + * @return bool + */ public function shouldCarryForward(Task $task, \DateTimeImmutable $selectedDay, ?WeatherForecast $previousDay, ?WeatherForecast $currentDay): bool { return $task->isOutdoor() diff --git a/templates/task/_task_composer.html.twig b/templates/task/_task_composer.html.twig index 3aef60a..b1c5fed 100644 --- a/templates/task/_task_composer.html.twig +++ b/templates/task/_task_composer.html.twig @@ -20,19 +20,23 @@ {{ form_errors(form.title) }}
-
{{ form_row(form.estimatedDurationMinutes) }}
-
{{ form_row(form.priority) }}
-
{{ form_row(form.category) }}
-
{{ form_row(form.scheduledFor) }}
-
{{ form_row(form.isOutdoor) }}
-
{{ form_row(form.weatherProfile) }}
-
- {{ form_widget(form.isRecurring, {attr: {class: 'task-composer__repeat-input'}}) }} - {{ form_label(form.isRecurring) }} - {{ form_errors(form.isRecurring) }} -
-
{{ form_row(form.recurrenceInterval) }}
-
{{ form_row(form.recurrenceUnit) }}
+
+
{{ form_row(form.estimatedDurationMinutes) }}
+
{{ form_row(form.priority) }}
+
{{ form_row(form.category) }}
+
+
+
{{ form_row(form.scheduledFor) }}
+
{{ form_row(form.isOutdoor) }}
+
{{ form_row(form.weatherProfile) }}
+
+ {{ form_widget(form.isRecurring, {attr: {class: 'task-composer__repeat-input'}}) }} + {{ form_label(form.isRecurring) }} + {{ form_errors(form.isRecurring) }} +
+
{{ form_row(form.recurrenceInterval) }}
+
{{ form_row(form.recurrenceUnit) }}
+
diff --git a/templates/task/index.html.twig b/templates/task/index.html.twig index a986ab8..09d73f8 100644 --- a/templates/task/index.html.twig +++ b/templates/task/index.html.twig @@ -1,38 +1,48 @@ {% extends 'base.html.twig' %} -{% block title %}Tasks{% endblock %} +{% block title %}Tasks +{% endblock %} {% block body %}
-

Tasks

+ - + {#

#} + {% if weather_forecast %} + {{ include('task/_weather_forecast.html.twig', {forecast: weather_forecast}) }} + {% endif %} + + +
+ +
- - -

- {% if weather_forecast %} - {{ include('task/_weather_forecast.html.twig', {forecast: weather_forecast}) }} - {% endif %} +

Tasks

{{ include('task/_task_composer.html.twig', {form: form}) }} {{ include('task/_task_recommendations.html.twig', {