Reformat DB data.
This commit is contained in:
parent
e45f4c6faa
commit
f95a396440
@ -8,15 +8,15 @@ import { getAllEspNames } from "../api/espNames";
|
|||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
const deviceName = useTracker(() => {
|
const deviceId = useTracker(() => {
|
||||||
return ActiveDeviceCollection.find().fetch()[0];
|
return ActiveDeviceCollection.find().fetch()[0];
|
||||||
});
|
});
|
||||||
|
|
||||||
const sensorData = useTracker(() => {
|
const sensorData = useTracker(() => {
|
||||||
if (deviceName === null || deviceName === undefined) {
|
if (deviceId === null || deviceId === undefined) {
|
||||||
return [];
|
return [];
|
||||||
} else {
|
} else {
|
||||||
return SensorDataCollection.find({device_id: deviceName.deviceName}, {
|
return SensorDataCollection.find({device_id: deviceId.deviceId}, {
|
||||||
sort: {timestamp: -1},
|
sort: {timestamp: -1},
|
||||||
limit: 61
|
limit: 61
|
||||||
}).fetch().reverse();
|
}).fetch().reverse();
|
||||||
@ -27,8 +27,8 @@ export default function Home() {
|
|||||||
if (e.target.value === "") {
|
if (e.target.value === "") {
|
||||||
console.log("No device selected!");
|
console.log("No device selected!");
|
||||||
} else {
|
} else {
|
||||||
var doc = ActiveDeviceCollection.findOne({deviceName: deviceName.deviceName});
|
var doc = ActiveDeviceCollection.findOne({deviceId: deviceId.deviceId});
|
||||||
ActiveDeviceCollection.update({_id: doc._id}, {$set: {deviceName: e.target.value}});
|
ActiveDeviceCollection.update({_id: doc._id}, {$set: {deviceId: e.target.value}});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ export default function Home() {
|
|||||||
</Form>
|
</Form>
|
||||||
</Col>
|
</Col>
|
||||||
<Col>
|
<Col>
|
||||||
<h6>active device: {deviceName.deviceName}</h6>
|
<h6>active device: {deviceId.deviceId}</h6>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
|
|||||||
@ -9,15 +9,15 @@ import {useTracker} from 'meteor/react-meteor-data';
|
|||||||
import { Card, CardDeck, Table } from "react-bootstrap";
|
import { Card, CardDeck, Table } from "react-bootstrap";
|
||||||
|
|
||||||
export default function Overview() {
|
export default function Overview() {
|
||||||
const deviceName = useTracker(() => {
|
const deviceId = useTracker(() => {
|
||||||
return ActiveDeviceCollection.find().fetch()[0];
|
return ActiveDeviceCollection.find().fetch()[0];
|
||||||
});
|
});
|
||||||
|
|
||||||
const sensorData = useTracker(() => {
|
const sensorData = useTracker(() => {
|
||||||
if (deviceName === null || deviceName === undefined) {
|
if (deviceId === null || deviceId === undefined) {
|
||||||
return [];
|
return [];
|
||||||
} else {
|
} else {
|
||||||
return SensorDataCollection.find({device_id: deviceName.deviceName}, {
|
return SensorDataCollection.find({device_id: deviceId.deviceId}, {
|
||||||
sort: {timestamp: -1},
|
sort: {timestamp: -1},
|
||||||
limit: 61
|
limit: 61
|
||||||
}).fetch().reverse();
|
}).fetch().reverse();
|
||||||
|
|||||||
@ -4,12 +4,12 @@ import {ActiveDeviceCollection, SensorDataCollection} from "../../client/main";
|
|||||||
import {useTracker} from 'meteor/react-meteor-data';
|
import {useTracker} from 'meteor/react-meteor-data';
|
||||||
|
|
||||||
export default function SensorCardDeck() {
|
export default function SensorCardDeck() {
|
||||||
const deviceName = useTracker(() => {
|
const deviceId = useTracker(() => {
|
||||||
return ActiveDeviceCollection.find().fetch()[0];
|
return ActiveDeviceCollection.find().fetch()[0];
|
||||||
});
|
});
|
||||||
|
|
||||||
const sensorData = useTracker(() => {
|
const sensorData = useTracker(() => {
|
||||||
return SensorDataCollection.find({ device_id: deviceName.deviceName }, { sort: { timestamp: -1 }, limit: 1 }).fetch();
|
return SensorDataCollection.find({ device_id: deviceId.deviceId }, { sort: { timestamp: -1 }, limit: 1 }).fetch();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -7,15 +7,15 @@ import {ConfiguredDevicesCollection, PlantTypesCollection, ActiveDeviceCollectio
|
|||||||
import {useTracker} from 'meteor/react-meteor-data';
|
import {useTracker} from 'meteor/react-meteor-data';
|
||||||
|
|
||||||
export default function Settings() {
|
export default function Settings() {
|
||||||
const deviceName = useTracker(() => {
|
const deviceId = useTracker(() => {
|
||||||
return ActiveDeviceCollection.find().fetch()[0];
|
return ActiveDeviceCollection.find().fetch()[0];
|
||||||
});
|
});
|
||||||
|
|
||||||
const sensorData = useTracker(() => {
|
const sensorData = useTracker(() => {
|
||||||
if (deviceName === null || deviceName === undefined) {
|
if (deviceId === null || deviceId === undefined) {
|
||||||
return [];
|
return [];
|
||||||
} else {
|
} else {
|
||||||
return SensorDataCollection.find({device_id: deviceName.deviceName}, {
|
return SensorDataCollection.find({device_id: deviceId.deviceId}, {
|
||||||
sort: {timestamp: -1},
|
sort: {timestamp: -1},
|
||||||
limit: 61
|
limit: 61
|
||||||
}).fetch().reverse();
|
}).fetch().reverse();
|
||||||
@ -68,8 +68,8 @@ export default function Settings() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
var doc = ConfiguredDevicesCollection.findOne({deviceName: selectedEspName});
|
var doc = ConfiguredDevicesCollection.findOne({deviceId: selectedEspName});
|
||||||
if (doc === undefined) {ConfiguredDevicesCollection.insert({deviceName: selectedEspName, type: selectedType});} else {
|
if (doc === undefined) {ConfiguredDevicesCollection.insert({deviceId: selectedEspName, type: selectedType});} else {
|
||||||
ConfiguredDevicesCollection.update({_id: doc._id}, {$set: {type: selectedType}});
|
ConfiguredDevicesCollection.update({_id: doc._id}, {$set: {type: selectedType}});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,7 @@ Meteor.startup(() => {
|
|||||||
return ConfiguredDevicesCollection.find();
|
return ConfiguredDevicesCollection.find();
|
||||||
})
|
})
|
||||||
|
|
||||||
//startMqttObserver()
|
startMqttObserver()
|
||||||
|
|
||||||
Meteor.methods({
|
Meteor.methods({
|
||||||
'mqttPublish'({ topic, payload }) {
|
'mqttPublish'({ topic, payload }) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user