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