summaryrefslogtreecommitdiff
path: root/doGui.go
diff options
context:
space:
mode:
Diffstat (limited to 'doGui.go')
-rw-r--r--doGui.go88
1 files changed, 29 insertions, 59 deletions
diff --git a/doGui.go b/doGui.go
index f94a768..14f6954 100644
--- a/doGui.go
+++ b/doGui.go
@@ -52,16 +52,33 @@ func drawWindow(win *gadgets.BasicWindow) {
group1 := vbox.NewGroup("Virtigo Settings")
grid := group1.NewGrid("buildOptions", 0, 0)
- var hyperWin *GenericWindow
- grid.NewButton("hypervisors", func() {
- if hyperWin != nil {
- hyperWin.Toggle()
+ /*
+ var hyperWin *gadgets.GenericWindow
+ grid.NewButton("hypervisors", func() {
+ if hyperWin != nil {
+ hyperWin.Toggle()
+ return
+ }
+ hyperWin = makeHypervisorsWindow(me.cluster.H)
+ })
+ */
+
+ var newHyperWin *stdHypervisorTableWin
+ grid.NewButton("show hypervisors", func() {
+ if newHyperWin != nil {
+ log.Info("redraw hypervisors")
+ newHyperWin.doNewStdHypervisors(me.cluster.H)
return
}
- hyperWin = makeHypervisorsWindow(me.cluster.H)
+ log.Info("Hypervisors len=", me.cluster.H.Len())
+ newHyperWin = newHypervisorsWindow()
+ newHyperWin.doNewStdHypervisors(me.cluster.H)
+ newHyperWin.win.Custom = func() {
+ log.Info("hiding table window")
+ }
})
- var dropWin *GenericWindow
+ var dropWin *gadgets.GenericWindow
grid.NewButton("droplets", func() {
if dropWin != nil {
dropWin.Toggle()
@@ -84,7 +101,7 @@ func drawWindow(win *gadgets.BasicWindow) {
}
})
- var eventWin *GenericWindow
+ var eventWin *gadgets.GenericWindow
grid.NewButton("events)", func() {
log.Info("todo: make code for this")
if eventWin != nil {
@@ -99,7 +116,7 @@ func drawWindow(win *gadgets.BasicWindow) {
log.Info("todo: make code for this")
})
- var testWin *GenericWindow
+ var testWin *gadgets.GenericWindow
grid.NewButton("create droplet", func() {
if testWin != nil {
testWin.Toggle()
@@ -127,8 +144,8 @@ func updateUptimeGui(uptime string) {
me.lastuptime.SetLabel("last uptime at " + datestamp)
}
-func makeDropletsWindow(pb *virtpb.Droplets) (*GenericWindow, *virtpb.DropletsTable) {
- win := NewGenericWindow("Droplets registered with Virtigo", "Buttons of things")
+func makeDropletsWindow(pb *virtpb.Droplets) (*gadgets.GenericWindow, *virtpb.DropletsTable) {
+ win := gadgets.NewGenericWindow("Droplets registered with Virtigo", "Buttons of things")
t := pb.NewTable("testDroptable")
t.NewUuid()
@@ -181,55 +198,8 @@ func makeDropletsWindow(pb *virtpb.Droplets) (*GenericWindow, *virtpb.DropletsTa
return win, t
}
-func makeHypervisorsWindow(pb *virtpb.Hypervisors) *GenericWindow {
- win := NewGenericWindow("Hypervisors registered with Virtigo", "Buttons of things")
- t := pb.NewTable("testHyper")
- grid := win.Group.RawGrid()
- grid.NewButton("List", func() {
- log.Info("list...")
- })
- /*
- grid.NewButton("Update", func() {
- t.Update()
- })
- */
-
- tbox := win.Bottom.Box() // a vertical box (like a stack of books)
- t.NewUuid()
- t.SetParent(tbox)
- t.AddHostname()
- t.AddMemory()
- t.AddCpus()
- t.AddTimeFunc("last poll", func(h *virtpb.Hypervisor) time.Time {
- hm := me.hmap[h]
- tmp := hm.lastpoll
- log.Info("poll age", h.Hostname, virtpb.FormatDuration(time.Since(tmp)))
- return tmp
- })
- t.AddKillcount()
- t.AddStringFunc("droplets", func(h *virtpb.Hypervisor) string {
- var totalDroplets int
- var totalUnknownDroplets int
- // dur := time.Since(h.lastpoll)
- // tmp := virtpb.FormatDuration(dur)
- // fmt.Fprintln(w, h.pb.Hostname, "killcount =", h.killcount, "lastpoll:", tmp)
- hm := me.hmap[h]
- for name, _ := range hm.lastDroplets {
- totalDroplets += 1
- d := me.cluster.FindDropletByName(name)
- if d == nil {
- totalUnknownDroplets += 1
- }
- }
- log.Printf("Total Droplets %d total libvirt only droplets = %d\n", totalDroplets, totalUnknownDroplets)
- return fmt.Sprintf("%d", totalDroplets)
- })
- t.ShowTable()
- return win
-}
-
-func makeEventsWindow(pb *virtpb.Events) *GenericWindow {
- win := NewGenericWindow("Cluster Events", "Buttons of things")
+func makeEventsWindow(pb *virtpb.Events) *gadgets.GenericWindow {
+ win := gadgets.NewGenericWindow("Cluster Events", "Buttons of things")
grid := win.Group.RawGrid()
grid.NewButton("List", func() {
log.Info("list...")