Projekt

Obecné

Profil

Stáhnout (1.46 KB) Statistiky
| Větev: | Revize:
1
<?php
2

    
3
namespace App\Controller;
4

    
5
use App\Entity\DataSet;
6
use App\Form\Type\DataSetType;
7
use App\OpenData\IOpenDataManager;
8
use Symfony\Component\HttpFoundation\Request;
9
use Symfony\Component\Routing\Annotation\Route;
10
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
11

    
12
class HeatmapController extends AbstractController {
13
    /**
14
     * @Route("/heatmap", name="heatmap")
15
     */
16
    public function index(Request $request) {
17
        $dataSet = new DataSet();
18

    
19
        $form = $this->createForm(DataSetType::class, $dataSet);
20
        $form->handleRequest($request);
21

    
22
        // Todo validation
23
        // $form->isValid()
24
        $dataSet = $form->getData();
25
        if ($form->isSubmitted()) {
26
            $dataSet = $form->getData();
27
        }
28

    
29
        return $this->render(
30
            'heatmap.html.twig',
31
            [
32
                'form' => $form->createView(),
33
                'data_to_display' => $dataSet,
34
            ]
35
        );
36
    }
37

    
38
    /**
39
     * @Route("heatmap/opendata/{name}/{date}/{time}", name="opendata")
40
     */
41
    public function opendata(IOpenDataManager $manager, $name = 'NONE', $date = '01012020', $time = '1') {
42
        return $this->json($manager->getCollectionDataByName($name, $date, $time));
43
    }
44

    
45
    /**
46
     * @Route("heatmap/available/{date}", name="available")
47
     */
48
    public function availableDatasets(IOpenDataManager $manager, $date = '01012020') {
49
        return $this->json($manager->getAvailableCollectionsByDay($date));
50
    }
51
}
(2-2/3)