From 4046e33a6399141636678a54be0902f573c3a300 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 23 Feb 2025 12:59:19 -0600 Subject: [PATCH] times kinda update --- table.go | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/table.go b/table.go index a8cf488..c790946 100644 --- a/table.go +++ b/table.go @@ -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) {