From 6916a6428dc2d2eb7cb8ac18552e3863459894e5 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 7 Jan 2024 11:52:15 -0600 Subject: [PATCH] error button disables Signed-off-by: Jeff Carr --- gui.go | 60 +++++++++++++++++++++++++++++++---------- linuxstatus/hostname.go | 6 ++--- main.go | 4 +-- 3 files changed, 51 insertions(+), 19 deletions(-) diff --git a/gui.go b/gui.go index 4172b11..dbc2034 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/control-panels/dns/linuxstatus" + "go.wit.com/control-panels/dns/smartwindow" ) // This setups up the dns control panel window @@ -81,11 +81,14 @@ func mainWindow(title string) { // me.hostname.Set(hostname) me.hostnameStatus.Set("WORKING") me.DnsStatus.Set("WORKING") + me.fixButton.SetText("No Errors!") + me.fixButton.Disable() }) statusGrid(me.window.Box()) gr = me.window.Box().NewGroup("debugging") +/* me.statusDNSbutton = gr.NewButton("hostname status", func () { if ! me.statusDNS.Ready() {return} me.statusDNS.window.Toggle() @@ -97,12 +100,7 @@ func mainWindow(title string) { if ! me.digStatus.Ready() {return} me.digStatus.window.Toggle() }) - gr.NewButton("cloudflare wit.com", func () { - if me.witcom != nil { - me.witcom.Toggle() - } - me.witcom = cloudflare.CreateRR(me.myGui, "wit.com", "3777302ac4a78cd7fa4f6d3f72086d06") - }) +*/ gr.NewButton("Debug", func () { me.debug.Toggle() }) @@ -116,30 +114,64 @@ func mainWindow(title string) { } myLS.Toggle() }) + gr.NewButton("Show Errors", func () { + if me.fixWindow == nil { + me.fixWindow = smartwindow.New() + me.fixWindow.SetParent(me.myGui) + me.fixWindow.Title("fix window") + me.fixWindow.SetDraw(drawFixWindow) + me.fixWindow.Vertical() + me.fixWindow.Make() + me.fixWindow.Draw() + me.fixWindow.Hide() + return + } + me.fixWindow.Toggle() + }) } + func statusGrid(n *gui.Node) { problems := n.NewGroup("status") - gridP := problems.NewGrid("nuts", 2, 2) + gridP := problems.NewGrid("nuts", 3, 1) gridP.NewLabel("hostname =") me.hostnameStatus = gridP.NewLabel("invalid") + gridP.NewButton("Linux Status", func () { + me.statusOS.Toggle() + }) gridP.NewLabel("DNS Status =") me.DnsStatus = gridP.NewLabel("unknown") + me.statusDNSbutton = gridP.NewButton("hostname status", func () { + if ! me.statusDNS.Ready() {return} + me.statusDNS.window.Toggle() + }) me.statusIPv6 = gadgets.NewOneLiner(gridP, "IPv6 working") me.statusIPv6.Set("known") - - gridP.NewLabel("dns resolution") - me.DnsSpeed = gridP.NewLabel("unknown") - - gridP.NewLabel("dns resolution speed") - me.DnsSpeedActual = gridP.NewLabel("unknown") + gridP.NewButton("resolver status", func () { + if ! me.digStatus.Ready() {return} + me.digStatus.window.Toggle() + }) gridP.NewLabel("dns API provider =") me.DnsAPI = gridP.NewLabel("unknown") + gridP.NewButton("cloudflare wit.com", func () { + if me.witcom != nil { + me.witcom.Toggle() + } + me.witcom = cloudflare.CreateRR(me.myGui, "wit.com", "3777302ac4a78cd7fa4f6d3f72086d06") + }) + + gridP.NewLabel("dns resolution") + me.DnsSpeed = gridP.NewLabel("unknown") + gridP.NewLabel("") + + gridP.NewLabel("dns resolution speed") + me.DnsSpeedActual = gridP.NewLabel("unknown") + gridP.NewLabel("") gridP.Margin() gridP.Pad() diff --git a/linuxstatus/hostname.go b/linuxstatus/hostname.go index 2a83eba..c36541a 100644 --- a/linuxstatus/hostname.go +++ b/linuxstatus/hostname.go @@ -33,7 +33,7 @@ func (ls *LinuxStatus) GetHostname() string { func (ls *LinuxStatus) ValidHostname() bool { if ! me.Ready() {return false} - if me.hostnameStatus.Get() == "VALID" { + if me.hostnameStatus.Get() == "WORKING" { return true } return false @@ -104,9 +104,9 @@ func lookupHostname() { me.hostnameStatus.Set("BROKEN") } } else { - if (me.hostnameStatus.Get() != "VALID") { + if (me.hostnameStatus.Get() != "WORKING") { log.Log(CHANGE, "hostname", hostname, "is valid") - me.hostnameStatus.Set("VALID") + me.hostnameStatus.Set("WORKING") me.changed = true } } diff --git a/main.go b/main.go index e57b4ef..f1f51d3 100644 --- a/main.go +++ b/main.go @@ -162,8 +162,8 @@ func linuxLoop() { me.statusOS.Update() if me.statusOS.ValidHostname() { - if me.hostnameStatus.GetText() != "VALID" { - me.hostnameStatus.Set("VALID") + if me.hostnameStatus.GetText() != "WORKING" { + me.hostnameStatus.Set("WORKING") me.changed = true } }