more debugging & smartwindow test

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-08 12:55:23 -06:00
parent 16fe0dacdd
commit b992949060
5 changed files with 76 additions and 2 deletions

View File

@ -103,6 +103,14 @@ func (eb *errorBox) add(kind string, ip string) bool {
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 {
if eb.fixes[key] == nil {
log.Log(WARN, "Unknown error. could not find key =", key)

18
gui.go
View File

@ -12,7 +12,7 @@ import (
"go.wit.com/gui/cloudflare"
"go.wit.com/gui/debugger"
"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
@ -105,6 +105,20 @@ func mainWindow(title string) {
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 () {
/*
if me.fixWindow == nil {
@ -121,6 +135,8 @@ func mainWindow(title string) {
*/
me.problems.Toggle()
})
me.autofix = gr.NewCheckbox("Auto-correct Errors")
me.autofix.Set(false)
// These are your problems
me.problems = NewErrorBox(me.window.Box(), "Errors", "has problems?")

View File

@ -152,7 +152,8 @@ func main() {
if working {
log.Log(CHANGE, "EVERYTHING IS WORKING. YOU HAVE IPv6 BLISS. TODO: don't check so often now")
} else {
log.Log(CHANGE, "EVERYTHING IS NOT WORKING. Probably run fix() here?")
log.Log(CHANGE, "EVERYTHING IS NOT WORKING. scanning errors:")
me.problems.Scan()
}
})
}

48
problems.go Normal file
View File

@ -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
}

View File

@ -65,6 +65,7 @@ type Host struct {
fixWindow *smartwindow.SmartWindow
problems *errorBox
autofix *gui.Node
}
type IPtype struct {