From fe695acc927515aa402eb66931dfface5011889e Mon Sep 17 00:00:00 2001 From: Emerson Felipe Date: Tue, 15 Oct 2024 13:38:32 +0000 Subject: [PATCH] Add 'Proxmox Cluster Name' and 'Proxmox Cluster Mode' --- .../templates/netbox_proxbox/home.html | 77 +++++++++++++------ 1 file changed, 52 insertions(+), 25 deletions(-) diff --git a/netbox_proxbox/templates/netbox_proxbox/home.html b/netbox_proxbox/templates/netbox_proxbox/home.html index 6fc568d..aef7be5 100755 --- a/netbox_proxbox/templates/netbox_proxbox/home.html +++ b/netbox_proxbox/templates/netbox_proxbox/home.html @@ -74,6 +74,7 @@

Log Messages

getBody() + async function getVersion() { let elemento = document.getElementsByClassName("proxmox_version") @@ -87,30 +88,48 @@

Log Messages

if (td[0].id) { let tdID = td[0].id - try { - request = await fetch(`${fastapi_endpoint}/proxmox/version?source=netbox&list_all=false&plugin_name=netbox_proxbox&domain=${tdID}`) - response = await request.json() - - // console.log(response[0]) - } catch (error) { - console.log(error) + + + const version_endpoint = `${fastapi_endpoint}/proxmox/version?source=netbox&list_all=false&plugin_name=netbox_proxbox&domain=${tdID}` + const cluster_endpoint = `${fastapi_endpoint}/proxmox/sessions?source=netbox&list_all=false&plugin_name=netbox_proxbox&domain=${tdID}` + const endpoints = [version_endpoint, cluster_endpoint] + + let apiResponses = [] + + for (let endpoint of endpoints){ + try { + const request = await fetch(endpoint) + const response = await request.json() + apiResponses.push(response[0]) + } catch (err) { + alert(err) + } } - for (let value in response[0]) { - console.log(response[0][value].release) - console.log(response[0][value].repoid) - console.log(response[0][value].version) - - console.log("th0", th[0]) + for (let value in apiResponses[0]) { + if (th[0].textContent === 'Proxmox Version') { - td[0].textContent = `${response[0][value].version}` + td[0].textContent = `${apiResponses[0][value].version}` } if (th[0].textContent === 'Proxmox RepoID') { - td[0].textContent = `${response[0][value].repoid}` + td[0].textContent = `${apiResponses[0][value].repoid}` + } + } + + for (let value in apiResponses[1]) { + + if (th[0].textContent === 'Proxmox Cluster Name') { + td[0].textContent = `${apiResponses[1].name}` + } + + if (th[0].textContent === 'Proxmox Cluster Mode') { + + let mode = apiResponses[1].mode + if ( mode === "standalone" ) { mode = "Standalone" } + if ( mode === "cluster" ) { mode = "Cluster" } + td[0].textContent = `${mode}` } - } - //td[0].textContent = JSON.stringify(response[0][value].version) } } @@ -158,6 +177,22 @@

+ + + + + + + + + + + + + + + + {% if px.domain %} @@ -208,14 +243,6 @@

{% endif %} - - - - - - - -
Proxmox Cluster Name
Proxmox Cluster Mode
Proxmox Version
Proxmox RepoID
Domain / IP{{ default_config.proxmox.ssl }} (default)
Proxmox Version
Proxmox RepoID
{% if px.domain %}