läuft mit api, main und ui
This commit is contained in:
@@ -283,13 +283,8 @@ Domains jährlich: <span id="costDomain">0</span> €<br>
|
|||||||
<button onclick="closeDomainModal()">Cancel</button>
|
<button onclick="closeDomainModal()">Cancel</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<script src="js/api.js"></script>
|
||||||
document.addEventListener("DOMContentLoaded",()=>{
|
<script src="js/ui.js"></script>
|
||||||
|
<script src="js/main.js"></script>
|
||||||
loadResources();
|
|
||||||
loadDomains();
|
|
||||||
loadCosts();
|
|
||||||
|
|
||||||
});
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ async function loadResources(){
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
table.appendChild(tr);
|
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();
|
loadResources();
|
||||||
loadDomains();
|
loadDomains();
|
||||||
loadMapping();
|
loadMapping();
|
||||||
|
|||||||
Reference in New Issue
Block a user