diff --git a/imports/ui/Overview.jsx b/imports/ui/Overview.jsx
index 020ace1..d7c03a9 100644
--- a/imports/ui/Overview.jsx
+++ b/imports/ui/Overview.jsx
@@ -73,7 +73,7 @@ export default function Overview() {
- active device: {ConfiguredDevicesCollection.findOne({deviceId: activeDevice.deviceId}).alias}
+ active device: {ConfiguredDevicesCollection.findOne({deviceId: activeDevice.deviceId}) === undefined ? "No device selected" : ConfiguredDevicesCollection.findOne({deviceId: activeDevice.deviceId}).alias}
diff --git a/imports/ui/SensorCardDeck.jsx b/imports/ui/SensorCardDeck.jsx
index 1c21dd4..7dabded 100644
--- a/imports/ui/SensorCardDeck.jsx
+++ b/imports/ui/SensorCardDeck.jsx
@@ -14,19 +14,32 @@ export default function SensorCardDeck() {
});
const sensorData = useTracker(() => {
- return SensorDataCollection.find({ device_id: deviceId.deviceId }, { sort: { timestamp: -1 }, limit: 1 }).fetch();
+ if (deviceId === null || deviceId === undefined) {
+ return undefined;
+ } else {
+ return SensorDataCollection.find({device_id: deviceId.deviceId}, {sort: {timestamp: -1}, limit: 1}).fetch();
+ }
});
const plantType = useTracker(() => {
- return ConfiguredDevicesCollection.findOne({ deviceId: deviceId.deviceId }).type;
+ if (deviceId === null || deviceId === undefined) {
+ return undefined;
+ } else {
+ return ConfiguredDevicesCollection.findOne({deviceId: deviceId.deviceId});
+ }
});
const plantTypeData = useTracker(() => {
- return PlantTypesCollection.findOne({ plantType: plantType });
+ if (plantType === null || plantType === undefined) {
+ return undefined;
+ } else {
+ return PlantTypesCollection.findOne({plantType: plantType.type});
+ }
});
+ console.log("Sens" + sensorData, plantType, plantTypeData, deviceId);
- if (sensorData.length <= 0) {
+ if (sensorData.length <= 0 || plantType === undefined || deviceId === undefined || plantTypeData === undefined) {
return (