aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarwolaethblack <a.unal677@gmail.com>2017-11-24 10:48:31 +0100
committermarwolaethblack <a.unal677@gmail.com>2017-11-24 10:48:31 +0100
commit1e0b1fa7ac2ad0ae07591aca296e3ef33839ef5e (patch)
tree417957cd569b27919468d46ea6e22009208ef1b5
parent8a476ef960d6cb20a580334f1e95f11abd069a07 (diff)
add real time data every 60sec
-rw-r--r--.idea/workspace.xml171
-rw-r--r--app/Resources/views/default/index.html.twig7
-rw-r--r--src/AppBundle/Controller/NewDataController.php45
-rw-r--r--web/js/realtime.js27
4 files changed, 211 insertions, 39 deletions
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 82e5509..2cf848a 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -2,7 +2,6 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="c02a68ca-4895-49ef-94e1-572ab8cf87ba" name="Default" comment="">
- <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/app/Resources/views/default/index.html.twig" afterPath="$PROJECT_DIR$/app/Resources/views/default/index.html.twig" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@@ -21,30 +20,44 @@
<file leaf-file-name="HomeController.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/AppBundle/Controller/HomeController.php">
<provider selected="true" editor-type-id="text-editor">
- <state relative-caret-position="472">
- <caret line="37" column="62" lean-forward="true" selection-start-line="37" selection-start-column="62" selection-end-line="37" selection-end-column="62" />
+ <state relative-caret-position="378">
+ <caret line="33" column="8" lean-forward="false" selection-start-line="33" selection-start-column="8" selection-end-line="34" selection-end-column="80" />
<folding>
+ <element signature="e#6#87#0#PHP" expanded="true" />
<element signature="e#122#181#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="index.html.twig" pinned="false" current-in-tab="true">
+ <file leaf-file-name="NewDataController.php" pinned="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/src/AppBundle/Controller/NewDataController.php">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="446">
+ <caret line="37" column="40" lean-forward="false" selection-start-line="37" selection-start-column="40" selection-end-line="37" selection-end-column="40" />
+ <folding>
+ <element signature="e#6#87#0#PHP" expanded="true" />
+ <element signature="e#122#181#0#PHP" expanded="true" />
+ </folding>
+ </state>
+ </provider>
+ </entry>
+ </file>
+ <file leaf-file-name="index.html.twig" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app/Resources/views/default/index.html.twig">
<provider selected="true" editor-type-id="text-editor">
- <state relative-caret-position="72">
- <caret line="4" column="9" lean-forward="false" selection-start-line="4" selection-start-column="9" selection-end-line="4" selection-end-column="9" />
+ <state relative-caret-position="198">
+ <caret line="11" column="28" lean-forward="false" selection-start-line="11" selection-start-column="28" selection-end-line="11" selection-end-column="28" />
<folding />
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="console" pinned="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/bin/console">
+ <file leaf-file-name="realtime.js" pinned="false" current-in-tab="true">
+ <entry file="file://$PROJECT_DIR$/web/js/realtime.js">
<provider selected="true" editor-type-id="text-editor">
- <state relative-caret-position="144">
- <caret line="10" column="14" lean-forward="true" selection-start-line="10" selection-start-column="14" selection-end-line="10" selection-end-column="14" />
+ <state relative-caret-position="468">
+ <caret line="26" column="25" lean-forward="false" selection-start-line="26" selection-start-column="25" selection-end-line="26" selection-end-column="25" />
<folding />
</state>
</provider>
@@ -53,8 +66,8 @@
<file leaf-file-name="app.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/web/app.php">
<provider selected="true" editor-type-id="text-editor">
- <state relative-caret-position="0">
- <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
+ <state relative-caret-position="216">
+ <caret line="12" column="1" lean-forward="false" selection-start-line="12" selection-start-column="1" selection-end-line="12" selection-end-column="1" />
<folding />
</state>
</provider>
@@ -62,6 +75,21 @@
</file>
</leaf>
</component>
+ <component name="FileTemplateManagerImpl">
+ <option name="RECENT_TEMPLATES">
+ <list>
+ <option value="JavaScript File" />
+ </list>
+ </option>
+ </component>
+ <component name="FindInProjectRecents">
+ <replaceStrings>
+ <replace />
+ </replaceStrings>
+ <dirStrings>
+ <dir>$PROJECT_DIR$/web</dir>
+ </dirStrings>
+ </component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
@@ -73,7 +101,10 @@
<option value="$PROJECT_DIR$/src/AppBundle/View/Home.php" />
<option value="$PROJECT_DIR$/src/AppBundle/Controller/HomeController.php" />
<option value="$PROJECT_DIR$/bin/console" />
+ <option value="$PROJECT_DIR$/src/AppBundle/Controller/NewData.php" />
<option value="$PROJECT_DIR$/app/Resources/views/default/index.html.twig" />
+ <option value="$PROJECT_DIR$/src/AppBundle/Controller/NewDataController.php" />
+ <option value="$PROJECT_DIR$/web/js/realtime.js" />
</list>
</option>
</component>
@@ -157,7 +188,31 @@
<path>
<item name="pollution-sensor" type="b2602c69:ProjectViewProjectNode" />
<item name="pollution-sensor" type="2a2b976b:PhpTreeStructureProvider$1" />
- <item name="web" type="2a2b976b:PhpTreeStructureProvider$1" />
+ <item name="app" type="2a2b976b:PhpTreeStructureProvider$1" />
+ </path>
+ <path>
+ <item name="pollution-sensor" type="b2602c69:ProjectViewProjectNode" />
+ <item name="pollution-sensor" type="2a2b976b:PhpTreeStructureProvider$1" />
+ <item name="app" type="2a2b976b:PhpTreeStructureProvider$1" />
+ <item name="config" type="2a2b976b:PhpTreeStructureProvider$1" />
+ </path>
+ <path>
+ <item name="pollution-sensor" type="b2602c69:ProjectViewProjectNode" />
+ <item name="pollution-sensor" type="2a2b976b:PhpTreeStructureProvider$1" />
+ <item name="src" type="2a2b976b:PhpTreeStructureProvider$1" />
+ </path>
+ <path>
+ <item name="pollution-sensor" type="b2602c69:ProjectViewProjectNode" />
+ <item name="pollution-sensor" type="2a2b976b:PhpTreeStructureProvider$1" />
+ <item name="src" type="2a2b976b:PhpTreeStructureProvider$1" />
+ <item name="AppBundle" type="2a2b976b:PhpTreeStructureProvider$1" />
+ </path>
+ <path>
+ <item name="pollution-sensor" type="b2602c69:ProjectViewProjectNode" />
+ <item name="pollution-sensor" type="2a2b976b:PhpTreeStructureProvider$1" />
+ <item name="src" type="2a2b976b:PhpTreeStructureProvider$1" />
+ <item name="AppBundle" type="2a2b976b:PhpTreeStructureProvider$1" />
+ <item name="Controller" type="2a2b976b:PhpTreeStructureProvider$1" />
</path>
</expand>
<select />
@@ -207,12 +262,12 @@
<workItem from="1511346717882" duration="176000" />
<workItem from="1511347081605" duration="1264000" />
<workItem from="1511428524892" duration="6187000" />
- <workItem from="1511512197156" duration="1678000" />
+ <workItem from="1511512197156" duration="4678000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
- <option name="totallyTimeSpent" value="9856000" />
+ <option name="totallyTimeSpent" value="12856000" />
</component>
<component name="ToolWindowManager">
<frame x="67" y="25" width="1853" height="925" extended-state="6" />
@@ -222,6 +277,7 @@
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.39968404" sideWeight="0.5036573" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
+ <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
@@ -233,7 +289,6 @@
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
- <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
</layout>
</component>
@@ -255,6 +310,7 @@
<state relative-caret-position="0">
<caret line="0" column="5" lean-forward="true" selection-start-line="0" selection-start-column="5" selection-end-line="0" selection-end-column="5" />
<folding>
+ <element signature="e#6#87#0#PHP" expanded="true" />
<element signature="e#122#181#0#PHP" expanded="true" />
</folding>
</state>
@@ -272,6 +328,7 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="18">
<caret line="1" column="13" lean-forward="false" selection-start-line="1" selection-start-column="13" selection-end-line="1" selection-end-column="13" />
+ <folding />
</state>
</provider>
</entry>
@@ -279,6 +336,7 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="468">
<caret line="26" column="82" lean-forward="false" selection-start-line="26" selection-start-column="82" selection-end-line="26" selection-end-column="82" />
+ <folding />
</state>
</provider>
</entry>
@@ -286,6 +344,7 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
+ <folding />
</state>
</provider>
</entry>
@@ -293,6 +352,7 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
+ <folding />
</state>
</provider>
</entry>
@@ -300,6 +360,7 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
+ <folding />
</state>
</provider>
</entry>
@@ -307,6 +368,7 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="18">
<caret line="1" column="13" lean-forward="false" selection-start-line="1" selection-start-column="13" selection-end-line="1" selection-end-column="13" />
+ <folding />
</state>
</provider>
</entry>
@@ -326,28 +388,37 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="18">
<caret line="26" column="82" lean-forward="false" selection-start-line="26" selection-start-column="82" selection-end-line="26" selection-end-column="82" />
+ <folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/AppBundle/Controller/DefaultController.php" />
<entry file="file://$PROJECT_DIR$/src/AppBundle/View/Home.php" />
- <entry file="file://$PROJECT_DIR$/src/AppBundle/AppBundle.php">
+ <entry file="file://$PROJECT_DIR$/tests/AppBundle/Controller/DefaultControllerTest.php">
<provider selected="true" editor-type-id="text-editor">
- <state relative-caret-position="0">
- <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
+ <state relative-caret-position="270">
+ <caret line="15" column="95" lean-forward="true" selection-start-line="15" selection-start-column="95" selection-end-line="15" selection-end-column="95" />
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/app/Resources/views/base.html.twig">
+ <entry file="file://$PROJECT_DIR$/.gitignore">
<provider selected="true" editor-type-id="text-editor">
- <state relative-caret-position="0">
- <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
+ <state relative-caret-position="288">
+ <caret line="16" column="13" lean-forward="true" selection-start-line="16" selection-start-column="13" selection-end-line="16" selection-end-column="13" />
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/web/app.php">
+ <entry file="file://$PROJECT_DIR$/bin/console">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="144">
+ <caret line="10" column="14" lean-forward="true" selection-start-line="10" selection-start-column="14" selection-end-line="10" selection-end-column="14" />
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/.web-server-pid">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
@@ -355,35 +426,55 @@
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/tests/AppBundle/Controller/DefaultControllerTest.php">
+ <entry file="file://$PROJECT_DIR$/app/Resources/views/base.html.twig">
<provider selected="true" editor-type-id="text-editor">
- <state relative-caret-position="270">
- <caret line="15" column="95" lean-forward="true" selection-start-line="15" selection-start-column="95" selection-end-line="15" selection-end-column="95" />
+ <state relative-caret-position="180">
+ <caret line="10" column="25" lean-forward="false" selection-start-line="10" selection-start-column="25" selection-end-line="10" selection-end-column="25" />
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/.gitignore">
+ <entry file="file://$PROJECT_DIR$/web/app.php">
<provider selected="true" editor-type-id="text-editor">
- <state relative-caret-position="288">
- <caret line="16" column="13" lean-forward="true" selection-start-line="16" selection-start-column="13" selection-end-line="16" selection-end-column="13" />
+ <state relative-caret-position="216">
+ <caret line="12" column="1" lean-forward="false" selection-start-line="12" selection-start-column="1" selection-end-line="12" selection-end-column="1" />
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/bin/console">
+ <entry file="file://$PROJECT_DIR$/src/AppBundle/AppBundle.php">
<provider selected="true" editor-type-id="text-editor">
- <state relative-caret-position="144">
- <caret line="10" column="14" lean-forward="true" selection-start-line="10" selection-start-column="14" selection-end-line="10" selection-end-column="14" />
+ <state relative-caret-position="0">
+ <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/app/config/services.yml">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="-184">
+ <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/AppBundle/Controller/HomeController.php">
<provider selected="true" editor-type-id="text-editor">
- <state relative-caret-position="472">
- <caret line="37" column="62" lean-forward="true" selection-start-line="37" selection-start-column="62" selection-end-line="37" selection-end-column="62" />
+ <state relative-caret-position="378">
+ <caret line="33" column="8" lean-forward="false" selection-start-line="33" selection-start-column="8" selection-end-line="34" selection-end-column="80" />
<folding>
+ <element signature="e#6#87#0#PHP" expanded="true" />
+ <element signature="e#122#181#0#PHP" expanded="true" />
+ </folding>
+ </state>
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/src/AppBundle/Controller/NewDataController.php">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="446">
+ <caret line="37" column="40" lean-forward="false" selection-start-line="37" selection-start-column="40" selection-end-line="37" selection-end-column="40" />
+ <folding>
+ <element signature="e#6#87#0#PHP" expanded="true" />
<element signature="e#122#181#0#PHP" expanded="true" />
</folding>
</state>
@@ -391,8 +482,16 @@
</entry>
<entry file="file://$PROJECT_DIR$/app/Resources/views/default/index.html.twig">
<provider selected="true" editor-type-id="text-editor">
- <state relative-caret-position="72">
- <caret line="4" column="9" lean-forward="false" selection-start-line="4" selection-start-column="9" selection-end-line="4" selection-end-column="9" />
+ <state relative-caret-position="198">
+ <caret line="11" column="28" lean-forward="false" selection-start-line="11" selection-start-column="28" selection-end-line="11" selection-end-column="28" />
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/web/js/realtime.js">
+ <provider selected="true" editor-type-id="text-editor">
+ <state relative-caret-position="468">
+ <caret line="26" column="25" lean-forward="false" selection-start-line="26" selection-start-column="25" selection-end-line="26" selection-end-column="25" />
<folding />
</state>
</provider>
diff --git a/app/Resources/views/default/index.html.twig b/app/Resources/views/default/index.html.twig
index cc24f54..36180cb 100644
--- a/app/Resources/views/default/index.html.twig
+++ b/app/Resources/views/default/index.html.twig
@@ -2,7 +2,6 @@
{% block body %}
<div id="wrapper">
- A
<table>
<tr>
<th>TimeStamp</th>
@@ -10,7 +9,7 @@
<th>No</th>
<th>So</th>
</tr>
- <tr>
+ <tr id="latest">
<td>{{ TimeStamp }}</td>
<td>{{ Co }}</td>
<td>{{ No }}</td>
@@ -19,4 +18,6 @@
</table>
</div>
{% endblock %}
-
+{% block javascripts %}
+ <script src="{{ asset('js/realtime.js') }}"></script>
+{% endblock %}
diff --git a/src/AppBundle/Controller/NewDataController.php b/src/AppBundle/Controller/NewDataController.php
new file mode 100644
index 0000000..1aacccc
--- /dev/null
+++ b/src/AppBundle/Controller/NewDataController.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: andy
+ * Date: 11/23/17
+ * Time: 10:21 AM
+ */
+
+namespace AppBundle\Controller;
+
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
+use Symfony\Component\HttpFoundation\Response;
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+
+
+class NewDataController extends Controller
+{
+ /**
+ * @Route("/latest")
+ */
+
+ public function getLatestData()
+ {
+ // Get cURL resource
+ $curl = curl_init();
+ curl_setopt($curl, CURLOPT_URL, "http://pollutometerapi.azurewebsites.net/api/Readings/latest");
+ 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);
+ $data['TimeStamp'] = gmdate("l jS \of F Y h:i:s A", $data['TimeStamp']);
+ $data = json_encode($data);
+
+ $response = new Response($data);
+ $response->headers->set('Content-Type', 'application/json');
+
+ return $response;
+
+ }
+
+} \ No newline at end of file
diff --git a/web/js/realtime.js b/web/js/realtime.js
new file mode 100644
index 0000000..4526e5e
--- /dev/null
+++ b/web/js/realtime.js
@@ -0,0 +1,27 @@
+function update() {
+
+ var data;
+
+ fetch('/latest')
+ .then(function(resp) {
+ return resp.json();
+ })
+ .then(function(response) {
+ data = response;
+ var table = document.querySelector('#latest').children;
+ table[0].textContent = data.TimeStamp;
+ table[1].textContent = data.Co;
+ table[2].textContent = data.No;
+ table[3].textContent = data.So;
+
+ })
+ .catch(function(error) {
+ console.log(error);
+ });
+
+
+
+
+}
+
+setInterval(update, 60000);