Skip to content

Commit

Permalink
Add 'Error Message' on top of Proxmox Cluster card with 'Connection E…
Browse files Browse the repository at this point in the history
…rror'
  • Loading branch information
emersonfelipesp committed Oct 15, 2024
1 parent d00b7fd commit c1d838f
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions netbox_proxbox/templates/netbox_proxbox/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@
const request = await fetch(endpoint)
const response = await request.json()
apiResponses.push(response[0])
console.log("endpoint test: ", response[0] )
//console.log("endpoint test: ", response[0] )


if (request.ok && response[0] && response[0].domain) {
console.log("NAME: ", response[0].domain)
statusBadge = document.getElementById(`proxmox-connection-status-${response[0].domain}`)
//console.log("NAME: ", response[0].domain)
let statusBadge = document.getElementById(`proxmox-connection-status-${response[0].domain}`)

console.log("statusBadge", statusBadge)
//console.log("statusBadge", statusBadge)
if (statusBadge) {
statusBadge.className = "text-bg-green badge p-1"
statusBadge.textContent = "Successful!"
Expand All @@ -90,17 +90,26 @@

if (request.status === 400) {
console.log("CONEXÃO DEU RUIM")

console.log("request text", response.message)
//console.log("request", response[0], await request)

let errorStatusBadge = document.getElementsByClassName("proxmox-connection-check")

errorStatusBadge = document.getElementsByClassName("proxmox-connection-check")
console.log("tdID", tdID)
let connectionError = document.getElementById(`proxmox-connection-error-${tdID}`)
console.log("connectionError", connectionError)
let connectionErrorFilledMessage = document.getElementById(`proxmox-filled-message-${tdID}`)

console.log("errorStatusBadge", errorStatusBadge)
if (!connectionErrorFilledMessage) {
connectionError.className = "text-bg-red p-2"
connectionError.innerHTML = `<p id="proxmox-filled-message-${tdID}"><strong>Message: </strong>${response.message}<br><strong>Detail: </strong>${response.message}<br><strong>Python Exception: </strong>${response.python_exception}</p>`
}

console.log("errorStatusBadge", errorStatusBadge)

for (let item of errorStatusBadge) {
console.log("testing it", item)

console.log("ITEM ID", item.id)

console.log("uvicorn_host", uvicorn_host, tdID)

if (item.id.includes(`${tdID}`)) {
console.log("ID FOUND.", item.id)
item.className = "text-bg-red badge p-1"
Expand Down Expand Up @@ -195,6 +204,9 @@ <h2>
{% for px in configuration.netbox_proxbox.proxmox %}
<div class="col col-md-6">
<div class="card">
<div class="p-4" id="proxmox-connection-error-{{ px.domain }}">

</div>
<div class="flex d-flex flex-row justify-content-center align-items-center p-2 mt-4">


Expand All @@ -207,6 +219,7 @@ <h2>
<div class="d-flex ms-auto " style="margin: 0 40px 0 0">
<span id="proxmox-connection-status-{{ px.domain }}" class="proxmox-connection-check badge p-1">Unknown</span>
</div>

</div>

<div class="card-body">
Expand Down

0 comments on commit c1d838f

Please sign in to comment.