This commit is contained in:
2019-07-01 21:17:33 +02:00
parent dbca57d7e1
commit 761f766ea0
5 changed files with 18 additions and 14 deletions

View File

@@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>sensor-web-v2</title> <title>DHT22</title>
</head> </head>
<body> <body>
<noscript> <noscript>

View File

@@ -38,10 +38,8 @@ app.get('/type/:type/startDate/:startDate/endDate/:endDate/sample/:sample', asyn
$ne: NaN $ne: NaN
} }
} }
console.time()
try { try {
const docs = await db.collection('dht22').find(query).toArray() const docs = await db.collection('dht22').find(query).toArray()
console.timeEnd()
const sampledDocs = docs const sampledDocs = docs
.filter((value, index) => index % sample === 0) .filter((value, index) => index % sample === 0)
.map(doc => { .map(doc => {
@@ -61,6 +59,6 @@ function dateFromObjectId(objectId) {
return Math.floor(mongo.ObjectId(objectId).getTimestamp().getTime() / 1000) return Math.floor(mongo.ObjectId(objectId).getTimestamp().getTime() / 1000)
}; };
app.use(express.static(path.join(__dirname, 'dist'))) app.use(express.static(path.join(__dirname, '../dist')))
module.exports = app module.exports = app

View File

@@ -19,7 +19,7 @@ export default {
}, },
data() { data() {
return { return {
type: {}, type: null,
window: {} window: {}
} }
}, },
@@ -38,6 +38,7 @@ export default {
this.updateRoute() this.updateRoute()
}, },
updateRoute() { updateRoute() {
if (this.type) {
this.$router.push({ this.$router.push({
name: 'view', name: 'view',
params: { params: {
@@ -48,12 +49,14 @@ export default {
} }
} }
} }
}
</script> </script>
<style scoped> <style scoped>
#app { #app {
height: 100%; height: 100%;
} }
#app, .section { #app,
.section {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
flex-grow: 1; flex-grow: 1;

View File

@@ -31,7 +31,7 @@ export default {
try { try {
const [start, end] = [this.window.getStart(), this.window.getEnd()] const [start, end] = [this.window.getStart(), this.window.getEnd()]
const sample = Math.round(((end - start) / 60) / 288) || 1 const sample = Math.round(((end - start) / 60) / 288) || 1
const host = 'http://localhost:3000' const host = process.env.NODE_ENV === 'development' ? 'http://localhost:3000' : ''
const fetchUrl = `${host}/type/${this.type}/startDate/${start}/endDate/${end}/sample/${sample}` const fetchUrl = `${host}/type/${this.type}/startDate/${start}/endDate/${end}/sample/${sample}`
const response = await fetch(fetchUrl) const response = await fetch(fetchUrl)
this.data = await response.json() this.data = await response.json()

3
vue.config.js Normal file
View File

@@ -0,0 +1,3 @@
module.exports = {
productionSourceMap: false
}