refactor: split ui into modules (resources, domains, infra, costs, modals)

This commit is contained in:
ecki
2026-03-22 15:42:45 +01:00
parent 67106ac1a1
commit 0559cc4cd1
9 changed files with 393 additions and 611 deletions
+3 -110
View File
@@ -1,114 +1,7 @@
function openIPManager(resourceId){
document.getElementById("ip_resource_id").value = resourceId
document.getElementById("ipModal").style.display = "block"
loadIPs(resourceId)
}
function closeIPModal(){
document.getElementById("ipModal").style.display = "none"
}
async function loadIPs(resourceId){
const ips = await api(API + "/resources/" + resourceId + "/ips")
const container = document.getElementById("ipList")
container.innerHTML = ""
ips.forEach(ip=>{
const div = document.createElement("div")
div.innerHTML = `
${ip.ip} (${ip.type||""}) ${ip.comment||""}
<button onclick="deleteIP(${ip.id},${resourceId})">Delete</button>
`
container.appendChild(div)
})
}
async function saveIP(){
const resourceId = document.getElementById("ip_resource_id").value
const ip = document.getElementById("new_ip").value
const type = document.getElementById("new_type").value
const comment = document.getElementById("new_comment").value
await api("/resman/api/resources/"+resourceId+"/ips",{
method:"POST",
headers:{'Content-Type':'application/json'},
body:JSON.stringify({ip,type,comment})
})
loadIPs(resourceId)
loadResources()
}
async function deleteIP(id, resourceId){
await api(API + "/ips/" + id,{
method:"DELETE"
});
loadIPs(resourceId);
loadResources();
}
function openSubCreate(domainId){
document.getElementById("sub_domain_id").value=domainId
document.getElementById("sub_name").value=""
document.getElementById("sub_ip").value=""
document.getElementById("subdomainModal").style.display="block"
}
function closeSubModal(){
document.getElementById("subdomainModal").style.display="none"
}
async function saveSubdomain(){
const domain_id=document.getElementById("sub_domain_id").value
const subdomain=document.getElementById("sub_name").value
const ip_address=document.getElementById("sub_ip").value
await api(API+"/subdomains",{
method:"POST",
headers:{'Content-Type':'application/json'},
body:JSON.stringify({
domain_id,
subdomain,
ip_address
})
})
closeSubModal()
loadDomains()
}
window.loadCosts = function(){}
window.loadCancelled = function(){}
window.loadInfrastructure = function(){}