diff --git a/machine.go b/machine.go index a5946b8..fa2975f 100644 --- a/machine.go +++ b/machine.go @@ -139,6 +139,11 @@ func updatePackages(m *zoopb.Machine, newp *zoopb.Packages) bool { changed = true } } + if p.Name == "forge" { + if updatePackageVersion(m, p) { + changed = true + } + } } return changed } diff --git a/windowZood.go b/windowZood.go index 38688d1..258153a 100644 --- a/windowZood.go +++ b/windowZood.go @@ -16,12 +16,13 @@ import ( 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 - version string // the current zood version - versionL *gui.Node // label widget to display the current zood version - update bool // if the window should be updated + win *gadgets.GenericWindow // the machines gui window + box *gui.Node // the machines gui parent box widget + TB *zoopb.MachinesTable // the machines gui table buffer + version string // the current zood version + versionL *gui.Node // label widget to display the current zood version + outOfDate *gui.Node // checkbox to only show out of date droplets + update bool // if the window should be updated } func (w *stdTableWin) Toggle() { @@ -35,22 +36,26 @@ func (w *stdTableWin) Toggle() { } func makeZoodWin() *stdTableWin { - zood := new(stdTableWin) - zood.win = gadgets.NewGenericWindow("zood daemon versions", "todo: add global controls here") - zood.win.Custom = func() { + stdw := new(stdTableWin) + stdw.win = gadgets.NewGenericWindow("zood daemon versions", "todo: add global controls here") + stdw.win.Custom = func() { log.Info("test delete window here") } - grid := zood.win.Group.RawGrid() + + grid := stdw.win.Group.RawGrid() grid.NewButton("save machines.pb", func() { saveMachineState() }) + grid.NewButton("show active", func() { - zood.doMachinesUpgradeTable(me.machines) + stdw.doMachinesUpgradeTable(me.machines) }) + grid.NewButton("refresh", func() { refresh() }) - zood.versionL = grid.NewLabel("scan") + + stdw.versionL = grid.NewLabel("scan") grid.NewButton("show out of date", func() { found := zoopb.NewMachines() all := me.machines.All() @@ -60,14 +65,32 @@ func makeZoodWin() *stdTableWin { found.Append(m) } } - zood.doMachinesUpgradeTable(found) + stdw.doMachinesUpgradeTable(found) }) // make a box at the bottom of the window for the protobuf table - zood.box = zood.win.Bottom.Box().SetProgName("TBOX") - zood.doMachinesUpgradeTable(me.machines) + stdw.box = stdw.win.Bottom.Box().SetProgName("TBOX") + stdw.doMachinesUpgradeTable(me.machines) - return zood + return stdw +} + +func (stdw *stdTableWin) refresh() { + if stdw.outOfDate.Checked() { + found := zoopb.NewMachines() + all := me.machines.All() + for all.Scan() { + m := all.Next() + if m.FindVersion("zood") != me.zood.version { + found.Append(m) + } + } + stdw.doMachinesUpgradeTable(found) + return + } + + // show all droplets + stdw.doMachinesUpgradeTable(me.machines) } func (zood *stdTableWin) doMachinesUpgradeTable(pb *zoopb.Machines) { @@ -145,10 +168,26 @@ func AddMachinesPB(tbox *gui.Node, pb *zoopb.Machines) *zoopb.MachinesTable { m.UpgradeCmd = "apt install virtigod" } + forgebut := t.AddButtonFunc("forge", func(m *zoopb.Machine) string { + ver := m.FindVersion("forge") + if ver == "n/a" { + return "" + } + return ver + }) + forgebut.Custom = func(m *zoopb.Machine) { + log.Info("Triggering machine", m.Hostname, "to upgrade forge") + m.Upgrade = true + m.UpgradeCmd = "apt install forge" + } + delf := func(m *zoopb.Machine) string { return "delete" } - t.AddButtonFunc("delete", delf) + delbut := t.AddButtonFunc("delete", delf) + delbut.Custom = func(m *zoopb.Machine) { + log.Info("Need to delete the protobuf record here", m.Hostname) + } /* // show if the machine needs to be upgraded