add hypervisors table

This commit is contained in:
Jeff Carr 2025-02-23 00:51:28 -06:00
parent 522723e946
commit 69b0d4c013
2 changed files with 74 additions and 8 deletions

View File

@ -51,8 +51,17 @@ func drawWindow(win *gadgets.BasicWindow) {
group1 := vbox.NewGroup("Zookeeper Settings")
grid := group1.NewGrid("buildOptions", 0, 0)
var hyperWin *genericWindow
grid.NewButton("hypervisors", func() {
if hyperWin != nil {
hyperWin.Toggle()
return
}
hyperWin = makeHypervisorsWindow(me.cluster.H)
})
var testWin *genericWindow
grid.NewButton("machine list", func() {
grid.NewButton("all defined droplets", func() {
if testWin != nil {
testWin.Toggle()
return
@ -106,11 +115,17 @@ func makeDropletsWindow(pb *virtpb.Droplets) *genericWindow {
log.Info("?")
})
grid.NextRow()
grid.NewButton("smore", func() {
grid.NewButton("2nd row", func() {
log.Info("smore")
})
win.middle.NewButton("middle", func() {
log.Info("smore")
})
win.middle.NewButton("middle", func() {
log.Info("smore")
})
tbox := win.win.Box().Vertical() // a vertical box (like a stack of books)
tbox := win.bottom.Box() // a vertical box (like a stack of books)
t := pb.NewTable("test 2")
t.SetParent(tbox)
t.AddHostname()
@ -133,3 +148,43 @@ func makeDropletsWindow(pb *virtpb.Droplets) *genericWindow {
t.ShowTable()
return win
}
func makeHypervisorsWindow(pb *virtpb.Hypervisors) *genericWindow {
win := initGenericWindow("Hypervisors registered with Virtigo", "Buttons of things")
grid := win.group.RawGrid()
grid.NewButton("List", func() {
log.Info("list...")
})
grid.NewButton("more", func() {
log.Info("?")
})
grid.NextRow()
grid.NewButton("smore", func() {
log.Info("smore")
})
tbox := win.bottom.Box() // a vertical box (like a stack of books)
t := pb.NewTable("test 2")
t.SetParent(tbox)
t.AddHostname()
t.AddMemory()
t.AddCpus()
/*
t.AddStringFunc("State", func(d *virtpb.Hypervisor) string {
if d.Current.State == virtpb.HypervisorState_ON {
return "ON"
}
return "UNKNOWN"
})
*/
/*
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()
})
*/
t.ShowTable()
return win
}

View File

@ -11,9 +11,14 @@ import (
)
type genericWindow struct {
win *gadgets.BasicWindow // the window widget itself
box *gui.Node // the top box of the repolist window
group *gui.Node // the default group
win *gadgets.BasicWindow // the window widget itself
box *gui.Node // the overall shelf
shelf *gui.Node // the overall shelf
stack *gui.Node // the first box is a shelf
top *gui.Node // the first item in the stack is always a box
group *gui.Node // the first item top box is always a group
middle *gui.Node // the middle box
bottom *gui.Node // the bottom box of the repolist window
}
func (r *genericWindow) Hidden() bool {
@ -79,13 +84,19 @@ func initGenericWindow(title string, grouptxt string) *genericWindow {
gw.win = gadgets.RawBasicWindow(title)
gw.win.Make()
gw.box = gw.win.Box().Vertical() // a vertical box (like a stack of books)
gw.win.Custom = func() {
log.Warn("Found Window close. setting hidden=true")
// sets the hidden flag to false so Toggle() works
gw.win.Hide()
}
gw.group = gw.box.NewGroup(grouptxt)
gw.box = gw.win.Box()
gw.shelf = gw.box
gw.stack = gw.shelf.NewVerticalBox("STACKBOX") // a vertical box (like a stack of books)
gw.top = gw.stack.Box()
gw.group = gw.top.NewGroup(grouptxt)
gw.middle = gw.stack.Box()
gw.middle.Vertical()
gw.bottom = gw.stack.Box()
gw.Show()
return gw