preliminary time column

This commit is contained in:
Jeff Carr 2025-02-20 03:15:24 -06:00
parent a52e81354a
commit 1322fbead0
1 changed files with 37 additions and 0 deletions

View File

@ -6,10 +6,15 @@ package tree
import (
"fmt"
"time"
"go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/guipb"
"go.wit.com/log"
"go.wit.com/widget"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
"google.golang.org/protobuf/types/known/timestamppb"
)
// repeated string order = 1;
@ -145,6 +150,38 @@ func (me *TreeInfo) addTableRow(t *guipb.Table, grid *Node, name string, w int)
return true
}
for _, r := range t.TimeRows {
if name != r.Header.Name {
// log.Info("skip sint row:", r.Header.Name, "!=", name)
continue
}
log.Info("tree: Add()ing to grid here", r.Header.Id, r.Header.Name, w, h)
head := grid.makeGridLabel(r.Header, w, h)
me.Add(head)
h += 1
for _, widg := range r.Widgets {
msg, err := anypb.UnmarshalNew(widg.Val, proto.UnmarshalOptions{})
if err != nil {
log.Fatalf("failed to unmarshal: %v", err)
}
switch v := msg.(type) {
case *timestamppb.Timestamp:
fmt.Println("Unpacked Timestamp:", shell.FormatDuration(time.Since(v.AsTime())))
widg.Name = shell.FormatDuration(time.Since(v.AsTime()))
default:
fmt.Println("Unknown type:", v)
widg.Name = fmt.Sprintf("%v", v)
}
log.Info("tree: Add()ing to grid here", widg.Id, widg.Name, w, h)
lab := grid.makeGridLabel(widg, w, h)
me.Add(lab)
h += 1
}
return true
}
return false
}