215 lines
5.8 KiB
HTML
215 lines
5.8 KiB
HTML
<!doctype html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>EVS Control Portal</title>
|
|
<style>
|
|
:root {
|
|
--bg: #f3f6f4;
|
|
--card: #ffffff;
|
|
--line: #d3ddd7;
|
|
--text: #1c2721;
|
|
--muted: #5d6c62;
|
|
--accent: #1f7a4f;
|
|
--accent-2: #16613f;
|
|
}
|
|
* { box-sizing: border-box; }
|
|
body {
|
|
margin: 0;
|
|
font-family: "Segoe UI", Tahoma, sans-serif;
|
|
background: linear-gradient(145deg, #eaf2ec, #f8fbf9);
|
|
color: var(--text);
|
|
}
|
|
.wrap {
|
|
max-width: 1100px;
|
|
margin: 20px auto;
|
|
padding: 0 14px;
|
|
}
|
|
.head {
|
|
background: var(--card);
|
|
border: 1px solid var(--line);
|
|
border-radius: 14px;
|
|
padding: 14px;
|
|
margin-bottom: 12px;
|
|
}
|
|
.head h1 {
|
|
margin: 0 0 6px;
|
|
font-size: 20px;
|
|
}
|
|
.meta {
|
|
color: var(--muted);
|
|
font-size: 13px;
|
|
}
|
|
.grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
|
|
gap: 12px;
|
|
}
|
|
.card {
|
|
background: var(--card);
|
|
border: 1px solid var(--line);
|
|
border-radius: 14px;
|
|
padding: 12px;
|
|
}
|
|
.card h2 {
|
|
margin: 0 0 10px;
|
|
font-size: 16px;
|
|
}
|
|
label {
|
|
display: block;
|
|
margin: 8px 0 4px;
|
|
font-size: 13px;
|
|
color: var(--muted);
|
|
}
|
|
input, select, textarea {
|
|
width: 100%;
|
|
border: 1px solid var(--line);
|
|
border-radius: 10px;
|
|
padding: 9px;
|
|
font: inherit;
|
|
background: #fff;
|
|
}
|
|
textarea { min-height: 120px; resize: vertical; }
|
|
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
|
|
button {
|
|
margin-top: 10px;
|
|
border: 0;
|
|
border-radius: 10px;
|
|
padding: 10px 12px;
|
|
font-weight: 600;
|
|
color: #fff;
|
|
background: var(--accent);
|
|
cursor: pointer;
|
|
}
|
|
button:hover { background: var(--accent-2); }
|
|
.log {
|
|
margin-top: 12px;
|
|
background: #101612;
|
|
color: #d8e7dc;
|
|
border-radius: 12px;
|
|
padding: 10px;
|
|
font-family: Consolas, monospace;
|
|
font-size: 12px;
|
|
min-height: 90px;
|
|
white-space: pre-wrap;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="wrap">
|
|
<div class="head">
|
|
<h1>EVS Control Portal</h1>
|
|
<div class="meta">MQTT: {{ mqtt_host }}:{{ mqtt_port }} | Base Topic: {{ base_topic }}/<device_id>/command</div>
|
|
<label>Device ID</label>
|
|
<input id="deviceId" value="esp32-evs-1">
|
|
</div>
|
|
|
|
<div class="grid">
|
|
<div class="card">
|
|
<h2>Status / Mode</h2>
|
|
<button onclick="sendCmd({cmd:'status'})">Status anfordern</button>
|
|
<div class="row">
|
|
<button onclick="sendCmd({cmd:'mode',value:'idle'})">Mode Idle</button>
|
|
<button onclick="sendCmd({cmd:'mode',value:'stream'})">Mode Stream</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<h2>IO Mode</h2>
|
|
<div class="row">
|
|
<button onclick="sendCmd({cmd:'io_mode',value:'mic'})">IO mic</button>
|
|
<button onclick="sendCmd({cmd:'io_mode',value:'spk'})">IO spk</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<h2>UDP Stream</h2>
|
|
<label>Target Host</label>
|
|
<input id="udpHost" value="10.100.3.247">
|
|
<label>Target Port</label>
|
|
<input id="udpPort" type="number" value="5004">
|
|
<div class="row">
|
|
<button onclick="sendUdp(true)">UDP Start</button>
|
|
<button onclick="sendCmd({cmd:'udp_stream',enabled:false})">UDP Stop</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<h2>Mic Gain</h2>
|
|
<label>Absoluter Wert</label>
|
|
<input id="gainValue" type="number" step="0.1" value="2.0">
|
|
<button onclick="setGain()">Set Gain</button>
|
|
<div class="row">
|
|
<button onclick="sendCmd({cmd:'mic_gain',action:'up',step:0.1})">Gain +0.1</button>
|
|
<button onclick="sendCmd({cmd:'mic_gain',action:'down',step:0.1})">Gain -0.1</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<h2>Raw JSON</h2>
|
|
<label>Payload (JSON Objekt)</label>
|
|
<textarea id="rawPayload">{"cmd":"status"}</textarea>
|
|
<button onclick="sendRaw()">Publish Raw</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="log" id="log"></div>
|
|
</div>
|
|
|
|
<script>
|
|
const logEl = document.getElementById("log");
|
|
|
|
function log(msg) {
|
|
const ts = new Date().toISOString();
|
|
logEl.textContent = `[${ts}] ${msg}\n` + logEl.textContent;
|
|
}
|
|
|
|
function getDeviceId() {
|
|
return (document.getElementById("deviceId").value || "").trim();
|
|
}
|
|
|
|
async function publish(payload) {
|
|
const deviceId = getDeviceId();
|
|
if (!deviceId) {
|
|
log("ERROR: device_id fehlt");
|
|
return;
|
|
}
|
|
const res = await fetch("/api/publish", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ device_id: deviceId, payload })
|
|
});
|
|
const body = await res.json();
|
|
if (!res.ok || !body.ok) {
|
|
log("FAIL: " + JSON.stringify(body));
|
|
} else {
|
|
log("OK topic=" + body.topic + " payload=" + JSON.stringify(body.payload));
|
|
}
|
|
}
|
|
|
|
function sendCmd(payload) { publish(payload); }
|
|
|
|
function sendUdp(enabled) {
|
|
const host = document.getElementById("udpHost").value.trim();
|
|
const port = parseInt(document.getElementById("udpPort").value, 10);
|
|
publish({ cmd: "udp_stream", enabled, target_host: host, target_port: port });
|
|
}
|
|
|
|
function setGain() {
|
|
const value = parseFloat(document.getElementById("gainValue").value);
|
|
publish({ cmd: "mic_gain", value });
|
|
}
|
|
|
|
function sendRaw() {
|
|
try {
|
|
const payload = JSON.parse(document.getElementById("rawPayload").value);
|
|
publish(payload);
|
|
} catch (e) {
|
|
log("ERROR: ungültiges JSON");
|
|
}
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|