Add code to apply the wifi config in the main ui
This commit is contained in:
parent
48d757a6b6
commit
e3008a6d43
20
cmd/ui/ui.go
20
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)
|
||||
|
@ -318,7 +330,7 @@ func main() {
|
|||
// We use this as a bit of a cheat to figure out if we're inside of a form that needs better nav options for users (ie. tab doesn't exist on a remote)
|
||||
wifiField, wifiButton := wifiConfigForm.GetFocusedItemIndex()
|
||||
albumField, albumButton := selectAlbumsForm.GetFocusedItemIndex()
|
||||
if wifiField != -1 || wifiButton != -1 || albumField != -1 || albumButton != -1 {
|
||||
if wifiField != -1 || wifiButton != -1 || albumField != -1 || albumButton != -1 {
|
||||
switch event.Key() {
|
||||
case tcell.KeyUp:
|
||||
return tcell.NewEventKey(tcell.KeyBacktab, 0, event.Modifiers())
|
||||
|
|
Loading…
Reference in a new issue