Make timestamp type date again and add attribute timestampToString.
This commit is contained in:
parent
7bb02a8508
commit
16a5521093
@ -25,5 +25,5 @@ Meteor.startup(() => {
|
||||
|
||||
Meteor.setTimeout(function() {
|
||||
ReactDOM.render(<App />, document.getElementById('root'));
|
||||
}, 1000);
|
||||
}, 1250);
|
||||
});
|
||||
@ -1,5 +1,5 @@
|
||||
import React from 'react'
|
||||
import { Button, Form, Container, Row, Col, Table } from 'react-bootstrap';
|
||||
import { Button, Form } from 'react-bootstrap';
|
||||
|
||||
class AddPlant extends React.Component{
|
||||
|
||||
@ -69,5 +69,4 @@ class AddPlant extends React.Component{
|
||||
}
|
||||
}
|
||||
|
||||
export default AddPlant;
|
||||
|
||||
export default AddPlant;
|
||||
@ -20,7 +20,7 @@ export default function Home() {
|
||||
<LineChart data={sensorData} margin={{ top: 60, right: 60, bottom: 30, left: 5 }}>
|
||||
<Line type="monotone" dataKey="temperature" stroke="#10b5de" />
|
||||
<CartesianGrid stroke="#ccc" strokeDasharray="5 5"/>
|
||||
<XAxis dataKey="timestamp" />
|
||||
<XAxis dataKey="timestampToString" />
|
||||
<YAxis />
|
||||
<Tooltip />
|
||||
<Legend />
|
||||
@ -32,7 +32,7 @@ export default function Home() {
|
||||
<LineChart data={sensorData} margin={{ top: 60, right: 60, bottom: 30, left: 5 }}>
|
||||
<Line type="monotone" dataKey="humidity" stroke="#ff6f00" />
|
||||
<CartesianGrid stroke="#ccc" strokeDasharray="5 5"/>
|
||||
<XAxis dataKey="timestamp" />
|
||||
<XAxis dataKey="timestampToString" />
|
||||
<YAxis />
|
||||
<Tooltip />
|
||||
<Legend />
|
||||
@ -46,7 +46,7 @@ export default function Home() {
|
||||
<LineChart data={sensorData} margin={{ top: 60, right: 60, bottom: 30, left: 5 }}>
|
||||
<Line type="monotone" dataKey="brightness" stroke="#ffd500" />
|
||||
<CartesianGrid stroke="#ccc" strokeDasharray="5 5"/>
|
||||
<XAxis dataKey="timestamp" />
|
||||
<XAxis dataKey="timestampToString" />
|
||||
<YAxis />
|
||||
<Tooltip />
|
||||
<Legend />
|
||||
@ -58,7 +58,7 @@ export default function Home() {
|
||||
<LineChart data={sensorData} margin={{ top: 60, right: 60, bottom: 30, left: 5 }}>
|
||||
<Line type="monotone" dataKey="moisture" stroke="#1c4399" />
|
||||
<CartesianGrid stroke="#ccc" strokeDasharray="5 5"/>
|
||||
<XAxis dataKey="timestamp" />
|
||||
<XAxis dataKey="timestampToString" />
|
||||
<YAxis />
|
||||
<Tooltip />
|
||||
<Legend />
|
||||
|
||||
@ -28,10 +28,22 @@ function messageCallback(collection) {
|
||||
const id = topicElements.pop();
|
||||
|
||||
var date = new Date;
|
||||
var time;
|
||||
|
||||
if (date.getHours() <= 9) {time = "0" + date.getHours();} else {
|
||||
time = date.getHours();
|
||||
}
|
||||
if (date.getMinutes() <= 9) {time = time + ":0" + date.getMinutes();} else {
|
||||
time = time + ":" + date.getMinutes();
|
||||
}
|
||||
if (date.getSeconds() <= 9) {time = time + ":0" + date.getSeconds();} else {
|
||||
time = time + ":" + date.getSeconds();
|
||||
}
|
||||
|
||||
let doc = {
|
||||
device_id: id,
|
||||
timestamp: date,
|
||||
timestampToString: time,
|
||||
}
|
||||
try {
|
||||
doc = _.merge(doc, JSON.parse(message));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user