Subdomain edit funktion eingebaut
This commit is contained in:
@@ -283,6 +283,7 @@ Domains jährlich: <span id="costDomain">0</span> €<br>
|
||||
<h3>Subdomain erstellen</h3>
|
||||
|
||||
<input type="hidden" id="sub_domain_id">
|
||||
<input type="hidden" id="sub_id">
|
||||
|
||||
<label>Subdomain</label>
|
||||
<input id="sub_name">
|
||||
|
||||
@@ -19,6 +19,7 @@ const sublist = subs
|
||||
↳ ${s.subdomain}.${s.domain_name}
|
||||
<span id="subdns-${s.id}">...</span>
|
||||
<span id="subserver-${s.id}" class="serverlink"></span>
|
||||
<button onclick='openSubEdit(${JSON.stringify(s)})'>Edit</button>
|
||||
<button onclick="deleteSub(${s.id})">Delete</button>
|
||||
|
||||
</div>
|
||||
@@ -215,3 +216,51 @@ async function loadMapping(){
|
||||
|
||||
}
|
||||
|
||||
window.saveSubdomain = async function(){
|
||||
|
||||
const id = document.getElementById("sub_id").value
|
||||
const domain_id = document.getElementById("sub_domain_id").value
|
||||
const subdomain = document.getElementById("sub_name").value
|
||||
const ip_address = document.getElementById("sub_ip").value
|
||||
|
||||
const data = {
|
||||
domain_id,
|
||||
subdomain,
|
||||
ip_address
|
||||
}
|
||||
|
||||
if(id){
|
||||
|
||||
await api(API+"/subdomains/"+id,{
|
||||
method:"PUT",
|
||||
headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify(data)
|
||||
})
|
||||
|
||||
}else{
|
||||
|
||||
await api(API+"/subdomains",{
|
||||
method:"POST",
|
||||
headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify(data)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
closeSubModal()
|
||||
|
||||
loadDomains()
|
||||
|
||||
}
|
||||
|
||||
window.deleteSub = async function(id){
|
||||
|
||||
if(!confirm("Subdomain löschen?")) return
|
||||
|
||||
await api(API + "/subdomains/" + id, {
|
||||
method: "DELETE"
|
||||
})
|
||||
|
||||
loadDomains()
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,33 @@
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
|
||||
await loadResources()
|
||||
await loadDomains()
|
||||
await loadMapping()
|
||||
await loadCancelled()
|
||||
await refreshAll()
|
||||
|
||||
loadInfrastructure()
|
||||
loadCosts()
|
||||
setInterval(refreshAll, 30000)
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
let refreshing = false
|
||||
|
||||
async function refreshAll(){
|
||||
|
||||
if(refreshing) return
|
||||
refreshing = true
|
||||
|
||||
try{
|
||||
|
||||
await loadResources()
|
||||
await loadDomains()
|
||||
await loadMapping()
|
||||
await loadCancelled()
|
||||
|
||||
loadInfrastructure()
|
||||
loadCosts()
|
||||
|
||||
}catch(e){
|
||||
console.error("Refresh error", e)
|
||||
}
|
||||
|
||||
refreshing = false
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
document.addEventListener("DOMContentLoaded",()=>{
|
||||
|
||||
loadResources()
|
||||
loadDomains()
|
||||
loadMapping()
|
||||
loadCosts()
|
||||
loadInfrastructure()
|
||||
loadCancelled();
|
||||
setInterval(()=>{
|
||||
|
||||
document.querySelectorAll("[id^='status-']").forEach(el=>{
|
||||
|
||||
const id = el.id.replace("status-","")
|
||||
|
||||
const resource = window.resources.find(r=>r.id==id)
|
||||
|
||||
if(resource){
|
||||
checkServerStatus(resource)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
},30000)
|
||||
|
||||
|
||||
});
|
||||
|
||||
@@ -134,10 +134,14 @@ document.getElementById("domainModal").style.display="none"
|
||||
|
||||
window.openSubCreate = function(domainId){
|
||||
|
||||
document.getElementById("sub_domain_id").value=domainId
|
||||
document.getElementById("sub_id").value = "" // RESET !!
|
||||
|
||||
document.getElementById("sub_domain_id").value = domainId
|
||||
document.getElementById("sub_name").value = ""
|
||||
document.getElementById("sub_ip").value = ""
|
||||
|
||||
document.querySelector("#subdomainModal h3").innerText = "Subdomain erstellen"
|
||||
|
||||
document.getElementById("sub_name").value=""
|
||||
document.getElementById("sub_ip").value=""
|
||||
|
||||
document.getElementById("subdomainModal").style.display="block"
|
||||
|
||||
@@ -150,6 +154,20 @@ document.getElementById("subdomainModal").style.display="none"
|
||||
|
||||
}
|
||||
|
||||
window.openSubEdit = function(s){
|
||||
|
||||
document.getElementById("sub_id").value = s.id
|
||||
document.getElementById("sub_domain_id").value = s.domain_id
|
||||
|
||||
document.getElementById("sub_name").value = s.subdomain
|
||||
document.getElementById("sub_ip").value = s.ip_address
|
||||
|
||||
document.querySelector("#subdomainModal h3").innerText = "Subdomain bearbeiten"
|
||||
|
||||
document.getElementById("subdomainModal").style.display="block"
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* =========================
|
||||
IP MODAL
|
||||
|
||||
@@ -85,6 +85,30 @@ res.status(500).json({error:"DB error"})
|
||||
|
||||
})
|
||||
|
||||
router.put("/:id", async (req,res)=>{
|
||||
|
||||
try{
|
||||
|
||||
const {subdomain, ip_address} = req.body
|
||||
|
||||
await db.query(`
|
||||
UPDATE subdomains
|
||||
SET subdomain=?, ip_address=?
|
||||
WHERE id=?
|
||||
`,[subdomain, ip_address, req.params.id])
|
||||
|
||||
res.json({success:true})
|
||||
|
||||
}catch(e){
|
||||
|
||||
console.error("UPDATE subdomain error:",e)
|
||||
res.status(500).json({error:"DB error"})
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
module.exports = router
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user