diff --git a/client/main.jsx b/client/main.jsx
index e42e679..e6385f7 100644
--- a/client/main.jsx
+++ b/client/main.jsx
@@ -5,18 +5,28 @@ import App from '../imports/ui/App';
import 'bootstrap/dist/css/bootstrap.min.css';
export const PlantTypesCollection = new Meteor.Collection('plantTypes');
+export const SensorDataCollection = new Meteor.Collection('sensorData');
Meteor.startup(() => {
if(Meteor.isServer) {
Meteor.publish('plantTypesCollection', function() {
return PlantTypesCollection.find();
})
+
+ Meteor.publish('sensorDataCollection', function() {
+ return SensorDataCollection.find();
+ })
}
if (Meteor.isClient) {
Meteor.subscribe('plantTypesCollection');
+ Meteor.subscribe('sensorDataCollection');
}
+ Meteor.setTimeout(function() {
+ console.log(SensorDataCollection.find().fetch());
+ }, 500);
+
Meteor.setTimeout(function() {
ReactDOM.render(, document.getElementById('root'));
}, 500);
diff --git a/imports/api/sensorData.js b/imports/api/sensorData.js
new file mode 100644
index 0000000..09a1202
--- /dev/null
+++ b/imports/api/sensorData.js
@@ -0,0 +1,14 @@
+import {SensorDataCollection} from '../../client/main'
+
+export function getAllSensorData() {
+ const sensorDataDocuments = SensorDataCollection.find();
+
+ var sensorDatas = [];
+
+ sensorDataDocuments.forEach((sensorData) => {
+ var brightnessInPercent = (sensorData.brightness/54000*100).toFixed(0);
+ sensorDatas.push({ name: sensorData.timestamp, temperature: sensorData.temperature, humidity: sensorData.humidity, light: brightnessInPercent, moisture: sensorData.moisture });
+ });
+
+ return sensorDatas;
+}
\ No newline at end of file
diff --git a/imports/ui/App.jsx b/imports/ui/App.jsx
index 7069c24..ff03696 100644
--- a/imports/ui/App.jsx
+++ b/imports/ui/App.jsx
@@ -4,16 +4,11 @@ import Home from './Home'
import About from './About'
import Settings from './Settings'
import {BrowserRouter as Router, Switch, Route} from 'react-router-dom'
+import {getAllSensorData} from "../api/sensorData";
function App() {
- const exampleData = [
- { name: 'Timestamp A', temperature: 38, humidity: 66, light: 75, moisture: 21 },
- { name: 'Timestamp B', temperature: 37, humidity: 65, light: 65, moisture: 22 },
- { name: 'Timestamp C', temperature: 39, humidity: 62, light: 55, moisture: 22 },
- { name: 'Timestamp D', temperature: 40, humidity: 61, light: 85, moisture: 21 },
- { name: 'Timestamp E', temperature: 40, humidity: 60, light: 80, moisture: 21 }
- ];
+ const exampleData = getAllSensorData();
return (
<>
diff --git a/imports/ui/SensorCardDeck.jsx b/imports/ui/SensorCardDeck.jsx
index 51fb24b..e679ecc 100644
--- a/imports/ui/SensorCardDeck.jsx
+++ b/imports/ui/SensorCardDeck.jsx
@@ -19,7 +19,7 @@ export default function SensorCardDeck( {sensorCardValues} ) {
Light
- {sensorCardValues[2]} H
+ {sensorCardValues[2]} %
diff --git a/server/main.js b/server/main.js
index 2913c65..addb8fa 100644
--- a/server/main.js
+++ b/server/main.js
@@ -1,15 +1,21 @@
import { Meteor } from 'meteor/meteor';
var PlantTypesCollection = new Meteor.Collection('plantTypes');
+var SensorDataCollection = new Meteor.Collection('sensorData');
Meteor.startup(() => {
if(Meteor.isServer) {
Meteor.publish('plantTypesCollection', function() {
return PlantTypesCollection.find();
})
+
+ Meteor.publish('sensorDataCollection', function() {
+ return SensorDataCollection.find();
+ })
}
if (Meteor.isClient) {
Meteor.subscribe('plantTypesCollection');
+ Meteor.subscribe('sensorDataCollection');
}
});
\ No newline at end of file