control-panel-dns/controlPanelWindow.go

105 lines
2.2 KiB
Go
Raw Permalink Normal View History

2023-02-08 11:04:04 -06:00
package main
import (
2023-02-08 11:04:04 -06:00
"os"
"go.wit.com/log"
"go.wit.com/gui"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/gui/cloudflare"
2023-02-08 11:04:04 -06:00
)
// This setups up the dns control panel window
func setupControlPanelWindow(title string) {
2023-02-08 11:04:04 -06:00
}
func makeMainWindow() {
if me.window == nil {
return
}
hbox := me.window.Box().NewBox("bw hbox", true)
statusGrid(hbox)
// some artificial padding to make the last row of buttons look less wierd
group := hbox.NewGroup("Under Development")
group.NewButton("Debug", func() {
me.debug.Toggle()
})
me.showErrorsB = group.NewCheckbox("Show Errors").SetChecked(true)
me.showErrorsB.Custom = func() {
if me.showErrorsB.Checked() {
me.problems.Show()
} else {
me.problems.Hide()
}
}
autofix := group.NewCheckbox("Auto-correct Errors").SetChecked(true)
os.Setenv("DNS_AUTOCORRECT", "true")
autofix.Custom = func() {
if autofix.Checked() {
os.Setenv("DNS_AUTOCORRECT", "true")
} else {
os.Unsetenv("DNS_AUTOCORRECT")
}
}
}
func statusGrid(n *gui.Node) {
problems := n.NewGroup("status")
2024-02-25 18:37:44 -06:00
grid := problems.RawGrid()
grid.NewLabel("hostname =")
me.hostnameStatus = grid.NewLabel("invalid")
grid.NewButton("Linux Status", func() {
me.statusOS.Toggle()
})
2024-02-25 18:37:44 -06:00
grid.NextRow()
me.statusIPv6 = gadgets.NewOneLiner(grid, "DNS Lookup")
me.statusIPv6.SetText("known")
grid.NewButton("resolver status", func() {
if !me.digStatus.Ready() {
return
}
me.digStatus.window.Toggle()
})
2024-02-25 18:37:44 -06:00
grid.NextRow()
grid.NewLabel("DNS Status")
me.DnsStatus = grid.NewLabel("unknown")
me.statusDNSbutton = grid.NewButton("hostname status", func() {
if !me.statusDNS.Ready() {
return
}
me.statusDNS.window.Toggle()
})
2024-02-25 18:37:44 -06:00
grid.NextRow()
grid.NewLabel("DNS API")
me.DnsAPIstatus = grid.NewLabel("unknown")
me.apiButton = grid.NewButton("unknown wit.com", func() {
log.Log(CHANGE, "WHAT API ARE YOU USING?")
provider := me.statusDNS.GetDNSapi()
if provider == "cloudflare" {
if me.witcom != nil {
me.witcom.Toggle()
} else {
me.witcom = cloudflare.CreateRR(me.myGui, "wit.com", "3777302ac4a78cd7fa4f6d3f72086d06")
}
}
})
2024-02-25 18:37:44 -06:00
grid.NextRow()
}
func myDefaultExit(n *gui.Node) {
log.Println("You can Do exit() things here")
os.Exit(0)
}