Code Reformat & minor fixes
This commit is contained in:
parent
bd0a913047
commit
56b593e9e8
@ -1,10 +1,6 @@
|
|||||||
|
<head>
|
||||||
<!--
|
<title>SmartGarden</title>
|
||||||
<script
|
</head>
|
||||||
src="https://unpkg.com/react-bootstrap@next/dist/react-bootstrap.min.js"
|
|
||||||
crossorigin>
|
|
||||||
</script>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="root" style="overflow: hidden;"></div>
|
<div id="root" style="overflow: hidden;"></div>
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 18 KiB |
@ -1,7 +1,4 @@
|
|||||||
import { connect } from 'mqtt';
|
import { connect } from 'mqtt';
|
||||||
import _ from 'lodash';
|
|
||||||
// var mqtt = require('mqtt');
|
|
||||||
|
|
||||||
|
|
||||||
var client = connect('mqtt://mqtt.timovolkmann.de')
|
var client = connect('mqtt://mqtt.timovolkmann.de')
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Container, Row, Col} from 'react-bootstrap';
|
import {Row, Col} from 'react-bootstrap';
|
||||||
|
|
||||||
|
|
||||||
export default function About() {
|
export default function About() {
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import About from './About'
|
|||||||
import { BrowserRouter as Router, Switch, Route } from 'react-router-dom'
|
import { BrowserRouter as Router, Switch, Route } from 'react-router-dom'
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<NavBar/>
|
<NavBar/>
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {ConfiguredDevicesCollection, PlantTypesCollection} from "../../client/main";
|
import {ConfiguredDevicesCollection, PlantTypesCollection} from "../../client/main";
|
||||||
import {useTracker} from 'meteor/react-meteor-data';
|
import {useTracker} from 'meteor/react-meteor-data';
|
||||||
import { Card, CardDeck, Table } from "react-bootstrap";
|
import { Table } from "react-bootstrap";
|
||||||
import Settings from "./Settings";
|
import Settings from "./Settings";
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
@ -35,7 +35,6 @@ export default function Home() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Table striped bordered hover responsive>
|
<Table striped bordered hover responsive>
|
||||||
|
|||||||
@ -1,23 +1,10 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Navbar, Nav } from 'react-bootstrap';
|
import { Navbar, Nav } from 'react-bootstrap';
|
||||||
|
|
||||||
//import logo from '../../client/public/SmartGarden.svg';
|
|
||||||
|
|
||||||
export default function NavigationBar() {
|
export default function NavigationBar() {
|
||||||
return (
|
return (
|
||||||
<Navbar collapseOnSelect expand="lg" bg="light" variant="light">
|
<Navbar collapseOnSelect expand="lg" bg="light" variant="light">
|
||||||
<Navbar.Brand href="/">
|
<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
|
SmartGarden
|
||||||
</Navbar.Brand>
|
</Navbar.Brand>
|
||||||
<Navbar.Toggle aria-controls="responsive-navbar-nav" />
|
<Navbar.Toggle aria-controls="responsive-navbar-nav" />
|
||||||
@ -25,16 +12,6 @@ export default function NavigationBar() {
|
|||||||
<Nav className="mr-auto">
|
<Nav className="mr-auto">
|
||||||
<Nav.Link href="/overview">Overview</Nav.Link>
|
<Nav.Link href="/overview">Overview</Nav.Link>
|
||||||
<Nav.Link href="/about">About</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>
|
</Nav>
|
||||||
</Navbar.Collapse>
|
</Navbar.Collapse>
|
||||||
</Navbar>
|
</Navbar>
|
||||||
|
|||||||
@ -21,7 +21,7 @@ export default function Overview() {
|
|||||||
} else {
|
} else {
|
||||||
return SensorDataCollection.find({device_id: activeDevice.deviceId}, {
|
return SensorDataCollection.find({device_id: activeDevice.deviceId}, {
|
||||||
sort: {timestamp: -1},
|
sort: {timestamp: -1},
|
||||||
limit: 1441
|
limit: 1440
|
||||||
}).fetch().reverse();
|
}).fetch().reverse();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -83,7 +83,7 @@ export default function Overview() {
|
|||||||
<Col>
|
<Col>
|
||||||
<ResponsiveContainer width='100%' height={325}>
|
<ResponsiveContainer width='100%' height={325}>
|
||||||
<LineChart data={sensorData.filter(el => el.temperature !== null)} margin={{top: 50, right: 50, bottom: 20, left: 5}}>
|
<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"/>
|
<CartesianGrid stroke="#ccc" strokeDasharray="5 5"/>
|
||||||
<XAxis dataKey={getLabelFromStamp}/>
|
<XAxis dataKey={getLabelFromStamp}/>
|
||||||
<YAxis/>
|
<YAxis/>
|
||||||
@ -95,7 +95,7 @@ export default function Overview() {
|
|||||||
<Col>
|
<Col>
|
||||||
<ResponsiveContainer width='100%' height={325}>
|
<ResponsiveContainer width='100%' height={325}>
|
||||||
<LineChart data={sensorData.filter(el => el.humidity !== null)} margin={{top: 50, right: 50, bottom: 20, left: 5}}>
|
<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"/>
|
<CartesianGrid stroke="#ccc" strokeDasharray="5 5"/>
|
||||||
<XAxis dataKey={getLabelFromStamp}/>
|
<XAxis dataKey={getLabelFromStamp}/>
|
||||||
<YAxis/>
|
<YAxis/>
|
||||||
@ -109,7 +109,7 @@ export default function Overview() {
|
|||||||
<Col>
|
<Col>
|
||||||
<ResponsiveContainer width='100%' height={325}>
|
<ResponsiveContainer width='100%' height={325}>
|
||||||
<LineChart data={sensorData.filter(el => el.brightness !== null)} margin={{top: 50, right: 50, bottom: 20, left: 5}}>
|
<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"/>
|
<CartesianGrid stroke="#ccc" strokeDasharray="5 5"/>
|
||||||
<XAxis dataKey={getLabelFromStamp}/>
|
<XAxis dataKey={getLabelFromStamp}/>
|
||||||
<YAxis/>
|
<YAxis/>
|
||||||
@ -121,7 +121,7 @@ export default function Overview() {
|
|||||||
<Col>
|
<Col>
|
||||||
<ResponsiveContainer width='100%' height={325}>
|
<ResponsiveContainer width='100%' height={325}>
|
||||||
<LineChart data={sensorData.filter(el => el.moisture !== null)} margin={{top: 50, right: 50, bottom: 20, left: 5}}>
|
<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"/>
|
<CartesianGrid stroke="#ccc" strokeDasharray="5 5"/>
|
||||||
<XAxis dataKey={getLabelFromStamp}/>
|
<XAxis dataKey={getLabelFromStamp}/>
|
||||||
<YAxis/>
|
<YAxis/>
|
||||||
|
|||||||
@ -37,6 +37,7 @@ export default function SensorCardDeck() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (sensorData.length <= 0 || plantType === undefined || deviceId === undefined || plantTypeData === undefined) {
|
if (sensorData.length <= 0 || plantType === undefined || deviceId === undefined || plantTypeData === undefined) {
|
||||||
return (
|
return (
|
||||||
<CardDeck>
|
<CardDeck>
|
||||||
|
|||||||
@ -1,11 +1,8 @@
|
|||||||
const mqtt = require('mqtt')
|
const mqtt = require('mqtt')
|
||||||
const { MongoClient } = require('mongodb')
|
const { MongoClient } = require('mongodb')
|
||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
|
|
||||||
const dbClient = new MongoClient("mongodb://garden:99009911@cloud.timovolkmann.de:27017/Smart_Garden", { useUnifiedTopology: true })
|
const dbClient = new MongoClient("mongodb://garden:99009911@cloud.timovolkmann.de:27017/Smart_Garden", { useUnifiedTopology: true })
|
||||||
|
|
||||||
// startMqttObserver()
|
|
||||||
|
|
||||||
export default async function startMqttObserver() {
|
export default async function startMqttObserver() {
|
||||||
console.log("setup connections...")
|
console.log("setup connections...")
|
||||||
// setup mongodb
|
// setup mongodb
|
||||||
@ -28,24 +25,10 @@ function messageCallback(collection) {
|
|||||||
const id = topicElements.pop();
|
const id = topicElements.pop();
|
||||||
|
|
||||||
var date = new Date;
|
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 = {
|
let doc = {
|
||||||
device_id: id,
|
device_id: id,
|
||||||
timestamp: date,
|
timestamp: date,
|
||||||
timeAsString: time,
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
doc = _.merge(doc, JSON.parse(message));
|
doc = _.merge(doc, JSON.parse(message));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user