2020-03-10 09:36:21 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Controller;
|
|
|
|
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
|
|
use Symfony\Component\Routing\Annotation\Route;
|
2020-03-10 12:02:21 +01:00
|
|
|
use Symfony\Component\Filesystem\Filesystem;
|
|
|
|
use App\Motion\SnapshotRepository;
|
2020-03-24 23:47:46 +01:00
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
2020-04-23 14:46:39 +02:00
|
|
|
use App\Repository\TemperatureRepository;
|
|
|
|
use App\Repository\HygrometryRepository;
|
2020-11-29 17:27:14 +01:00
|
|
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
2020-03-10 09:36:21 +01:00
|
|
|
|
|
|
|
class MonitoringController extends AbstractController
|
|
|
|
{
|
|
|
|
/**
|
2020-03-10 10:42:04 +01:00
|
|
|
* @Route("/", name="charts")
|
2020-03-10 09:36:21 +01:00
|
|
|
*/
|
2020-03-24 23:47:46 +01:00
|
|
|
public function charts(): Response
|
2020-03-10 09:36:21 +01:00
|
|
|
{
|
2020-03-10 10:42:04 +01:00
|
|
|
return $this->render('charts.html.twig');
|
|
|
|
}
|
2020-04-23 14:46:39 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @Route("/datas", name="datas")
|
|
|
|
*/
|
2020-11-29 17:27:14 +01:00
|
|
|
public function datas(
|
|
|
|
TemperatureRepository $temperatureRepository,
|
|
|
|
HygrometryRepository $hygrometryRepository,
|
|
|
|
ParameterBagInterface $params
|
|
|
|
): Response
|
2020-04-23 14:46:39 +02:00
|
|
|
{
|
|
|
|
$from = new \DateTime('now - 1 day');
|
|
|
|
$to = new \DateTime('now');
|
|
|
|
|
|
|
|
return $this->render('datas.html.twig', [
|
2020-04-23 15:04:47 +02:00
|
|
|
'temperatures' => $temperatureRepository->findByDateRange($from, $to, 100, 'DESC'),
|
|
|
|
'hygrometries' => $hygrometryRepository->findByDateRange($from, $to, 100, 'DESC'),
|
2020-11-29 17:27:14 +01:00
|
|
|
'lightOnAt' => (int) $params->get('light_on_at'),
|
|
|
|
'lightOffAt' => (int) $params->get('light_off_at'),
|
2020-04-23 14:46:39 +02:00
|
|
|
]);
|
|
|
|
}
|
2020-03-10 09:36:21 +01:00
|
|
|
}
|