Browse Source

Merge pull request #1223 from gravitl/bugfix_v0.14.4_gui_static_checks

removed deprecated references and fixed static checks
Matthew R Kasun 3 years ago
parent
commit
bb76dcf266
2 changed files with 13 additions and 15 deletions
  1. 2 2
      netclient/daemon/windows.go
  2. 11 13
      netclient/gui/components/views/networks.go

+ 2 - 2
netclient/daemon/windows.go

@@ -30,7 +30,7 @@ func SetupWindowsDaemon() error {
 	}
 	}
 	//get exact formatted commands
 	//get exact formatted commands
 	RunWinSWCMD("install")
 	RunWinSWCMD("install")
-	time.Sleep(1)
+	time.Sleep(time.Millisecond)
 	RunWinSWCMD("start")
 	RunWinSWCMD("start")
 
 
 	return nil
 	return nil
@@ -39,7 +39,7 @@ func SetupWindowsDaemon() error {
 // RestartWindowsDaemon - restarts windows service
 // RestartWindowsDaemon - restarts windows service
 func RestartWindowsDaemon() {
 func RestartWindowsDaemon() {
 	RunWinSWCMD("stop")
 	RunWinSWCMD("stop")
-	time.Sleep(1)
+	time.Sleep(time.Millisecond)
 	RunWinSWCMD("start")
 	RunWinSWCMD("start")
 }
 }
 
 

+ 11 - 13
netclient/gui/components/views/networks.go

@@ -15,12 +15,10 @@ import (
 	"github.com/gravitl/netmaker/netclient/ncutils"
 	"github.com/gravitl/netmaker/netclient/ncutils"
 )
 )
 
 
-var currentNetwork *string
-
 // GetNetworksView - displays the view of all networks
 // GetNetworksView - displays the view of all networks
 func GetNetworksView(networks []string) fyne.CanvasObject {
 func GetNetworksView(networks []string) fyne.CanvasObject {
 	// renders := []fyne.CanvasObject{}
 	// renders := []fyne.CanvasObject{}
-	if networks == nil || len(networks) == 0 {
+	if len(networks) == 0 {
 		return container.NewCenter(widget.NewLabel("No networks present"))
 		return container.NewCenter(widget.NewLabel("No networks present"))
 	}
 	}
 	grid := container.New(layout.NewGridLayout(4),
 	grid := container.New(layout.NewGridLayout(4),
@@ -31,22 +29,22 @@ func GetNetworksView(networks []string) fyne.CanvasObject {
 	)
 	)
 	for i := range networks {
 	for i := range networks {
 		network := &networks[i]
 		network := &networks[i]
-		grid.AddObject(
+		grid.Add(
 			container.NewCenter(widget.NewLabel(*network)),
 			container.NewCenter(widget.NewLabel(*network)),
 		)
 		)
-		grid.AddObject(
+		grid.Add(
 			components.ColoredIconButton("info", theme.InfoIcon(), func() {
 			components.ColoredIconButton("info", theme.InfoIcon(), func() {
 				RefreshComponent(NetDetails, GetSingleNetworkView(*network))
 				RefreshComponent(NetDetails, GetSingleNetworkView(*network))
 				ShowView(NetDetails)
 				ShowView(NetDetails)
 			}, components.Gold_color),
 			}, components.Gold_color),
 		)
 		)
-		grid.AddObject(
+		grid.Add(
 			components.ColoredIconButton("pull", theme.DownloadIcon(), func() {
 			components.ColoredIconButton("pull", theme.DownloadIcon(), func() {
 				// TODO call pull with network name
 				// TODO call pull with network name
 				pull(*network)
 				pull(*network)
 			}, components.Blue_color),
 			}, components.Blue_color),
 		)
 		)
-		grid.AddObject(
+		grid.Add(
 			components.ColoredIconButton("leave", theme.DeleteIcon(), func() {
 			components.ColoredIconButton("leave", theme.DeleteIcon(), func() {
 				leave(*network)
 				leave(*network)
 			}, components.Danger_color),
 			}, components.Danger_color),
@@ -59,7 +57,7 @@ func GetNetworksView(networks []string) fyne.CanvasObject {
 
 
 // GetSingleNetworkView - returns details and option to pull a network
 // GetSingleNetworkView - returns details and option to pull a network
 func GetSingleNetworkView(network string) fyne.CanvasObject {
 func GetSingleNetworkView(network string) fyne.CanvasObject {
-	if network == "" || len(network) == 0 {
+	if len(network) == 0 {
 		return container.NewCenter(widget.NewLabel("No valid network selected"))
 		return container.NewCenter(widget.NewLabel("No valid network selected"))
 	}
 	}
 
 
@@ -117,16 +115,16 @@ func GetSingleNetworkView(network string) fyne.CanvasObject {
 			if i > 0 && i < len(p.Addresses) {
 			if i > 0 && i < len(p.Addresses) {
 				peerString += ", "
 				peerString += ", "
 			}
 			}
-			peerString += fmt.Sprintf("%s", addr.IP)
+			peerString += addr.IP
 		}
 		}
 		newEntry.Text = peerString
 		newEntry.Text = peerString
 		newEntry.Disable()
 		newEntry.Disable()
-		peerView.AddObject(widget.NewLabel(fmt.Sprintf("Peer: %s", p.PublicKey)))
-		peerView.AddObject(container.NewVBox(container.NewVBox(endpointEntry), container.NewVBox(newEntry)))
+		peerView.Add(widget.NewLabel(fmt.Sprintf("Peer: %s", p.PublicKey)))
+		peerView.Add(container.NewVBox(container.NewVBox(endpointEntry), container.NewVBox(newEntry)))
 	}
 	}
 	peerScroller := container.NewVScroll(peerView)
 	peerScroller := container.NewVScroll(peerView)
-	view.AddObject(peerScroller)
-	view.AddObject(container.NewVBox(pullBtn))
+	view.Add(peerScroller)
+	view.Add(container.NewVBox(pullBtn))
 	netDetailsView.Refresh()
 	netDetailsView.Refresh()
 	ClearNotification()
 	ClearNotification()
 	return netDetailsView
 	return netDetailsView