- viac senzorov, oprava chyb ked nevracia hodnotu controller
This commit is contained in:
@@ -32,13 +32,15 @@ class MeasurementController extends Controller
|
||||
if ($enddate == NULL || $enddate == '') $enddate = "now()";
|
||||
else $enddate = sprintf("'%s'",Carbon::parse($enddate)->toDateTimeString());
|
||||
|
||||
$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);
|
||||
$q = sprintf("select time,mean(value) as v from %s_value where host='%s' and type='%s' and time >= %s and time <= %s group by time(%s) fill(linear)",$model,$host,$type,$startdate,$enddate,'5m');
|
||||
\Debugbar::info($q);
|
||||
$result = \InfluxDB::query($q);
|
||||
$points = $result->getPoints();
|
||||
$a = [];
|
||||
foreach ($points as $p) {
|
||||
$a[] = [ Carbon::createFromFormat("Y-m-d\TH:i:s.u+",$p["time"],'UTC'), $p["value"]];
|
||||
if (!isset($p["v"])) continue;
|
||||
$a[] = [ $p["time"], $p["v"]];
|
||||
// $a[] = [ Carbon::createFromFormat("Y-m-d\TH:i:s.u+",$p["time"],'UTC'), $p["v"]];
|
||||
}
|
||||
|
||||
return response()->json($a);
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
"devDependencies": {
|
||||
"axios": "^0.21",
|
||||
"bootstrap": "^4.6.0",
|
||||
"jquery": "^1.9.1",
|
||||
"laravel-mix": "^6.0.6",
|
||||
"lodash": "^4.17.19",
|
||||
"popper.js": "^1.16.1",
|
||||
@@ -27,6 +26,7 @@
|
||||
"dependencies": {
|
||||
"bootstrap-vue": "^2.21.2",
|
||||
"font-awesome": "^4.7.0",
|
||||
"jquery": "^1.9.1",
|
||||
"luxon": "^1.25.0",
|
||||
"moment": "^2.29.1",
|
||||
"vue-datetime": "^1.0.0-beta.14",
|
||||
|
||||
9
public/js/app.js
vendored
9
public/js/app.js
vendored
@@ -2085,7 +2085,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
||||
/* harmony export */ });
|
||||
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
|
||||
props: ['fromdate', 'todate', 'type', 'range', 'host'],
|
||||
props: ['fromdate', 'todate', 'type', 'range', 'host', 'model'],
|
||||
name: 'Stats',
|
||||
data: function data() {
|
||||
return {
|
||||
@@ -2131,7 +2131,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
that.params.height = 400;
|
||||
}
|
||||
} else {
|
||||
that.params.data.push(['Hodnota', response.data[0].min, response.data[0].max, response.data[0].mean.toFixed(2), response.data[0].last]);
|
||||
if (response.data.length > 0) that.params.data.push(['Hodnota', response.data[0].min, response.data[0].max, response.data[0].mean.toFixed(2), response.data[0].last]);
|
||||
}
|
||||
;
|
||||
console.log(that.params.data);
|
||||
@@ -2395,7 +2395,7 @@ var app = new vue__WEBPACK_IMPORTED_MODULE_0__["default"]({
|
||||
var that = this;
|
||||
window.setInterval(function () {
|
||||
console.log("TIMER");
|
||||
that.getData();
|
||||
that.getData(); // ZOPTIALIZOVAT ABY BRAL IBA NOVE DATA
|
||||
}, 300000);
|
||||
},
|
||||
methods: {
|
||||
@@ -2497,8 +2497,7 @@ var app = new vue__WEBPACK_IMPORTED_MODULE_0__["default"]({
|
||||
model: this.model
|
||||
}
|
||||
}).then(function (response) {
|
||||
console.log("GET DATA");
|
||||
console.log(response.config.params.type);
|
||||
console.log("GET DATA = ", response.config.params.type);
|
||||
var data = response.data.map(function (x) {
|
||||
return [moment(x[0]).toDate(), x[1]];
|
||||
});
|
||||
|
||||
5
resources/js/app.js
vendored
5
resources/js/app.js
vendored
@@ -133,7 +133,7 @@ var app = new Vue({
|
||||
var that = this;
|
||||
window.setInterval(function () {
|
||||
console.log("TIMER");
|
||||
that.getData();
|
||||
that.getData(); // ZOPTIALIZOVAT ABY BRAL IBA NOVE DATA
|
||||
}, 300000);
|
||||
|
||||
},
|
||||
@@ -256,8 +256,7 @@ var app = new Vue({
|
||||
}
|
||||
})
|
||||
.then(function (response) {
|
||||
console.log("GET DATA");
|
||||
console.log(response.config.params.type);
|
||||
console.log("GET DATA = ",response.config.params.type);
|
||||
let data = response.data.map(x => [moment(x[0]).toDate(), x[1]]);
|
||||
app.series[response.config.params.type] = data;
|
||||
app.componentKey += 1;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: ['fromdate','todate','type','range','host'],
|
||||
props: ['fromdate','todate','type','range','host','model'],
|
||||
name: 'Stats',
|
||||
data() {
|
||||
return {
|
||||
@@ -59,6 +59,7 @@ export default {
|
||||
that.params.height = 400;
|
||||
}
|
||||
} else {
|
||||
if (response.data.length > 0)
|
||||
that.params.data.push(['Hodnota',response.data[0].min,response.data[0].max,response.data[0].mean.toFixed(2),response.data[0].last]);
|
||||
};
|
||||
console.log(that.params.data);
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
|
||||
<div class="content" id="app">
|
||||
<div class="title m-b-md">
|
||||
@{{ sensormap[ti].desc }}
|
||||
@{{ sensormap[si].desc }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user