summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-03-11 20:17:46 -0500
committerJeff Carr <[email protected]>2025-03-11 20:17:46 -0500
commit50d16b3d86882456f4e17e400c4b8beed79d30e5 (patch)
tree1244bfa54bfd8e8605e73dee5ccb76f5d3cd5970
parent19b1588512e60419915913a109c14355166ed33d (diff)
early events
-rw-r--r--doAdminGui.go27
-rw-r--r--windowEvents.go77
2 files changed, 104 insertions, 0 deletions
diff --git a/doAdminGui.go b/doAdminGui.go
index 5ea68c4..77f30bf 100644
--- a/doAdminGui.go
+++ b/doAdminGui.go
@@ -62,6 +62,19 @@ func (admin *adminT) refresh() {
}
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
@@ -145,6 +158,20 @@ func (admin *adminT) doAdminGui() {
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.NewButton("refresh", func() {
diff --git a/windowEvents.go b/windowEvents.go
new file mode 100644
index 0000000..912dc2e
--- /dev/null
+++ b/windowEvents.go
@@ -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()
+}