ResMan update
This commit is contained in:
@@ -93,3 +93,8 @@ input, textarea {
|
||||
box-shadow: 0 10px 30px rgba(0,0,0,0.3);
|
||||
border-radius: 6px;
|
||||
}
|
||||
.subdomain{
|
||||
margin-left:15px;
|
||||
font-size:13px;
|
||||
color:#555;
|
||||
}
|
||||
|
||||
+40
-4
@@ -84,9 +84,8 @@ async function loadResources(){
|
||||
|
||||
async function loadDomains(){
|
||||
|
||||
console.count("loadDomains")
|
||||
|
||||
const domains = await api(API + "/domains")
|
||||
const subs = await api(API + "/subdomains")
|
||||
|
||||
const table = document.getElementById("domains")
|
||||
table.innerHTML = ""
|
||||
@@ -97,7 +96,26 @@ const tr = document.createElement("tr")
|
||||
|
||||
tr.innerHTML = `
|
||||
|
||||
<td>${d.domain_name}</td> <td> <span class="provider">${d.provider || ""}</span> </td> <td>${d.ip_address || ""}</td> <td id="server-${d.id}"> ${d.resource_name ? d.resource_name : "<span style='color:red'>⚠ no server</span>"} </td> <td id="dns-${d.id}">...</td> <td>${d.yearly_cost || ""}</td> <td> <button onclick='openDomainEdit(${JSON.stringify(d)})'>Edit</button> <button onclick="deleteDomain(${d.id})">Delete</button> </td> `
|
||||
<td>
|
||||
|
||||
${d.domain_name}
|
||||
|
||||
|
||||
${
|
||||
subs
|
||||
.filter(s => s.domain_id === d.id)
|
||||
.map(s => `<div style="margin-left:15px;color:#555">↳ ${s.subdomain}.${s.domain_name}</div>`)
|
||||
.join("")
|
||||
}
|
||||
|
||||
</td>
|
||||
|
||||
<span class="provider">${d.provider || ""}</span> </td>
|
||||
<td>${d.ip_address || ""}</td>
|
||||
<td id="server-${d.id}"> ${d.resource_name ? d.resource_name : "<span style='color:red'>⚠ no server</span>"} </td>
|
||||
<td id="dns-${d.id}">...</td>
|
||||
<td>${d.yearly_cost || ""}</td>
|
||||
<td> <button onclick='openDomainEdit(${JSON.stringify(d)})'>Edit</button> <button onclick="deleteDomain(${d.id})">Delete</button> </td> `
|
||||
|
||||
table.appendChild(tr)
|
||||
|
||||
@@ -658,9 +676,27 @@ html += `
|
||||
${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"
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
const express = require("express")
|
||||
const router = express.Router()
|
||||
const db = require("../db")
|
||||
|
||||
/* alle Subdomains laden */
|
||||
|
||||
router.get("/", async (req,res)=>{
|
||||
|
||||
try{
|
||||
|
||||
const [rows] = await db.query(`
|
||||
SELECT
|
||||
s.id,
|
||||
s.subdomain,
|
||||
s.ip_address,
|
||||
d.domain_name,
|
||||
s.domain_id
|
||||
FROM subdomains s
|
||||
JOIN domains d ON s.domain_id=d.id
|
||||
`)
|
||||
|
||||
res.json(rows)
|
||||
|
||||
}catch(e){
|
||||
|
||||
console.error("SUBDOMAIN LIST error:",e)
|
||||
res.status(500).json({error:"DB error"})
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
/* Subdomains einer Domain */
|
||||
|
||||
router.get("/domain/:id", async (req,res)=>{
|
||||
|
||||
try{
|
||||
|
||||
const [rows] = await db.query(
|
||||
"SELECT * FROM subdomains WHERE domain_id=?",
|
||||
[req.params.id]
|
||||
)
|
||||
|
||||
res.json(rows)
|
||||
|
||||
}catch(e){
|
||||
|
||||
console.error("SUBDOMAIN DOMAIN error:",e)
|
||||
res.status(500).json({error:"DB error"})
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
module.exports = router
|
||||
@@ -9,6 +9,7 @@ const domainMapping = require('./routes/domainMapping')
|
||||
const dnsRoutes = require("./routes/dns")
|
||||
const pingRoutes = require("./routes/ping")
|
||||
const ipCheck = require("./routes/ipcheck")
|
||||
const subdomainRoutes = require("./routes/subdomains")
|
||||
|
||||
const app = express();
|
||||
|
||||
@@ -44,6 +45,8 @@ app.use("/resman/api/ping", pingRoutes)
|
||||
|
||||
app.use("/resman/api/ipcheck", ipCheck)
|
||||
|
||||
app.use("/resman/api/subdomains", subdomainRoutes)
|
||||
|
||||
|
||||
app.use((err, req, res, next) => {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user