MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / updateHistoryTable

Method updateHistoryTable

internal/ui/components/tasks_list.go:238–341  ·  view source on GitHub ↗

updateHistoryTable refreshes the history table content.

()

Source from the content-addressed store, hash-verified

236
237// updateHistoryTable refreshes the history table content.
238func (tl *TasksList) updateHistoryTable() {
239 tl.historyTable.Clear()
240
241 if len(tl.tasks) == 0 {
242 tl.historyTable.SetCell(0, 0, tl.noTasksCell())
243 return
244 }
245
246 // Sort tasks by start time (newest first)
247 sortedTasks := make([]*api.ClusterTask, len(tl.tasks))
248 copy(sortedTasks, tl.tasks)
249 sort.Slice(sortedTasks, func(i, j int) bool {
250 return sortedTasks[i].StartTime > sortedTasks[j].StartTime
251 })
252
253 // Set headers
254 for i, column := range tasksTableColumns {
255 tc := tview.NewTableCell(column.title).
256 SetTextColor(theme.Colors.HeaderText).
257 SetAlign(tview.AlignLeft).
258 SetExpansion(column.expansion)
259 tl.historyTable.SetCell(0, i, tc)
260 }
261
262 // Add task data
263 for i, task := range sortedTasks {
264 row := i + 1
265
266 startTime := "N/A"
267 if task.StartTime > 0 {
268 startTime = time.Unix(task.StartTime, 0).Format("01-02-2006 15:04:05")
269 }
270
271 tl.historyTable.SetCell(row, 0, tview.NewTableCell(startTime).
272 SetTextColor(theme.Colors.Secondary).
273 SetAlign(tview.AlignLeft).
274 SetExpansion(tasksTableColumns[0].expansion))
275
276 node := task.Node
277 if len(node) > 16 {
278 node = node[:13] + "..."
279 }
280
281 tl.historyTable.SetCell(row, 1, tview.NewTableCell(node).
282 SetTextColor(theme.Colors.Primary).
283 SetAlign(tview.AlignLeft).
284 SetExpansion(tasksTableColumns[1].expansion))
285
286 typeStr := formatTaskType(task.Type)
287 if len(typeStr) > 16 {
288 typeStr = typeStr[:13] + "..."
289 }
290
291 tl.historyTable.SetCell(row, 2, tview.NewTableCell(typeStr).
292 SetTextColor(theme.Colors.Info).
293 SetAlign(tview.AlignLeft).
294 SetExpansion(tasksTableColumns[2].expansion))
295

Callers 2

SetTasksMethod · 0.95
SetFilteredTasksMethod · 0.95

Calls 8

noTasksCellMethod · 0.95
formatTaskTypeFunction · 0.85
createStatusCellFunction · 0.85
formatUserFunction · 0.85
formatDurationFunction · 0.85
SetTextColorMethod · 0.80
ClearMethod · 0.65
SelectMethod · 0.65

Tested by

no test coverage detected