Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

www: show current power state in web-ui #378

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion mtda/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<div class="menu">
<div class="title" id="mtda_title">MTDA</div>
<ul class="nav">
<li><a href="#" id=power-toggle><i class="large material-icons">power</i></a></li>
<li><a href="#" id=power-toggle><i id=power-status-icon class="large material-icons">power</i></a></li>
<li><a href="#" id=keyboard-show><i class="large material-icons">keyboard</i></a></li>
<li id="mtda_status">Connecting...</li>
<li id="vnc_status">Loading Video</li>
Expand All @@ -96,6 +96,7 @@
<script type=text/javascript>
$(function() {
$('a#power-toggle').bind('click', function() {
document.getElementById("power-status-icon").innerHTML = "downloading"
$.getJSON('./power-toggle', function(data) {
// do nothing
});
Expand Down Expand Up @@ -133,6 +134,7 @@
const status = document.getElementById("mtda_status");
const version = document.getElementById("mtda_version");
const video = document.getElementById("video");
const power_status = document.getElementById("power-status-icon")

socket.on("console-output", function (data) {
term.write(data.output);
Expand Down Expand Up @@ -165,6 +167,14 @@
socket.on("disconnect", () => {
status.innerHTML = '<span style="color: #ff8383;"><b>Disconnected</b></span>';
});

socket.on("power-event", (data) => {
switch(data.event) {
case 'ON': power_status.innerHTML = "power_off"; break;
case 'OFF': power_status.innerHTML = "power"; break;
default: power_status.innerHTML = "help"
}
});
</script>
</body>
</html>
Loading