summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-03-06 03:54:08 -0600
committerJeff Carr <[email protected]>2025-03-06 05:34:25 -0600
commitf97e2a48c6330baea7e99dd5dc1e560c23e64494 (patch)
tree8529f6ecd56144174988e16ff14dec37030bc0ba
parent40fedc09b47d2af9fc231b371f346f7e9fc65188 (diff)
1st really awesome table with auto updates
-rw-r--r--doGui.go18
-rw-r--r--main.go2
-rw-r--r--structs.go30
-rw-r--r--windowZooPB.go59
4 files changed, 49 insertions, 60 deletions
diff --git a/doGui.go b/doGui.go
index fb15a82..8ee8c30 100644
--- a/doGui.go
+++ b/doGui.go
@@ -19,6 +19,9 @@ func debug() {
for {
time.Sleep(90 * time.Second)
log.Info("TODO: zookeeper scan here. repo count =")
+ if me.machinesWin != nil {
+ doMachinesUpgradeTable()
+ }
}
}
@@ -42,7 +45,20 @@ func doGui() {
group1 := vbox.NewGroup("Zookeeper Settings")
grid := group1.NewGrid("buildOptions", 0, 0)
- addButtonForZooPB(grid)
+ grid.NewButton("show zoo", func() {
+ // if the window exists, just toggle it open or closed
+ if me.machinesWin != nil {
+ me.machinesWin.Toggle()
+ return
+ }
+
+ me.machinesWin = gadgets.NewGenericWindow("Zoo Machines", "Stuff")
+ me.machinesWin.Win.Custom = func() {
+ log.Info("test delete window here")
+ }
+ me.machinesBox = me.machinesWin.Bottom.Box().SetProgName("TBOX")
+ doMachinesUpgradeTable()
+ })
// sits here forever
debug()
diff --git a/main.go b/main.go
index f7d670f..bae1d78 100644
--- a/main.go
+++ b/main.go
@@ -35,7 +35,7 @@ func main() {
log.DaemonMode(true)
}
- me = new(stuff)
+ me = new(zookeep)
me.hostname, _ = os.Hostname()
me.pollDelay = 10 * time.Second
me.machines = zoopb.NewMachines()
diff --git a/structs.go b/structs.go
index f3978c3..20b3a34 100644
--- a/structs.go
+++ b/structs.go
@@ -7,22 +7,26 @@ import (
"time"
"go.wit.com/gui"
+ "go.wit.com/lib/gadgets"
"go.wit.com/lib/protobuf/zoopb"
)
-var me *stuff
+var me *zookeep
// this app's variables
-type stuff struct {
- hostname string // my fqdn dns zookeeper hostname
- pollDelay time.Duration // how often to report our status
- dog *time.Ticker // the watchdog timer
- dogchan chan bool // can kill the watchdog
- distro string // debian,redhat,gentoo,macos,wincrap
- packages *zoopb.Packages // installed packages and versions
- machines *zoopb.Machines // every machine that has reported itself to the zookeeper
- machines2 *zoopb.Machines // every machine that has reported itself to the zookeeper
- targets map[string]string // what versions the machines should be running
- upgrade map[string]bool // use this to trigger builds
- myGui *gui.Node // the gui toolkit handle
+type zookeep struct {
+ hostname string // my fqdn dns zookeeper hostname
+ pollDelay time.Duration // how often to report our status
+ dog *time.Ticker // the watchdog timer
+ dogchan chan bool // can kill the watchdog
+ distro string // debian,redhat,gentoo,macos,wincrap
+ packages *zoopb.Packages // installed packages and versions
+ machines *zoopb.Machines // every machine that has reported itself to the zookeeper
+ machines2 *zoopb.Machines // every machine that has reported itself to the zookeeper
+ targets map[string]string // what versions the machines should be running
+ upgrade map[string]bool // use this to trigger builds
+ myGui *gui.Node // the gui toolkit handle
+ machinesWin *gadgets.GenericWindow // the machines gui window
+ machinesBox *gui.Node // the machines gui parent box widget
+ machinesTB *zoopb.MachinesTable // the machines gui table buffer
}
diff --git a/windowZooPB.go b/windowZooPB.go
index 154335b..5f7eb74 100644
--- a/windowZooPB.go
+++ b/windowZooPB.go
@@ -8,56 +8,25 @@ import (
"time"
"go.wit.com/gui"
- "go.wit.com/lib/gadgets"
"go.wit.com/lib/protobuf/zoopb"
"go.wit.com/log"
)
-func addButtonForZooPB(grid *gui.Node) (*gui.Node, *gadgets.GenericWindow) {
- var win *gadgets.GenericWindow
- b := grid.NewButton("show zoo", func() {
- // if the window exists, just toggle it open or closed
- if win != nil {
- win.Toggle()
- return
- }
-
- win = gadgets.NewGenericWindow("Zoo Raw PB View", "Stuff")
- win.Win.Custom = func() {
- log.Info("test delete window here")
- }
- tbox := win.Bottom.Box().SetProgName("TBOX")
- grid := win.Group.RawGrid()
-
- var t *zoopb.MachinesTable
- grid.NewButton("Show", func() {
- if t != nil {
- t.Delete()
- t = nil
- }
-
- // display the protobuf
- t = AddMachinesPB(tbox, me.machines)
- f := func(m *zoopb.Machine) {
- log.Info("got to MachinesTable.Custom() ", m.Hostname)
- }
- t.Custom(f)
- log.Info("table has uuid", t.GetUuid())
- })
+func doMachinesUpgradeTable() {
+ if me.machinesTB != nil {
+ me.machinesTB.Delete()
+ me.machinesTB = nil
+ }
- grid.NewButton("update", func() {
- if t != nil {
- t.Delete()
- t = nil
- }
- t = AddMachinesPB(tbox, me.machines)
- log.Info("table has uuid", t.GetUuid())
- })
- grid.NewButton("ListChildren", func() {
- me.myGui.ListChildren(false)
- })
- })
- return b, win
+ // display the protobuf
+ me.machinesTB = AddMachinesPB(me.machinesBox, me.machines)
+ f := func(m *zoopb.Machine) {
+ log.Info("upgrade machine", m.Hostname, "memory", m.Memory/(1024*1024*1024))
+ log.Info("ADD THE CODE TO TRIGGER AN UPGRADE HERE")
+ log.Info("ADD THE CODE TO TRIGGER AN UPGRADE HERE")
+ }
+ me.machinesTB.Custom(f)
+ log.Info("table has uuid", me.machinesTB.GetUuid())
}
func AddMachinesPB(tbox *gui.Node, pb *zoopb.Machines) *zoopb.MachinesTable {