early events
This commit is contained in:
parent
19b1588512
commit
50d16b3d86
|
@ -62,6 +62,19 @@ func (admin *adminT) refresh() {
|
||||||
}
|
}
|
||||||
fmt.Println("Hypervisors len=", admin.hypervisors.Len())
|
fmt.Println("Hypervisors len=", admin.hypervisors.Len())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update the events list
|
||||||
|
if data, err := postData(url+"/EventsPB", msg); err != nil {
|
||||||
|
log.Info("Error:", err)
|
||||||
|
} else {
|
||||||
|
fmt.Println("EventsPB Response len:", len(data))
|
||||||
|
admin.events = new(virtpb.Events)
|
||||||
|
if err := admin.events.Unmarshal(data); err != nil {
|
||||||
|
fmt.Println("events marshal failed", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fmt.Println("Events len=", admin.events.Len())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var client *http.Client
|
var client *http.Client
|
||||||
|
@ -145,6 +158,20 @@ func (admin *adminT) doAdminGui() {
|
||||||
log.Info("hiding droplet table window")
|
log.Info("hiding droplet table window")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
grid.NewButton("events", func() {
|
||||||
|
if admin.events == nil {
|
||||||
|
log.Info("events are not initialized")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Info("Events len=", admin.events.Len())
|
||||||
|
hwin := newEventsWindow()
|
||||||
|
hwin.doStdEvents(admin.events)
|
||||||
|
hwin.win.Custom = func() {
|
||||||
|
log.Info("hiding table window")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
grid.NextRow()
|
grid.NextRow()
|
||||||
|
|
||||||
grid.NewButton("refresh", func() {
|
grid.NewButton("refresh", func() {
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
||||||
|
// Use of this source code is governed by the GPL 3.0
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"go.wit.com/gui"
|
||||||
|
"go.wit.com/lib/gadgets"
|
||||||
|
"go.wit.com/lib/protobuf/virtpb"
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
type stdEventTableWin struct {
|
||||||
|
sync.Mutex
|
||||||
|
win *gadgets.GenericWindow // the machines gui window
|
||||||
|
box *gui.Node // the machines gui parent box widget
|
||||||
|
pb *virtpb.Events // the protobuf
|
||||||
|
TB *virtpb.EventsTable // the gui table buffer
|
||||||
|
update bool // if the window should be updated
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *stdEventTableWin) Toggle() {
|
||||||
|
if w == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if w.win == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w.win.Toggle()
|
||||||
|
}
|
||||||
|
|
||||||
|
func newEventsWindow() *stdEventTableWin {
|
||||||
|
dwin := new(stdEventTableWin)
|
||||||
|
dwin.win = gadgets.NewGenericWindow("virtigo current events", "things to do")
|
||||||
|
dwin.win.Custom = func() {
|
||||||
|
log.Info("test delete window here")
|
||||||
|
}
|
||||||
|
|
||||||
|
// make a box at the bottom of the window for the protobuf table
|
||||||
|
dwin.box = dwin.win.Bottom.Box().SetProgName("TBOX")
|
||||||
|
return dwin
|
||||||
|
}
|
||||||
|
|
||||||
|
// default table protobuf window
|
||||||
|
func (dw *stdEventTableWin) doStdEvents(pb *virtpb.Events) {
|
||||||
|
dw.Lock()
|
||||||
|
defer dw.Unlock()
|
||||||
|
|
||||||
|
// erase the old table
|
||||||
|
if dw.TB != nil {
|
||||||
|
dw.TB.Delete()
|
||||||
|
dw.TB = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// init the table
|
||||||
|
dw.pb = pb
|
||||||
|
t := dw.pb.NewTable("EventsPB Off")
|
||||||
|
t.NewUuid()
|
||||||
|
t.SetParent(dw.box)
|
||||||
|
|
||||||
|
// pick the columns
|
||||||
|
t.AddDroplet()
|
||||||
|
t.AddDropletUuid()
|
||||||
|
t.AddHypervisor()
|
||||||
|
|
||||||
|
// display the protobuf
|
||||||
|
dw.TB = t
|
||||||
|
f := func(e *virtpb.Event) {
|
||||||
|
log.Info("std EventWindow() something here", e.Droplet)
|
||||||
|
// m.Enabled = true
|
||||||
|
}
|
||||||
|
dw.TB.Custom(f)
|
||||||
|
|
||||||
|
dw.TB.ShowTable()
|
||||||
|
}
|
Loading…
Reference in New Issue