242 lines
6.5 KiB
HTML
242 lines
6.5 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<link href="bootstrap.min.css" rel="stylesheet" />
|
|
<script src="bootstrap.bundle.min.js"></script>
|
|
<script defer src="windows.js"></script>
|
|
<script defer src="alpinejs.min.js"></script>
|
|
|
|
<style>
|
|
[x-cloak] {
|
|
display: none !important;
|
|
}
|
|
|
|
body {
|
|
background-color: #f8f9fa;
|
|
background-image:
|
|
linear-gradient(90deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px),
|
|
linear-gradient(rgba(0, 0, 0, 0.03) 1px, transparent 1px);
|
|
background-size: 20px 20px;
|
|
height: 100vh;
|
|
margin: 0;
|
|
padding-top: 56px; /* Space for navbar */
|
|
overflow: hidden;
|
|
}
|
|
|
|
.drag-handle {
|
|
cursor: move;
|
|
}
|
|
.card[style*="cursor: move"] {
|
|
transition: none;
|
|
}
|
|
|
|
.navbar {
|
|
z-index: 2000; /* Above windows */
|
|
}
|
|
|
|
.ws-indicator {
|
|
width: 12px;
|
|
height: 12px;
|
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
|
transition: all 0.3s ease;
|
|
}
|
|
.glow-success {
|
|
box-shadow: 0 0 10px #198754;
|
|
}
|
|
.glow-danger {
|
|
box-shadow: 0 0 10px #dc3545;
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
document.addEventListener("alpine:init", () => {
|
|
Alpine.store("sys", {
|
|
ws_connected: false,
|
|
adapters: ["/dev/ttyUSB0"],
|
|
selected_adapter: "",
|
|
baudrates: ["115200", "916000"],
|
|
selected_baudrate: "",
|
|
uart_connected: false,
|
|
});
|
|
});
|
|
</script>
|
|
|
|
<script>
|
|
let socket;
|
|
|
|
function connectWS() {
|
|
socket = new WebSocket("ws://" + window.location.host + "/ws");
|
|
|
|
socket.onopen = () => {
|
|
console.log("[open] Connection established");
|
|
Alpine.store("sys").ws_connected = true;
|
|
};
|
|
|
|
socket.onmessage = (event) => {
|
|
try {
|
|
let mes = JSON.parse(event.data);
|
|
if (mes && mes.cmd === "value") {
|
|
Alpine.store(mes.name, mes.value);
|
|
}
|
|
} catch (e) {
|
|
console.log("Invalid JSON:", event.data);
|
|
}
|
|
};
|
|
|
|
socket.onclose = () => {
|
|
console.log("[close] Connection died");
|
|
Alpine.store("sys").ws_connected = false;
|
|
setTimeout(connectWS, 2000);
|
|
};
|
|
|
|
socket.onerror = (error) => {
|
|
console.log("[error]");
|
|
socket.close();
|
|
};
|
|
}
|
|
|
|
connectWS();
|
|
</script>
|
|
</head>
|
|
|
|
<body x-data>
|
|
<!-- Top Navbar -->
|
|
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top shadow">
|
|
<div class="container-fluid">
|
|
<a class="navbar-brand fw-bold" href="#">
|
|
<span class="text-primary">Alox</span> Debug Tool
|
|
</a>
|
|
|
|
<div class="d-flex align-items-center gap-2">
|
|
<span class="text-light small opacity-75">Websocket:</span>
|
|
<div
|
|
class="rounded-circle ws-indicator"
|
|
:class="$store.sys.ws_connected ? 'bg-success glow-success' : 'bg-danger glow-danger'"
|
|
></div>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<!-- UART Configuration Window -->
|
|
<yet-window
|
|
id="uart_config"
|
|
title="UART Configuration"
|
|
x="50"
|
|
y="80"
|
|
width="400px"
|
|
>
|
|
<label class="form-label small fw-bold text-uppercase text-muted"
|
|
>Interface</label
|
|
>
|
|
<div
|
|
class="input-group mb-3"
|
|
x-data="{ open: false }"
|
|
@click.outside="open = false"
|
|
>
|
|
<button
|
|
class="btn btn-outline-secondary dropdown-toggle"
|
|
type="button"
|
|
@click="open = !open"
|
|
:disabled="$store.sys.uart_connected"
|
|
>
|
|
Adapter
|
|
</button>
|
|
<ul class="dropdown-menu" :class="{ 'show': open }" x-show="open">
|
|
<template x-for="adapter in $store.sys.adapters">
|
|
<li>
|
|
<button
|
|
class="dropdown-item"
|
|
type="button"
|
|
x-text="adapter"
|
|
@click="$store.sys.selected_adapter = adapter; open = false"
|
|
></button>
|
|
</li>
|
|
</template>
|
|
</ul>
|
|
<input
|
|
type="text"
|
|
class="form-control bg-light"
|
|
readonly
|
|
:value="$store.sys.selected_adapter || 'Select Interface...'"
|
|
/>
|
|
</div>
|
|
|
|
<label class="form-label small fw-bold text-uppercase text-muted"
|
|
>Baudrate</label
|
|
>
|
|
<div
|
|
class="input-group mb-4"
|
|
x-data="{ open: false }"
|
|
@click.outside="open = false"
|
|
>
|
|
<button
|
|
class="btn btn-outline-secondary dropdown-toggle"
|
|
type="button"
|
|
@click="open = !open"
|
|
:disabled="$store.sys.uart_connected"
|
|
>
|
|
Speed
|
|
</button>
|
|
<ul class="dropdown-menu" :class="{ 'show': open }" x-show="open">
|
|
<template x-for="rate in $store.sys.baudrates">
|
|
<li>
|
|
<button
|
|
class="dropdown-item"
|
|
type="button"
|
|
x-text="rate"
|
|
@click="$store.sys.selected_baudrate = rate; open = false"
|
|
></button>
|
|
</li>
|
|
</template>
|
|
</ul>
|
|
<input
|
|
type="text"
|
|
class="form-control bg-light"
|
|
readonly
|
|
:value="$store.sys.selected_baudrate || 'Select Baudrate...'"
|
|
/>
|
|
</div>
|
|
|
|
<div class="d-grid">
|
|
<button
|
|
x-show="!$store.sys.uart_connected"
|
|
class="btn btn-primary btn-lg"
|
|
type="button"
|
|
:disabled="!$store.sys.selected_adapter || !$store.sys.selected_baudrate"
|
|
@click="socket.send(JSON.stringify({cmd: 'connect', adapter: $store.sys.selected_adapter, baudrate: parseInt($store.sys.selected_baudrate)}))"
|
|
>
|
|
Connect to UART
|
|
</button>
|
|
<button
|
|
x-show="$store.sys.uart_connected"
|
|
x-cloak
|
|
class="btn btn-danger btn-lg"
|
|
type="button"
|
|
@click="socket.send(JSON.stringify({cmd: 'disconnect'}))"
|
|
>
|
|
Disconnect
|
|
</button>
|
|
</div>
|
|
</yet-window>
|
|
|
|
<!-- UART Log Window -->
|
|
<yet-window
|
|
id="uart_log"
|
|
title="UART Log"
|
|
x="500"
|
|
y="80"
|
|
width="550px"
|
|
header-class="bg-primary text-white"
|
|
>
|
|
<div
|
|
class="bg-dark text-success font-monospace small p-2 rounded shadow-inner"
|
|
style="height: 400px; overflow-y: auto"
|
|
>
|
|
<div class="text-muted small mt-2">
|
|
// UART log data will appear here...
|
|
</div>
|
|
</div>
|
|
</yet-window>
|
|
</body>
|
|
</html>
|