Add code to apply the wifi config in the main ui
This commit is contained in:
parent
48d757a6b6
commit
e3008a6d43
18
cmd/ui/ui.go
18
cmd/ui/ui.go
|
@ -13,6 +13,8 @@ import (
|
|||
"github.com/gdamore/tcell"
|
||||
"github.com/guillermo/go.procmeminfo"
|
||||
"github.com/rivo/tview"
|
||||
|
||||
"git.kemonine.info/PiFrame/wifi"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -130,9 +132,19 @@ func main() {
|
|||
|
||||
// WiFi Config Form
|
||||
wifiConfigForm := tview.NewForm()
|
||||
wifiConfigForm.AddInputField("Access Point", "", 0, nil, nil)
|
||||
wifiConfigForm.AddPasswordField("Password", "", 0, '*', nil)
|
||||
wifiConfigForm.AddButton("Apply", nil)
|
||||
wifiConfigAccessPoint := ""
|
||||
wifiConfigPassword := ""
|
||||
wifiConfigForm.AddInputField("Access Point", "", 0, nil, func(value string) {
|
||||
wifiConfigAccessPoint = value
|
||||
})
|
||||
wifiConfigForm.AddPasswordField("Password", "", 0, '*', func(value string) {
|
||||
wifiConfigPassword = value
|
||||
})
|
||||
wifiConfigForm.AddButton("Apply", func() {
|
||||
// Cleanup old wifi configs and apply new one
|
||||
nmWifi := wifi.New(wifiConfigAccessPoint, wifiConfigPassword)
|
||||
nmWifi.ApplyConfig()
|
||||
})
|
||||
wifiConfigForm.AddButton("Cancel", func() {
|
||||
main.Clear()
|
||||
app.SetFocus(menu)
|
||||
|
|
Loading…
Reference in a new issue