summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-02-19 17:22:00 -0600
committerJeff Carr <[email protected]>2025-02-19 17:39:45 -0600
commit032d1b609abe5dd077c526606a86475ffae9032e (patch)
tree618460f04687a087b65c210a28039bca09c14c6a
parent8ba9c858f479426068c8dc626918b569ee3c48b6 (diff)
table week 1v0.0.30
-rw-r--r--machine.gui.go130
1 files changed, 68 insertions, 62 deletions
diff --git a/machine.gui.go b/machine.gui.go
index d3beb94..e077339 100644
--- a/machine.gui.go
+++ b/machine.gui.go
@@ -8,99 +8,105 @@ import (
func (x *Machines) NewTable(title string) *MachinesTable {
t := new(MachinesTable)
- // t.gt = gui.NewTable(title)
t.x = x
pb := new(guipb.Table)
pb.Title = title
- // pb.Order = append(pb.Order, "Hostname")
pb.Order = append(pb.Order, "Memory")
- // pb.Order = append(pb.Order, "Cpus")
t.pb = pb
return t
}
+func (t *MachinesTable) AddStringFunc(title string, f func(*Machine) string) {
+ t.pb.Order = append(t.pb.Order, title)
+
+ sf := new(MachineStringFunc)
+ sf.title = title
+ sf.f = f
+ t.stringFuncs = append(t.stringFuncs, sf)
+}
+
func (t *MachinesTable) AddHostname() {
log.Info("zoopb: GOT TO AddHostname()")
t.pb.Order = append(t.pb.Order, "Hostname")
t.pb.Order = append(t.pb.Order, "Cpus")
+ t.pb.Order = append(t.pb.Order, "Memory")
+}
- r := new(guipb.StringRow)
- r.Header = new(guipb.Widget)
- r.Header.Name = "Hostname"
- all := t.x.All()
- for all.Scan() {
- m := all.Next()
- r.Vals = append(r.Vals, m.Hostname)
- log.Info("zoopb: adding hostname", r.Vals)
+func (mt *MachinesTable) MakeTable() {
+ for _, name := range mt.pb.Order {
+ log.Info("zoopb: looking for row name()", name)
+ switch name {
+ case "Hostname":
+ r := new(guipb.StringRow)
+ r.Header = new(guipb.Widget)
+ r.Header.Name = "Hostname"
+ all := mt.x.All()
+ for all.Scan() {
+ m := all.Next()
+ r.Vals = append(r.Vals, m.Hostname)
+ log.Info("zoopb: adding hostname", r.Vals)
+ }
+ mt.pb.StringRows = append(mt.pb.StringRows, r)
+ case "Cpus":
+ i := new(guipb.IntRow)
+ i.Header = new(guipb.Widget)
+ i.Header.Name = "Cpus"
+ all := mt.x.All()
+ for all.Scan() {
+ m := all.Next()
+ i.Vals = append(i.Vals, m.Cpus)
+ log.Info("zoopb: adding cpus", i.Vals)
+ }
+ mt.pb.IntRows = append(mt.pb.IntRows, i)
+ case "Memory":
+ i := new(guipb.IntRow)
+ i.Header = new(guipb.Widget)
+ i.Header.Name = "Memories"
+ all := mt.x.All()
+ for all.Scan() {
+ m := all.Next()
+ i.Vals = append(i.Vals, m.Memory)
+ log.Info("zoopb: adding cpus", i.Vals)
+ }
+ mt.pb.IntRows = append(mt.pb.IntRows, i)
+ default:
+ // mt.addFuncRow(name)
+ }
}
- t.pb.StringRows = append(t.pb.StringRows, r)
+}
+/*
+func (mt *MachinesTable) addRow(name string) {
i := new(guipb.IntRow)
i.Header = new(guipb.Widget)
- i.Header.Name = "Cpus"
- all = t.x.All()
+ i.Header.Name = "Memories"
+ all := t.x.All()
for all.Scan() {
m := all.Next()
- i.Vals = append(i.Vals, m.Cpus)
+ i.Vals = append(i.Vals, m.Memory)
log.Info("zoopb: adding cpus", i.Vals)
}
t.pb.IntRows = append(t.pb.IntRows, i)
}
+*/
func (mt *MachinesTable) ShowTable() {
log.Info("zoopb.ShowTable() SENDING TO GUI")
+ mt.MakeTable()
gui.ShowTable(mt.pb)
}
+type MachineStringFunc struct {
+ title string
+ f func(*Machine) string
+}
+
type MachinesTable struct {
// gt *gui.NodeTable
- pb *guipb.Table
- x *Machines
- hostnames []string
+ pb *guipb.Table
+ x *Machines
+ hostnames []string
+ stringFuncs []*MachineStringFunc
// columns []*gui.NodeColumn
// order []*gui.NodeColumn
}
-
-/*
-type RepoTableRow struct {
- nodes []*gui.Node
-}
-
-
-type repoTableFullPath struct {
-}
-
-func (x *repoTableFullPath) Add(s string) {
-}
-
-func (x *RepoTable) FullPath() *RepoTableFullPath {
-}
-
-func (x *RepoTable) AddFullPath() {
- x.order = append(x.order, x.n.AddStringFunc( f() string {
- return t.x.getRepoFullPath(rx *RepoTableRow)
- }))
- return *RepoTableRow
-}
-
-func (x *RepoTable) Show() {
- x.order.f()
- ZZ
-}
-
-func (x *RepoTable) AddMasterVersion() {
-
- all := x.x.SortByFullPath()
- for all.Scan() {
- repo := all.Next()
- for x.order
-
-
- return *RepoTableRow
-}
-
-func (x *RepoTable) NewColumn() *RepoRow {
- t := new(RepoTableRow)
- return *RepoTableRow
-}
-*/