v1.1.50: scenario_definitions DB+CRUD, seed, runner from DB, 409 lock, UI definitions, drop config.yaml scenarios
This commit is contained in:
+5
-5
@@ -491,11 +491,11 @@ async function loadScenarios(){
|
||||
if(sr.length){
|
||||
html+='<div style="display:flex;flex-wrap:wrap;gap:4px;margin-bottom:4px;">';
|
||||
sr.forEach(s=>{
|
||||
html+=`<button class="btn btn-sm" style="font-size:11px;" onclick="runScenario('${_esc(s.name)}')">▶ ${_esc(s.name)} <span style="color:var(--muted);">(${s.steps} шагов)</span></button>`;
|
||||
html+=`<button class="btn btn-sm" style="font-size:11px;" onclick="runScenario(${s.id})">▶ ${_esc(s.name)} <span style="color:var(--muted);">(${s.steps} шагов)</span></button>`;
|
||||
});
|
||||
html+='</div>';
|
||||
}else{
|
||||
html+='<span style="color:var(--muted);font-size:11px;">Нет сценариев в config.yaml</span>';
|
||||
html+='<span style="color:var(--muted);font-size:11px;">Нет сценариев в БД</span>';
|
||||
}
|
||||
// Последний запуск
|
||||
if(srHistory && srHistory.length){
|
||||
@@ -509,14 +509,14 @@ async function loadScenarios(){
|
||||
}catch(e){body.innerHTML='<span style="color:var(--destructive);font-size:11px;">Ошибка загрузки</span>';}
|
||||
}
|
||||
|
||||
async function runScenario(name){
|
||||
async function runScenario(defId){
|
||||
if(busy){ return; }
|
||||
busy=true;
|
||||
stopScenarioPoll();
|
||||
const body=document.getElementById('scenario-body');
|
||||
body.innerHTML=`<div style="font-size:11px;">⏳ Запуск сценария ${_esc(name)}...</div>`;
|
||||
body.innerHTML=`<div style="font-size:11px;">⏳ Запуск...</div>`;
|
||||
try{
|
||||
const r=await fetch('/api/scenario/run',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({scenario:name})});
|
||||
const r=await fetch('/api/scenario/run',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({definition_id:defId})});
|
||||
const d=await r.json();
|
||||
if(d.error){ body.innerHTML=`<span style="color:var(--destructive);">Ошибка: ${_esc(d.error)}</span>`; busy=false; return; }
|
||||
const runId=d.run_id;
|
||||
|
||||
Reference in New Issue
Block a user