control-panel-dns/controlPanelWindow.go

109 lines
2.3 KiB
Go

package main
import (
"os"
"go.wit.com/log"
"go.wit.com/gui"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/gui/cloudflare"
)
// This setups up the dns control panel window
func setupControlPanelWindow(title string) {
log.Info("artificial sleep of:", me.artificialSleep)
log.Sleep(me.artificialSleep)
// setup the main tab
me.window = gadgets.NewBasicWindow(me.myGui, title)
me.window.Vertical()
me.window.Make()
makeMainWindow()
// These are your problems
me.problems = NewErrorBox(me.window.Box(), "Errors", "has problems?")
me.problems.addIPerror(RR, USER, "1:1:1:1")
me.window.Draw()
}
func myDefaultExit(n *gui.Node) {
log.Println("You can Do exit() things here")
os.Exit(0)
}
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()
}
}
me.autofix = group.NewCheckbox("Auto-correct Errors")
me.autofix.SetChecked(false)
}
func statusGrid(n *gui.Node) {
problems := n.NewGroup("status")
grid := problems.NewGrid("nuts", 3, 1)
grid.NewLabel("hostname =")
me.hostnameStatus = grid.NewLabel("invalid")
grid.NewButton("Linux Status", func() {
me.statusOS.Toggle()
})
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()
})
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()
})
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")
}
}
})
}