97 lines
3.3 KiB
Rust
97 lines
3.3 KiB
Rust
pub const DEFAULT_INDEX_HTML: &str = r#"
|
||
<!doctype html>
|
||
<html lang="de">
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||
<title>Aurora Print — UI</title>
|
||
<link rel="stylesheet" href="/static/styles.css" />
|
||
</head>
|
||
<body>
|
||
<header>
|
||
<h1>Aurora Print</h1>
|
||
</header>
|
||
<main>
|
||
<section class="card">
|
||
<h2>Gerät erkennen</h2>
|
||
<label for="ip">IP-Adresse</label>
|
||
<input id="ip" type="text" placeholder="z.B. 192.168.1.50" />
|
||
<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');
|
||
|
||
btn.addEventListener('click', async () => {
|
||
const val = (ip.value || '').trim();
|
||
if (!val) { status.textContent = 'Bitte IP eingeben.'; return; }
|
||
|
||
status.textContent = 'Starte…';
|
||
|
||
try {
|
||
// 1) Job starten → job_id erhalten
|
||
const res = await fetch('/api/start', {
|
||
method: 'POST',
|
||
headers: { 'Content-Type': 'application/json' },
|
||
body: JSON.stringify({ ip: val })
|
||
});
|
||
const data = await res.json();
|
||
const jobId = data.job_id;
|
||
status.textContent = `Job: ${jobId}`;
|
||
consoleEl.textContent = '';
|
||
|
||
// 2) individuellen Log-Stream für diesen Job öffnen
|
||
const es = new EventSource(`/api/logs?job=${encodeURIComponent(jobId)}`);
|
||
es.onmessage = (ev) => {
|
||
consoleEl.textContent += ev.data + '\n';
|
||
consoleEl.scrollTop = consoleEl.scrollHeight;
|
||
};
|
||
es.onerror = () => {
|
||
// Stream beendet/Fehler – optional kennzeichnen
|
||
};
|
||
} catch (err) {
|
||
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;
|
||
background: #0b0f19; color: #e6eefc; }
|
||
header { padding: 16px 24px; border-bottom: 1px solid #1c2233; }
|
||
h1 { margin: 0; font-size: 20px; }
|
||
main { max-width: 720px; margin: 32px auto; padding: 0 16px; }
|
||
.card { background: #121829; border: 1px solid #1f2740; border-radius: 12px; padding: 16px;
|
||
box-shadow: 0 6px 18px rgba(0,0,0,0.25); }
|
||
label { display:block; margin: 8px 0 4px; color: #9db4ff; }
|
||
input { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid #34406a;
|
||
background: #0e1424; color: #e6eefc; }
|
||
button { margin-top: 12px; padding: 10px 14px; border-radius: 8px; border: 1px solid #3a5bff;
|
||
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; }
|
||
"#;
|