fixed dropdown when no data for device

This commit is contained in:
Timo Volkmann 2020-07-26 13:52:43 +02:00
parent 399ffeae83
commit ac4cd8f0c3

View File

@ -20,8 +20,9 @@ export default function Overview() {
return [];
} else {
return SensorDataCollection.find({device_id: activeDevice.deviceId}, {
sort: {timestamp: -1},
limit: 1440
timestamp: { $gt: moment(Date.now()).subtract(1, 'days').toDate() },
sort: { timestamp: -1 },
//limit: 1440
}).fetch().reverse();
}
});
@ -41,6 +42,31 @@ export default function Overview() {
if ((sensorData.length <= 0)) {
return (
<>
<br></br>
<Row>
<Col xs lg="2">
<h4>Devices:</h4>
</Col>
</Row>
<Row>
<Col xs lg="2">
<Form>
<Form.Group>
<Form.Control as="select" type="text" onChange={handleChange}>
<option></option>
{configuredDevices.map((devices, index) => {
return <option key={index} value={devices.deviceId}>{devices.alias}</option>
})}
</Form.Control>
</Form.Group>
</Form>
</Col>
<Col>
<h6>active device: {!activeDevice === undefined && !ConfiguredDevicesCollection.findOne({ deviceId: activeDevice.deviceId }) === undefined ? ConfiguredDevicesCollection.findOne({ deviceId: activeDevice.deviceId }).alias : "No device selected"}</h6>
</Col>
</Row>
<CardDeck>
<Card>
<Card.Body>
@ -48,7 +74,8 @@ export default function Overview() {
<Card.Text>Please wait...</Card.Text>
</Card.Body>
</Card>
</CardDeck>
</CardDeck>
</>
)
} else {
return (