Resourcen ujnd Domians aus ux.js entfernt.
This commit is contained in:
@@ -194,3 +194,294 @@ async function checkServerStatus(resource){
|
||||
|
||||
}
|
||||
|
||||
|
||||
function openCreate(){
|
||||
|
||||
document.getElementById("modalTitle").innerText = "Create Resource"
|
||||
document.getElementById("resource_id").value = ""
|
||||
|
||||
document.querySelectorAll("#resourceModal input, #resourceModal textarea")
|
||||
.forEach(e=>e.value="")
|
||||
|
||||
document.getElementById("status").value = "aktiv"
|
||||
|
||||
document.getElementById("resourceModal").style.display = "block"
|
||||
|
||||
}
|
||||
|
||||
|
||||
function openEdit(resource){
|
||||
|
||||
document.getElementById("modalTitle").innerText = "Edit Resource"
|
||||
|
||||
document.getElementById("resource_id").value = resource.id
|
||||
|
||||
Object.keys(resource).forEach(k=>{
|
||||
|
||||
const el = document.getElementById(k)
|
||||
|
||||
if(el) el.value = resource[k] || ""
|
||||
|
||||
})
|
||||
|
||||
document.getElementById("resourceModal").style.display = "block"
|
||||
|
||||
}
|
||||
|
||||
|
||||
function closeModal(){
|
||||
|
||||
document.getElementById("resourceModal").style.display="none"
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function openServerDetail(resource){
|
||||
|
||||
const mappings = await api(API+"/domainmap")
|
||||
|
||||
let html = `
|
||||
|
||||
<b>Name:</b> ${resource.name}<br>
|
||||
<b>Produkt:</b> ${resource.produkt || ""}<br>
|
||||
<b>Provider:</b> ${resource.provider || ""}<br>
|
||||
<b>Provider Name:</b> ${resource.providername || ""}
|
||||
|
||||
<br><br>
|
||||
|
||||
<b>System</b><br>
|
||||
CPU: ${resource.cpu || ""}<br>
|
||||
RAM: ${resource.ram || ""}<br>
|
||||
Disk: ${resource.disk || ""}<br>
|
||||
OS: ${resource.os || ""}
|
||||
|
||||
<br><br>
|
||||
|
||||
<b>IPs</b><br>
|
||||
`
|
||||
|
||||
if(Array.isArray(resource.ips)){
|
||||
|
||||
resource.ips.forEach(ip=>{
|
||||
html += `<div class="ip">${ip.type || ""} ${ip.ip}</div>`
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
html += `<br><b>Domains</b><br>`
|
||||
|
||||
const domains = mappings.filter(m => m.resource_id == resource.id)
|
||||
|
||||
domains.forEach(d=>{
|
||||
html += `<div class="ip">🌐 ${d.domain_name}</div>`
|
||||
})
|
||||
|
||||
html += `
|
||||
|
||||
<br>
|
||||
|
||||
<b>Bestelldatum:</b> ${resource.bestelldatum || ""}<br>
|
||||
<b>Kündbar ab:</b> ${resource.kuendbar_ab || ""}
|
||||
|
||||
<br><br>
|
||||
|
||||
<b>Bemerkung</b><br>
|
||||
${resource.bemerkung || ""}
|
||||
|
||||
`
|
||||
const subs = await api(API + "/subdomains")
|
||||
|
||||
html += "<br><b>Subdomains</b><br>"
|
||||
|
||||
if(Array.isArray(resource.ips)){
|
||||
|
||||
subs.forEach(s => {
|
||||
|
||||
const match = resource.ips.find(ip => ip.ip === s.ip_address)
|
||||
|
||||
if(match){
|
||||
html += `<div class="ip">🌐 ${s.subdomain}.${s.domain_name}</div>`
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/* jetzt erst rendern */
|
||||
|
||||
document.getElementById("serverDetailContent").innerHTML = html
|
||||
document.getElementById("serverDetailModal").style.display="block"
|
||||
|
||||
}
|
||||
|
||||
|
||||
function closeServerDetail(){
|
||||
|
||||
document.getElementById("serverDetailModal").style.display="none"
|
||||
|
||||
}
|
||||
|
||||
|
||||
document.addEventListener("click", function(event){
|
||||
|
||||
const modal = document.getElementById("serverDetailModal");
|
||||
|
||||
if(!modal) return;
|
||||
|
||||
if(event.target === modal){
|
||||
modal.style.display = "none";
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
document.addEventListener("keydown", function(e){
|
||||
|
||||
if(e.key === "Escape"){
|
||||
const modal = document.getElementById("serverDetailModal");
|
||||
if(modal) modal.style.display="none";
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
router.delete("/:id", async (req,res)=>{
|
||||
|
||||
await db.query("DELETE FROM subdomains WHERE id=?",[req.params.id])
|
||||
|
||||
res.json({success:true})
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
async function loadCancelled(){
|
||||
|
||||
const res = await api(API+"/resources/cancelled")
|
||||
|
||||
const table = document.getElementById("cancelled")
|
||||
|
||||
table.innerHTML=""
|
||||
|
||||
res.forEach(r=>{
|
||||
|
||||
const tr=document.createElement("tr")
|
||||
|
||||
tr.innerHTML=`
|
||||
|
||||
<td>${r.name}</td>
|
||||
<td>${r.produkt||""}</td>
|
||||
<td><span class="provider">${r.provider || ""}</span></td>
|
||||
<td>${r.cpu||""}</td>
|
||||
<td>${r.ram||""}</td>
|
||||
<td>${r.disk||""}</td>
|
||||
<td>gekündigt</td>
|
||||
|
||||
`
|
||||
|
||||
table.appendChild(tr)
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
async function loadCosts(){
|
||||
|
||||
const resources = await api(API+"/resources/active")
|
||||
const domains = await api(API+"/domains")
|
||||
|
||||
let month = 0
|
||||
let year = 0
|
||||
let domainYear = 0
|
||||
|
||||
resources.forEach(r=>{
|
||||
|
||||
let m = Number(r.kosten_monat || 0)
|
||||
let y = Number(r.kosten_jahr || 0)
|
||||
|
||||
if(m){
|
||||
month += m
|
||||
}else if(y){
|
||||
month += y / 12
|
||||
}
|
||||
|
||||
if(y){
|
||||
year += y
|
||||
}else if(m){
|
||||
year += m * 12
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
domains.forEach(d=>{
|
||||
domainYear += Number(d.yearly_cost || 0)
|
||||
})
|
||||
|
||||
document.getElementById("costMonth").innerText = month.toFixed(2)
|
||||
document.getElementById("costYear").innerText = year.toFixed(2)
|
||||
document.getElementById("costDomain").innerText = domainYear.toFixed(2)
|
||||
document.getElementById("costTotal").innerText = (year + domainYear).toFixed(2)
|
||||
|
||||
}
|
||||
|
||||
|
||||
async function loadInfrastructure(){
|
||||
|
||||
const resources = await api(API + "/resources/active")
|
||||
const mappings = await api(API + "/domainmap")
|
||||
|
||||
let html = ""
|
||||
|
||||
resources.forEach(r => {
|
||||
|
||||
html += `
|
||||
<div style="margin-bottom:20px;border:1px solid #ddd;padding:10px;border-radius:6px">
|
||||
|
||||
<b>${r.name}</b><br>
|
||||
Produkt: ${r.produkt || ""}<br>
|
||||
CPU: ${r.cpu || ""} | RAM: ${r.ram || ""} | Disk: ${r.disk || ""}<br>
|
||||
OS: ${r.os || ""}
|
||||
|
||||
<br><br>
|
||||
`
|
||||
|
||||
if(Array.isArray(r.ips)){
|
||||
|
||||
r.ips.forEach(ip => {
|
||||
|
||||
html += `
|
||||
<div style="margin-left:20px">
|
||||
|
||||
<b>IP:</b> ${ip.ip} (${ip.type || ""})
|
||||
`
|
||||
|
||||
const domains = mappings.filter(m => m.ip_address == ip.ip)
|
||||
|
||||
domains.forEach(d => {
|
||||
|
||||
html += `
|
||||
<div style="margin-left:20px;color:#444">
|
||||
🌐 ${d.domain_name}
|
||||
</div>
|
||||
`
|
||||
|
||||
})
|
||||
|
||||
html += "</div>"
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
html += "</div>"
|
||||
|
||||
})
|
||||
|
||||
document.getElementById("infraView").innerHTML = html
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user