Update fills the node details table for the given node.
(node *api.Node, allNodes []*api.Node)
| 56 | |
| 57 | // Update fills the node details table for the given node. |
| 58 | func (nd *NodeDetails) Update(node *api.Node, allNodes []*api.Node) { |
| 59 | if node == nil { |
| 60 | nd.Clear() |
| 61 | nd.SetCell(0, 0, tview.NewTableCell("Select a node").SetTextColor(theme.Colors.Primary)) |
| 62 | |
| 63 | return |
| 64 | } |
| 65 | |
| 66 | nd.Clear() |
| 67 | |
| 68 | showIcons := true |
| 69 | if nd.app != nil { |
| 70 | showIcons = nd.app.config.ShowIcons |
| 71 | } |
| 72 | |
| 73 | row := 0 |
| 74 | |
| 75 | // Basic Info |
| 76 | // nd.SetCell(row, 0, tview.NewTableCell(utils.GetIconLabel("Name", "📛", showIcons)).SetTextColor(theme.Colors.HeaderText)) |
| 77 | // nd.SetCell(row, 1, tview.NewTableCell(node.Name).SetTextColor(theme.Colors.Primary)) |
| 78 | // row++ |
| 79 | |
| 80 | nd.SetCell(row, 0, tview.NewTableCell(utils.GetIconLabel("ID", "🆔", showIcons)).SetTextColor(theme.Colors.HeaderText)) |
| 81 | nd.SetCell(row, 1, tview.NewTableCell(node.ID).SetTextColor(theme.Colors.Primary)) |
| 82 | |
| 83 | row++ |
| 84 | |
| 85 | // Status Info |
| 86 | statusText := "Online" |
| 87 | if !node.Online { |
| 88 | statusText = "Offline" |
| 89 | } |
| 90 | |
| 91 | var statusColor tcell.Color |
| 92 | if node.Online { |
| 93 | statusColor = theme.Colors.StatusRunning |
| 94 | } else { |
| 95 | statusColor = theme.Colors.StatusStopped |
| 96 | } |
| 97 | |
| 98 | nd.SetCell(row, 0, tview.NewTableCell(utils.GetIconLabel("Status", utils.GetStatusEmoji(statusText, showIcons), showIcons)).SetTextColor(theme.Colors.HeaderText)) |
| 99 | nd.SetCell(row, 1, tview.NewTableCell(statusText).SetTextColor(statusColor)) |
| 100 | |
| 101 | row++ |
| 102 | |
| 103 | nd.SetCell(row, 0, tview.NewTableCell(utils.GetIconLabel("IP", "📡", showIcons)).SetTextColor(theme.Colors.HeaderText)) |
| 104 | nd.SetCell(row, 1, tview.NewTableCell(node.IP).SetTextColor(theme.Colors.Primary)) |
| 105 | |
| 106 | row++ |
| 107 | |
| 108 | // CPU Usage |
| 109 | nd.SetCell(row, 0, tview.NewTableCell(utils.GetIconLabel("CPU", "🧮", showIcons)).SetTextColor(theme.Colors.HeaderText)) |
| 110 | |
| 111 | cpuValue := api.StringNA |
| 112 | cpuUsageColor := theme.Colors.Primary |
| 113 | |
| 114 | if node.CPUUsage >= 0 && node.CPUCount > 0 { |
| 115 | cpuPercent := node.CPUUsage * 100 |
nothing calls this directly
no test coverage detected