Try without timer.
This commit is contained in:
parent
40c5dc2cb0
commit
76eb9012fa
@ -29,7 +29,5 @@ Meteor.startup(() => {
|
|||||||
Meteor.subscribe('activeDeviceCollection');
|
Meteor.subscribe('activeDeviceCollection');
|
||||||
}
|
}
|
||||||
|
|
||||||
Meteor.setTimeout(function() {
|
ReactDOM.render(<App />, document.getElementById('root'));
|
||||||
ReactDOM.render(<App />, document.getElementById('root'));
|
|
||||||
}, 1250);
|
|
||||||
});
|
});
|
||||||
@ -6,11 +6,11 @@ import {useTracker} from 'meteor/react-meteor-data';
|
|||||||
|
|
||||||
import {Col, Form, Row} from "react-bootstrap";
|
import {Col, Form, Row} from "react-bootstrap";
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
|
|
||||||
const uniqueEspNames = _.uniq(SensorDataCollection.find({}, {
|
const uniqueEspNames = _.uniq(SensorDataCollection.find({}, {
|
||||||
sort: {device_id: 1}, fields: {device_id: true}
|
sort: {device_id: 1}, fields: {device_id: true}
|
||||||
}).fetch().map(function(x) {
|
}).fetch().map(function (x) {
|
||||||
return x.device_id;
|
return x.device_id;
|
||||||
}), true);
|
}), true);
|
||||||
|
|
||||||
@ -19,18 +19,23 @@ export default function Home() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const sensorData = useTracker(() => {
|
const sensorData = useTracker(() => {
|
||||||
return SensorDataCollection.find({ device_id: deviceName.deviceName }, { sort: { timestamp: -1 }, limit: 61 }).fetch().reverse();
|
return SensorDataCollection.find({device_id: deviceName.deviceName}, {
|
||||||
|
sort: {timestamp: -1},
|
||||||
|
limit: 61
|
||||||
|
}).fetch().reverse();
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleChange = (e) => {
|
const handleChange = (e) => {
|
||||||
if (e.target.value === "") {console.log("No device selected!");} else {
|
if (e.target.value === "") {
|
||||||
var doc = ActiveDeviceCollection.findOne({ deviceName: deviceName.deviceName });
|
console.log("No device selected!");
|
||||||
ActiveDeviceCollection.update({ _id: doc._id }, {$set:{deviceName: e.target.value}});
|
} else {
|
||||||
|
var doc = ActiveDeviceCollection.findOne({deviceName: deviceName.deviceName});
|
||||||
|
ActiveDeviceCollection.update({_id: doc._id}, {$set: {deviceName: e.target.value}});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*if (sensorData.length <= 0) {
|
if ((sensorData.length <= 0) || (deviceName.length <= 0) || (uniqueEspNames.length <= 0)) {
|
||||||
return (
|
return (
|
||||||
<CardDeck>
|
<CardDeck>
|
||||||
<Card>
|
<Card>
|
||||||
@ -41,85 +46,86 @@ export default function Home() {
|
|||||||
</Card>
|
</Card>
|
||||||
</CardDeck>
|
</CardDeck>
|
||||||
)
|
)
|
||||||
} else {}*/
|
} else {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Row>
|
<Row>
|
||||||
<Col xs lg="2">
|
<Col xs lg="2">
|
||||||
<h4>Devices:</h4>
|
<h4>Devices:</h4>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
<Row>
|
<Row>
|
||||||
<Col xs lg="2">
|
<Col xs lg="2">
|
||||||
<Form>
|
<Form>
|
||||||
<Form.Group>
|
<Form.Group>
|
||||||
<Form.Control as="select" type="text" onChange={handleChange}>
|
<Form.Control as="select" type="text" onChange={handleChange}>
|
||||||
<option></option>
|
<option></option>
|
||||||
{uniqueEspNames.map((espName, index) =>{
|
{uniqueEspNames.map((espName, index) => {
|
||||||
return <option key={index} value={espName}>{espName}</option>
|
return <option key={index} value={espName}>{espName}</option>
|
||||||
})}
|
})}
|
||||||
</Form.Control>
|
</Form.Control>
|
||||||
</Form.Group>
|
</Form.Group>
|
||||||
</Form>
|
</Form>
|
||||||
</Col>
|
</Col>
|
||||||
<Col>
|
<Col>
|
||||||
<h6>active device: {deviceName.deviceName}</h6>
|
<h6>active device: {deviceName.deviceName}</h6>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
<SensorCardDeck/>
|
<SensorCardDeck/>
|
||||||
<Row>
|
<Row>
|
||||||
<Col>
|
<Col>
|
||||||
<ResponsiveContainer width='100%' height={350}>
|
<ResponsiveContainer width='100%' height={350}>
|
||||||
<LineChart data={sensorData} margin={{ top: 50, right: 50, bottom: 25, left: 5 }}>
|
<LineChart data={sensorData} margin={{top: 50, right: 50, bottom: 25, left: 5}}>
|
||||||
<Line type="monotone" dataKey="temperature" stroke="#10b5de" />
|
<Line type="monotone" dataKey="temperature" stroke="#10b5de"/>
|
||||||
<CartesianGrid stroke="#ccc" strokeDasharray="5 5"/>
|
<CartesianGrid stroke="#ccc" strokeDasharray="5 5"/>
|
||||||
<XAxis dataKey="timeAsString" />
|
<XAxis dataKey="timeAsString"/>
|
||||||
<YAxis />
|
<YAxis/>
|
||||||
<Tooltip />
|
<Tooltip/>
|
||||||
<Legend />
|
<Legend/>
|
||||||
</LineChart>
|
</LineChart>
|
||||||
</ResponsiveContainer>
|
</ResponsiveContainer>
|
||||||
</Col>
|
</Col>
|
||||||
<Col>
|
<Col>
|
||||||
<ResponsiveContainer width='100%' height={350}>
|
<ResponsiveContainer width='100%' height={350}>
|
||||||
<LineChart data={sensorData} margin={{ top: 50, right: 50, bottom: 25, left: 5 }}>
|
<LineChart data={sensorData} margin={{top: 50, right: 50, bottom: 25, left: 5}}>
|
||||||
<Line type="monotone" dataKey="humidity" stroke="#ff6f00" />
|
<Line type="monotone" dataKey="humidity" stroke="#ff6f00"/>
|
||||||
<CartesianGrid stroke="#ccc" strokeDasharray="5 5"/>
|
<CartesianGrid stroke="#ccc" strokeDasharray="5 5"/>
|
||||||
<XAxis dataKey="timeAsString" />
|
<XAxis dataKey="timeAsString"/>
|
||||||
<YAxis />
|
<YAxis/>
|
||||||
<Tooltip />
|
<Tooltip/>
|
||||||
<Legend />
|
<Legend/>
|
||||||
</LineChart>
|
</LineChart>
|
||||||
</ResponsiveContainer>
|
</ResponsiveContainer>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
<Row>
|
<Row>
|
||||||
<Col>
|
<Col>
|
||||||
<ResponsiveContainer width='100%' height={350}>
|
<ResponsiveContainer width='100%' height={350}>
|
||||||
<LineChart data={sensorData} margin={{ top: 50, right: 50, bottom: 25, left: 5 }}>
|
<LineChart data={sensorData} margin={{top: 50, right: 50, bottom: 25, left: 5}}>
|
||||||
<Line type="monotone" dataKey="brightness" stroke="#ffd500" />
|
<Line type="monotone" dataKey="brightness" stroke="#ffd500"/>
|
||||||
<CartesianGrid stroke="#ccc" strokeDasharray="5 5"/>
|
<CartesianGrid stroke="#ccc" strokeDasharray="5 5"/>
|
||||||
<XAxis dataKey="timeAsString" />
|
<XAxis dataKey="timeAsString"/>
|
||||||
<YAxis />
|
<YAxis/>
|
||||||
<Tooltip />
|
<Tooltip/>
|
||||||
<Legend />
|
<Legend/>
|
||||||
</LineChart>
|
</LineChart>
|
||||||
</ResponsiveContainer>
|
</ResponsiveContainer>
|
||||||
</Col>
|
</Col>
|
||||||
<Col>
|
<Col>
|
||||||
<ResponsiveContainer width='100%' height={350}>
|
<ResponsiveContainer width='100%' height={350}>
|
||||||
<LineChart data={sensorData} margin={{ top: 50, right: 50, bottom: 25, left: 5 }}>
|
<LineChart data={sensorData} margin={{top: 50, right: 50, bottom: 25, left: 5}}>
|
||||||
<Line type="monotone" dataKey="moisture" stroke="#1c4399" />
|
<Line type="monotone" dataKey="moisture" stroke="#1c4399"/>
|
||||||
<CartesianGrid stroke="#ccc" strokeDasharray="5 5"/>
|
<CartesianGrid stroke="#ccc" strokeDasharray="5 5"/>
|
||||||
<XAxis dataKey="timeAsString" />
|
<XAxis dataKey="timeAsString"/>
|
||||||
<YAxis />
|
<YAxis/>
|
||||||
<Tooltip />
|
<Tooltip/>
|
||||||
<Legend />
|
<Legend/>
|
||||||
</LineChart>
|
</LineChart>
|
||||||
</ResponsiveContainer>
|
</ResponsiveContainer>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user