diff --git a/backend/public/index.html b/backend/public/index.html index e1e7be8..b615a11 100644 --- a/backend/public/index.html +++ b/backend/public/index.html @@ -602,7 +602,7 @@ document.querySelectorAll("#resourceModal input, #resourceModal textarea") .forEach(e=>e.value="") document.getElementById("resourceModal").style.display="block" - +document.getElementById("status").value="aktiv" } @@ -823,19 +823,17 @@ document.getElementById("domainModal").style.display="none" } - - async function saveDomain(){ const id=document.getElementById("domain_id").value const data={ -domain_name:domain_name.value, -provider:domain_provider.value, -ip_address:domain_ip.value, -yearly_cost:domain_cost.value, -notes:domain_notes.value +domain_name:document.getElementById("domain_name").value, +provider:document.getElementById("domain_provider").value, +ip_address:document.getElementById("domain_ip").value, +yearly_cost:document.getElementById("domain_cost").value || null, +notes:document.getElementById("domain_notes").value } @@ -861,11 +859,11 @@ closeDomainModal() loadDomains() loadMapping() +loadCosts() } - async function deleteDomain(id){ await fetch(API+"/domains/"+id,{method:"DELETE"}) diff --git a/backend/routes/domains.js b/backend/routes/domains.js index 7ea3b4d..f0b324a 100644 --- a/backend/routes/domains.js +++ b/backend/routes/domains.js @@ -54,14 +54,24 @@ router.get('/:id', async (req, res) => { // CREATE DOMAIN router.post('/', async (req, res) => { try { - const { domain_name, provider, ip_address, yearly_cost, notes } = req.body; - const [result] = await pool.query( - `INSERT INTO domains - (domain_name, provider, ip_address, yearly_cost, notes) - VALUES (?, ?, ?, ?, ?)`, - [domain_name, provider, ip_address, yearly_cost, notes] - ); + +const { domain_name, provider, ip_address, yearly_cost, notes } = req.body; + +await pool.query( +`INSERT INTO domains +(domain_name, provider, ip_address, yearly_cost, notes) +VALUES (?, ?, ?, ?, ?)`, +[ +domain_name, +provider, +ip_address, +yearly_cost || null, +notes +] +); + + res.json({ message: "Domain created",