diff options
| -rw-r--r-- | app/Resources/views/default/AllDataPage.html.twig | 25 | ||||
| -rw-r--r-- | app/Resources/views/default/index.html.twig | 1 | ||||
| -rw-r--r-- | app/config/parameters.yml | 18 | ||||
| -rw-r--r-- | src/AppBundle/Controller/AllDataController.php | 38 | 
4 files changed, 69 insertions, 13 deletions
| diff --git a/app/Resources/views/default/AllDataPage.html.twig b/app/Resources/views/default/AllDataPage.html.twig new file mode 100644 index 0000000..7851afb --- /dev/null +++ b/app/Resources/views/default/AllDataPage.html.twig @@ -0,0 +1,25 @@ +<!DOCTYPE html> +<html lang="en"> +<head> +    <meta charset="UTF-8"> +    <title>Title</title> +</head> +<body> +<table> +    <tr> +        <th>TimeStamp</th> +        <th>Co</th> +        <th>No</th> +        <th>So</th> +    </tr> +    <tr> +        {% for table in data %} +        <td>{{ table.TimeStamp }}</td> +        <td>{{ table.Co }}</td> +        <td>{{ table.No }}</td> +        <td>{{ table.So }}</td> +    </tr> +    {% endfor %} +</table> +</body> +</html>
\ No newline at end of file diff --git a/app/Resources/views/default/index.html.twig b/app/Resources/views/default/index.html.twig index 2fc12a2..684393d 100644 --- a/app/Resources/views/default/index.html.twig +++ b/app/Resources/views/default/index.html.twig @@ -17,6 +17,7 @@              </tr>          </table>      </div> +    <a href="/AllDataReadings">All Data Page</a>      <p id="aq">{{ Aqi }}</p>      <img src="https://www.ourair.org/wp-content/uploads/AQItable.gif">  {% endblock %} diff --git a/app/config/parameters.yml b/app/config/parameters.yml index 3651354..355c026 100644 --- a/app/config/parameters.yml +++ b/app/config/parameters.yml @@ -1,20 +1,12 @@ -# This file is a "template" of what your parameters.yml file should look like -# Set parameters here that may be different on each deployment target of the app, e.g. development, staging, production. -# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration +# This file is auto-generated during the composer install  parameters:      database_host: 127.0.0.1 -    database_port: ~ +    database_port: null      database_name: symfony      database_user: root -    database_password: ~ -    # You should uncomment this if you want to use pdo_sqlite -    #database_path: '%kernel.project_dir%/var/data/data.sqlite' - -    # Mail settings +    database_password: null      mailer_transport: smtp -    mailer_host: mail.cock.li:587 +    mailer_host: 'mail.cock.li:587'      mailer_user: ***REMOVED***      mailer_password: ***REMOVED*** - -    # A secret key that's used to generate certain security-related tokens -    secret: ThisTokenIsNotSoSecretChangeIt
\ No newline at end of file +    secret: ThisTokenIsNotSoSecretChangeIt diff --git a/src/AppBundle/Controller/AllDataController.php b/src/AppBundle/Controller/AllDataController.php new file mode 100644 index 0000000..18a30a1 --- /dev/null +++ b/src/AppBundle/Controller/AllDataController.php @@ -0,0 +1,38 @@ +<?php +namespace AppBundle\Controller; + +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Bundle\FrameworkBundle\Controller\Controller; + +class AllDataController extends Controller +{ +    /** +     * @Route("/AllDataReadings", name="AllData") +     */ +    public function GetAllData() +    { +        // Get cURL resource +        $curl = curl_init(); +        curl_setopt($curl, CURLOPT_URL, "https://pollutometerapi.azurewebsites.net/api/Readings"); +        curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/json')); // Assuming you're requesting JSON +        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); +        // Send the request & save response to $resp +        $resp = curl_exec($curl); +        // Close request to clear up some resources +        curl_close($curl); + +        $data = json_decode($resp, true); +        foreach($data as $index => $item) +        { +            $data[$index]['TimeStamp'] = gmdate("l jS \of F Y h:i:s A", $item['TimeStamp']); +        } + +        $parametersToTwig = array("data" => $data); + + +        return $this->render('default/AllDataPage.html.twig',$parametersToTwig); + + +    } +}
\ No newline at end of file |