From 16a5521093e2af0e616922f70c8eac8ca37e5ae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Uribe=20Stengel?= Date: Wed, 15 Jul 2020 12:16:04 +0200 Subject: [PATCH] Make timestamp type date again and add attribute timestampToString. --- client/main.jsx | 2 +- imports/ui/AddPlant.jsx | 5 ++--- imports/ui/Home.jsx | 8 ++++---- mongo-mqtt.js | 12 ++++++++++++ 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/client/main.jsx b/client/main.jsx index d0a31b8..c719b8a 100644 --- a/client/main.jsx +++ b/client/main.jsx @@ -25,5 +25,5 @@ Meteor.startup(() => { Meteor.setTimeout(function() { ReactDOM.render(, document.getElementById('root')); - }, 1000); + }, 1250); }); \ No newline at end of file diff --git a/imports/ui/AddPlant.jsx b/imports/ui/AddPlant.jsx index 0121cc4..af800e3 100644 --- a/imports/ui/AddPlant.jsx +++ b/imports/ui/AddPlant.jsx @@ -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; \ No newline at end of file diff --git a/imports/ui/Home.jsx b/imports/ui/Home.jsx index e2715cc..1399c17 100644 --- a/imports/ui/Home.jsx +++ b/imports/ui/Home.jsx @@ -20,7 +20,7 @@ export default function Home() { - + @@ -32,7 +32,7 @@ export default function Home() { - + @@ -46,7 +46,7 @@ export default function Home() { - + @@ -58,7 +58,7 @@ export default function Home() { - + diff --git a/mongo-mqtt.js b/mongo-mqtt.js index b1a6d8f..66fee96 100644 --- a/mongo-mqtt.js +++ b/mongo-mqtt.js @@ -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));