ui touch ups
This commit is contained in:
+31
-3
@@ -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;
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -20,19 +20,23 @@
|
||||
{{ form_errors(form.title) }}
|
||||
</div>
|
||||
<div class="task-composer__details">
|
||||
<div>{{ form_row(form.estimatedDurationMinutes) }}</div>
|
||||
<div>{{ form_row(form.priority) }}</div>
|
||||
<div>{{ form_row(form.category) }}</div>
|
||||
<div>{{ form_row(form.scheduledFor) }}</div>
|
||||
<div>{{ form_row(form.isOutdoor) }}</div>
|
||||
<div>{{ form_row(form.weatherProfile) }}</div>
|
||||
<div class="task-composer__repeat">
|
||||
{{ form_widget(form.isRecurring, {attr: {class: 'task-composer__repeat-input'}}) }}
|
||||
{{ form_label(form.isRecurring) }}
|
||||
{{ form_errors(form.isRecurring) }}
|
||||
<div class="task-composer__repeat-fields">
|
||||
<div>{{ form_row(form.recurrenceInterval) }}</div>
|
||||
<div>{{ form_row(form.recurrenceUnit) }}</div>
|
||||
<div class="task-composer__row">
|
||||
<div>{{ form_row(form.estimatedDurationMinutes) }}</div>
|
||||
<div>{{ form_row(form.priority) }}</div>
|
||||
<div>{{ form_row(form.category) }}</div>
|
||||
</div>
|
||||
<div class="task-composer__row">
|
||||
<div>{{ form_row(form.scheduledFor) }}</div>
|
||||
<div>{{ form_row(form.isOutdoor) }}</div>
|
||||
<div>{{ form_row(form.weatherProfile) }}</div>
|
||||
<div class="task-composer__repeat">
|
||||
{{ form_widget(form.isRecurring, {attr: {class: 'task-composer__repeat-input'}}) }}
|
||||
{{ form_label(form.isRecurring) }}
|
||||
{{ form_errors(form.isRecurring) }}
|
||||
<div class="task-composer__repeat-fields">
|
||||
<div>{{ form_row(form.recurrenceInterval) }}</div>
|
||||
<div>{{ form_row(form.recurrenceUnit) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,38 +1,48 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Tasks{% endblock %}
|
||||
{% block title %}Tasks
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<div class="container">
|
||||
<div class="task-list-header">
|
||||
<h1>Tasks</h1>
|
||||
<button class="weather-location" type="button" data-weather-location data-location-url="{{ path('app_task_location') }}" data-location-token="{{ csrf_token('weather_location') }}">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">my_location</span>
|
||||
{{ has_saved_location ? 'Update weather location' : 'Use my location for weather' }}
|
||||
</button>
|
||||
|
||||
<nav class="day-picker" aria-label="Choose task day">
|
||||
<a href="{{ path('app_task_index', {date: selected_date|date_modify('-1 day')|date('Y-m-d')}) }}" aria-label="Previous day"><span class="material-symbols-outlined">
|
||||
chevron_backward
|
||||
</span></a>
|
||||
<div>
|
||||
<strong>{{ selected_date|date('l, j F') }}</strong>
|
||||
{% if selected_date|date('Y-m-d') != 'now'|date('Y-m-d') %}
|
||||
<a href="{{ path('app_task_index') }}">Today</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<a href="{{ path('app_task_index', {date: selected_date|date_modify('+1 day')|date('Y-m-d')}) }}" aria-label="Next day"><span class="material-symbols-outlined">
|
||||
chevron_forward
|
||||
</span></a>
|
||||
</nav>
|
||||
{# <p class="weather-location__status" data-weather-location-status aria-live="polite"></p> #}
|
||||
{% if weather_forecast %}
|
||||
{{ include('task/_weather_forecast.html.twig', {forecast: weather_forecast}) }}
|
||||
{% endif %}
|
||||
|
||||
<nav class="day-picker" aria-label="Choose task day">
|
||||
<a href="{{ path('app_task_index', {date: selected_date|date_modify('-1 day')|date('Y-m-d')}) }}" aria-label="Previous day">
|
||||
<span class="material-symbols-outlined">
|
||||
chevron_backward
|
||||
</span>
|
||||
</a>
|
||||
<div>
|
||||
<strong>{{ selected_date|date('l, j F') }}</strong>
|
||||
{% if selected_date|date('Y-m-d') != 'now'|date('Y-m-d') %}
|
||||
<a href="{{ path('app_task_index') }}">Today</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<a href="{{ path('app_task_index', {date: selected_date|date_modify('+1 day')|date('Y-m-d')}) }}" aria-label="Next day">
|
||||
<span class="material-symbols-outlined">
|
||||
chevron_forward
|
||||
</span>
|
||||
</a>
|
||||
</nav>
|
||||
<form method="post" action="{{ path('weather_refresh') }}" class="weather-refresh">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Update weather
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<button class="weather-location" type="button" data-weather-location data-location-url="{{ path('app_task_location') }}" data-location-token="{{ csrf_token('weather_location') }}">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">my_location</span>
|
||||
{{ has_saved_location ? 'Update weather location' : 'Use my location for weather' }}
|
||||
</button>
|
||||
|
||||
<p class="weather-location__status" data-weather-location-status aria-live="polite"></p>
|
||||
{% if weather_forecast %}
|
||||
{{ include('task/_weather_forecast.html.twig', {forecast: weather_forecast}) }}
|
||||
{% endif %}
|
||||
<h1>Tasks</h1>
|
||||
{{ include('task/_task_composer.html.twig', {form: form}) }}
|
||||
|
||||
{{ include('task/_task_recommendations.html.twig', {
|
||||
|
||||
Reference in New Issue
Block a user