Update populates both tables with current cluster data.
(cluster *api.Cluster)
| 84 | |
| 85 | // Update populates both tables with current cluster data. |
| 86 | func (cs *ClusterStatus) Update(cluster *api.Cluster) { |
| 87 | if cluster == nil { |
| 88 | return |
| 89 | } |
| 90 | |
| 91 | showIcons := true |
| 92 | if cs.app != nil { |
| 93 | showIcons = cs.app.config.ShowIcons |
| 94 | } |
| 95 | |
| 96 | // Update summary table |
| 97 | cs.SummaryTable.SetCell(0, 0, tview.NewTableCell("Cluster Name").SetTextColor(theme.Colors.HeaderText)) |
| 98 | cs.SummaryTable.SetCell(0, 1, tview.NewTableCell(cluster.Name).SetTextColor(theme.Colors.Primary)) |
| 99 | |
| 100 | // Show only the version number (e.g., '8.3.5') in the 'Proxmox VE' row |
| 101 | ver := cluster.Version |
| 102 | if parts := strings.Split(ver, "/"); len(parts) > 1 { |
| 103 | ver = parts[1] |
| 104 | } |
| 105 | |
| 106 | cs.SummaryTable.SetCell(1, 0, tview.NewTableCell("Proxmox VE").SetTextColor(theme.Colors.HeaderText)) |
| 107 | cs.SummaryTable.SetCell(1, 1, tview.NewTableCell(ver).SetTextColor(theme.Colors.Primary)) |
| 108 | |
| 109 | cs.SummaryTable.SetCell(2, 0, tview.NewTableCell("Nodes Online").SetTextColor(theme.Colors.HeaderText)) |
| 110 | |
| 111 | totalNodes := cluster.TotalNodes |
| 112 | if totalNodes == 0 && len(cluster.Nodes) > 0 { |
| 113 | totalNodes = len(cluster.Nodes) |
| 114 | } |
| 115 | |
| 116 | singleNode := totalNodes <= 1 |
| 117 | |
| 118 | // Show different indicators based on node status with proper colors |
| 119 | var nodeStatusText string |
| 120 | |
| 121 | var nodeStatusColor tcell.Color |
| 122 | |
| 123 | if cluster.OnlineNodes == totalNodes { |
| 124 | // All nodes online |
| 125 | if showIcons { |
| 126 | nodeStatusText = fmt.Sprintf("%d/%d 🟢", cluster.OnlineNodes, totalNodes) |
| 127 | } else { |
| 128 | nodeStatusText = fmt.Sprintf("%d/%d ✓", cluster.OnlineNodes, totalNodes) |
| 129 | } |
| 130 | nodeStatusColor = theme.Colors.StatusRunning |
| 131 | } else if cluster.OnlineNodes > 0 { |
| 132 | // Some nodes offline |
| 133 | if showIcons { |
| 134 | nodeStatusText = fmt.Sprintf("%d/%d ⚠️", cluster.OnlineNodes, totalNodes) |
| 135 | } else { |
| 136 | nodeStatusText = fmt.Sprintf("%d/%d !", cluster.OnlineNodes, totalNodes) |
| 137 | } |
| 138 | nodeStatusColor = theme.Colors.Warning |
| 139 | } else { |
| 140 | // All nodes offline (critical) |
| 141 | if showIcons { |
| 142 | nodeStatusText = fmt.Sprintf("%d/%d 🔴", cluster.OnlineNodes, totalNodes) |
| 143 | } else { |
nothing calls this directly
no test coverage detected