diff --git a/site/app.py b/site/app.py index fd8b154..783244e 100644 --- a/site/app.py +++ b/site/app.py @@ -19,7 +19,7 @@ from routes.api_scenario_run import bp_run as api_scenario_run_bp from routes.api_scenario_defs import bp_defs as api_scenario_defs_bp # Версия — меняется при КАЖДОМ изменении кода. Показывается в топбаре UI. -VERSION = "1.2.10" +VERSION = "1.2.11" app = Flask(__name__, template_folder="templates", static_folder="static") app.config["NUBES_API_ENDPOINT"] = os.getenv("NUBES_API_ENDPOINT", "https://lk-api-gateway-test.ngcloud.ru/api/v1/svc") diff --git a/site/static/js/scenario-list.js b/site/static/js/scenario-list.js index 9a16ef2..b7c924e 100644 --- a/site/static/js/scenario-list.js +++ b/site/static/js/scenario-list.js @@ -23,13 +23,17 @@ async function loadScenarios(){ html+='
'; sr.forEach(s=>{ const seed = s.is_seed; - html+=`
`; - html+=``; - if(!seed) html+=``; - html+=``; - if(!seed) html+=``; + html+=`
`; + html+=`
`; + html+=`${_esc(s.name)}`; + html+=`${s.steps} шагов`; + if(!seed) html+=``; + html+=``; + if(!seed) html+=``; if(seed) html+=`seed`; html+=`
`; + html+=``; + html+=`
`; }); html+='
'; }else{ @@ -49,8 +53,39 @@ async function loadScenarios(){ }catch(e){body.innerHTML='Ошибка загрузки';} } +async function toggleScenarioSteps(defId) { + const el = document.getElementById('scenario-steps-' + defId); + if (!el) return; + if (el.style.display === 'block') { el.style.display = 'none'; return; } + // Загрузить шаги + try { + const r = await fetch('/api/scenario/definitions/' + defId); + const def = await r.json(); + if (def.error) return; + const steps = def.steps || []; + let html = '
'; + steps.forEach((s, i) => { + const svcName = s.service_id ? 'сервис ' + s.service_id : '?'; + html += `
${i+1}. ${_esc(s.operation)} → ${svcName}`; + if (s.output) html += ` (${_esc(s.output)})`; + if (s.instance_ref) html += ` → ${_esc(s.instance_ref)}`; + if (s.instance_uid) html += ` → ${_esc(s.instance_uid.substring(0,8))}...`; + const params = Object.entries(s.params || {}); + if (params.length) html += ' (' + params.map(([k,v]) => k+'='+v).join(', ') + ')'; + html += '
'; + }); + html += ``; + html += '
'; + el.innerHTML = html; + el.style.display = 'block'; + // Закрыть другие + document.querySelectorAll('[id^="scenario-steps-"]').forEach(e => { if (e !== el) e.style.display = 'none'; }); + } catch (e) {} +} + async function runScenario(defId){ if(busy){ return; } + if(!confirm('Запустить сценарий?')) return; busy=true; stopScenarioPoll(); const body=document.getElementById('scenario-body');