From c12afe88803019c41709882ae8c23f5bf7752852 Mon Sep 17 00:00:00 2001 From: ecki Date: Sat, 7 Mar 2026 13:05:56 +0100 Subject: [PATCH] working resman with create form --- backend/public/index.html | 131 +++++++++++++++++++++++++++----------- 1 file changed, 94 insertions(+), 37 deletions(-) diff --git a/backend/public/index.html b/backend/public/index.html index 0dafcc7..0c5f650 100644 --- a/backend/public/index.html +++ b/backend/public/index.html @@ -6,40 +6,42 @@ ResMan @@ -48,26 +50,61 @@ margin-bottom:20px

ResMan

-

Create Resource

+

Neue Resource

-
+
+ + + + + + +

+ + + - + + +

+ + + + + + + +

+ + + + + + + +

+ + + +

+ +
+

Active Resources

+ - @@ -88,7 +125,6 @@ margin-bottom:20px - @@ -100,7 +136,7 @@ margin-bottom:20px

Domains

-
+
@@ -115,7 +151,6 @@ margin-bottom:20px
- @@ -158,18 +193,22 @@ const res=await fetch(API+"/resources/active") const data=await res.json() const table=document.getElementById("resources") + table.innerHTML="" data.forEach(r=>{ -const ips=r.ips.map(ip=>ip.ip).join("
") +let ips="" + +if(r.ips){ +ips=r.ips.map(ip=>ip.ip).join("
") +} const tr=document.createElement("tr") tr.innerHTML=` - - + @@ -181,7 +220,7 @@ ${ips}
- + @@ -209,9 +248,11 @@ table.appendChild(tr) async function loadCancelled(){ const res=await fetch(API+"/resources/cancelled") + const data=await res.json() const table=document.getElementById("cancelled") + table.innerHTML="" data.forEach(r=>{ @@ -219,7 +260,6 @@ data.forEach(r=>{ const tr=document.createElement("tr") tr.innerHTML=` - ` @@ -236,21 +276,39 @@ table.appendChild(tr) async function createResource(){ -const body={ -name:document.getElementById("r_name").value, -provider:document.getElementById("r_provider").value, -cpu:document.getElementById("r_cpu").value, -ram:document.getElementById("r_ram").value, -disk:document.getElementById("r_disk").value +const body = { + +name: document.getElementById("r_name").value, +produkt: document.getElementById("r_produkt").value, +provider: document.getElementById("r_provider").value, +art: document.getElementById("r_art").value, + +cpu: document.getElementById("r_cpu").value, +ram: document.getElementById("r_ram").value, +disk: document.getElementById("r_disk").value, +os: document.getElementById("r_os").value, + +kosten_monat: document.getElementById("r_kosten_monat").value, +kosten_jahr: document.getElementById("r_kosten_jahr").value, +laufzeit_monate: document.getElementById("r_laufzeit").value, + +bestelldatum: document.getElementById("r_bestellt").value, +kuendbar_ab: document.getElementById("r_kuendbar").value, +kuendigungsdatum: document.getElementById("r_kuendigungsdatum").value, + +bemerkung: document.getElementById("r_bemerkung").value + } -await fetch(API+"/resources",{ +await fetch("/resman/api/resources",{ method:"POST", -headers:{'Content-Type':'application/json'}, +headers:{ +"Content-Type":"application/json" +}, -body:JSON.stringify(body) +body: JSON.stringify(body) }) @@ -279,6 +337,7 @@ loadResources() async function editResource(id){ const name=prompt("Name") + if(!name) return await fetch(API+"/resources/"+id,{ @@ -337,8 +396,6 @@ const tr=document.createElement("tr") tr.innerHTML=` - -
ID Name Provider CPU
ID Name Provider
ID Domain Provider IP${r.id}${r.name}${r.name||""} ${r.provider||""} ${r.cpu||""} ${r.ram||""} ${r.id} ${r.name} ${r.provider||""}${d.id}${d.domain_name} ${d.provider||""}