diff --git a/imports/ui/Home.jsx b/imports/ui/Home.jsx index 9d63f78..e57d60e 100644 --- a/imports/ui/Home.jsx +++ b/imports/ui/Home.jsx @@ -3,8 +3,7 @@ import {CartesianGrid, Legend, Line, LineChart, ResponsiveContainer, Tooltip, XA import SensorCardDeck from './SensorCardDeck' import {SensorDataCollection, ActiveDeviceCollection} from "../../client/main"; import {useTracker} from 'meteor/react-meteor-data'; - -import {Col, Form, Row} from "react-bootstrap"; +import {Col, Form, Row, Card, CardDeck} from "react-bootstrap"; export default function Home() { @@ -19,10 +18,14 @@ export default function Home() { }); const sensorData = useTracker(() => { - return SensorDataCollection.find({device_id: deviceName.deviceName}, { - sort: {timestamp: -1}, - limit: 61 - }).fetch().reverse(); + if (deviceName === null || deviceName === undefined) { + return []; + } else { + return SensorDataCollection.find({device_id: deviceName.deviceName}, { + sort: {timestamp: -1}, + limit: 61 + }).fetch().reverse(); + } }); const handleChange = (e) => { @@ -35,7 +38,7 @@ export default function Home() { } - if ((sensorData.length <= 0) || (deviceName.length <= 0) || (uniqueEspNames.length <= 0)) { + if ((sensorData.length <= 0) || (deviceName.length <= 0)) { return (