add lights in datas
This commit is contained in:
parent
b502120716
commit
5432c0c330
|
@ -9,6 +9,7 @@ use App\Motion\SnapshotRepository;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use App\Repository\TemperatureRepository;
|
use App\Repository\TemperatureRepository;
|
||||||
use App\Repository\HygrometryRepository;
|
use App\Repository\HygrometryRepository;
|
||||||
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||||
|
|
||||||
class MonitoringController extends AbstractController
|
class MonitoringController extends AbstractController
|
||||||
{
|
{
|
||||||
|
@ -23,7 +24,11 @@ class MonitoringController extends AbstractController
|
||||||
/**
|
/**
|
||||||
* @Route("/datas", name="datas")
|
* @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');
|
$from = new \DateTime('now - 1 day');
|
||||||
$to = new \DateTime('now');
|
$to = new \DateTime('now');
|
||||||
|
@ -31,6 +36,8 @@ class MonitoringController extends AbstractController
|
||||||
return $this->render('datas.html.twig', [
|
return $this->render('datas.html.twig', [
|
||||||
'temperatures' => $temperatureRepository->findByDateRange($from, $to, 100, 'DESC'),
|
'temperatures' => $temperatureRepository->findByDateRange($from, $to, 100, 'DESC'),
|
||||||
'hygrometries' => $hygrometryRepository->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'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,17 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<tr class="{{ class }}">
|
<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>
|
<td>{{ item.value|number_format(2, ',', '') }}°</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -64,7 +74,17 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<tr class="{{ class }}">
|
<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>
|
<td>{{ item.value|number_format(2, ',', '') }}%</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
Loading…
Reference in New Issue