Rebuilding with Tree Browser

This commit is contained in:
2026-01-29 20:43:32 -06:00
parent abf21d8e1b
commit 330a2e3ddf
3 changed files with 410 additions and 28 deletions

View File

@@ -50,8 +50,9 @@ type ScreenHome struct {
layout *w.LinearLayout
columns *w.LinearLayout
activePds *models.Pds
pdsListing *w.SimpleListWithHelp
activePds *models.Pds
//pdsListing *w.SimpleListWithHelp
pdsListing *wd.TreeBrowser
jsonContent *wd.JsonContent
status *wd.StatusBar
stTmBlock *wd.StatusBlock
@@ -102,7 +103,8 @@ func (s *ScreenHome) Init(a *App) {
s.columns = w.NewLinearLayout("home.layout.columns", s.style)
s.columns.SetOrientation(w.LinLayH)
s.pdsListing = w.NewSimpleListWithHelp("pdslisting", s.style)
//s.pdsListing = w.NewSimpleListWithHelp("pdslisting", s.style)
s.pdsListing = wd.NewTreeBrowser("pdslisting", s.style)
s.pdsListing.SetBorder(
[]rune{'─', '┬', '│', '┴', '─', '└', '│', '┌', '├', '─', '┤', '┬', '│', '┴', '┼'},
)
@@ -141,6 +143,7 @@ func (s *ScreenHome) Init(a *App) {
s.status.SetLogger(s.Log)
s.stPathBlock = wd.NewStatusBlock("home.statusbar.block", statusStyle.Foreground(tcell.ColorDarkSlateGray).Background(tcell.ColorOrange))
s.stPathBlock.SetType(wd.SBTypePath)
s.stPathBlock.SetParts([]string{"No PDS Loaded"})
s.status.Add(s.stPathBlock)
s.columns.AddAll(s.pdsListing, s.jsonContent)
@@ -323,7 +326,10 @@ func (s *ScreenHome) cliGetPds(args ...string) bool {
s.activePds = pds
s.expandedEntries = make(map[string]interface{})
s.updatePdsListing()
s.changePdsList(s.pdsListing.SelectedIndex(), s.pdsListing.GetSelectedItem())
n, err := s.pdsListing.GetActiveNode()
if err == nil && n != nil {
s.changePdsList(n)
}
s.isLoading = false
}()
return true
@@ -331,30 +337,61 @@ func (s *ScreenHome) cliGetPds(args ...string) bool {
func (s *ScreenHome) updatePdsListing() {
s.pdsListing.SetTitle(fmt.Sprintf("─ %s (%s)", s.activePds.AtId.String(), s.activePds.Did.String()))
// When we first get the pds, all entries are models.TypeNSID
s.pdsListingTypes = []models.EntryType{}
s.recordIdsToNSIDs = make(map[string]syntax.NSID)
var wrk []string
s.pdsListing.Clear()
nsidList := s.activePds.NSIDStringList()
for i, v := range nsidList {
wrk = append(wrk, v)
s.pdsListingTypes = append(s.pdsListingTypes, models.TypeNSID)
if _, ok := s.expandedEntries[v]; ok {
nsid := s.activePds.NSIDs[i]
rIds := s.activePds.GetRecordIdsFor(nsid)
for j := range rIds {
wrk = append(wrk, fmt.Sprintf("• %s", rIds[j]))
s.pdsListingTypes = append(s.pdsListingTypes, models.TypeRecord)
s.recordIdsToNSIDs[rIds[j]] = nsid
}
t := wd.NewTreeNode(v, v)
nsid := s.activePds.NSIDs[i]
rIds := s.activePds.GetRecordIdsFor(nsid)
for j := range rIds {
c := wd.NewTreeNode(fmt.Sprintf("%s (%s)", "record", rIds[j]), rIds[j])
t.AddChild(c)
}
s.pdsListing.Add(t)
/*
wrk = append(wrk, t)
wrk = append(wrk, v)
s.pdsListingTypes = append(s.pdsListingTypes, models.TypeNSID)
if _, ok := s.expandedEntries[v]; ok {
nsid := s.activePds.NSIDs[i]
rIds := s.activePds.GetRecordIdsFor(nsid)
for j := range rIds {
wrk = append(wrk, fmt.Sprintf("• %s", rIds[j]))
s.pdsListingTypes = append(s.pdsListingTypes, models.TypeRecord)
s.recordIdsToNSIDs[rIds[j]] = nsid
}
}
*/
}
s.pdsListing.SetList(wrk)
//s.pdsListing.AddChild(wrk)
s.hideCli()
}
func (s *ScreenHome) selectPdsListingEntry(idx int, nm string) bool {
if !s.updateJsonView(idx, nm) {
func (s *ScreenHome) selectPdsListingEntry(tn *wd.TreeNode) bool {
if !s.updateJsonView(tn) {
return false
}
return true
}
func (s *ScreenHome) changePdsList(tn *wd.TreeNode) bool {
upd := s.updateJsonView(tn)
upd = s.updateStatusPathBlock(tn)
return upd
}
func (s *ScreenHome) updateStatusPathBlock(tn *wd.TreeNode) bool {
// TODO: UpdateStatusPathBlock
return true
}
func (s *ScreenHome) updateJsonView(tn *wd.TreeNode) bool {
// TODO: Update JSON View
return true
}
func (s *ScreenHome) o_selectPdsListingEntry(idx int, nm string) bool {
if !s.o_updateJsonView(idx, nm) {
return false
}
@@ -377,14 +414,12 @@ func (s *ScreenHome) selectPdsListingEntry(idx int, nm string) bool {
return false
}
func (s *ScreenHome) changePdsList(idx int, nm string) bool {
upd := s.updateJsonView(idx, nm)
upd = s.updateStatusPathBlock(idx, nm)
func (s *ScreenHome) o_changePdsList(idx int, nm string) bool {
upd := s.o_updateJsonView(idx, nm)
upd = s.o_updateStatusPathBlock(idx, nm)
return upd
}
func (s *ScreenHome) updateStatusPathBlock(idx int, nm string) bool {
func (s *ScreenHome) o_updateStatusPathBlock(idx int, nm string) bool {
if len(s.pdsListingTypes) < idx {
s.Log("error finding pds listing type (idx: %d >= list length: %d", idx, len(s.pdsListingTypes))
return false
@@ -398,7 +433,7 @@ func (s *ScreenHome) updateStatusPathBlock(idx int, nm string) bool {
}
return true
}
func (s *ScreenHome) updateJsonView(idx int, nm string) bool {
func (s *ScreenHome) o_updateJsonView(idx int, nm string) bool {
if len(s.pdsListingTypes) < idx {
s.Log("error finding pds listing type (idx: %d >= list length: %d", idx, len(s.pdsListingTypes))
return false