Initial Headless Functions v2
This commit is contained in:
parent
615c5c9edd
commit
a41f765211
4 changed files with 90 additions and 36 deletions
|
|
@ -19,26 +19,39 @@ pub const DEFAULT_INDEX_HTML: &str = r#"
|
|||
<button id="btn-start">Start</button>
|
||||
<p id="status" class="status"></p>
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<h2>Konsole</h2>
|
||||
<pre id="console" class="console"></pre>
|
||||
</section>
|
||||
</main>
|
||||
<script src="/static/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
"#;
|
||||
|
||||
|
||||
pub const DEFAULT_APP_JS: &str = r#"
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const ip = document.getElementById('ip');
|
||||
const btn = document.getElementById('btn-start');
|
||||
const status = document.getElementById('status');
|
||||
const consoleEl = document.getElementById('console');
|
||||
|
||||
// SSE: Logs anhören
|
||||
const es = new EventSource('/api/logs');
|
||||
es.onmessage = (ev) => {
|
||||
consoleEl.textContent += ev.data + '\n';
|
||||
consoleEl.scrollTop = consoleEl.scrollHeight;
|
||||
};
|
||||
es.onerror = () => {
|
||||
// optional: Reconnect-Info
|
||||
};
|
||||
|
||||
btn.addEventListener('click', async () => {
|
||||
const val = (ip.value || '').trim();
|
||||
if (!val) {
|
||||
status.textContent = 'Bitte IP eingeben.';
|
||||
return;
|
||||
}
|
||||
|
||||
status.textContent = `Starte Erkennung für ${val} ...`;
|
||||
if (!val) { status.textContent = 'Bitte IP eingeben.'; return; }
|
||||
status.textContent = `Starte…`;
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/start', {
|
||||
|
|
@ -46,18 +59,17 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ ip: val })
|
||||
});
|
||||
|
||||
const text = await res.text();
|
||||
status.textContent = text || 'Anfrage gesendet.';
|
||||
status.textContent = text || 'OK';
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
status.textContent = 'Fehler beim Senden der Anfrage.';
|
||||
status.textContent = 'Fehler: ' + (err?.message || err);
|
||||
}
|
||||
});
|
||||
});
|
||||
"#;
|
||||
|
||||
|
||||
|
||||
pub const DEFAULT_STYLES_CSS: &str = r#"
|
||||
* { box-sizing: border-box; }
|
||||
body { margin: 0; font: 16px system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
|
||||
|
|
@ -74,4 +86,8 @@ button { margin-top: 12px; padding: 10px 14px; border-radius: 8px; border: 1px s
|
|||
background: #3056ff; color: white; cursor: pointer; }
|
||||
button:hover { filter: brightness(1.05); }
|
||||
.status { margin-top: 10px; color: #9db4ff; }
|
||||
|
||||
.console { margin: 0; margin-top: 10px; padding: 10px; height: 220px; overflow: auto;
|
||||
background: #0b0f19; border: 1px solid #1f2740; border-radius: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
white-space: pre-wrap; }
|
||||
"#;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue