summaryrefslogtreecommitdiff
path: root/windowPortmap.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-03-09 09:30:39 -0500
committerJeff Carr <[email protected]>2025-03-09 09:30:39 -0500
commit2495995e6e50be78e8501eeeaf1a1b7cf067e6ae (patch)
treecb4b867efc5402cfcab7ab9ffcfc315a5140aa73 /windowPortmap.go
parent66000419bf15cb255e436db44a2a74bf104484e3 (diff)
testing ConfigSave() and load
Diffstat (limited to 'windowPortmap.go')
-rw-r--r--windowPortmap.go76
1 files changed, 25 insertions, 51 deletions
diff --git a/windowPortmap.go b/windowPortmap.go
index 83ce7aa..3fb1ecf 100644
--- a/windowPortmap.go
+++ b/windowPortmap.go
@@ -6,7 +6,6 @@ package main
import (
"go.wit.com/gui"
"go.wit.com/lib/gadgets"
- "go.wit.com/lib/protobuf/zoopb"
"go.wit.com/log"
)
@@ -17,9 +16,11 @@ func makePortmapWin() {
log.Info("test delete window here")
}
grid := me.portwin.win.Group.RawGrid()
- grid.NewButton("save machines.pb", func() {
+ grid.NewButton("ConfigSave() ", func() {
saveMachineState()
})
+ grid.NewButton("Add() ", func() {
+ })
grid.NewCheckbox("hide active")
grid.NewButton("update", func() {
doMachinesUpgradeTable()
@@ -53,63 +54,36 @@ func AddMachinesPB(tbox *gui.Node, pb *Portmaps) *PortmapsTable {
t.NewUuid()
t.SetParent(tbox)
- f := func(m *Portmap) string {
+ editf := func(m *Portmap) string {
log.Info("machine =", m.Connect)
- return "now"
+ return "edit"
}
- t.AddButtonFunc("upgrade", f)
-
- t.AddConnect()
- // t.AddMemory()
- // t.AddCpus()
- /*
- t.AddStringFunc("sMB", func(m *oopb.Machine) string {
- return fmt.Sprintf("%d mb", m.Memory/(1024*1024))
- })
-
- t.AddStringFunc("portwin", func(m *zoopb.Machine) string {
- return findVersion(m, "portwin")
- })
- */
+ t.AddButtonFunc("edit", editf)
- /*
- // show if the machine needs to be upgraded
- t.AddStringFunc("triggered?", func(m *zoopb.Machine) string {
- if m.Upgrade {
- return "yes"
- }
- return ""
- })
- */
+ enablef := func(p *Portmap) string {
+ if p.Enabled {
+ p.Enabled = false
+ } else {
+ p.Enabled = true
+ }
+ return "enable"
+ }
+ t.AddButtonFunc("enable", enablef)
- /*
- t.AddTimeFunc("age", func(m *zoopb.Machine) time.Time {
- return m.Laststamp.AsTime()
- })
- */
+ enabledf := func(p *Portmap) string {
+ if p.Enabled {
+ return "true"
+ }
+ return "false"
+ }
+ t.AddStringFunc("enabled", enabledf)
+ t.AddListen()
+ t.AddConnect()
t.ShowTable()
return t
}
-func findVersion(m *zoopb.Machine, pkgname string) string {
- portwin := m.Packages.FindByName(pkgname)
- if portwin == nil {
- return "n/a"
- }
- return portwin.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()
- */
+ me.portmaps.ConfigSave()
}