show last 20 events works

This commit is contained in:
Jeff Carr 2025-03-10 07:08:28 -05:00
parent 22d0798749
commit 18c1221efc
2 changed files with 36 additions and 14 deletions

View File

@ -51,12 +51,7 @@ func doGui() {
makePortmapWin()
})
grid.NewButton("Save Events", func() {
log.Info("event log is len =", me.events.Len())
me.events.Save()
})
grid.NewButton("Show Last 20 Events", func() {
grid.NewButton("Show Events", func() {
// if the window exists, just toggle it open or closed
if me.eventswin != nil {
me.eventswin.Toggle()

View File

@ -11,24 +11,51 @@ import (
func makeEventsWin() {
me.eventswin = new(stdEventTableWin)
me.eventswin.win = gadgets.NewGenericWindow("zood daemon versions", "todo: add global controls here")
me.eventswin.win = gadgets.NewGenericWindow("Gus current event log", "who is squirreling around?")
me.eventswin.win.Custom = func() {
log.Info("test delete window here")
}
grid := me.eventswin.win.Group.RawGrid()
grid.NewButton("ConfigSave() ", func() {
saveMachineState()
grid.NewButton("first 20", func() {
var count int
found := NewEvents()
all := me.events.All()
for all.Scan() {
e := all.Next()
count += 1
found.Append(e)
if count > 20 {
break
}
}
doEventsTable(found)
})
grid.NewButton("Add() ", func() {
grid.NewButton("last 20", func() {
var count int
total := me.events.Len()
found := NewEvents()
all := me.events.All()
for all.Scan() {
e := all.Next()
count += 1
if count < total-20 {
continue
}
found.Append(e)
}
doEventsTable(found)
})
grid.NewCheckbox("hide active")
grid.NewButton("update", func() {
doMachinesUpgradeTable()
grid.NewButton("Save Current", func() {
log.Info("event log is len =", me.events.Len())
me.events.Save()
})
// make a box at the bottom of the window for the protobuf table
me.eventswin.box = me.eventswin.win.Bottom.Box().SetProgName("TBOX")
doEventsTable(me.events)
// doEventsTable(me.events)
}
func doEventsTable(currentEvents *Events) {