Code Reformat & minor fixes

This commit is contained in:
Andrés Uribe Stengel 2020-07-24 20:24:46 +02:00
parent bd0a913047
commit 56b593e9e8
10 changed files with 14 additions and 75 deletions

View File

@ -1,10 +1,6 @@
<!--
<script
src="https://unpkg.com/react-bootstrap@next/dist/react-bootstrap.min.js"
crossorigin>
</script>
-->
<head>
<title>SmartGarden</title>
</head>
<body>
<div id="root" style="overflow: hidden;"></div>

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 18 KiB

View File

@ -1,7 +1,4 @@
import { connect } from 'mqtt';
import _ from 'lodash';
// var mqtt = require('mqtt');
var client = connect('mqtt://mqtt.timovolkmann.de')

View File

@ -1,5 +1,5 @@
import React from 'react'
import { Container, Row, Col} from 'react-bootstrap';
import {Row, Col} from 'react-bootstrap';
export default function About() {
@ -33,4 +33,4 @@ export default function About() {
</div>
</>
)
}
}

View File

@ -6,7 +6,6 @@ import About from './About'
import { BrowserRouter as Router, Switch, Route } from 'react-router-dom'
function App() {
return (
<>
<NavBar/>
@ -27,4 +26,4 @@ function App() {
)
}
export default App;
export default App;

View File

@ -1,7 +1,7 @@
import React from 'react'
import {ConfiguredDevicesCollection, PlantTypesCollection} from "../../client/main";
import {useTracker} from 'meteor/react-meteor-data';
import { Card, CardDeck, Table } from "react-bootstrap";
import { Table } from "react-bootstrap";
import Settings from "./Settings";
export default function Home() {
@ -35,7 +35,6 @@ export default function Home() {
}
return (
<>
<Table striped bordered hover responsive>

View File

@ -1,23 +1,10 @@
import React from 'react'
import { Navbar, Nav } from 'react-bootstrap';
//import logo from '../../client/public/SmartGarden.svg';
export default function NavigationBar() {
return (
<Navbar collapseOnSelect expand="lg" bg="light" variant="light">
<Navbar.Brand href="/">
{/* NOT POSSIBLE IN METEOR, only from the DB -> https://forums.meteor.com/t/importing-assets-image/30266/2
<img
src={logo}
width="30"
height="30"
className="d-inline-block align-top"
rounded="true"
alt="SmartGarden"
/>{' '}
*/}
SmartGarden
</Navbar.Brand>
<Navbar.Toggle aria-controls="responsive-navbar-nav" />
@ -25,18 +12,8 @@ export default function NavigationBar() {
<Nav className="mr-auto">
<Nav.Link href="/overview">Overview</Nav.Link>
<Nav.Link href="/about">About</Nav.Link>
{
/*
<NavDropdown title="Dropdown" id="collasible-nav-dropdown">
<NavDropdown.Item href="#action/3.1">Action</NavDropdown.Item>
<NavDropdown.Item href="#action/3.2">Another action</NavDropdown.Item>
<NavDropdown.Item href="#action/3.3">Something</NavDropdown.Item>
<NavDropdown.Divider />
<NavDropdown.Item href="#action/3.4">Separated link</NavDropdown.Item>
</NavDropdown>*/
}
</Nav>
</Navbar.Collapse>
</Navbar>
)
}
}

View File

@ -21,7 +21,7 @@ export default function Overview() {
} else {
return SensorDataCollection.find({device_id: activeDevice.deviceId}, {
sort: {timestamp: -1},
limit: 1441
limit: 1440
}).fetch().reverse();
}
});
@ -83,7 +83,7 @@ export default function Overview() {
<Col>
<ResponsiveContainer width='100%' height={325}>
<LineChart data={sensorData.filter(el => el.temperature !== null)} margin={{top: 50, right: 50, bottom: 20, left: 5}}>
<Line type="monotone" dataKey="temperature" stroke="#10b5de"/>
<Line type="monotone" dataKey="temperature" stroke="#10b5de" dot={false}/>
<CartesianGrid stroke="#ccc" strokeDasharray="5 5"/>
<XAxis dataKey={getLabelFromStamp}/>
<YAxis/>
@ -95,7 +95,7 @@ export default function Overview() {
<Col>
<ResponsiveContainer width='100%' height={325}>
<LineChart data={sensorData.filter(el => el.humidity !== null)} margin={{top: 50, right: 50, bottom: 20, left: 5}}>
<Line type="monotone" dataKey="humidity" stroke="#ff6f00"/>
<Line type="monotone" dataKey="humidity" stroke="#ff6f00" dot={false}/>
<CartesianGrid stroke="#ccc" strokeDasharray="5 5"/>
<XAxis dataKey={getLabelFromStamp}/>
<YAxis/>
@ -109,7 +109,7 @@ export default function Overview() {
<Col>
<ResponsiveContainer width='100%' height={325}>
<LineChart data={sensorData.filter(el => el.brightness !== null)} margin={{top: 50, right: 50, bottom: 20, left: 5}}>
<Line type="monotone" dataKey="brightness" stroke="#ffd500"/>
<Line type="monotone" dataKey="brightness" stroke="#ffd500" dot={false}/>
<CartesianGrid stroke="#ccc" strokeDasharray="5 5"/>
<XAxis dataKey={getLabelFromStamp}/>
<YAxis/>
@ -121,7 +121,7 @@ export default function Overview() {
<Col>
<ResponsiveContainer width='100%' height={325}>
<LineChart data={sensorData.filter(el => el.moisture !== null)} margin={{top: 50, right: 50, bottom: 20, left: 5}}>
<Line type="monotone" dataKey="moisture" stroke="#1c4399"/>
<Line type="monotone" dataKey="moisture" stroke="#1c4399" dot={false}/>
<CartesianGrid stroke="#ccc" strokeDasharray="5 5"/>
<XAxis dataKey={getLabelFromStamp}/>
<YAxis/>

View File

@ -37,6 +37,7 @@ export default function SensorCardDeck() {
}
});
if (sensorData.length <= 0 || plantType === undefined || deviceId === undefined || plantTypeData === undefined) {
return (
<CardDeck>

View File

@ -1,11 +1,8 @@
const mqtt = require('mqtt')
const { MongoClient } = require('mongodb')
const _ = require('lodash')
const dbClient = new MongoClient("mongodb://garden:99009911@cloud.timovolkmann.de:27017/Smart_Garden", { useUnifiedTopology: true })
// startMqttObserver()
export default async function startMqttObserver() {
console.log("setup connections...")
// setup mongodb
@ -28,24 +25,10 @@ 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,
timeAsString: time,
}
try {
doc = _.merge(doc, JSON.parse(message));