added mqtt log

This commit is contained in:
Paul
2019-08-16 21:49:52 +02:00
parent e12fa66462
commit ae766b09e1
11 changed files with 398 additions and 144 deletions

View File

@@ -158,7 +158,8 @@
<div class="alert alert-warning">
<h5><b>Warning!</b> This action <strong>cannot</strong> be undone. This will permanently
delete <strong>all
the settings and logs.</strong> Please make sure you've made a backup before resetting!</h5>
the settings and logs.</strong> Please make sure you've made a backup before
resetting!</h5>
</div>
<div class="modal-body">
<h5>Please type in the hostname of the device to confirm.</h5>

View File

@@ -107,7 +107,7 @@
<div class="row form-group">
<label class="col-xs-3">Serial Port<i style="margin-left: 10px;" class="glyphicon glyphicon-info-sign"
aria-hidden="true" data-toggle="popover" data-trigger="hover" data-placement="right"
data-content="Please choose if you want to enable Serial port for debugging"></i></label>
data-content="Serial port for console output directly via USB as well as Telnet"></i></label>
<div class="col-xs-9">
<form>
<label class="radio-inline">
@@ -224,7 +224,7 @@
<div class="row form-group">
<label class="col-xs-3">Heartbeat<i style="margin-left: 10px;" class="glyphicon glyphicon-info-sign"
aria-hidden="true" data-toggle="popover" data-trigger="hover" data-placement="right"
data-content="Please choose if you want to enable the MQTT heartbeat"></i></label>
data-content="enable/disable an automatic MQTT publish with system stats"></i></label>
<div class="col-xs-9">
<form>
<label class="radio-inline">
@@ -391,7 +391,7 @@
<br><br>
<legend>System Status</legend>
<br>
<div class="row text-center">
<div class="row text-left">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default table-responsive">
<table class="table table-hover table-striped table-condensed">
@@ -476,9 +476,15 @@
</td>
</tr>
</table>
<div class="panel-heading">
<div class="panel-title" id="mqttloghdr"></div>
</div>
<div>
<table id="mqttlogtable" class="table" data-paging="false" data-filtering="false"
data-sorting="false" data-editing="false" data-state="true"></table>
</div>
</div>
</div>
<br>
<br>
</div>
</div>

View File

@@ -346,8 +346,8 @@ function listStats() {
document.getElementById("uptime").innerHTML = ajaxobj.uptime;
document.getElementById("heap").innerHTML = ajaxobj.heap + " KB";
document.getElementById("heap").style.width = (ajaxobj.heap * 100) / 41 + "%";
document.getElementById("heap").innerHTML = ajaxobj.heap + " bytes";
document.getElementById("heap").style.width = (ajaxobj.heap * 100) / ajaxobj.initheap + "%";
colorStatusbar(document.getElementById("heap"));
document.getElementById("flash").innerHTML = ajaxobj.availsize + " KB";
@@ -380,6 +380,8 @@ function listStats() {
document.getElementById("mqttheartbeat").className = "label label-primary";
}
document.getElementById("mqttloghdr").innerHTML = "MQTT Publish Log: (topics are prefixed with <b>" + ajaxobj.mqttloghdr + "</b>)";
}
function getContent(contentname) {
@@ -605,6 +607,55 @@ function initEventTable() {
});
}
function initMQTTLogTable() {
var newlist = [];
for (var i = 0; i < ajaxobj.mqttlog.length; i++) {
var data = JSON.stringify(ajaxobj.mqttlog[i]);
newlist[i] = {};
newlist[i].options = {};
newlist[i].value = {};
newlist[i].value = JSON.parse(data);
newlist[i].options.classes = "warning";
newlist[i].options.style = "color: blue";
}
jQuery(function ($) {
window.FooTable.init("#mqttlogtable", {
columns: [{
"name": "time",
"title": "Last Published",
"style": { "min-width": "160px" },
"parser": function (value) {
if (value < 1563300000) {
return "(" + value + ")";
} else {
var comp = new Date();
value = Math.floor(value + ((comp.getTimezoneOffset() * 60) * -1));
var vuepoch = new Date(value * 1000);
var formatted = vuepoch.getUTCFullYear() +
"-" + twoDigits(vuepoch.getUTCMonth() + 1) +
"-" + twoDigits(vuepoch.getUTCDate()) +
" " + twoDigits(vuepoch.getUTCHours()) +
":" + twoDigits(vuepoch.getUTCMinutes()) +
":" + twoDigits(vuepoch.getUTCSeconds());
return formatted;
}
},
"breakpoints": "xs sm"
},
{
"name": "topic",
"title": "Topic",
},
{
"name": "payload",
"title": "Payload",
},
],
rows: newlist
});
});
}
function restartESP() {
inProgress("restart");
}
@@ -617,6 +668,7 @@ function socketMessageListener(evt) {
switch (obj.command) {
case "status":
ajaxobj = obj;
initMQTTLogTable();
getContent("#statuscontent");
break;
case "custom_settings":