From 622a7c70236bd360a92ff533b5527eb403a3ce51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Fri, 31 Jul 2026 11:40:29 +0400 Subject: [PATCH] v1.2.3: instance_ref shows cloud instances + bigger CRUD buttons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit scenario-form.js: - showScenarioEditor loads /api/instances/list alongside services - renderStepRow: non-create instance_ref dropdown shows: 🆕 outputs from previous create steps ☁ existing cloud instances filtered by service_id - Removed separate instance_uid text field (now in dropdown) scenario-list.js: - CRUD buttons: ✏📋🗑 bigger (13px, padding), vertical layout - Run button: full-width, left-aligned --- site/app.py | 2 +- site/static/js/scenario-form.js | 28 ++++++++++++++++++++-------- site/static/js/scenario-list.js | 16 ++++++++-------- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/site/app.py b/site/app.py index c771804..75f1193 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.2" +VERSION = "1.2.3" 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 0454b7f..47a3765 100644 --- a/site/static/js/scenario-form.js +++ b/site/static/js/scenario-form.js @@ -17,11 +17,15 @@ async function showScenarioEditor(def) { 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 = []; } + const [svcR, instR] = await Promise.all([ + fetch('/api/services').then(r => r.json()), + fetch('/api/instances/list').then(r => r.json()) + ]); + scenarioEditorState.services = svcR || []; + scenarioEditorState.cloudInstances = instR || []; + } catch (e) { scenarioEditorState.services = []; scenarioEditorState.cloudInstances = []; } renderEditor(); } @@ -110,10 +114,18 @@ function renderStepRow(idx, step) { if (op === 'create') { html += ``; } else if (op) { - let refOpts = ''; - prevOutputs.forEach(o => { refOpts += ``; }); - html += ``; - html += ``; + // Предыдущие output'ы + облачные инстансы этого сервиса + let refOpts = ''; + // output'ы из предыдущих create-шагов + prevOutputs.forEach(o => { refOpts += ``; }); + // Облачные инстансы того же сервиса + const cloudInsts = (st.cloudInstances || []).filter(i => i.serviceId == svcId && i.explainedStatus !== 'deleted'); + if (cloudInsts.length) refOpts += ''; + cloudInsts.forEach(i => { + const sel = i.instanceUid == ref ? 'selected' : ''; + refOpts += ``; + }); + html += ``; } html += ''; diff --git a/site/static/js/scenario-list.js b/site/static/js/scenario-list.js index 9d8c6e4..de08fd5 100644 --- a/site/static/js/scenario-list.js +++ b/site/static/js/scenario-list.js @@ -18,17 +18,17 @@ async function loadScenarios(){ fetch('/api/scenario/status').then(r=>r.json()), ]); let html=''; - html+=``; + html+=``; if(sr.length){ - html+='
'; + html+='
'; sr.forEach(s=>{ const seed = s.is_seed; - html+=`
`; - html+=``; - if(!seed) html+=``; - html+=``; - if(!seed) html+=``; - if(seed) html+=`seed`; + html+=`
`; + html+=``; + if(!seed) html+=``; + html+=``; + if(!seed) html+=``; + if(seed) html+=`seed`; html+=`
`; }); html+='
';