remove debugging options
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
82b5717f48
commit
930bdc941b
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
Show a box for a configuration error
|
||||||
|
*/
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.wit.com/log"
|
||||||
|
"go.wit.com/gui/gui"
|
||||||
|
"go.wit.com/gui/gadgets"
|
||||||
|
)
|
||||||
|
|
||||||
|
type errorBox struct {
|
||||||
|
name string // the problem name
|
||||||
|
|
||||||
|
parent *gui.Node
|
||||||
|
group *gui.Node
|
||||||
|
grid *gui.Node
|
||||||
|
|
||||||
|
l *gui.Node
|
||||||
|
b *gui.Node
|
||||||
|
|
||||||
|
something *gadgets.OneLiner
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewErrorBox(p *gui.Node, name string) *errorBox {
|
||||||
|
var eb *errorBox
|
||||||
|
eb = new(errorBox)
|
||||||
|
eb.parent = p
|
||||||
|
// eb.group = p.NewGroup("eg")
|
||||||
|
// eb.grid = eb.group.NewGrid("labels", 2, 1)
|
||||||
|
|
||||||
|
eb.l = p.NewLabel("click to fix")
|
||||||
|
eb.b = p.NewButton("fix", func() {
|
||||||
|
log.Log(WARN, "should try to fix here")
|
||||||
|
})
|
||||||
|
eb.something = gadgets.NewOneLiner(eb.grid, "something")
|
||||||
|
|
||||||
|
return eb
|
||||||
|
}
|
||||||
|
|
||||||
|
func (eb *errorBox) update() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (eb *errorBox) toggle() {
|
||||||
|
}
|
24
fix.go
24
fix.go
|
@ -4,6 +4,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/cloudflare"
|
"go.wit.com/gui/cloudflare"
|
||||||
|
"go.wit.com/control-panels/dns/smartwindow"
|
||||||
)
|
)
|
||||||
|
|
||||||
func fix() bool {
|
func fix() bool {
|
||||||
|
@ -65,13 +66,16 @@ func fixIPv6dns() bool {
|
||||||
// remove old DNS entries first
|
// remove old DNS entries first
|
||||||
for aaaa, _ := range dnsAAAA {
|
for aaaa, _ := range dnsAAAA {
|
||||||
if osAAAA[aaaa] == "dns" {
|
if osAAAA[aaaa] == "dns" {
|
||||||
log.Log(INFO, "DNS AAAA is not in OS", aaaa)
|
|
||||||
broken = true
|
broken = true
|
||||||
|
log.Log(INFO, "DNS AAAA is not in OS", aaaa)
|
||||||
|
addToFixWindow("DELETE", aaaa)
|
||||||
|
/*
|
||||||
if deleteFromDNS(aaaa) {
|
if deleteFromDNS(aaaa) {
|
||||||
log.Log(INFO, "Delete AAAA", aaaa, "Worked")
|
log.Log(INFO, "Delete AAAA", aaaa, "Worked")
|
||||||
} else {
|
} else {
|
||||||
log.Log(INFO, "Delete AAAA", aaaa, "Failed")
|
log.Log(INFO, "Delete AAAA", aaaa, "Failed")
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
} else {
|
} else {
|
||||||
log.Log(INFO, "DNS AAAA is in OS", aaaa)
|
log.Log(INFO, "DNS AAAA is in OS", aaaa)
|
||||||
}
|
}
|
||||||
|
@ -84,11 +88,14 @@ func fixIPv6dns() bool {
|
||||||
} else {
|
} else {
|
||||||
broken = true
|
broken = true
|
||||||
log.Log(INFO, "OS AAAA is not in DNS", aaaa)
|
log.Log(INFO, "OS AAAA is not in DNS", aaaa)
|
||||||
|
addToFixWindow("CREATE", aaaa)
|
||||||
|
/*
|
||||||
if addToDNS(aaaa) {
|
if addToDNS(aaaa) {
|
||||||
log.Log(INFO, "Add AAAA", aaaa, "Worked")
|
log.Log(INFO, "Add AAAA", aaaa, "Worked")
|
||||||
} else {
|
} else {
|
||||||
log.Log(INFO, "Add AAAA", aaaa, "Failed")
|
log.Log(INFO, "Add AAAA", aaaa, "Failed")
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,3 +126,18 @@ func exists(m map[string]bool, s string) bool {
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func addToFixWindow(t string, ip string) {
|
||||||
|
if me.fixWindow == nil {
|
||||||
|
me.fixWindow = smartwindow.New()
|
||||||
|
me.fixWindow.SetParent(me.myGui)
|
||||||
|
me.fixWindow.InitWindow()
|
||||||
|
me.fixWindow.Title("fix window")
|
||||||
|
me.fixWindow.SetDraw(drawFixWindow)
|
||||||
|
me.fixWindow.Make()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func drawFixWindow(sw *smartwindow.SmartWindow) {
|
||||||
|
log.Log(WARN, "drawFixWindow() START")
|
||||||
|
}
|
||||||
|
|
20
gui.go
20
gui.go
|
@ -149,26 +149,6 @@ func mainWindow(title string) {
|
||||||
if ! me.statusDNS.Ready() {return}
|
if ! me.statusDNS.Ready() {return}
|
||||||
me.statusDNS.window.Toggle()
|
me.statusDNS.window.Toggle()
|
||||||
})
|
})
|
||||||
|
|
||||||
gr.NewButton("linuxstatus.New()", func () {
|
|
||||||
if (me.statusOS == nil) {
|
|
||||||
me.statusOS = linuxstatus.New()
|
|
||||||
}
|
|
||||||
me.statusOS.SetParent(me.myGui)
|
|
||||||
me.statusOS.InitWindow()
|
|
||||||
me.statusOS.Make()
|
|
||||||
me.statusOS.Draw2()
|
|
||||||
})
|
|
||||||
gr.NewButton("statusOS.Ready()", func () {
|
|
||||||
me.statusOS.Ready()
|
|
||||||
})
|
|
||||||
gr.NewButton("statusOS.Draw()", func () {
|
|
||||||
me.statusOS.Draw()
|
|
||||||
me.statusOS.Draw2()
|
|
||||||
})
|
|
||||||
gr.NewButton("statusOS.Update()", func () {
|
|
||||||
me.statusOS.Update()
|
|
||||||
})
|
|
||||||
gr.NewButton("Linux Status", func () {
|
gr.NewButton("Linux Status", func () {
|
||||||
me.statusOS.Toggle()
|
me.statusOS.Toggle()
|
||||||
})
|
})
|
||||||
|
|
7
main.go
7
main.go
|
@ -48,7 +48,12 @@ func main() {
|
||||||
me.digStatus = NewDigStatusWindow(me.myGui)
|
me.digStatus = NewDigStatusWindow(me.myGui)
|
||||||
me.statusDNS = NewHostnameStatusWindow(me.myGui)
|
me.statusDNS = NewHostnameStatusWindow(me.myGui)
|
||||||
|
|
||||||
linuxstatus.New()
|
me.statusOS = linuxstatus.New()
|
||||||
|
me.statusOS.SetParent(me.myGui)
|
||||||
|
me.statusOS.InitWindow()
|
||||||
|
me.statusOS.Make()
|
||||||
|
me.statusOS.Draw()
|
||||||
|
me.statusOS.Draw2()
|
||||||
|
|
||||||
if debugger.ArgDebug() {
|
if debugger.ArgDebug() {
|
||||||
log.Sleep(2)
|
log.Sleep(2)
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package smartwindow
|
||||||
|
|
||||||
|
/*
|
||||||
|
this enables command line options from other packages like 'gui' and 'log'
|
||||||
|
*/
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
var NOW log.LogFlag
|
||||||
|
var INFO log.LogFlag
|
||||||
|
var SPEW log.LogFlag
|
||||||
|
var WARN log.LogFlag
|
||||||
|
|
||||||
|
func myreg(f *log.LogFlag, b bool, name string, desc string) {
|
||||||
|
f.B = b
|
||||||
|
f.Subsystem = "go.wit.com/gadgets/smartwindow"
|
||||||
|
f.Short = "smartWin"
|
||||||
|
f.Desc = desc
|
||||||
|
f.Name = name
|
||||||
|
f.Register()
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
myreg(&NOW, true, "NOW", "temp debugging stuff")
|
||||||
|
myreg(&INFO, false, "INFO", "normal debugging stuff")
|
||||||
|
myreg(&SPEW, false, "SPEW", "spew stuff")
|
||||||
|
myreg(&WARN, true, "WARN", "bad things")
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
// This creates a 'smart window'
|
||||||
|
// it should work even when it is hidden
|
||||||
|
// from the gui toolkit plugins
|
||||||
|
package smartwindow
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (sw *SmartWindow) Ready() bool {
|
||||||
|
log.Log(WARN, "Ready() maybe not ready? sw =", sw)
|
||||||
|
if sw == nil {return false}
|
||||||
|
if sw == nil {return false}
|
||||||
|
if sw.window == nil {return false}
|
||||||
|
return sw.ready
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sw *SmartWindow) Initialized() bool {
|
||||||
|
log.Log(WARN, "checking Initialized()")
|
||||||
|
if sw == nil {return false}
|
||||||
|
if sw == nil {return false}
|
||||||
|
if sw.parent == nil {return false}
|
||||||
|
return true
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package smartwindow
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.wit.com/log"
|
||||||
|
|
||||||
|
"go.wit.com/gui/gadgets"
|
||||||
|
)
|
||||||
|
|
||||||
|
func New() *SmartWindow {
|
||||||
|
sw := SmartWindow {
|
||||||
|
hidden: true,
|
||||||
|
ready: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
return &sw
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sw *SmartWindow) InitWindow() {
|
||||||
|
if sw == nil {
|
||||||
|
log.Log(WARN, "not initalized yet (no parent for the window?)")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if sw.window != nil {
|
||||||
|
log.Log(WARN, "You already have a SmartWindow")
|
||||||
|
sw.ready = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Log(WARN, "Creating the Window")
|
||||||
|
sw.window = gadgets.NewBasicWindow(sw.parent, sw.title)
|
||||||
|
sw.ready = true
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
// This creates a 'smart window'
|
||||||
|
// it should work even when it is hidden
|
||||||
|
// from the gui toolkit plugins
|
||||||
|
package smartwindow
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.wit.com/log"
|
||||||
|
"go.wit.com/gui/gui"
|
||||||
|
)
|
||||||
|
|
||||||
|
/*
|
||||||
|
all these functions run after the window is Ready()
|
||||||
|
so they should all start with that check
|
||||||
|
*/
|
||||||
|
|
||||||
|
// reports externally if something has changed
|
||||||
|
// since the last time it was asked about it
|
||||||
|
func (sw *SmartWindow) Changed() bool {
|
||||||
|
if ! sw.Ready() {return false}
|
||||||
|
|
||||||
|
if sw.changed {
|
||||||
|
sw.changed = false
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sw *SmartWindow) Show() {
|
||||||
|
if ! sw.Ready() {return}
|
||||||
|
|
||||||
|
log.Log(WARN, "Show() window ready =", sw.ready)
|
||||||
|
sw.window.Show()
|
||||||
|
sw.hidden = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sw *SmartWindow) Hide() {
|
||||||
|
if ! sw.Ready() {return}
|
||||||
|
|
||||||
|
log.Log(WARN, "Hide() window ready =", sw.ready)
|
||||||
|
sw.window.Hide()
|
||||||
|
sw.hidden = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sw *SmartWindow) Toggle() {
|
||||||
|
if ! sw.Ready() {return}
|
||||||
|
|
||||||
|
log.Log(WARN, "Toggle() window ready =", sw.ready)
|
||||||
|
if sw.hidden {
|
||||||
|
sw.Show()
|
||||||
|
} else {
|
||||||
|
sw.Hide()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sw *SmartWindow) Box() *gui.Node {
|
||||||
|
if ! sw.Ready() {return nil}
|
||||||
|
|
||||||
|
return sw.window.Box()
|
||||||
|
}
|
|
@ -0,0 +1,84 @@
|
||||||
|
// these are things you can config
|
||||||
|
package smartwindow
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.wit.com/log"
|
||||||
|
"go.wit.com/gui/gui"
|
||||||
|
)
|
||||||
|
|
||||||
|
/* for now, run these before the window is ready
|
||||||
|
That is, they all start with:
|
||||||
|
|
||||||
|
if ! sw.Initialized() {return}
|
||||||
|
if sw.Ready() {return}
|
||||||
|
*/
|
||||||
|
|
||||||
|
func (sw *SmartWindow) Title(title string) {
|
||||||
|
if ! sw.Initialized() {return}
|
||||||
|
if sw.Ready() {return}
|
||||||
|
|
||||||
|
log.Log(WARN, "Title() =", title)
|
||||||
|
sw.title = title
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sw *SmartWindow) SetParent(p *gui.Node) {
|
||||||
|
if ! sw.Initialized() {return}
|
||||||
|
if sw.Ready() {return}
|
||||||
|
|
||||||
|
log.Log(WARN, "SetParent")
|
||||||
|
if sw.parent == nil {
|
||||||
|
log.Log(WARN, "SetParent =", p)
|
||||||
|
sw.parent = p
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
log.Log(WARN, "SetParent was already set. TODO: Move to new parent")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sw *SmartWindow) SetDraw(f func(*SmartWindow)) {
|
||||||
|
if ! sw.Initialized() {return}
|
||||||
|
if sw.Ready() {return}
|
||||||
|
|
||||||
|
sw.populate = f
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sw *SmartWindow) Make() {
|
||||||
|
if ! sw.Initialized() {return}
|
||||||
|
if sw.Ready() {return}
|
||||||
|
|
||||||
|
log.Log(WARN, "Make() window ready =", sw.ready)
|
||||||
|
sw.window.Make()
|
||||||
|
if (sw.populate != nil) {
|
||||||
|
log.Log(WARN, "Make() trying to run Custom sw.populate() here")
|
||||||
|
sw.populate(sw)
|
||||||
|
}
|
||||||
|
sw.ready = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sw *SmartWindow) Draw() {
|
||||||
|
if ! sw.Initialized() {return}
|
||||||
|
if sw.Ready() {return}
|
||||||
|
|
||||||
|
log.Log(WARN, "Draw() window ready =", sw.ready)
|
||||||
|
sw.window.Draw()
|
||||||
|
if (sw.populate != nil) {
|
||||||
|
log.Log(WARN, "Make() trying to run Custom sw.populate() here")
|
||||||
|
sw.populate(sw)
|
||||||
|
}
|
||||||
|
sw.ready = true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (sw *SmartWindow) Vertical() {
|
||||||
|
if ! sw.Initialized() {return}
|
||||||
|
if sw.Ready() {return}
|
||||||
|
|
||||||
|
log.Log(WARN, "Draw() window ready =", sw.ready)
|
||||||
|
sw.window.Draw()
|
||||||
|
if (sw.populate != nil) {
|
||||||
|
log.Log(WARN, "Make() trying to run Custom sw.populate() here")
|
||||||
|
sw.populate(sw)
|
||||||
|
}
|
||||||
|
sw.ready = true
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package smartwindow
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.wit.com/gui/gui"
|
||||||
|
"go.wit.com/gui/gadgets"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SmartWindow struct {
|
||||||
|
ready bool // track if the window is ready
|
||||||
|
hidden bool // track if the window is hidden from the toolkits
|
||||||
|
changed bool // track if something changed in the window
|
||||||
|
|
||||||
|
title string // what the user sees as the name
|
||||||
|
name string // the programatic name aka: "CALANDAR"
|
||||||
|
|
||||||
|
parent *gui.Node // where to place the window if you try to draw it
|
||||||
|
window *gadgets.BasicWindow // the underlying BasicWindow
|
||||||
|
box *gui.Node // the box inside the window // get this from BasicWindow() ?
|
||||||
|
|
||||||
|
populate func(*SmartWindow) // the function to generate the widgets
|
||||||
|
}
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"go.wit.com/gui/gadgets"
|
"go.wit.com/gui/gadgets"
|
||||||
// "go.wit.com/gui/cloudflare"
|
// "go.wit.com/gui/cloudflare"
|
||||||
"go.wit.com/control-panels/dns/linuxstatus"
|
"go.wit.com/control-panels/dns/linuxstatus"
|
||||||
|
"go.wit.com/control-panels/dns/smartwindow"
|
||||||
|
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
)
|
)
|
||||||
|
@ -60,6 +61,7 @@ type Host struct {
|
||||||
digStatusButton *gui.Node
|
digStatusButton *gui.Node
|
||||||
witcom *gadgets.BasicWindow
|
witcom *gadgets.BasicWindow
|
||||||
fixButton *gui.Node
|
fixButton *gui.Node
|
||||||
|
fixWindow *smartwindow.SmartWindow
|
||||||
}
|
}
|
||||||
|
|
||||||
type IPtype struct {
|
type IPtype struct {
|
||||||
|
|
Loading…
Reference in New Issue