diff --git a/site/app.py b/site/app.py index e60515a..c771804 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.1" +VERSION = "1.2.2" 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-form.js b/site/static/js/scenario-form.js index 704555d..0454b7f 100644 --- a/site/static/js/scenario-form.js +++ b/site/static/js/scenario-form.js @@ -1,56 +1,130 @@ -// scenario-form.js — общий редактор шагов сценария (create + edit) -let scenarioEditorState = null; // {defId, version, name, steps:[]} -// steps: [{service_id, operation, params: [["key","val"],...]}] +// scenario-form.js — модальный редактор сценариев +// Использует: params-render.js (renderParamRow, renderMapFixedRow, collectParams) +// Зависит от: utils.js (_esc), instances.js (currentSvcId) -function showScenarioEditor(def) { - const body = document.getElementById('scenario-body'); +let scenarioEditorState = null; // {defId, version, name, steps, services:[], opsCache:{}} +// step: {service_id, operation, output, instance_ref, instance_uid, params: [["k","v"],...]} + +async function showScenarioEditor(def) { scenarioEditorState = def ? { defId: def.id, version: def.version, name: def.name, steps: (def.steps || []).map(s => ({ - service_id: s.service_id, operation: s.operation, + service_id: s.service_id || '', operation: s.operation || '', + output: s.output || '', instance_ref: s.instance_ref || '', + instance_uid: s.instance_uid || '', params: Object.entries(s.params || {}) - })) - } : { defId: null, version: 1, name: '', steps: [] }; + })), + services: [], opsCache: {} + } : { defId: null, version: 1, name: '', steps: [], services: [], opsCache: {} }; + + // Загрузить список сервисов + try { + const r = await fetch('/api/services'); + scenarioEditorState.services = await r.json(); + } catch (e) { scenarioEditorState.services = []; } renderEditor(); } +function openModal(html) { + let modal = document.getElementById('scenario-modal'); + if (!modal) { + modal = document.createElement('div'); + modal.id = 'scenario-modal'; + modal.innerHTML = '
'; + document.body.appendChild(modal); + } + modal.style.display = 'block'; + document.getElementById('modal-content').innerHTML = html; +} + +function closeModal() { + const modal = document.getElementById('scenario-modal'); + if (modal) modal.style.display = 'none'; + loadScenarios(); +} + function renderEditor() { - const body = document.getElementById('scenario-body'); const st = scenarioEditorState; - let html = '