v1.1.44: 5 fixes — null-guard + try/catch in toggleInstance/selectService/refreshInstances/CMDB

This commit is contained in:
2026-07-30 09:49:08 +04:00
parent b7f7bba22c
commit b5d139a04a
3 changed files with 29 additions and 4 deletions
+9 -3
View File
@@ -46,6 +46,7 @@ async function selectService(svcId){
const svcEl=document.querySelector(`.svc-item[onclick*="${svcId}"]`);
if(svcEl) svcEl.classList.add('active');
try{
const r=await fetch('/api/operations/'+svcId);
const d=await r.json();
svcInstances=d.instances||[];
@@ -67,6 +68,7 @@ async function selectService(svcId){
html+=`<div class="inst-ops" id="ops-${i.instanceUid}"></div>`;
});
document.getElementById('inst-list').innerHTML=html;
}catch(e){document.getElementById('inst-list').innerHTML='<span style="color:var(--destructive);font-size:11px;">Ошибка загрузки</span>';}
}
async function toggleInstance(iuid){
@@ -81,9 +83,10 @@ async function toggleInstance(iuid){
// Операции для ИНСТАНСА, не для выбранного сервиса
const inst=svcInstances.find(x=>x.instanceUid===iuid);
const svcId=inst?inst.serviceId:currentSvcId;
try{
const r=await fetch('/api/operations/'+svcId);
const d=await r.json();
let ops=d.operations.filter(o=>o.operation!=='reconcile'&&o.operation!=='create');
let ops=(d.operations||[]).filter(o=>o.operation!=='reconcile'&&o.operation!=='create');
if(inst&&(inst.status||inst.explainedStatus)==='not created'){
ops=ops.filter(o=>o.operation==='delete');
}
@@ -91,6 +94,7 @@ async function toggleInstance(iuid){
`<button class="btn btn-sm op-btn ${opClass(o.operation)}" onclick="runOp('${o.operation}',${o.svcOperationId})">${o.operation}</button>`
).join('');
opsEl.classList.add('open');
}catch(e){opsEl.innerHTML='<span style="color:var(--destructive);font-size:11px;">Ошибка загрузки</span>';opsEl.classList.add('open');}
}
function opClass(opName){
@@ -338,8 +342,8 @@ async function executeOp(params){
if(d.status==='OK'&&(d.opUid||'').startsWith('cmdb-')){
busy=false;
setFinishedState('OK','badge-success','',0,d.displayName);
await refreshInstances();
if(historyOpen) await loadHistory();
try{await refreshInstances();}catch(e){}
if(historyOpen) try{await loadHistory();}catch(e){}
return;
}
// start polling
@@ -390,6 +394,7 @@ function stopPoll(){
}
async function refreshInstances(){
try{
const r=await fetch('/api/operations/'+currentSvcId);
const d=await r.json();
const newInsts=d.instances||[];
@@ -406,6 +411,7 @@ async function refreshInstances(){
html+=`<div class="inst-ops" id="ops-${i.instanceUid}"></div>`;
});
document.getElementById('inst-list').innerHTML=html;
}catch(e){}
}
// === История тестов ===