diff --git a/pvcweb-vue/src/components/NodeStatus.vue b/pvcweb-vue/src/components/NodeStatus.vue index 533061f..0fcc25b 100644 --- a/pvcweb-vue/src/components/NodeStatus.vue +++ b/pvcweb-vue/src/components/NodeStatus.vue @@ -11,16 +11,18 @@
{{ node.name }}

- Health: {{ node.health }}% + Health: {{ node.health || 0 }}%

- State: {{ node.state }}
- CPU: {{ node.cpu_cores }} cores ({{ node.cpu_load }}% load)
- Memory: {{ formatMemory(node.memory_used) }}/{{ formatMemory(node.memory_total) }} ({{ node.memory_utilization }}%)
- VMs: {{ node.vms.length }} {{ node.vms.length === 1 ? 'VM' : 'VMs' }} + Daemon: {{ node.daemon_state || 'Unknown' }}
+ Coordinator: {{ node.coordinator_state || 'Unknown' }}
+ Domain: {{ node.domain_state || 'Unknown' }}
+ CPU: {{ node.cpu_count || 0 }} cores ({{ node.load || 0 }}% load)
+ Memory: {{ formatMemory(node).used }}GB/{{ formatMemory(node).total }}GB ({{ formatMemory(node).percent }}%)
+ VMs: {{ node.domains_count || 0 }} {{ node.domains_count === 1 ? 'VM' : 'VMs' }}

-
- {{ node.vms.join(', ') }} +
+ {{ (node.vms || []).join(', ') }}
@@ -41,15 +43,41 @@ const props = defineProps({ }); const getHealthClass = (health) => { + if (!health) return 'status-error'; if (health > 90) return 'status-healthy'; if (health > 50) return 'status-warning'; return 'status-error'; }; -const formatMemory = (bytes) => { - if (bytes === 0) return '0GB'; - const gb = bytes / (1024 * 1024 * 1024); - return `${Math.round(gb)}GB`; +const formatMemory = (node) => { + console.log('Memory data for node:', node.name, node.memory); + + if (!node.memory || typeof node.memory !== 'object') { + return { used: 'N/A', total: 'N/A', percent: 'N/A' }; + } + + // Convert MB to GB with 2 decimal places + const toGB = (mb) => { + if (typeof mb !== 'number' || isNaN(mb)) { + console.log('Invalid MB value:', mb); + return 'N/A'; + } + return (mb / 1024).toFixed(2); + }; + + // Extract values from the Proxy object + const memoryData = Object.assign({}, node.memory); + const used = toGB(memoryData.used); + const total = toGB(memoryData.total); + + console.log('Converted memory values:', { used, total }); + + let percent = 'N/A'; + if (used !== 'N/A' && total !== 'N/A' && parseFloat(total) > 0) { + percent = Math.round((parseFloat(used) / parseFloat(total)) * 100); + } + + return { used, total, percent }; };