From bfa21accf53a23f610fb0a93884b4e97fce3d584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Fri, 31 Jul 2026 13:55:11 +0400 Subject: [PATCH] =?UTF-8?q?v1.2.11:=20scenario=20list=20=E2=80=94=20expand?= =?UTF-8?q?able=20steps=20+=20run=20confirmation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Click on scenario name → expands to show step details: operation → service_id (output/ref/uid) (params) - ▶ Запустить button inside expanded view - confirm('Запустить сценарий?') before running - CRUD buttons (✏📋🗑) with event.stopPropagation() - toggleScenarioSteps(defId): single-expand (closes others) --- site/app.py | 2 +- site/static/js/scenario-list.js | 45 +++++++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 6 deletions(-) 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');