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

Method applyInitialClusterUpdate

internal/ui/components/refresh.go:293–336  ·  view source on GitHub ↗

applyInitialClusterUpdate updates global state and UI with basic cluster data and rebuilt VM list

(cluster *api.Cluster)

Source from the content-addressed store, hash-verified

291
292// applyInitialClusterUpdate updates global state and UI with basic cluster data and rebuilt VM list
293func (a *App) applyInitialClusterUpdate(cluster *api.Cluster) {
294 a.QueueUpdateDraw(func() {
295 // Update global state nodes from cluster resources
296 models.GlobalState.OriginalNodes = make([]*api.Node, len(cluster.Nodes))
297 copy(models.GlobalState.OriginalNodes, cluster.Nodes)
298
299 // Apply node filter if active
300 if nodeState := models.GlobalState.GetSearchState(api.PageNodes); nodeState != nil && nodeState.Filter != "" {
301 models.FilterNodes(nodeState.Filter)
302 } else {
303 models.GlobalState.FilteredNodes = make([]*api.Node, len(cluster.Nodes))
304 copy(models.GlobalState.FilteredNodes, cluster.Nodes)
305 }
306 a.nodeList.SetNodes(models.GlobalState.FilteredNodes)
307 a.syncStorageBrowserNodes()
308
309 // Rebuild VM list from fresh cluster resources so new guests appear immediately
310 var vms []*api.VM
311 for _, n := range cluster.Nodes {
312 if n != nil {
313 for _, vm := range n.VMs {
314 if vm != nil {
315 vms = append(vms, vm)
316 }
317 }
318 }
319 }
320 models.GlobalState.OriginalVMs = make([]*api.VM, len(vms))
321 copy(models.GlobalState.OriginalVMs, vms)
322
323 // Apply VM filter if active
324 if vmState := models.GlobalState.GetSearchState(api.PageGuests); vmState != nil && vmState.HasActiveVMFilter() {
325 models.FilterVMs(vmState.Filter)
326 a.vmList.SetVMs(models.GlobalState.FilteredVMs)
327 } else {
328 models.GlobalState.FilteredVMs = make([]*api.VM, len(vms))
329 copy(models.GlobalState.FilteredVMs, vms)
330 a.vmList.SetVMs(models.GlobalState.FilteredVMs)
331 }
332
333 // Update cluster summary/status
334 a.clusterStatus.Update(cluster)
335 })
336}
337
338// doEnrichNodes enriches node data in parallel and finalizes the refresh.
339// Selections are always captured inside the final QueueUpdateDraw callback (on the UI

Callers 2

doManualRefreshMethod · 0.95
doFastRefreshMethod · 0.95

Calls 9

FilterNodesFunction · 0.92
FilterVMsFunction · 0.92
QueueUpdateDrawMethod · 0.80
GetSearchStateMethod · 0.80
HasActiveVMFilterMethod · 0.80
SetNodesMethod · 0.65
SetVMsMethod · 0.65
UpdateMethod · 0.65

Tested by

no test coverage detected