Fix Loading Error when data not loaded on time from DB.
This commit is contained in:
parent
8da0b54d2b
commit
4e8d270eba
@ -73,7 +73,7 @@ export default function Overview() {
|
||||
</Form>
|
||||
</Col>
|
||||
<Col>
|
||||
<h6>active device: {ConfiguredDevicesCollection.findOne({deviceId: activeDevice.deviceId}).alias}</h6>
|
||||
<h6>active device: {ConfiguredDevicesCollection.findOne({deviceId: activeDevice.deviceId}) === undefined ? "No device selected" : ConfiguredDevicesCollection.findOne({deviceId: activeDevice.deviceId}).alias}</h6>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
|
||||
@ -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 (
|
||||
<CardDeck>
|
||||
<Card>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user