summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-08 12:55:23 -0600
committerJeff Carr <[email protected]>2024-01-08 12:55:23 -0600
commitb9929490609301454eacbc4bf0358002efb680c8 (patch)
tree57891adffaa205752dafc1025988c1d6be3af841
parent16fe0dacddbb3f425ec43174ccd7fb347e2e310d (diff)
more debugging & smartwindow test
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--errorBox.go8
-rw-r--r--gui.go18
-rw-r--r--main.go3
-rw-r--r--problems.go48
-rw-r--r--structs.go1
5 files changed, 76 insertions, 2 deletions
diff --git a/errorBox.go b/errorBox.go
index 768f762..1e6cbf4 100644
--- a/errorBox.go
+++ b/errorBox.go
@@ -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)
diff --git a/gui.go b/gui.go
index 38d1ec8..06f10ee 100644
--- a/gui.go
+++ b/gui.go
@@ -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?")
diff --git a/main.go b/main.go
index 485c63a..7c3c803 100644
--- a/main.go
+++ b/main.go
@@ -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()
}
})
}
diff --git a/problems.go b/problems.go
new file mode 100644
index 0000000..f315d8b
--- /dev/null
+++ b/problems.go
@@ -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
+}
diff --git a/structs.go b/structs.go
index 0bbe939..df3bc4c 100644
--- a/structs.go
+++ b/structs.go
@@ -65,6 +65,7 @@ type Host struct {
fixWindow *smartwindow.SmartWindow
problems *errorBox
+ autofix *gui.Node
}
type IPtype struct {