diff options
| author | Jeff Carr <[email protected]> | 2025-03-05 07:46:05 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-03-05 12:42:50 -0600 |
| commit | a57b2875af4f60c24a5c655304dd1ec5a69c7c0b (patch) | |
| tree | 1d5ac31ecf3ab989d9159e176c0efa1cbc7f198f /windowZooPB.go | |
| parent | 46f69bee210ac7bb9f0e87e1467d8cf322df1521 (diff) | |
protobuf update works
Diffstat (limited to 'windowZooPB.go')
| -rw-r--r-- | windowZooPB.go | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/windowZooPB.go b/windowZooPB.go new file mode 100644 index 0000000..72f0a4e --- /dev/null +++ b/windowZooPB.go @@ -0,0 +1,81 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + +package main + +import ( + "fmt" + "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) + log.Info("table has uuid", t.GetUuid()) + }) + + grid.NewButton("update", func() { + if t != nil { + t.Delete() + t = nil + } + t = AddMachinesPB(tbox, me.machines) + log.Info("table has uuid", t.GetUuid()) + }) + }) + return b, win +} + +func AddMachinesPB(tbox *gui.Node, pb *zoopb.Machines) *zoopb.MachinesTable { + t := pb.NewTable("MachinesPB") + t.NewUuid() + t.SetParent(tbox) + + t.AddHostname() + t.AddMemory() + t.AddCpus() + t.AddStringFunc("sMB", func(m *zoopb.Machine) string { + return fmt.Sprintf("%d mb", m.Memory/(1024*1024)) + }) + t.AddStringFunc("zood", func(m *zoopb.Machine) string { + return findVersion(m, "zood") + }) + t.AddTimeFunc("age", func(m *zoopb.Machine) time.Time { + return m.Laststamp.AsTime() + }) + + f := func(m *zoopb.Machine) string { + log.Info("machine =", m.Hostname) + return m.Hostname + } + t.AddButtonFunc("upgrade", f) + t.ShowTable() + return t +} |
