Skip to content

Commit

Permalink
Fix FastAPI status badge on homepage.
Browse files Browse the repository at this point in the history
  • Loading branch information
emersonfelipesp committed Oct 16, 2024
1 parent c061157 commit 420e556
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions netbox_proxbox/templates/netbox_proxbox/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@
fullUpdateMessage.innerHTML = errorMessage


statusBadgeError = document.getElementById('fastapi-connection-status')
statusBadgeError.className = "text-bg-red badge p-2"
let statusBadgeError = document.getElementById('fastapi-connection-status')
statusBadgeError.className = "text-bg-red badge p-1"
statusBadgeError.textContent = "Connection Failed!"

statusErrorMessage = document.getElementById('fastapi-connection-error')
let statusErrorMessage = document.getElementById('fastapi-connection-error')
statusErrorMessage.className = "text-bg-red p-2"
statusErrorMessage.innerHTML = errorMessage
}
Expand All @@ -61,6 +61,25 @@
event.preventDefault()
}

async function FastAPIConnectionTest() {
let fastapi_docs_endpoint = `${fastapi_endpoint}/docs`

const request_fastapi = await fetch(fastapi_docs_endpoint)
console.log("request_fastapi", request_fastapi)
if (request_fastapi.ok) {
console.log("FastAPI OK")
//onst response_fastapi = await request_fastapi.json()

console.log("request_fastapi", request_fastapi)

statusBadgeFastAPI = document.getElementById('fastapi-connection-status')
statusBadgeFastAPI.className = "text-bg-green badge p-1"
statusBadgeFastAPI.textContent = "Successful!"

}

}


function getBody () {
// Load 'getVersion()' function on HTML
Expand All @@ -71,9 +90,16 @@

}



getBody()

async function getVersion() {
// Test FastAPI Proxbox Backend Connection
console.log("1")
FastAPIConnectionTest()
console.log("2")

// Get Info from Proxmox and Add to GUI Page, like Connection Status and Error Messages
let elemento = document.getElementsByClassName("proxmox_version")

Expand Down

0 comments on commit 420e556

Please sign in to comment.