Skip to content

Commit

Permalink
Use selector to display dns routes in GUI (netbirdio#2185)
Browse files Browse the repository at this point in the history
Use select widget for dns routes on GUI
  • Loading branch information
mlsmaycon authored Jun 24, 2024
1 parent 628673d commit 10cee8f
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions client/ui/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, ", ")

if len(domains) == 0 {
grid.Add(widget.NewLabel(network))
grid.Add(widget.NewLabel(""))
continue
}
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(), ", ")))
}

// 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(), ", ")))
}
// TODO: limit width
resolvedIPsLabel := widget.NewLabel(strings.Join(resolvedIPsList, ", "))
grid.Add(resolvedIPsLabel)
} else {
grid.Add(widget.NewLabel(""))
}

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()
Expand Down

0 comments on commit 10cee8f

Please sign in to comment.