mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-19 14:08:57 +03:00
Fix reloading of data file (#1635)
* Update data.html * fixed * show link to graph Co-authored-by: CaCO3 <caco@ruinelli.ch>
This commit is contained in:
@@ -25,7 +25,7 @@
|
|||||||
flex: 0 1 auto;
|
flex: 0 1 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
#log {
|
#data {
|
||||||
font-family: 'Courier New', Courier, monospace;
|
font-family: 'Courier New', Courier, monospace;
|
||||||
font-size: small;
|
font-size: small;
|
||||||
}
|
}
|
||||||
@@ -37,54 +37,36 @@
|
|||||||
<button onClick="reload();">Reload</button>
|
<button onClick="reload();">Reload</button>
|
||||||
<button onClick="window.open('datafileact');">Show full data</button>
|
<button onClick="window.open('datafileact');">Show full data</button>
|
||||||
<button onClick="window.location.href = 'fileserver/log/data/'">Show older data files</button>
|
<button onClick="window.location.href = 'fileserver/log/data/'">Show older data files</button>
|
||||||
|
<a href="graph.html" target="_self">Show graph</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="row content" id="log"><br><br><br><b>Loading Logfile, please wait...</b></div>
|
<div class="row content" id="data"><br><br><br><b>Loading Data file, please wait...</b></div>
|
||||||
<div class="row footer">
|
<div class="row footer">
|
||||||
<button onClick="reload();">Reload</button>
|
<button onClick="reload();">Reload</button>
|
||||||
<button onClick="window.open('datafileact');">Show full data</button>
|
<button onClick="window.open('datafileact');">Show full data</button>
|
||||||
<button onClick="window.location.href = 'fileserver/log/data/'">Show older data files</button>
|
<button onClick="window.location.href = 'fileserver/log/data/'">Show older data files</button>
|
||||||
|
<a href="graph.html" target="_self">Show graph</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function reload() {
|
function reload() {
|
||||||
// document.getElementById('log').innerHTML += "<br><b>Reloading...<b><br><br>";
|
document.getElementById('data').innerHTML += "<br><b>Reloading...<b><br><br>";
|
||||||
document.getElementById('log').innerHTML += "<b>Reloading...</b>";
|
|
||||||
window.scrollBy(0,document.body.scrollHeight);
|
window.scrollBy(0,document.body.scrollHeight);
|
||||||
funcRequest('log');
|
funcRequest('data');
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function processLogLine(line, index, arr) {
|
|
||||||
if (line.includes("<WRN>")) {
|
|
||||||
arr[index] = "<span style=\"color:#e83c00\">" + line + "</span>";
|
|
||||||
}
|
|
||||||
else if (line.includes("<ERR>")) {
|
|
||||||
arr[index] = "<span style=\"color:red\"><b>" + line + "</b></span>";
|
|
||||||
}
|
|
||||||
else if (line.includes("<DBG>")) {
|
|
||||||
arr[index] = "<span style=\"color:gray\">" + line + "</span>";
|
|
||||||
}
|
|
||||||
|
|
||||||
arr[index] += "<br>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function funcRequest(url){
|
async function funcRequest(url){
|
||||||
await fetch(url)
|
await fetch(url)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
document.getElementById("log").innerHTML = "HTTP error " + res.status;
|
document.getElementById("data").innerHTML = "HTTP error " + res.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.text();
|
return res.text();
|
||||||
})
|
})
|
||||||
.then((log) => {
|
.then((data) => {
|
||||||
log = log.replace(/</g, "<").replace(/>/g, ">");
|
document.getElementById('data').innerHTML = "<br>" + data.split("\n").join("\n<br>") + " ";
|
||||||
logArr = log.split("\n");
|
|
||||||
logArr.forEach(processLogLine);
|
|
||||||
|
|
||||||
document.getElementById('log').innerHTML = "<br>" + logArr.join("\n") + " ";
|
|
||||||
|
|
||||||
window.scrollBy(0,document.body.scrollHeight);
|
window.scrollBy(0,document.body.scrollHeight);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user