54 lines
1.9 KiB
HTML
54 lines
1.9 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>
|
|
<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>
|
|
|
|
|