v1.1.1: scrollable services + dynamic CREATE for any service

This commit is contained in:
2026-07-28 11:24:51 +04:00
parent 0b810fdee1
commit 12e3d12e09
3 changed files with 21 additions and 19 deletions
+19 -17
View File
@@ -26,28 +26,21 @@
* showStages() — отрисовка этапов выполнения операции (⏳/✅/❌)
*/
let svcInstances=[], selectedInst=null, selectedOp=null, pollTimer=null;
let currentSvcId=1; // динамический — загружается из /api/services
let currentSvcId=1; // динамический — обновляется при selectService()
const AUTOTEST_PREFIX='autotest-';
// Загрузка списка сервисов при старте
(async function initServices(){
try{
const r=await fetch('/api/services');
const svcList=await r.json();
if(!svcList||!svcList.length) return;
// Сохраняем глобально для UI переключения
window._svcList=svcList;
currentSvcId=svcList[0].svcId; // первый сервис по умолчанию
selectService(currentSvcId);
}catch(e){
selectService(1); // fallback — Болванка
}
})();
// Первый сервис из списка (рендерится Jinja2)
selectService(currentSvcId);
async function selectService(svcId){
currentSvcId=svcId;
selectedInst=null; selectedOp=null; stopPoll();
document.getElementById('params-card').style.display='none';
document.getElementById('stages-box').style.display='none';
// Подсветить активный сервис в боковой панели
document.querySelectorAll('.svc-item').forEach(e=>e.classList.remove('active'));
const svcEl=document.querySelector(`.svc-item[onclick*="${svcId}"]`);
if(svcEl) svcEl.classList.add('active');
const r=await fetch('/api/operations/'+svcId);
const d=await r.json();
@@ -97,11 +90,20 @@ function opClass(opName){
return '';
}
function startCreate(){
async function startCreate(){
selectedInst=null; stopPoll();
document.querySelectorAll('[data-iuid]').forEach(e=>e.classList.remove('active'));
document.querySelectorAll('.inst-ops').forEach(e=>e.classList.remove('open'));
showParams(18,'create');
// Найти svcOperationId для create у текущего сервиса
try{
const r=await fetch('/api/operations/'+currentSvcId);
const d=await r.json();
const createOp=d.operations.find(o=>o.operation==='create');
const opId=createOp?createOp.svcOperationId:18; // fallback — Болванка
showParams(opId,'create');
}catch(e){
showParams(18,'create'); // fallback
}
}
function makeCreateDisplayName(){