v1.0.92: Steps 5-9 — dynamic services, PostgreSQL history, /api/history

This commit is contained in:
2026-07-27 22:59:52 +04:00
parent 4952f8b096
commit d95afc60e3
7 changed files with 219 additions and 9 deletions
+21 -8
View File
@@ -12,7 +12,7 @@
* selectedInst — UID выбранного инстанса (null если не выбран)
* selectedOp — {opId, opName, svcId} выбранная операция
* pollTimer — setInterval таймер поллинга статуса операции
* SVC_ID = 1 — фиксированный сервис (Болванка)
* currentSvcId — ID текущего выбранного сервиса (по умолчанию 1 = Болванка)
* AUTOTEST_PREFIX — префикс имён autotest-инстансов
*
* Потоки:
@@ -26,10 +26,23 @@
* showStages() — отрисовка этапов выполнения операции (⏳/✅/❌)
*/
let svcInstances=[], selectedInst=null, selectedOp=null, pollTimer=null;
const SVC_ID=1;
let currentSvcId=1; // динамический — загружается из /api/services
const AUTOTEST_PREFIX='autotest-';
selectService(SVC_ID);
// Загрузка списка сервисов при старте
(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 — Болванка
}
})();
async function selectService(svcId){
selectedInst=null; selectedOp=null; stopPoll();
@@ -65,7 +78,7 @@ async function toggleInstance(iuid){
if(opsEl.classList.contains('open')){opsEl.classList.remove('open');return;}
document.querySelectorAll('.inst-ops').forEach(e=>e.classList.remove('open'));
const r=await fetch('/api/operations/'+SVC_ID);
const r=await fetch('/api/operations/'+currentSvcId);
const d=await r.json();
const ops=d.operations.filter(o=>o.operation!=='reconcile'&&o.operation!=='create');
opsEl.innerHTML=ops.map(o=>
@@ -98,7 +111,7 @@ function makeCreateDisplayName(){
function runOp(opName,opId){
stopPoll();
selectedOp={opId,opName,svcId:SVC_ID};
selectedOp={opId,opName,svcId:currentSvcId};
if(opName==='modify'){
showParams(opId,opName);
}else{
@@ -114,7 +127,7 @@ function findInstName(){
}
function showParams(opId,opName){
selectedOp={opId,opName,svcId:SVC_ID};
selectedOp={opId,opName,svcId:currentSvcId};
document.getElementById('params-card').style.display='block';
document.getElementById('stages-box').style.display='none';
document.getElementById('test-status').textContent='';
@@ -232,7 +245,7 @@ async function executeOp(params){
try{
const r=await fetch('/api/test',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({
serviceId:SVC_ID,
serviceId:currentSvcId,
operation:selectedOp.opName,
svcOperationId:selectedOp.opId,
params,
@@ -278,7 +291,7 @@ function stopPoll(){
}
async function refreshInstances(){
const r=await fetch('/api/operations/'+SVC_ID);
const r=await fetch('/api/operations/'+currentSvcId);
const d=await r.json();
const newInsts=d.instances||[];
svcInstances=newInsts;