diff options
| author | Jeff Carr <[email protected]> | 2025-03-06 03:54:08 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-03-06 05:34:25 -0600 |
| commit | f97e2a48c6330baea7e99dd5dc1e560c23e64494 (patch) | |
| tree | 8529f6ecd56144174988e16ff14dec37030bc0ba | |
| parent | 40fedc09b47d2af9fc231b371f346f7e9fc65188 (diff) | |
1st really awesome table with auto updates
| -rw-r--r-- | doGui.go | 18 | ||||
| -rw-r--r-- | main.go | 2 | ||||
| -rw-r--r-- | structs.go | 30 | ||||
| -rw-r--r-- | windowZooPB.go | 59 |
4 files changed, 49 insertions, 60 deletions
@@ -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() @@ -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() @@ -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 { |
