Zakladna migracia na viacej senzorov

This commit is contained in:
2022-10-28 15:16:05 +02:00
parent 997aa81ff9
commit 5e521583af
12 changed files with 128091 additions and 20872 deletions

View File

@@ -21,6 +21,10 @@ class MeasurementController extends Controller
$startdate = $request->input('startdate',NULL);
$enddate = $request->input('enddate',NULL);
$host = $request->input('host','balkon');
$model = $request->input('model','bme280');
if (preg_match("/^[a-zA-Z0-9_]+/", $model) == 0) $model = 'bme280';
if (!in_array($type,$types)) $type = $types[0];
if ($startdate == NULL || $startdate == '') $startdate = "now()-1d";
else $startdate = sprintf("'%s'",Carbon::parse($startdate)->toDateTimeString());
@@ -28,7 +32,7 @@ class MeasurementController extends Controller
if ($enddate == NULL || $enddate == '') $enddate = "now()";
else $enddate = sprintf("'%s'",Carbon::parse($enddate)->toDateTimeString());
$q = sprintf("select time,value from bme280_value where host='%s' and type='%s' and time >= %s and time <= %s",$host,$type,$startdate,$enddate);
$q = sprintf("select time,value from %s_value where host='%s' and type='%s' and time >= %s and time <= %s",$model,$host,$type,$startdate,$enddate);
\Debugbar::info($q);
$result = \InfluxDB::query($q);
$points = $result->getPoints();
@@ -49,8 +53,13 @@ class MeasurementController extends Controller
// for t in ('temperature','humidity','pressure')
$a = [];
$host = $request->input('host','balkon');
$model = $request->input('model','bme280');
if (preg_match("/^[a-zA-Z0-9_]+/", $model) == 0) $model = 'bme280';
foreach (['temperature','humidity','pressure'] as $type) {
$q = sprintf("select * from bme280_value where host='%s' and type='%s' order by time desc limit 1",$host,$type);
$q = sprintf("select * from %s_value where host='%s' and type='%s' order by time desc limit 1",$model,$host,$type);
$result = \InfluxDB::query($q);
$points = $result->getPoints();
foreach ($points as $p) {
@@ -58,7 +67,7 @@ class MeasurementController extends Controller
$a["time"] = Carbon::createFromFormat("Y-m-d\TH:i:s.u+",$p["time"],'UTC')->toATOMString();
}
}
$q = sprintf("select * from esp32_value where host='%s' and type='voltage' order by time desc limit 1",$host,$type);
$q = sprintf("select * from %s_value where host='%s' and type='voltage' order by time desc limit 1",$model,$host,$type);
$result = \InfluxDB::query($q);
$points = $result->getPoints();
foreach ($points as $p) {

View File

@@ -21,6 +21,10 @@ class StatisticsController extends Controller
$enddate = $request->input('enddate',NULL);
$range = $request->input('range',NULL);
$host = $request->input('host','balkon');
$model = $request->input('model','bme280');
if (preg_match("/^[a-zA-Z0-9_]+/", $model) == 0) $model = 'bme280';
if (!in_array($type,$types)) $type = $types[0];
if ($startdate == NULL || $startdate == '') $startdate = "now()-1d";
else $startdate = sprintf("'%s'",Carbon::parse($startdate)->toDateTimeString());
@@ -35,7 +39,7 @@ class StatisticsController extends Controller
}
}
$q = sprintf("select time,min(value),max(value),mean(value),last(value) from bme280_value where host='%s' and type='%s' and time >= %s and time <= %s group by time(%s);",$host,$type,$startdate,$enddate,$range);
$q = sprintf("select time,min(value),max(value),mean(value),last(value) from %s_value where host='%s' and type='%s' and time >= %s and time <= %s group by time(%s);",$model,$host,$type,$startdate,$enddate,$range);
\Debugbar::info($q);
$result = \InfluxDB::query($q);
$points = $result->getPoints();

24919
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -2,26 +2,27 @@
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --disable-host-check --config=node_modules/laravel-mix/setup/webpack.config.js",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --config=node_modules/laravel-mix/setup/webpack.config.js"
"production": "mix --production"
},
"devDependencies": {
"axios": "^0.19",
"bootstrap": "^4.0.0",
"cross-env": "^7.0",
"jquery": "^3.2",
"laravel-mix": "^5.0.1",
"axios": "^0.21",
"bootstrap": "^4.6.0",
"jquery": "^1.9.1",
"laravel-mix": "^6.0.6",
"lodash": "^4.17.19",
"popper.js": "^1.12",
"resolve-url-loader": "^2.3.1",
"sass": "^1.20.1",
"sass-loader": "^8.0.0",
"vue": "^2.5.17",
"vue-template-compiler": "^2.6.10"
"popper.js": "^1.16.1",
"postcss": "^8.1.14",
"resolve-url-loader": "^3.1.2",
"sass": "^1.32.5",
"sass-loader": "^10.1.1",
"vue": "^2.6.12",
"vue-loader": "^15.10.0",
"vue-template-compiler": "^2.6.12"
},
"dependencies": {
"bootstrap-vue": "^2.21.2",

12754
public/css/app.css vendored

File diff suppressed because one or more lines are too long

98789
public/js/app.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -1,38 +1,38 @@
/*!
* Bootstrap v4.5.3 (https://getbootstrap.com/)
* Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Bootstrap v4.6.2 (https://getbootstrap.com/)
* Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
/*!
* Sizzle CSS Selector Engine v2.3.5
* https://sizzlejs.com/
* Sizzle CSS Selector Engine v2.2.1
* http://sizzlejs.com/
*
* Copyright JS Foundation and other contributors
* Copyright jQuery Foundation and other contributors
* Released under the MIT license
* https://js.foundation/
* http://jquery.org/license
*
* Date: 2020-03-14
* Date: 2015-10-17
*/
/*!
* Vue.js v2.6.12
* (c) 2014-2020 Evan You
* Vue.js v2.7.13
* (c) 2014-2022 Evan You
* Released under the MIT License.
*/
/*!
* jQuery JavaScript Library v3.5.1
* https://jquery.com/
* jQuery JavaScript Library v1.12.4
* http://jquery.com/
*
* Includes Sizzle.js
* https://sizzlejs.com/
* http://sizzlejs.com/
*
* Copyright JS Foundation and other contributors
* Copyright jQuery Foundation and other contributors
* Released under the MIT license
* https://jquery.org/license
* http://jquery.org/license
*
* Date: 2020-05-04T22:49Z
* Date: 2016-05-20T17:17Z
*/
/*!

38
resources/js/app.js vendored
View File

@@ -6,7 +6,7 @@
require('./bootstrap');
window.Vue = require('vue');
import Vue from 'vue';
window.moment = require('moment');
/**
@@ -51,14 +51,26 @@ Vue.use(CardPlugin);
import { BButton } from 'bootstrap-vue'
Vue.component('b-button', BButton);
import { BFormSelect } from 'bootstrap-vue'
Vue.component('b-form-select', BFormSelect)
import VuePictureSwipe from 'vue-picture-swipe';
import { data } from 'jquery';
Vue.component('vue-picture-swipe', VuePictureSwipe);
//(function () {
var app = new Vue({
el: '#app',
data: {
names: { balkon: "balkón", strecha:"strecha", decka: "decká"},
names: { balkon: "balkón", strecha: "strecha", decka: "decká", byt: "byt" },
sensormap: [
{ model: 'bme280', host: 'balkon', desc: 'Senzor na balkóne', camera: false },
{ model: 'bme280', host: 'decka', desc: 'Senzor v detskej izbe', camera: false },
{ model: 'bme280', host: 'strecha', desc: 'Senzor na streche', camera: true },
{ model: 'LYWSD03MMC', host: 'byt', desc: 'Senzor Xiaomi v byte', camera: false },
{ model: 'ThermoBeacon', host: 'byt', desc: 'Senzor Beacon v byte', camera: false }],
soptions: [],
si: 0, // Sensor index
tmin: -10,
tmax: 50,
temperature: null,
@@ -67,6 +79,7 @@ Vue.component('vue-picture-swipe', VuePictureSwipe);
enddate: null,
date4search: null,
host: 'balkon',
model: 'bme280',
componentKey: 0,
ti: 0, //Tab Index
graphShow: [],
@@ -109,6 +122,13 @@ Vue.component('vue-picture-swipe', VuePictureSwipe);
},
mounted: function () {
console.log('MOUNTED');
for (var i in this.sensormap) {
this.soptions.push({ value: i, text: this.sensormap[i].desc});
}
console.log('OPTIONS',this.soptions);
this.getData();
var that = this;
window.setInterval(function () {
@@ -125,10 +145,12 @@ Vue.component('vue-picture-swipe', VuePictureSwipe);
displayResults: function () {
this.getData();
},
sethost: function (host) {
this.host = host;
sethost: function (i) {
this.host = this.sensormap[i].host;
this.model = this.sensormap[i].model;
console.log('GET =',this.host,this.model);
this.getData();
console.log(host);
},
resizeGraph: function (i) {
console.log("RESIZE");
@@ -159,7 +181,8 @@ Vue.component('vue-picture-swipe', VuePictureSwipe);
axios.get('/data', {
params: {
host: this.host
host: this.host,
model: this.model
}
})
.then(function (response) {
@@ -228,7 +251,8 @@ Vue.component('vue-picture-swipe', VuePictureSwipe);
type: vts[t],
startdate: this.startdate,
enddate: this.enddate,
host: this.host
host: this.host,
model: this.model
}
})
.then(function (response) {

View File

@@ -35,7 +35,8 @@ export default {
startdate: this.fromdate,
enddate: this.todate,
range: this.range,
host: this.host
host: this.host,
model: this.model
}
})
.then(function (response) {

View File

@@ -85,7 +85,7 @@
<div class="content" id="app">
<div class="title m-b-md">
Teplomer @{{ names[host] }}
@{{ sensormap[ti].desc }}
</div>
<div>
@@ -93,12 +93,10 @@
<vue-thermometer class="justify-content-center col-sm-3" :value="temperature" :min="tmin" :max="tmax"></vue-thermometer>
<div class="col-sm-9" id="values">
<div>
<b-button variant="primary" v-on:click="sethost('balkon')">Balkón</b-button>
<b-button variant="secondary" v-on:click="sethost('decka')">Decká</b-button>
<b-button variant="success" v-on:click="sethost('strecha')">Strecha</b-button>
<b-form-select v-model="si" :options="soptions" v-on:change="sethost(si)"></b-form-select>
</div>
<vue-table-dynamic :params="params" :key="host"></vue-table-dynamic>
<vue-table-dynamic :params="params" :key="si"></vue-table-dynamic>
<ul>
<li>Čas: @{{time}}</li>
</ul>
@@ -136,13 +134,13 @@
<b-tabs card>
<b-tab title="Celá doba">
<div>Štatistika za celú dobu v grafe</div>
<stats-table :fromdate="startdate" :todate="enddate" :type="'temperature'" :key="componentKey" :host="host"></stats-table>
<stats-table :fromdate="startdate" :todate="enddate" :type="'temperature'" :key="componentKey" :host="host" :model="model"></stats-table>
</b-tab>
<b-tab title="Hodina">
<stats-table :fromdate="startdate" :todate="enddate" :type="'temperature'" :range="'1h'" :key="componentKey" :host="host"></stats-table>
<stats-table :fromdate="startdate" :todate="enddate" :type="'temperature'" :range="'1h'" :key="componentKey" :host="host" :model="model"></stats-table>
</b-tab>
<b-tab title="Deň" v-if="startdate">
<stats-table :fromdate="startdate" :todate="enddate" :type="'temperature'" :range="'1d'" :key="componentKey" :host="host"></stats-table>
<stats-table :fromdate="startdate" :todate="enddate" :type="'temperature'" :range="'1d'" :key="componentKey" :host="host" :model="model"></stats-table>
</b-tab>
</b-tabs>
</b-card>
@@ -153,13 +151,13 @@
<b-tabs card>
<b-tab title="Celá doba">
<div>Štatistika za celú dobu v grafe</div>
<stats-table :fromdate="startdate" :todate="enddate" :type="'humidity'" :key="componentKey" :host="host"></stats-table>
<stats-table :fromdate="startdate" :todate="enddate" :type="'humidity'" :key="componentKey" :host="host" :model="model"></stats-table>
</b-tab>
<b-tab title="Hodina">
<stats-table :fromdate="startdate" :todate="enddate" :type="'humidity'" :range="'1h'" :key="componentKey" :host="host"></stats-table>
<stats-table :fromdate="startdate" :todate="enddate" :type="'humidity'" :range="'1h'" :key="componentKey" :host="host" :model="model"></stats-table>
</b-tab>
<b-tab title="Deň" v-if="startdate">
<stats-table :fromdate="startdate" :todate="enddate" :type="'humidity'" :range="'1d'" :key="componentKey" :host="host"></stats-table>
<stats-table :fromdate="startdate" :todate="enddate" :type="'humidity'" :range="'1d'" :key="componentKey" :host="host" :model="model"></stats-table>
</b-tab>
</b-tabs>
</b-card>
@@ -170,13 +168,13 @@
<b-tabs card>
<b-tab title="Celá doba">
<div>Štatistika za celú dobu v grafe</div>
<stats-table :fromdate="startdate" :todate="enddate" :type="'pressure'" :key="componentKey" :host="host"></stats-table>
<stats-table :fromdate="startdate" :todate="enddate" :type="'pressure'" :key="componentKey" :host="host" :model="model"></stats-table>
</b-tab>
<b-tab title="Hodina">
<stats-table :fromdate="startdate" :todate="enddate" :type="'pressure'" :range="'1h'" :key="componentKey" :host="host"></stats-table>
<stats-table :fromdate="startdate" :todate="enddate" :type="'pressure'" :range="'1h'" :key="componentKey" :host="host" :model="model"></stats-table>
</b-tab>
<b-tab title="Deň" v-if="startdate">
<stats-table :fromdate="startdate" :todate="enddate" :type="'pressure'" :range="'1d'" :key="componentKey" :host="host"></stats-table>
<stats-table :fromdate="startdate" :todate="enddate" :type="'pressure'" :range="'1d'" :key="componentKey" :host="host" :model="model"></stats-table>
</b-tab>
</b-tabs>
</b-card>

2
webpack.mix.js vendored
View File

@@ -11,5 +11,5 @@ const mix = require('laravel-mix');
|
*/
mix.js('resources/js/app.js', 'public/js')
mix.js('resources/js/app.js', 'public/js').vue({ version: 2 })
.sass('resources/sass/app.scss', 'public/css');

12066
yarn.lock

File diff suppressed because it is too large Load Diff