import React from 'react' import {CartesianGrid, Legend, Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis} from 'recharts'; import SensorCardDeck from './SensorCardDeck' import {SensorDataCollection, ActiveDeviceCollection, ConfiguredDevicesCollection} from "../../client/main"; import {useTracker} from 'meteor/react-meteor-data'; import { Col, Form, Row, Card, CardDeck } from "react-bootstrap"; import moment from 'moment' export default function Overview() { const activeDevice = useTracker(() => { return ActiveDeviceCollection.find().fetch()[0]; }); const configuredDevices = useTracker(() => { return ConfiguredDevicesCollection.find().fetch(); }); const sensorData = useTracker(() => { if (activeDevice === null || activeDevice === undefined) { return []; } else { return SensorDataCollection.find({device_id: activeDevice.deviceId}, { timestamp: { $gt: moment(Date.now()).subtract(1, 'days').toDate() }, sort: { timestamp: -1 }, //limit: 1440 }).fetch().reverse(); } }); const handleChange = (e) => { if (e.target.value === "") { console.log("No device selected!"); } else { var doc = ActiveDeviceCollection.findOne({deviceId: activeDevice.deviceId}); ActiveDeviceCollection.update({_id: doc._id}, {$set: {deviceId: e.target.value}}); } } const getLabelFromStamp = (x) => { return moment(x.timestamp).format("HH:mm"); } if ((sensorData.length <= 0)) { return ( <>

Devices:

{configuredDevices.map((devices, index) => { return })}
active device: {!activeDevice === undefined && !ConfiguredDevicesCollection.findOne({ deviceId: activeDevice.deviceId }) === undefined ? ConfiguredDevicesCollection.findOne({ deviceId: activeDevice.deviceId }).alias : "No device selected"}
Loading! Please wait... ) } else { return ( <>

Devices:

{configuredDevices.map((devices, index) => { return })}
active device: {ConfiguredDevicesCollection.findOne({deviceId: activeDevice.deviceId}) === undefined ? "No device selected" : ConfiguredDevicesCollection.findOne({deviceId: activeDevice.deviceId}).alias}
el.temperature !== null)} margin={{top: 50, right: 50, bottom: 20, left: 5}}> el.humidity !== null)} margin={{top: 50, right: 50, bottom: 20, left: 5}}> el.brightness !== null)} margin={{top: 50, right: 50, bottom: 20, left: 5}}> el.moisture !== null)} margin={{top: 50, right: 50, bottom: 20, left: 5}}> ) } }