Files
HadTavern/static/pipeline.html
T

60 lines
2.3 KiB
HTML

<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>НадTavern — Pipeline Editor (JSON)</title>
<link rel="icon" href="/favicon.ico" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<link rel="manifest" href="/site.webmanifest" />
<meta name="theme-color" content="#ffffff" />
<style>
body { font-family: Arial, sans-serif; margin: 24px; }
textarea { width: 100%; height: 70vh; }
pre { background: #111; color: #eee; padding: 12px; border-radius: 6px; }
.row { display: flex; gap: 16px; }
.col { flex: 1; }
</style>
</head>
<body>
<h1>Pipeline Editor (JSON)</h1>
<p>
Редактируйте JSON пайплайна. Нажмите "Сохранить" — используется немедленно.
<a href="/">Домой</a>
</p>
<div>
<button id="btn-load">Загрузить</button>
<button id="btn-save">Сохранить</button>
</div>
<textarea id="editor"></textarea>
<pre id="status"></pre>
<script>
async function loadPipeline() {
const res = await fetch('/admin/pipeline');
const json = await res.json();
document.getElementById('editor').value = JSON.stringify(json, null, 2);
setStatus('Загружено');
}
async function savePipeline() {
try {
const body = document.getElementById('editor').value;
JSON.parse(body);
const res = await fetch('/admin/pipeline', { method: 'POST', headers: {'Content-Type': 'application/json'}, body });
const out = await res.json();
setStatus('Сохранено: ' + JSON.stringify(out));
} catch (e) {
setStatus('Ошибка: ' + e.message);
}
}
function setStatus(t) { document.getElementById('status').textContent = t; }
document.getElementById('btn-load').onclick = loadPipeline;
document.getElementById('btn-save').onclick = savePipeline;
loadPipeline();
</script>
</body>
</html>