mirror of
https://github.com/netbirdio/netbird.git
synced 2025-02-16 18:21:24 +01:00
Use selector to display dns routes in GUI (#2185)
Use select widget for dns routes on GUI
This commit is contained in:
parent
628673db20
commit
10cee8f46e
@ -80,25 +80,39 @@ func (s *serviceClient) updateRoutes(grid *fyne.Container) {
|
||||
grid.Add(checkBox)
|
||||
network := r.GetNetwork()
|
||||
domains := r.GetDomains()
|
||||
if len(domains) > 0 {
|
||||
network = strings.Join(domains, ", ")
|
||||
}
|
||||
grid.Add(widget.NewLabel(network))
|
||||
|
||||
if len(domains) > 0 {
|
||||
var resolvedIPsList []string
|
||||
for _, domain := range r.GetDomains() {
|
||||
if ipList, exists := r.GetResolvedIPs()[domain]; exists {
|
||||
resolvedIPsList = append(resolvedIPsList, fmt.Sprintf("%s: %s", domain, strings.Join(ipList.GetIps(), ", ")))
|
||||
}
|
||||
}
|
||||
// TODO: limit width
|
||||
resolvedIPsLabel := widget.NewLabel(strings.Join(resolvedIPsList, ", "))
|
||||
grid.Add(resolvedIPsLabel)
|
||||
} else {
|
||||
if len(domains) == 0 {
|
||||
grid.Add(widget.NewLabel(network))
|
||||
grid.Add(widget.NewLabel(""))
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
// our selectors are only for display
|
||||
noopFunc := func(_ string) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
domainsSelector := widget.NewSelect(domains, noopFunc)
|
||||
domainsSelector.Selected = domains[0]
|
||||
grid.Add(domainsSelector)
|
||||
|
||||
var resolvedIPsList []string
|
||||
for _, domain := range domains {
|
||||
if ipList, exists := r.GetResolvedIPs()[domain]; exists {
|
||||
resolvedIPsList = append(resolvedIPsList, fmt.Sprintf("%s: %s", domain, strings.Join(ipList.GetIps(), ", ")))
|
||||
}
|
||||
}
|
||||
|
||||
if len(resolvedIPsList) == 0 {
|
||||
grid.Add(widget.NewLabel(""))
|
||||
continue
|
||||
}
|
||||
|
||||
// TODO: limit width within the selector display
|
||||
resolvedIPsSelector := widget.NewSelect(resolvedIPsList, noopFunc)
|
||||
resolvedIPsSelector.Selected = resolvedIPsList[0]
|
||||
resolvedIPsSelector.Resize(fyne.NewSize(100, 100))
|
||||
grid.Add(resolvedIPsSelector)
|
||||
}
|
||||
|
||||
s.wRoutes.Content().Refresh()
|
||||
|
Loading…
Reference in New Issue
Block a user