got rid of render delay
This commit is contained in:
parent
16a5521093
commit
efe1001682
@ -23,7 +23,5 @@ Meteor.startup(() => {
|
|||||||
Meteor.subscribe('sensorDataCollection');
|
Meteor.subscribe('sensorDataCollection');
|
||||||
}
|
}
|
||||||
|
|
||||||
Meteor.setTimeout(function() {
|
|
||||||
ReactDOM.render(<App />, document.getElementById('root'));
|
ReactDOM.render(<App />, document.getElementById('root'));
|
||||||
}, 1250);
|
|
||||||
});
|
});
|
||||||
@ -4,12 +4,26 @@ import SensorCardDeck from './SensorCardDeck'
|
|||||||
import {SensorDataCollection} from "../../client/main";
|
import {SensorDataCollection} from "../../client/main";
|
||||||
import {useTracker} from 'meteor/react-meteor-data';
|
import {useTracker} from 'meteor/react-meteor-data';
|
||||||
import {Col, Row} from "react-bootstrap";
|
import {Col, Row} from "react-bootstrap";
|
||||||
|
import { Card, CardDeck } from 'react-bootstrap';
|
||||||
|
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
const sensorData = useTracker(() => {
|
const sensorData = useTracker(() => {
|
||||||
return SensorDataCollection.find({ device_id: 'esp-andy' }, { sort: { timestamp: -1 }, limit: 10 }).fetch().reverse();
|
return SensorDataCollection.find({ device_id: 'esp-andy' }, { sort: { timestamp: -1 }, limit: 10 }).fetch().reverse();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (sensorData.length <= 0) {
|
||||||
|
return (
|
||||||
|
<CardDeck>
|
||||||
|
<Card>
|
||||||
|
<Card.Body>
|
||||||
|
<Card.Title>Loading!</Card.Title>
|
||||||
|
<Card.Text>Please wait...</Card.Text>
|
||||||
|
</Card.Body>
|
||||||
|
</Card>
|
||||||
|
</CardDeck>
|
||||||
|
)
|
||||||
|
} else {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SensorCardDeck />
|
<SensorCardDeck />
|
||||||
@ -69,3 +83,4 @@ export default function Home() {
|
|||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@ -7,7 +7,18 @@ export default function SensorCardDeck() {
|
|||||||
const sensorData = useTracker(() => {
|
const sensorData = useTracker(() => {
|
||||||
return SensorDataCollection.find({ device_id: 'esp-andy' }, { sort: { timestamp: -1 }, limit: 1 }).fetch();
|
return SensorDataCollection.find({ device_id: 'esp-andy' }, { sort: { timestamp: -1 }, limit: 1 }).fetch();
|
||||||
});
|
});
|
||||||
|
if (sensorData.length <= 0) {
|
||||||
|
return (
|
||||||
|
<CardDeck>
|
||||||
|
<Card>
|
||||||
|
<Card.Body>
|
||||||
|
<Card.Title>Loading!</Card.Title>
|
||||||
|
<Card.Text>Please wait...</Card.Text>
|
||||||
|
</Card.Body>
|
||||||
|
</Card>
|
||||||
|
</CardDeck>
|
||||||
|
)
|
||||||
|
} else {
|
||||||
return (
|
return (
|
||||||
<CardDeck>
|
<CardDeck>
|
||||||
<Card>
|
<Card>
|
||||||
@ -37,3 +48,4 @@ export default function SensorCardDeck() {
|
|||||||
</CardDeck>
|
</CardDeck>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@ -2,7 +2,8 @@
|
|||||||
"name": "smart_garden_server",
|
"name": "smart_garden_server",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "meteor run",
|
"start": "MONGO_URL=mongodb://garden:99009911@cloud.timovolkmann.de:27017/Smart_Garden meteor run",
|
||||||
|
"plainstart": "meteor run",
|
||||||
"test": "meteor test --once --driver-package meteortesting:mocha",
|
"test": "meteor test --once --driver-package meteortesting:mocha",
|
||||||
"test-app": "TEST_WATCH=1 meteor test --full-app --driver-package meteortesting:mocha",
|
"test-app": "TEST_WATCH=1 meteor test --full-app --driver-package meteortesting:mocha",
|
||||||
"visualize": "meteor --production --extra-packages bundle-visualizer"
|
"visualize": "meteor --production --extra-packages bundle-visualizer"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user