more debugging & smartwindow test
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
16fe0dacdd
commit
b992949060
|
@ -103,6 +103,14 @@ func (eb *errorBox) add(kind string, ip string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get all your problems!
|
||||||
|
func (eb *errorBox) Scan() []anError {
|
||||||
|
for s, thing := range eb.fixes {
|
||||||
|
log.Log(CHANGE, "Scan()", s, thing)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (eb *errorBox) fix(key string) bool {
|
func (eb *errorBox) fix(key string) bool {
|
||||||
if eb.fixes[key] == nil {
|
if eb.fixes[key] == nil {
|
||||||
log.Log(WARN, "Unknown error. could not find key =", key)
|
log.Log(WARN, "Unknown error. could not find key =", key)
|
||||||
|
|
18
gui.go
18
gui.go
|
@ -12,7 +12,7 @@ import (
|
||||||
"go.wit.com/gui/cloudflare"
|
"go.wit.com/gui/cloudflare"
|
||||||
"go.wit.com/gui/debugger"
|
"go.wit.com/gui/debugger"
|
||||||
"go.wit.com/gui/gadgets/logsettings"
|
"go.wit.com/gui/gadgets/logsettings"
|
||||||
// "go.wit.com/apps/control-panel-dns/smartwindow"
|
"go.wit.com/apps/control-panel-dns/smartwindow"
|
||||||
)
|
)
|
||||||
|
|
||||||
// This setups up the dns control panel window
|
// This setups up the dns control panel window
|
||||||
|
@ -105,6 +105,20 @@ func mainWindow(title string) {
|
||||||
myLS.Toggle()
|
myLS.Toggle()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
gr.NewButton("test smartwindow()", func () {
|
||||||
|
if me.fixWindow == nil {
|
||||||
|
me.fixWindow = smartwindow.New()
|
||||||
|
me.fixWindow.SetParent(me.myGui)
|
||||||
|
me.fixWindow.Title("smart window test")
|
||||||
|
me.fixWindow.SetDraw(drawFixWindow)
|
||||||
|
me.fixWindow.Vertical()
|
||||||
|
me.fixWindow.Make()
|
||||||
|
me.fixWindow.Draw()
|
||||||
|
me.fixWindow.Hide()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
gr.NewButton("Show Errors", func () {
|
gr.NewButton("Show Errors", func () {
|
||||||
/*
|
/*
|
||||||
if me.fixWindow == nil {
|
if me.fixWindow == nil {
|
||||||
|
@ -121,6 +135,8 @@ func mainWindow(title string) {
|
||||||
*/
|
*/
|
||||||
me.problems.Toggle()
|
me.problems.Toggle()
|
||||||
})
|
})
|
||||||
|
me.autofix = gr.NewCheckbox("Auto-correct Errors")
|
||||||
|
me.autofix.Set(false)
|
||||||
|
|
||||||
// These are your problems
|
// These are your problems
|
||||||
me.problems = NewErrorBox(me.window.Box(), "Errors", "has problems?")
|
me.problems = NewErrorBox(me.window.Box(), "Errors", "has problems?")
|
||||||
|
|
3
main.go
3
main.go
|
@ -152,7 +152,8 @@ func main() {
|
||||||
if working {
|
if working {
|
||||||
log.Log(CHANGE, "EVERYTHING IS WORKING. YOU HAVE IPv6 BLISS. TODO: don't check so often now")
|
log.Log(CHANGE, "EVERYTHING IS WORKING. YOU HAVE IPv6 BLISS. TODO: don't check so often now")
|
||||||
} else {
|
} else {
|
||||||
log.Log(CHANGE, "EVERYTHING IS NOT WORKING. Probably run fix() here?")
|
log.Log(CHANGE, "EVERYTHING IS NOT WORKING. scanning errors:")
|
||||||
|
me.problems.Scan()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
// this defines the kinds of problems that can be detected
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ProblemType int
|
||||||
|
type ActionType int
|
||||||
|
|
||||||
|
type Problem struct {
|
||||||
|
kind ProblemType
|
||||||
|
action ActionType
|
||||||
|
|
||||||
|
id int
|
||||||
|
Name string
|
||||||
|
value string
|
||||||
|
fixed bool
|
||||||
|
duration *time.Duration
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
var hostname Problem = (
|
||||||
|
kind: ProblemType.OS,
|
||||||
|
action: ActionType.CREATE,
|
||||||
|
Name: "Your /etc/hostname file is incorrect",
|
||||||
|
fixed: false,
|
||||||
|
)
|
||||||
|
*/
|
||||||
|
|
||||||
|
const (
|
||||||
|
OS ProblemType = iota
|
||||||
|
ETC
|
||||||
|
RESOLVE
|
||||||
|
RR
|
||||||
|
PING
|
||||||
|
LOOKUP
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
USER ActionType = iota
|
||||||
|
CREATE
|
||||||
|
DELETE
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s Problem) String() string {
|
||||||
|
return s.Name
|
||||||
|
}
|
|
@ -65,6 +65,7 @@ type Host struct {
|
||||||
fixWindow *smartwindow.SmartWindow
|
fixWindow *smartwindow.SmartWindow
|
||||||
|
|
||||||
problems *errorBox
|
problems *errorBox
|
||||||
|
autofix *gui.Node
|
||||||
}
|
}
|
||||||
|
|
||||||
type IPtype struct {
|
type IPtype struct {
|
||||||
|
|
Loading…
Reference in New Issue