diff --git a/templates/index.html b/templates/index.html
index 9ed03d9..202f8df 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -7,7 +7,7 @@
@@ -60,6 +70,16 @@
@@ -243,10 +263,10 @@ function paint(){
${esc(ro.rci_base_url)} |
${fromEnv?'из .env':esc(lo)} |
${fromEnv?'из .env':(hasPw?'есть':'нет')} |
- |
-
-
- |
+ |
+
+
+ |
`;
}).join('')||'| Нет роутеров |
';
}
@@ -333,7 +353,9 @@ async function addR(){
}
async function delR(id){
if(!confirm('Удалить?'))return;
- await fetch('/api/routers/'+id,{method:'DELETE',headers:hdr()});
+ const r=await fetch('/api/routers/'+encodeURIComponent(id),{method:'DELETE',headers:hdr()});
+ if(r.status===401){logout();return;}
+ if(!r.ok){alert(await r.text());return;}
await load();
}
async function toggleEn(id,en){
@@ -343,8 +365,16 @@ async function toggleEn(id,en){
await fetch('/api/data',{method:'PUT',headers:hdr(),body:JSON.stringify({groups,routers:ST.routers})});
}
async function testR(id){
- const r=await fetch('/api/test-router/'+id,{method:'POST',headers:hdr()});
- const j=await r.json();
+ const r=await fetch('/api/test-router/'+encodeURIComponent(id),{method:'POST',headers:hdr()});
+ if(r.status===401){logout();return;}
+ const raw=await r.text();
+ let j=null; try{j=JSON.parse(raw);}catch(_){}
+ if(!r.ok){
+ const d=j&&j.detail;
+ alert('Ошибка: '+(typeof d==='string'?d:Array.isArray(d)?d.map(x=>x.msg||x).join('; '):raw||r.status));
+ return;
+ }
+ if(!j){alert('Ошибка: '+raw);return;}
alert(j.ok?'OK: '+j.message:'Ошибка: '+j.message);
}
@@ -381,5 +411,15 @@ async function applySel(){
}
})();
+