1st really awesome table with auto updates

This commit is contained in:
Jeff Carr 2025-03-06 03:54:08 -06:00
parent 40fedc09b4
commit f97e2a48c6
4 changed files with 49 additions and 60 deletions

View File

@ -19,6 +19,9 @@ func debug() {
for { for {
time.Sleep(90 * time.Second) time.Sleep(90 * time.Second)
log.Info("TODO: zookeeper scan here. repo count =") log.Info("TODO: zookeeper scan here. repo count =")
if me.machinesWin != nil {
doMachinesUpgradeTable()
}
} }
} }
@ -42,7 +45,20 @@ func doGui() {
group1 := vbox.NewGroup("Zookeeper Settings") group1 := vbox.NewGroup("Zookeeper Settings")
grid := group1.NewGrid("buildOptions", 0, 0) 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 // sits here forever
debug() debug()

View File

@ -35,7 +35,7 @@ func main() {
log.DaemonMode(true) log.DaemonMode(true)
} }
me = new(stuff) me = new(zookeep)
me.hostname, _ = os.Hostname() me.hostname, _ = os.Hostname()
me.pollDelay = 10 * time.Second me.pollDelay = 10 * time.Second
me.machines = zoopb.NewMachines() me.machines = zoopb.NewMachines()

View File

@ -7,13 +7,14 @@ import (
"time" "time"
"go.wit.com/gui" "go.wit.com/gui"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/protobuf/zoopb" "go.wit.com/lib/protobuf/zoopb"
) )
var me *stuff var me *zookeep
// this app's variables // this app's variables
type stuff struct { type zookeep struct {
hostname string // my fqdn dns zookeeper hostname hostname string // my fqdn dns zookeeper hostname
pollDelay time.Duration // how often to report our status pollDelay time.Duration // how often to report our status
dog *time.Ticker // the watchdog timer dog *time.Ticker // the watchdog timer
@ -25,4 +26,7 @@ type stuff struct {
targets map[string]string // what versions the machines should be running targets map[string]string // what versions the machines should be running
upgrade map[string]bool // use this to trigger builds upgrade map[string]bool // use this to trigger builds
myGui *gui.Node // the gui toolkit handle 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
} }

View File

@ -8,56 +8,25 @@ import (
"time" "time"
"go.wit.com/gui" "go.wit.com/gui"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/protobuf/zoopb" "go.wit.com/lib/protobuf/zoopb"
"go.wit.com/log" "go.wit.com/log"
) )
func addButtonForZooPB(grid *gui.Node) (*gui.Node, *gadgets.GenericWindow) { func doMachinesUpgradeTable() {
var win *gadgets.GenericWindow if me.machinesTB != nil {
b := grid.NewButton("show zoo", func() { me.machinesTB.Delete()
// if the window exists, just toggle it open or closed me.machinesTB = nil
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 // display the protobuf
t = AddMachinesPB(tbox, me.machines) me.machinesTB = AddMachinesPB(me.machinesBox, me.machines)
f := func(m *zoopb.Machine) { f := func(m *zoopb.Machine) {
log.Info("got to MachinesTable.Custom() ", m.Hostname) 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")
} }
t.Custom(f) me.machinesTB.Custom(f)
log.Info("table has uuid", t.GetUuid()) log.Info("table has uuid", me.machinesTB.GetUuid())
})
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
} }
func AddMachinesPB(tbox *gui.Node, pb *zoopb.Machines) *zoopb.MachinesTable { func AddMachinesPB(tbox *gui.Node, pb *zoopb.Machines) *zoopb.MachinesTable {