* improved serial console

* repaired /save
* removed yields (not allowed with async-web)
This commit is contained in:
lumapu 2022-09-08 22:52:51 +02:00
parent c32927a94e
commit 4561655d9d
9 changed files with 88 additions and 60 deletions

View file

@ -9,7 +9,10 @@
<body>
<h1>Serial Console</h1>
<div id="content" class="content">
<textarea rows="20" cols="90" id="serial" readonly></textarea>
<div class="serial">
<textarea id="serial" cols="80" rows="20" readonly></textarea><br/>
conntected: <span class="dot" id="connected"></span><input type="button" value="clear" class="btn" id="clear"/> <input type="button" value="autoscroll" class="btn" id="scroll"/>
</div>
</div>
<div id="footer">
<p class="left">&copy 2022</p>
@ -17,34 +20,43 @@
<p class="right" id="version"></p>
</div>
<script type="text/javascript">
var printTime = true;
var mPrintTime = true;
var mAutoScroll = true;
var con = document.getElementById("serial");
function parseSys(obj) {
document.getElementById("version").innerHTML = "Git SHA: " + obj["build"] + " :: " + obj["version"];
}
var con = document.getElementById("serial");
document.getElementById("clear").addEventListener("click", function() {
con.value = "";
});
document.getElementById("scroll").addEventListener("click", function() {
mAutoScroll = !mAutoScroll;
this.value = (mAutoScroll) ? "autoscroll" : "manual scoll";
});
if (!!window.EventSource) {
var source = new EventSource('/events');
source.addEventListener('open', function(e) {
//console.log("Events Connected");
document.getElementById("connected").style.backgroundColor = "#0c0";
}, false);
source.addEventListener('error', function(e) {
if (e.target.readyState != EventSource.OPEN) {
//console.log("Events Disconnected");
document.getElementById("connected").style.backgroundColor = "#f00";
}
}, false);
source.addEventListener('serial', function(e) {
if(printTime) {
if(mPrintTime) {
var d = new Date();
con.value += d.toLocaleTimeString() + ": ";
printTime = false;
mPrintTime = false;
}
if(e.data.includes('<rn>'))
printTime = true;
mPrintTime = true;
con.value += e.data.replace(/\<rn\>/g, '\r\n');
con.scrollTop = con.scrollHeight;

View file

@ -168,8 +168,8 @@
iv.appendChild(inp(id + i[0], obj[i[1]], i[3]));
}
iv.appendChild(lbl(id + "ActivePowerLimitConType", "Active Power Limit Control Type"));
iv.appendChild(sel(id + "ActivePowerLimitConType", [
iv.appendChild(lbl(id + "PowerLimitControl", "Active Power Limit Control Type"));
iv.appendChild(sel(id + "PowerLimitControl", [
[65535, "no power limit"],
[0, "absolute in Watt non persistent"],
[1, "absolute in Watt persistent"],
@ -179,7 +179,7 @@
for(var j of [["ModPwr", "ch_max_power", "Max Module Power (Wp)"], ["ModName", "ch_name", "Module Name"]]) {
iv.appendChild(lbl(id + j[0], j[2]));
d = div(j[0]);
d = div([j[0]]);
i = 0;
for(it of obj[j[1]]) {
d.appendChild(inp(id + j[0] + i, it, 4, ["text", "sh"]));

View file

@ -134,8 +134,14 @@ input.btn {
color: #fff;
border: 0px;
float: right;
margin: 10px 0 30px;
margin: 10px 0px 30px 10px;
padding: 7px 20px 7px 20px;
text-transform: uppercase;
cursor: pointer;
}
input.btn:hover {
background-color: #044e86;
}
input.cb {
@ -271,3 +277,20 @@ div.ModPwr, div.ModName {
width: 180px;
}
}
#serial {
width: 100%;
}
#content .serial {
max-width: 1000px;
}
.dot {
height: 15px;
width: 15px;
background-color: #f00;
border-radius: 50%;
display: inline-block;
margin-top: 15px;
}