- 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()";
|
if ($enddate == NULL || $enddate == '') $enddate = "now()";
|
||||||
else $enddate = sprintf("'%s'",Carbon::parse($enddate)->toDateTimeString());
|
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);
|
\Debugbar::info($q);
|
||||||
$result = \InfluxDB::query($q);
|
$result = \InfluxDB::query($q);
|
||||||
$points = $result->getPoints();
|
$points = $result->getPoints();
|
||||||
$a = [];
|
$a = [];
|
||||||
foreach ($points as $p) {
|
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);
|
return response()->json($a);
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"axios": "^0.21",
|
"axios": "^0.21",
|
||||||
"bootstrap": "^4.6.0",
|
"bootstrap": "^4.6.0",
|
||||||
"jquery": "^1.9.1",
|
|
||||||
"laravel-mix": "^6.0.6",
|
"laravel-mix": "^6.0.6",
|
||||||
"lodash": "^4.17.19",
|
"lodash": "^4.17.19",
|
||||||
"popper.js": "^1.16.1",
|
"popper.js": "^1.16.1",
|
||||||
@@ -27,6 +26,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bootstrap-vue": "^2.21.2",
|
"bootstrap-vue": "^2.21.2",
|
||||||
"font-awesome": "^4.7.0",
|
"font-awesome": "^4.7.0",
|
||||||
|
"jquery": "^1.9.1",
|
||||||
"luxon": "^1.25.0",
|
"luxon": "^1.25.0",
|
||||||
"moment": "^2.29.1",
|
"moment": "^2.29.1",
|
||||||
"vue-datetime": "^1.0.0-beta.14",
|
"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 */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
||||||
/* harmony export */ });
|
/* harmony export */ });
|
||||||
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
|
||||||
props: ['fromdate', 'todate', 'type', 'range', 'host'],
|
props: ['fromdate', 'todate', 'type', 'range', 'host', 'model'],
|
||||||
name: 'Stats',
|
name: 'Stats',
|
||||||
data: function data() {
|
data: function data() {
|
||||||
return {
|
return {
|
||||||
@@ -2131,7 +2131,7 @@ __webpack_require__.r(__webpack_exports__);
|
|||||||
that.params.height = 400;
|
that.params.height = 400;
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
console.log(that.params.data);
|
||||||
@@ -2395,7 +2395,7 @@ var app = new vue__WEBPACK_IMPORTED_MODULE_0__["default"]({
|
|||||||
var that = this;
|
var that = this;
|
||||||
window.setInterval(function () {
|
window.setInterval(function () {
|
||||||
console.log("TIMER");
|
console.log("TIMER");
|
||||||
that.getData();
|
that.getData(); // ZOPTIALIZOVAT ABY BRAL IBA NOVE DATA
|
||||||
}, 300000);
|
}, 300000);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -2497,8 +2497,7 @@ var app = new vue__WEBPACK_IMPORTED_MODULE_0__["default"]({
|
|||||||
model: this.model
|
model: this.model
|
||||||
}
|
}
|
||||||
}).then(function (response) {
|
}).then(function (response) {
|
||||||
console.log("GET DATA");
|
console.log("GET DATA = ", response.config.params.type);
|
||||||
console.log(response.config.params.type);
|
|
||||||
var data = response.data.map(function (x) {
|
var data = response.data.map(function (x) {
|
||||||
return [moment(x[0]).toDate(), x[1]];
|
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;
|
var that = this;
|
||||||
window.setInterval(function () {
|
window.setInterval(function () {
|
||||||
console.log("TIMER");
|
console.log("TIMER");
|
||||||
that.getData();
|
that.getData(); // ZOPTIALIZOVAT ABY BRAL IBA NOVE DATA
|
||||||
}, 300000);
|
}, 300000);
|
||||||
|
|
||||||
},
|
},
|
||||||
@@ -256,8 +256,7 @@ var app = new Vue({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
console.log("GET DATA");
|
console.log("GET DATA = ",response.config.params.type);
|
||||||
console.log(response.config.params.type);
|
|
||||||
let data = response.data.map(x => [moment(x[0]).toDate(), x[1]]);
|
let data = response.data.map(x => [moment(x[0]).toDate(), x[1]]);
|
||||||
app.series[response.config.params.type] = data;
|
app.series[response.config.params.type] = data;
|
||||||
app.componentKey += 1;
|
app.componentKey += 1;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
props: ['fromdate','todate','type','range','host'],
|
props: ['fromdate','todate','type','range','host','model'],
|
||||||
name: 'Stats',
|
name: 'Stats',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -59,7 +59,8 @@ export default {
|
|||||||
that.params.height = 400;
|
that.params.height = 400;
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
console.log(that.params.data);
|
||||||
that.redraw += 1;
|
that.redraw += 1;
|
||||||
|
|||||||
@@ -85,7 +85,7 @@
|
|||||||
|
|
||||||
<div class="content" id="app">
|
<div class="content" id="app">
|
||||||
<div class="title m-b-md">
|
<div class="title m-b-md">
|
||||||
@{{ sensormap[ti].desc }}
|
@{{ sensormap[si].desc }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
Reference in New Issue
Block a user