Subdomain Anzeige mit Ips
This commit is contained in:
@@ -299,9 +299,32 @@ Domains jährlich: <span id="costDomain">0</span> €<br>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="subdomainModal" class="modal">
|
||||
|
||||
<h3>Subdomain erstellen</h3>
|
||||
|
||||
<input type="hidden" id="sub_domain_id">
|
||||
|
||||
<label>Subdomain</label>
|
||||
<input id="sub_name">
|
||||
|
||||
<label>IP Adresse</label>
|
||||
<input id="sub_ip">
|
||||
|
||||
<br><br>
|
||||
|
||||
<button onclick="saveSubdomain()">Save</button>
|
||||
<button onclick="closeSubModal()">Cancel</button>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script src="js/api.js"></script>
|
||||
<script src="js/ui.js"></script>
|
||||
<script src="js/main.js"></script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+89
-7
@@ -66,11 +66,6 @@ async function loadResources(){
|
||||
Delete
|
||||
</button>
|
||||
|
||||
</td>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<button onclick="deleteResource(${r.id})">Delete</button>
|
||||
</td>
|
||||
`;
|
||||
|
||||
@@ -96,11 +91,20 @@ const tr = document.createElement("tr")
|
||||
|
||||
const sublist = subs
|
||||
.filter(s => s.domain_id === d.id)
|
||||
.map(s => `<div style="margin-left:15px;font-size:13px;color:#555">
|
||||
.map(s => `
|
||||
<div class="subdomain">
|
||||
|
||||
↳ ${s.subdomain}.${s.domain_name}
|
||||
</div>`)
|
||||
<span id="subdns-${s.id}">...</span>
|
||||
|
||||
<button onclick="deleteSub(${s.id})">Delete</button>
|
||||
|
||||
</div>
|
||||
`)
|
||||
|
||||
.join("");
|
||||
|
||||
|
||||
tr.innerHTML = `
|
||||
<td>
|
||||
${d.domain_name}
|
||||
@@ -116,9 +120,40 @@ ${sublist}
|
||||
<td>
|
||||
<button onclick='openDomainEdit(${JSON.stringify(d)})'>Edit</button>
|
||||
<button onclick="deleteDomain(${d.id})">Delete</button>
|
||||
<button onclick="openSubCreate(${d.id},'${d.domain_name}')">
|
||||
+ Subdomain
|
||||
</button>
|
||||
</td>
|
||||
`;
|
||||
table.appendChild(tr)
|
||||
subs
|
||||
.filter(s => s.domain_id === d.id)
|
||||
.forEach(async s => {
|
||||
|
||||
const full = s.subdomain + "." + s.domain_name
|
||||
|
||||
try{
|
||||
|
||||
const dns = await api(API + "/dns/" + full)
|
||||
|
||||
let status="❌"
|
||||
|
||||
if(dns.ips && dns.ips.includes(s.ip_address)){
|
||||
status="✅" + dns.ips.join(", ")
|
||||
}else if(dns.ips.length){
|
||||
status="⚠" + dns.ips.join(", ")
|
||||
}
|
||||
|
||||
document.getElementById("subdns-"+s.id).innerHTML=status
|
||||
|
||||
}catch(e){
|
||||
|
||||
document.getElementById("subdns-"+s.id).innerHTML="❌"
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
try{
|
||||
|
||||
@@ -733,3 +768,50 @@ document.addEventListener("keydown", function(e){
|
||||
});
|
||||
|
||||
|
||||
router.delete("/:id", async (req,res)=>{
|
||||
|
||||
await db.query("DELETE FROM subdomains WHERE id=?",[req.params.id])
|
||||
|
||||
res.json({success:true})
|
||||
|
||||
})
|
||||
|
||||
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()
|
||||
|
||||
}
|
||||
|
||||
@@ -52,4 +52,39 @@ res.status(500).json({error:"DB error"})
|
||||
|
||||
})
|
||||
|
||||
|
||||
router.delete("/:id", async (req,res)=>{
|
||||
|
||||
await db.query("DELETE FROM subdomains WHERE id=?",[req.params.id])
|
||||
|
||||
res.json({success:true})
|
||||
|
||||
})
|
||||
|
||||
|
||||
router.post("/", async (req,res)=>{
|
||||
|
||||
try{
|
||||
|
||||
const {domain_id, subdomain, ip_address} = req.body
|
||||
|
||||
await db.query(`
|
||||
INSERT INTO subdomains
|
||||
(domain_id, subdomain, ip_address)
|
||||
VALUES (?,?,?)
|
||||
`,[domain_id, subdomain, ip_address])
|
||||
|
||||
res.json({success:true})
|
||||
|
||||
}catch(e){
|
||||
|
||||
console.error("CREATE subdomain error:",e)
|
||||
res.status(500).json({error:"DB error"})
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
module.exports = router
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user