times kinda update

This commit is contained in:
Jeff Carr 2025-02-23 12:59:19 -06:00
parent 344b3ab1d1
commit 4046e33a63
1 changed files with 35 additions and 7 deletions

View File

@ -42,9 +42,9 @@ func (me *TreeInfo) doTable(a widget.Action) {
// }
// dumpTable(t)
// me.ShowTable(t)
log.Info("TREE FOUND TABLE UUID", t.Uuid)
// log.Info("TREE FOUND TABLE UUID", t.Uuid)
for i, ot := range me.currentTables {
log.Info("TREE already has UUID", i, ot.Uuid)
// log.Info("TREE already has UUID", i, ot.Uuid)
if t.Uuid == ot.Uuid {
log.Info("TREE found UUID! update table here", i, ot.Uuid)
me.updateTable(t)
@ -102,11 +102,12 @@ func (me *TreeInfo) updateTable(t *guipb.Table) {
func (me *TreeInfo) updateRow(t *guipb.Table, name string) {
for _, r := range t.StringRows {
if name == r.Header.Name {
id := r.Header.Id
n := treeRoot.FindWidgetId(int(id))
if n == nil {
log.Info("could not find widget id", id)
}
// debugging code
// id := r.Header.Id
// n := treeRoot.FindWidgetId(int(id))
// if n == nil {
// log.Info("could not find widget id", id)
// }
// log.Info("tree.updateRow() start found header", id, r.Header, "len =", len(r.Widgets))
// if r.Header.Name == "Hostname" {
// }
@ -127,6 +128,33 @@ func (me *TreeInfo) updateRow(t *guipb.Table, name string) {
return
}
}
for _, r := range t.TimeRows {
if name != r.Header.Name {
continue
}
for i, _ := range r.Vals {
// log.Info("tree: Hostname Widget", i, v, w.Name)
w := r.Widgets[i]
n := treeRoot.FindWidgetId(int(w.Id))
if n == nil {
log.Info("tree.TableUpdate() err n == nil ", w.Id, w.Name)
continue
}
msg, err := anypb.UnmarshalNew(w.Val, proto.UnmarshalOptions{})
if err != nil {
log.Fatalf("failed to unmarshal: %v", err)
}
switch v := msg.(type) {
case *timestamppb.Timestamp:
me.SetText(n, shell.FormatDuration(time.Since(v.AsTime())))
default:
me.SetText(n, fmt.Sprintf("%v", v))
}
}
return
}
}
func (me *TreeInfo) makeTable(t *guipb.Table) {