diff --git a/.env b/.env index 04166ae..377924c 100644 --- a/.env +++ b/.env @@ -31,3 +31,5 @@ APP_SECRET=f040dfea5e5e9d096302582577d2e3c8 # IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7 ###< doctrine/doctrine-bundle ### + +CAMERA1_URL=https://terrarium/camera diff --git a/config/services.yaml b/config/services.yaml index 78fa0d9..9feb84c 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -5,6 +5,7 @@ # https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration parameters: motion_snapshots_directory: "motion/snapshots" + camera1_url: "%env(CAMERA1_URL)%" services: # default configuration for services in *this* file diff --git a/src/Controller/CameraController.php b/src/Controller/CameraController.php index 7a54ed3..da8cfa9 100644 --- a/src/Controller/CameraController.php +++ b/src/Controller/CameraController.php @@ -6,14 +6,18 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Filesystem\Filesystem; use App\Motion\SnapshotRepository; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; +use Symfony\Component\HttpFoundation\Response; class CameraController extends AbstractController { /** * @Route("/camera", name="camera") */ - public function camera() + public function camera(ParameterBagInterface $params): Response { - return $this->render('camera.html.twig'); + return $this->render('camera.html.twig', [ + 'camera1_url' => $params->get('camera1_url'), + ]); } } diff --git a/src/Controller/EventController.php b/src/Controller/EventController.php index 5eb222a..b933142 100644 --- a/src/Controller/EventController.php +++ b/src/Controller/EventController.php @@ -8,13 +8,14 @@ use Symfony\Component\Filesystem\Filesystem; use App\Motion\SnapshotRepository; use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; class EventController extends AbstractController { /** * @Route("/events/{date}", name="events") */ - public function events(SnapshotRepository $snapshotRepository, string $date = null) + public function events(SnapshotRepository $snapshotRepository, string $date = null): Response { $date = $date ?? date('Y-m-d'); diff --git a/src/Controller/HygrometryApiController.php b/src/Controller/HygrometryApiController.php index 7dea0ef..40d4c82 100644 --- a/src/Controller/HygrometryApiController.php +++ b/src/Controller/HygrometryApiController.php @@ -8,13 +8,14 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Request; use App\Validator\ApiValidator; use App\Entity\Hygrometry; +use Symfony\Component\HttpFoundation\JsonResponse; class HygrometryApiController extends AbstractController { /** * @Route("/api/hygrometry/create", name="api_hygrometry_create", methods={"POST"}) */ - public function create(Request $request, ApiValidator $validator, \Swift_Mailer $mailer): Response + public function create(Request $request, ApiValidator $validator, \Swift_Mailer $mailer): JsonResponse { if ('application/json' === $request->getContentType()) { return $this->json([], 400); diff --git a/src/Controller/MonitoringApiController.php b/src/Controller/MonitoringApiController.php index 9943a1f..ce99a97 100644 --- a/src/Controller/MonitoringApiController.php +++ b/src/Controller/MonitoringApiController.php @@ -14,7 +14,7 @@ class MonitoringApiController extends AbstractController /** * @Route("/api/monitoring/temperature", name="api_monitoring_temperature", methods={"GET"}) */ - public function temperature(Request $request, TemperatureRepository $repository) + public function temperature(Request $request, TemperatureRepository $repository): JsonResponse { $labels = []; $datasets = []; @@ -59,7 +59,7 @@ class MonitoringApiController extends AbstractController /** * @Route("/api/monitoring/hygrometry", name="api_monitoring_hygrometry", methods={"GET"}) */ - public function hygrometry(Request $request, HygrometryRepository $repository) + public function hygrometry(Request $request, HygrometryRepository $repository): JsonResponse { $labels = []; $datasets = []; diff --git a/src/Controller/MonitoringController.php b/src/Controller/MonitoringController.php index 0acd845..4415932 100644 --- a/src/Controller/MonitoringController.php +++ b/src/Controller/MonitoringController.php @@ -6,13 +6,14 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Filesystem\Filesystem; use App\Motion\SnapshotRepository; +use Symfony\Component\HttpFoundation\Response; class MonitoringController extends AbstractController { /** * @Route("/", name="charts") */ - public function charts() + public function charts(): Response { return $this->render('charts.html.twig'); } diff --git a/src/Controller/MotionApiController.php b/src/Controller/MotionApiController.php deleted file mode 100644 index b696132..0000000 --- a/src/Controller/MotionApiController.php +++ /dev/null @@ -1,20 +0,0 @@ -getContentType()) { return $this->json([], 400); diff --git a/templates/camera.html.twig b/templates/camera.html.twig index 1fcbb0e..12d67e1 100644 --- a/templates/camera.html.twig +++ b/templates/camera.html.twig @@ -5,7 +5,7 @@ {% block body %}
- Caméra 1 + Caméra 1
{% endblock %}