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) }}