-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from mp-se/dev
Dev
- Loading branch information
Showing
11 changed files
with
168 additions
and
16 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
<meta name="description" content=""> | ||
<title>Keg Monitor</title> | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"> | ||
<style> | ||
.row-margin-10 { margin-top: 1.0em; } | ||
</style> | ||
</head> | ||
|
||
<body class="py-4"> | ||
|
||
<!-- START MENU --> | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script> | ||
|
||
<!-- START BODY --> | ||
|
||
<div class="container row-margin-10"> | ||
|
||
<div class="accordion row-margin-10" id="accordion"> | ||
<div class="accordion-item"> | ||
<h2 class="accordion-header" id="headingTest"> | ||
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTest" aria-expanded="true" aria-controls="collapseTest"> | ||
<b>Serial Log</b> | ||
</button> | ||
</h2> | ||
<div id="collapseTest" class="accordion-collapse collapse show" aria-labelledby="headingTest" data-bs-parent="#accordion"> | ||
<div class="accordion-body"> | ||
<div class="collapse row-margin-10 show" id="collapseLog"> | ||
<div class="card card-body"> | ||
<pre><code class="card-text" id="logContent" data-bs-toggle="tooltip" title="Shows the serial .">Connecting to websocket, please wait...</code></pre> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
|
||
<script> | ||
let log = ""; | ||
let maxLog = 50; | ||
|
||
connectSocket(); | ||
|
||
function connectSocket() { | ||
console.log("Attempting to connect to websocket"); | ||
socket = new WebSocket(`ws://${location.host}/serialws`); | ||
// socket = new WebSocket("ws://192.168.1.136/serialws"); | ||
|
||
socket.onopen = function(e) { | ||
log = log + "Websocket established\n"; | ||
document.getElementById("logContent").innerHTML = log; | ||
}; | ||
|
||
socket.onmessage = function(event) { | ||
log = log + event.data; | ||
list = log.split("\n"); | ||
|
||
while(list.length > maxLog) { | ||
list.shift(); | ||
} | ||
|
||
log = list.join('\n'); | ||
document.getElementById("logContent").innerHTML = log; | ||
}; | ||
|
||
socket.onclose = function(event) { | ||
if (event.wasClean) { | ||
console.log(`Connection closed cleanly, code=${event.code} reason=${event.reason}`); | ||
} else { | ||
console.log('Connection died'); | ||
} | ||
|
||
log = log + "Websocket closed/died\n"; | ||
document.getElementById("logContent").innerHTML = log; | ||
setTimeout( function() { connectSocket(); }, 2000 ); | ||
}; | ||
|
||
socket.onerror = function(error) { | ||
console.log(error); | ||
}; | ||
} | ||
|
||
</script> | ||
|
||
<!-- START FOOTER --> | ||
|
||
<div class="container themed-container bg-primary text-light row-margin-10">(C) Copyright 2023 Magnus Persson</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="description" content=""><title>Keg Monitor</title><link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"><style>.row-margin-10{margin-top:1em}</style></head><body class="py-4"><!-- START MENU --><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script><!-- START BODY --><div class="container row-margin-10"><div class="accordion row-margin-10" id="accordion"><div class="accordion-item"><h2 class="accordion-header" id="headingTest"><button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTest" aria-expanded="true" aria-controls="collapseTest"><b>Serial Log</b></button></h2><div id="collapseTest" class="accordion-collapse collapse show" aria-labelledby="headingTest" data-bs-parent="#accordion"><div class="accordion-body"><div class="collapse row-margin-10 show" id="collapseLog"><div class="card card-body"><pre><code class="card-text" id="logContent" data-bs-toggle="tooltip" title="Shows the serial .">Connecting to websocket, please wait...</code></pre></div></div></div></div></div></div></div><script>let log = ""; | ||
let maxLog = 50; | ||
|
||
connectSocket(); | ||
|
||
function connectSocket() { | ||
console.log("Attempting to connect to websocket"); | ||
socket = new WebSocket(`ws://${location.host}/serialws`); | ||
// socket = new WebSocket("ws://192.168.1.136/serialws"); | ||
|
||
socket.onopen = function(e) { | ||
log = log + "Websocket established\n"; | ||
document.getElementById("logContent").innerHTML = log; | ||
}; | ||
|
||
socket.onmessage = function(event) { | ||
log = log + event.data; | ||
list = log.split("\n"); | ||
|
||
while(list.length > maxLog) { | ||
list.shift(); | ||
} | ||
|
||
log = list.join('\n'); | ||
document.getElementById("logContent").innerHTML = log; | ||
}; | ||
|
||
socket.onclose = function(event) { | ||
if (event.wasClean) { | ||
console.log(`Connection closed cleanly, code=${event.code} reason=${event.reason}`); | ||
} else { | ||
console.log('Connection died'); | ||
} | ||
|
||
log = log + "Websocket closed/died\n"; | ||
document.getElementById("logContent").innerHTML = log; | ||
setTimeout( function() { connectSocket(); }, 2000 ); | ||
}; | ||
|
||
socket.onerror = function(error) { | ||
console.log(error); | ||
}; | ||
}</script><!-- START FOOTER --><div class="container themed-container bg-primary text-light row-margin-10">(C) Copyright 2023 Magnus Persson</div></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters