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

Function FilterNodes

internal/ui/models/state.go:111–161  ·  view source on GitHub ↗

FilterNodes filters the nodes based on the given search string.

(filter string)

Source from the content-addressed store, hash-verified

109
110// FilterNodes filters the nodes based on the given search string.
111func FilterNodes(filter string) {
112 if filter == "" {
113 // No filter, use all nodes
114 GlobalState.FilteredNodes = make([]*api.Node, len(GlobalState.OriginalNodes))
115 copy(GlobalState.FilteredNodes, GlobalState.OriginalNodes)
116
117 return
118 }
119
120 // Convert filter to lowercase for case-insensitive search
121 filter = strings.ToLower(filter)
122
123 // Create a new filtered list
124 GlobalState.FilteredNodes = make([]*api.Node, 0)
125
126 // Add nodes that match the filter
127 for _, node := range GlobalState.OriginalNodes {
128 if node == nil {
129 continue
130 }
131
132 // Check node name
133 if strings.Contains(strings.ToLower(node.Name), filter) {
134 GlobalState.FilteredNodes = append(GlobalState.FilteredNodes, node)
135
136 continue
137 }
138
139 // Check node IP
140 if strings.Contains(strings.ToLower(node.IP), filter) {
141 GlobalState.FilteredNodes = append(GlobalState.FilteredNodes, node)
142
143 continue
144 }
145
146 // Check node status (using online status instead)
147 statusText := "offline"
148 if node.Online {
149 statusText = "online"
150 }
151
152 if strings.Contains(statusText, filter) {
153 GlobalState.FilteredNodes = append(GlobalState.FilteredNodes, node)
154
155 continue
156 }
157 }
158 // GetUILogger().Debug("Filtered nodes from %d to %d with filter '%s'",
159 //
160 // len(GlobalState.OriginalNodes), len(GlobalState.FilteredNodes), filter)
161}
162
163// FilterVMs filters the VMs based on the given search string.
164func FilterVMs(filter string) {

Callers 7

doManualRefreshMethod · 0.92
doEnrichNodesMethod · 0.92
autoRefreshDataMethod · 0.92
activateSearchMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected