events table
This commit is contained in:
parent
affb055c56
commit
19e29d21d7
83
doGui.go
83
doGui.go
|
@ -6,6 +6,7 @@ package main
|
|||
// An app to submit patches for the 30 GO GUI repos
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -62,7 +63,6 @@ func drawWindow(win *gadgets.BasicWindow) {
|
|||
})
|
||||
|
||||
var dropWin *GenericWindow
|
||||
var dropTable *virtpb.DropletsTable
|
||||
grid.NewButton("droplets", func() {
|
||||
if dropWin != nil {
|
||||
dropWin.Toggle()
|
||||
|
@ -79,22 +79,25 @@ func drawWindow(win *gadgets.BasicWindow) {
|
|||
}
|
||||
found.Append(vm)
|
||||
}
|
||||
dropWin, dropTable = makeDropletsWindow(found)
|
||||
dropWin, _ = makeDropletsWindow(found)
|
||||
dropWin.Win.Custom = func() {
|
||||
log.Info("hiding droplet table window")
|
||||
}
|
||||
})
|
||||
|
||||
grid.NewButton("Update droplets table", func() {
|
||||
if dropTable == nil {
|
||||
log.Info("make the droplets window first")
|
||||
var eventWin *GenericWindow
|
||||
grid.NewButton("events)", func() {
|
||||
log.Info("todo: make code for this")
|
||||
if eventWin != nil {
|
||||
eventWin.Toggle()
|
||||
return
|
||||
}
|
||||
dropTable.Update()
|
||||
e := me.cluster.GetEventsPB()
|
||||
eventWin = makeEventsWindow(e)
|
||||
})
|
||||
|
||||
grid.NewButton("ConfigSave()", func() {
|
||||
log.Info("todo: find this code")
|
||||
log.Info("todo: make code for this")
|
||||
})
|
||||
|
||||
var testWin *GenericWindow
|
||||
|
@ -118,6 +121,8 @@ func findVersion(m *zoopb.Machine, pkgname string) string {
|
|||
|
||||
func makeDropletsWindow(pb *virtpb.Droplets) (*GenericWindow, *virtpb.DropletsTable) {
|
||||
win := NewGenericWindow("Droplets registered with Virtigo", "Buttons of things")
|
||||
t := pb.NewTable("test 2")
|
||||
|
||||
grid := win.Group.RawGrid()
|
||||
grid.NewButton("Create", func() {
|
||||
log.Info("todo: open create window here")
|
||||
|
@ -126,10 +131,16 @@ func makeDropletsWindow(pb *virtpb.Droplets) (*GenericWindow, *virtpb.DropletsTa
|
|||
log.Info("todo")
|
||||
})
|
||||
|
||||
grid.NewButton("Update", func() {
|
||||
t.Update()
|
||||
})
|
||||
|
||||
tbox := win.Bottom.Box()
|
||||
t := pb.NewTable("test 2")
|
||||
t.SetParent(tbox)
|
||||
t.AddHostname()
|
||||
t.AddStringFunc("location", func(d *virtpb.Droplet) string {
|
||||
return d.Current.Hypervisor
|
||||
})
|
||||
t.AddMemory()
|
||||
t.AddCpus()
|
||||
t.AddTimeFunc("age", func(d *virtpb.Droplet) time.Time {
|
||||
|
@ -171,22 +182,48 @@ func makeHypervisorsWindow(pb *virtpb.Hypervisors) *GenericWindow {
|
|||
t.AddHostname()
|
||||
t.AddMemory()
|
||||
t.AddCpus()
|
||||
/*
|
||||
t.AddStringFunc("State", func(d *virtpb.Hypervisor) string {
|
||||
if d.Current.State == virtpb.HypervisorState_ON {
|
||||
return "ON"
|
||||
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
|
||||
}
|
||||
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()
|
||||
})
|
||||
*/
|
||||
}
|
||||
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")
|
||||
grid := win.Group.RawGrid()
|
||||
grid.NewButton("List", func() {
|
||||
log.Info("list...")
|
||||
})
|
||||
tmp := fmt.Sprintf("num of events = %d", pb.Len())
|
||||
grid.NewLabel(tmp)
|
||||
|
||||
tbox := win.Bottom.Box() // a vertical box (like a stack of books)
|
||||
t := pb.NewTable("test 2")
|
||||
t.SetParent(tbox)
|
||||
t.AddDroplet()
|
||||
t.AddHypervisor()
|
||||
t.ShowTable()
|
||||
return win
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue