summaryrefslogtreecommitdiff
path: root/windowZood.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-03-12 13:16:05 -0500
committerJeff Carr <[email protected]>2025-03-12 13:17:19 -0500
commit767380abd080682f2e13d8d41633c0f600b8f616 (patch)
tree932fdffe21bce59c57580857135633b4ff7ef196 /windowZood.go
parentbb4a6a01df71f7ce4338b8f61806ebf8832bffbf (diff)
the forgotten patchv0.0.47
Diffstat (limited to 'windowZood.go')
-rw-r--r--windowZood.go83
1 files changed, 53 insertions, 30 deletions
diff --git a/windowZood.go b/windowZood.go
index 347aa4e..bd18044 100644
--- a/windowZood.go
+++ b/windowZood.go
@@ -5,6 +5,7 @@ package main
import (
"fmt"
+ "sync"
"time"
"go.wit.com/gui"
@@ -13,42 +14,71 @@ import (
"go.wit.com/log"
)
-func makeZoodWin() {
- me.zood = new(stdTableWin)
- me.zood.win = gadgets.NewGenericWindow("zood daemon versions", "todo: add global controls here")
- me.zood.win.Custom = func() {
+type stdTableWin struct {
+ sync.Mutex
+ win *gadgets.GenericWindow // the machines gui window
+ box *gui.Node // the machines gui parent box widget
+ TB *zoopb.MachinesTable // the machines gui table buffer
+ update bool // if the window should be updated
+}
+
+func (w *stdTableWin) Toggle() {
+ if w == nil {
+ return
+ }
+ if w.win == nil {
+ return
+ }
+ w.win.Toggle()
+}
+
+func makeZoodWin() *stdTableWin {
+ zood := new(stdTableWin)
+ zood.win = gadgets.NewGenericWindow("zood daemon versions", "todo: add global controls here")
+ zood.win.Custom = func() {
log.Info("test delete window here")
}
- grid := me.zood.win.Group.RawGrid()
+ grid := zood.win.Group.RawGrid()
grid.NewButton("save machines.pb", func() {
saveMachineState()
})
grid.NewCheckbox("hide active")
grid.NewButton("update", func() {
- doMachinesUpgradeTable()
+ zood.doMachinesUpgradeTable(me.machines)
})
// make a box at the bottom of the window for the protobuf table
- me.zood.box = me.zood.win.Bottom.Box().SetProgName("TBOX")
- doMachinesUpgradeTable()
+ zood.box = zood.win.Bottom.Box().SetProgName("TBOX")
+ zood.doMachinesUpgradeTable(me.machines)
+
+ return zood
}
-func doMachinesUpgradeTable() {
- me.zood.Lock()
- defer me.zood.Unlock()
- if me.zood.TB != nil {
- me.zood.TB.Delete()
- me.zood.TB = nil
+func (zood *stdTableWin) doMachinesUpgradeTable(pb *zoopb.Machines) {
+ zood.Lock()
+ defer zood.Unlock()
+ if zood.TB != nil {
+ zood.TB.Delete()
+ zood.TB = nil
}
+ /*
+ found := zoopb.NewMachines()
+ all := pb.SortByHostname()
+ for all.Scan() {
+ m := all.Next()
+ found.Append(m)
+ }
+ */
+
// display the protobuf
- me.zood.TB = AddMachinesPB(me.zood.box, me.machines)
+ zood.TB = AddMachinesPB(zood.box, pb)
f := func(m *zoopb.Machine) {
log.Info("Triggering machine", m.Hostname, "to upgrade zood")
m.Upgrade = true
}
- me.zood.TB.Custom(f)
- log.Info("table has uuid", me.zood.TB.GetUuid())
+ zood.TB.Custom(f)
+ log.Info("table has uuid", zood.TB.GetUuid())
}
func AddMachinesPB(tbox *gui.Node, pb *zoopb.Machines) *zoopb.MachinesTable {
@@ -57,7 +87,7 @@ func AddMachinesPB(tbox *gui.Node, pb *zoopb.Machines) *zoopb.MachinesTable {
t.SetParent(tbox)
f := func(m *zoopb.Machine) string {
- log.Info("machine =", m.Hostname)
+ // log.Info("machine =", m.Hostname)
return "now"
}
t.AddButtonFunc("upgrade", f)
@@ -72,6 +102,11 @@ func AddMachinesPB(tbox *gui.Node, pb *zoopb.Machines) *zoopb.MachinesTable {
t.AddStringFunc("zood", func(m *zoopb.Machine) string {
return findVersion(m, "zood")
})
+ delf := func(m *zoopb.Machine) string {
+ pb.DeleteByHostname(m.Hostname)
+ return "delete"
+ }
+ t.AddButtonFunc("delete", delf)
/*
// show if the machine needs to be upgraded
@@ -98,15 +133,3 @@ func findVersion(m *zoopb.Machine, pkgname string) string {
}
return zood.Version
}
-
-func saveMachineState() {
- cur := zoopb.NewMachines()
-
- all := me.machines.SortByHostname()
- for all.Scan() {
- m := all.Next()
- log.Info("have machine:", m.Hostname)
- cur.Append(m)
- }
- cur.ConfigSave()
-}