vor subdomain UX anpassung
This commit is contained in:
@@ -111,20 +111,35 @@ window.saveResource = async function(){
|
||||
bemerkung:bemerkung.value
|
||||
}
|
||||
|
||||
if(id){
|
||||
await api(API+"/resources/"+id,{method:"PUT",headers:{'Content-Type':'application/json'},body:JSON.stringify(data)})
|
||||
}else{
|
||||
await api(API+"/resources",{method:"POST",headers:{'Content-Type':'application/json'},body:JSON.stringify(data)})
|
||||
}
|
||||
|
||||
closeModal()
|
||||
loadResources()
|
||||
await runAction(
|
||||
async () => {
|
||||
if(id){
|
||||
await api(API+"/resources/"+id,{method:"PUT",headers:{'Content-Type':'application/json'},body:JSON.stringify(data)})
|
||||
}else{
|
||||
await api(API+"/resources",{method:"POST",headers:{'Content-Type':'application/json'},body:JSON.stringify(data)})
|
||||
}
|
||||
},
|
||||
async () => {
|
||||
closeModal()
|
||||
await loadResources()
|
||||
loadInfrastructure()
|
||||
loadCosts()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
window.deleteResource = async function(id){
|
||||
if(!confirm("delete resource?")) return
|
||||
await api(API+"/resources/"+id,{method:"DELETE"})
|
||||
loadResources()
|
||||
await runAction(
|
||||
async () => {
|
||||
await api(API+"/resources/"+id,{method:"DELETE"})
|
||||
},
|
||||
async () => {
|
||||
await loadResources()
|
||||
loadInfrastructure()
|
||||
loadCosts()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
window.checkServerStatus = async function(resource){
|
||||
@@ -187,46 +202,51 @@ window.saveIP = async function(){
|
||||
const type = document.getElementById("new_type").value
|
||||
const comment = document.getElementById("new_comment").value
|
||||
|
||||
if(id){
|
||||
// 🔥 UPDATE
|
||||
await api(API + "/ips/" + id, {
|
||||
method: "PUT",
|
||||
headers: {'Content-Type':'application/json'},
|
||||
body: JSON.stringify({ip, type, comment})
|
||||
})
|
||||
await runAction(
|
||||
async () => {
|
||||
if(id){
|
||||
await api(API + "/ips/" + id, {
|
||||
method: "PUT",
|
||||
headers: {'Content-Type':'application/json'},
|
||||
body: JSON.stringify({ip, type, comment})
|
||||
})
|
||||
|
||||
delete ipField.dataset.editId
|
||||
delete ipField.dataset.editId
|
||||
|
||||
}else{
|
||||
// 🔥 CREATE
|
||||
}else{
|
||||
try{
|
||||
const result = await api(API + "/ipcheck/" + ip, {}, { showError: false })
|
||||
|
||||
try{
|
||||
const result = await api(API + "/ipcheck/" + ip)
|
||||
|
||||
if(result.length){
|
||||
if(!confirm("IP existiert bereits. Trotzdem speichern?")){
|
||||
return
|
||||
if(result.length){
|
||||
if(!confirm("IP existiert bereits. Trotzdem speichern?")){
|
||||
const error = new Error("IP save cancelled")
|
||||
error.silent = true
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}catch(e){
|
||||
if(e.silent) throw e
|
||||
console.warn("IP check fehlgeschlagen", e)
|
||||
}
|
||||
|
||||
await api(API + "/resources/" + resourceId + "/ips", {
|
||||
method: "POST",
|
||||
headers: {'Content-Type':'application/json'},
|
||||
body: JSON.stringify({ip, type, comment})
|
||||
})
|
||||
}
|
||||
}catch(e){
|
||||
console.log("Save IP Fehler:", e)
|
||||
},
|
||||
async () => {
|
||||
ipField.value = ""
|
||||
document.getElementById("new_type").value = ""
|
||||
document.getElementById("new_comment").value = ""
|
||||
|
||||
await loadIPs(resourceId)
|
||||
await loadResources()
|
||||
loadInfrastructure()
|
||||
cancelIPEdit()
|
||||
}
|
||||
|
||||
await api(API + "/resources/" + resourceId + "/ips", {
|
||||
method: "POST",
|
||||
headers: {'Content-Type':'application/json'},
|
||||
body: JSON.stringify({ip, type, comment})
|
||||
})
|
||||
}
|
||||
|
||||
// Felder reset
|
||||
ipField.value = ""
|
||||
document.getElementById("new_type").value = ""
|
||||
document.getElementById("new_comment").value = ""
|
||||
|
||||
loadIPs(resourceId)
|
||||
loadResources()
|
||||
cancelIPEdit()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -234,12 +254,18 @@ window.deleteIP = async function(id, resourceId){
|
||||
|
||||
if(!confirm("IP löschen?")) return
|
||||
|
||||
await api(API + "/ips/" + id, {
|
||||
method: "DELETE"
|
||||
})
|
||||
|
||||
loadIPs(resourceId) // Modal neu laden
|
||||
loadResources() // Tabelle aktualisieren
|
||||
await runAction(
|
||||
async () => {
|
||||
await api(API + "/ips/" + id, {
|
||||
method: "DELETE"
|
||||
})
|
||||
},
|
||||
async () => {
|
||||
await loadIPs(resourceId)
|
||||
await loadResources()
|
||||
loadInfrastructure()
|
||||
}
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
@@ -317,19 +343,18 @@ window.cancelIPEdit = function(){
|
||||
}
|
||||
|
||||
window.moveResource = async function(id, direction){
|
||||
|
||||
try {
|
||||
|
||||
await api(API + "/resources/" + id + "/move", {
|
||||
method: "POST",
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ direction })
|
||||
})
|
||||
|
||||
loadResources()
|
||||
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
|
||||
}
|
||||
await runAction(
|
||||
async () => {
|
||||
await api(API + "/resources/" + id + "/move", {
|
||||
method: "POST",
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ direction })
|
||||
})
|
||||
},
|
||||
async () => {
|
||||
await loadResources()
|
||||
loadInfrastructure()
|
||||
loadCosts()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user