clean code and add PSR compliance
This commit is contained in:
parent
d9b9612fc0
commit
aa9c2422ae
2
.env
2
.env
|
@ -31,3 +31,5 @@ APP_SECRET=f040dfea5e5e9d096302582577d2e3c8
|
||||||
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
|
# 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
|
DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7
|
||||||
###< doctrine/doctrine-bundle ###
|
###< doctrine/doctrine-bundle ###
|
||||||
|
|
||||||
|
CAMERA1_URL=https://terrarium/camera
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
|
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
|
||||||
parameters:
|
parameters:
|
||||||
motion_snapshots_directory: "motion/snapshots"
|
motion_snapshots_directory: "motion/snapshots"
|
||||||
|
camera1_url: "%env(CAMERA1_URL)%"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# default configuration for services in *this* file
|
# default configuration for services in *this* file
|
||||||
|
|
|
@ -6,14 +6,18 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
use App\Motion\SnapshotRepository;
|
use App\Motion\SnapshotRepository;
|
||||||
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
class CameraController extends AbstractController
|
class CameraController extends AbstractController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @Route("/camera", name="camera")
|
* @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'),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,14 @@ use Symfony\Component\Filesystem\Filesystem;
|
||||||
use App\Motion\SnapshotRepository;
|
use App\Motion\SnapshotRepository;
|
||||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
class EventController extends AbstractController
|
class EventController extends AbstractController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @Route("/events/{date}", name="events")
|
* @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');
|
$date = $date ?? date('Y-m-d');
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,14 @@ use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use App\Validator\ApiValidator;
|
use App\Validator\ApiValidator;
|
||||||
use App\Entity\Hygrometry;
|
use App\Entity\Hygrometry;
|
||||||
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
|
||||||
class HygrometryApiController extends AbstractController
|
class HygrometryApiController extends AbstractController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @Route("/api/hygrometry/create", name="api_hygrometry_create", methods={"POST"})
|
* @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()) {
|
if ('application/json' === $request->getContentType()) {
|
||||||
return $this->json([], 400);
|
return $this->json([], 400);
|
||||||
|
|
|
@ -14,7 +14,7 @@ class MonitoringApiController extends AbstractController
|
||||||
/**
|
/**
|
||||||
* @Route("/api/monitoring/temperature", name="api_monitoring_temperature", methods={"GET"})
|
* @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 = [];
|
$labels = [];
|
||||||
$datasets = [];
|
$datasets = [];
|
||||||
|
@ -59,7 +59,7 @@ class MonitoringApiController extends AbstractController
|
||||||
/**
|
/**
|
||||||
* @Route("/api/monitoring/hygrometry", name="api_monitoring_hygrometry", methods={"GET"})
|
* @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 = [];
|
$labels = [];
|
||||||
$datasets = [];
|
$datasets = [];
|
||||||
|
|
|
@ -6,13 +6,14 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
use App\Motion\SnapshotRepository;
|
use App\Motion\SnapshotRepository;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
class MonitoringController extends AbstractController
|
class MonitoringController extends AbstractController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @Route("/", name="charts")
|
* @Route("/", name="charts")
|
||||||
*/
|
*/
|
||||||
public function charts()
|
public function charts(): Response
|
||||||
{
|
{
|
||||||
return $this->render('charts.html.twig');
|
return $this->render('charts.html.twig');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Controller;
|
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
|
|
||||||
class MotionApiController extends AbstractController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @Route("/api/motion/hook", name="api_motion_hook")
|
|
||||||
*/
|
|
||||||
public function hook(Request $request): Response
|
|
||||||
{
|
|
||||||
return new Response();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -8,13 +8,14 @@ use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use App\Validator\ApiValidator;
|
use App\Validator\ApiValidator;
|
||||||
use App\Entity\Temperature;
|
use App\Entity\Temperature;
|
||||||
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
|
||||||
class TemperatureApiController extends AbstractController
|
class TemperatureApiController extends AbstractController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @Route("/api/temperature/create", name="api_temperature_create", methods={"POST"})
|
* @Route("/api/temperature/create", name="api_temperature_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()) {
|
if ('application/json' === $request->getContentType()) {
|
||||||
return $this->json([], 400);
|
return $this->json([], 400);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="camera-wrapper">
|
<div class="camera-wrapper">
|
||||||
<img src="https://api:WFVbTdZbad1EGC3vtwazECVqVzaD@terrarium-proxy.deblan.fr/proxy/camera1" class="box camera" alt="Caméra 1">
|
<img src="{{ camera1_url }}" class="box camera" alt="Caméra 1">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in a new issue