läuft mit api, main und ui

This commit is contained in:
ecki
2026-03-10 18:03:19 +01:00
parent 6912e1cc39
commit d748c19242
2 changed files with 69 additions and 8 deletions
+3 -8
View File
@@ -283,13 +283,8 @@ Domains jährlich: <span id="costDomain">0</span> €<br>
<button onclick="closeDomainModal()">Cancel</button>
</div>
document.addEventListener("DOMContentLoaded",()=>{
loadResources();
loadDomains();
loadCosts();
});
<script src="js/api.js"></script>
<script src="js/ui.js"></script>
<script src="js/main.js"></script>
</body>
</html>
+66
View File
@@ -66,6 +66,7 @@ async function loadResources(){
`;
table.appendChild(tr);
checkServerStatus(r);
});
@@ -528,6 +529,71 @@ document.getElementById("infraView").innerHTML = html
}
async function checkServerStatus(resource){
if(!Array.isArray(resource.ips)) return;
// zuerst public IP suchen
let ip = resource.ips.find(i =>
i.type && i.type.toLowerCase().includes("public")
);
// wenn keine public IP existiert → erste nehmen
if(!ip){
ip = resource.ips[0];
}
if(!ip) return;
try{
const res = await fetch(API + "/ping/" + ip.ip);
const data = await res.json();
let icon = "🔴";
if(data.status === "online"){
icon = "🟢";
}
const el = document.getElementById("status-" + resource.id);
if(el){
el.innerHTML = icon;
}
}catch(e){
console.log("Ping error", e);
}
}
async function deleteResource(id){
if(!confirm("delete resource?")) return;
await api(API + "/resources/" + id,{
method:"DELETE"
});
loadResources();
loadCosts();
}
async function deleteIP(id, resourceId){
await api(API + "/ips/" + id,{
method:"DELETE"
});
loadIPs(resourceId);
loadResources();
}
loadResources();
loadDomains();
loadMapping();