Browse Source

add lights in datas

develop
Simon Vieille 3 months ago
parent
commit
5432c0c330
Signed by: deblan GPG Key ID: 03383D15A1D31745
2 changed files with 30 additions and 3 deletions
  1. +8
    -1
      src/Controller/MonitoringController.php
  2. +22
    -2
      templates/datas.html.twig

+ 8
- 1
src/Controller/MonitoringController.php View File

@ -9,6 +9,7 @@ use App\Motion\SnapshotRepository;
use Symfony\Component\HttpFoundation\Response;
use App\Repository\TemperatureRepository;
use App\Repository\HygrometryRepository;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class MonitoringController extends AbstractController
{
@ -23,7 +24,11 @@ class MonitoringController extends AbstractController
/**
* @Route("/datas", name="datas")
*/
public function datas(TemperatureRepository $temperatureRepository, HygrometryRepository $hygrometryRepository): Response
public function datas(
TemperatureRepository $temperatureRepository,
HygrometryRepository $hygrometryRepository,
ParameterBagInterface $params
): Response
{
$from = new \DateTime('now - 1 day');
$to = new \DateTime('now');
@ -31,6 +36,8 @@ class MonitoringController extends AbstractController
return $this->render('datas.html.twig', [
'temperatures' => $temperatureRepository->findByDateRange($from, $to, 100, 'DESC'),
'hygrometries' => $hygrometryRepository->findByDateRange($from, $to, 100, 'DESC'),
'lightOnAt' => (int) $params->get('light_on_at'),
'lightOffAt' => (int) $params->get('light_off_at'),
]);
}
}

+ 22
- 2
templates/datas.html.twig View File

@ -29,7 +29,17 @@
{% endif %}
<tr class="{{ class }}">
<td>{{ item.date.format('d/m H:i') }}</td>
<td>
{% set lightTime = item.date.format('Gi') %}
{% if lightTime >= lightOnAt and lightTime <= lightOffAt %}
🌕
{% else %}
🌑
{% endif %}
{{ item.date.format('d/m H:i') }}
</td>
<td>{{ item.value|number_format(2, ',', '') }}°</td>
</tr>
{% endfor %}
@ -64,7 +74,17 @@
{% endif %}
<tr class="{{ class }}">
<td>{{ item.date.format('d/m H:i') }}</td>
<td>
{% set lightTime = item.date.format('Gi') %}
{% if lightTime >= lightOnAt and lightTime <= lightOffAt %}
🌕
{% else %}
🌑
{% endif %}
{{ item.date.format('d/m H:i') }}
</td>
<td>{{ item.value|number_format(2, ',', '') }}%</td>
</tr>
{% endfor %}


Loading…
Cancel
Save