Merge branch 'main' of ssh://git.bullercodeworks.com:2200/brian/expds

This commit is contained in:
2026-02-12 06:13:56 -06:00
10 changed files with 954 additions and 33 deletions

View File

@@ -23,8 +23,10 @@ package app
import (
"fmt"
"log/slog"
"net/url"
"strings"
"time"
"git.bullercodeworks.com/brian/expds/data"
"git.bullercodeworks.com/brian/expds/data/models"
@@ -43,8 +45,7 @@ type ScreenHome struct {
w, h int
style tcell.Style
alert *w.Alert
showAlert bool
alert *w.Alert
menuLayout *w.TopMenuLayout
@@ -215,9 +216,6 @@ func (s *ScreenHome) Draw() {
s.a.DrawWidget(s.loading)
}
s.a.DrawWidget(s.status)
if s.showAlert {
s.a.DrawWidget(s.alert)
}
}
func (s *ScreenHome) Exit() error { return nil }
func (s *ScreenHome) Log(t string, a ...any) {
@@ -318,9 +316,11 @@ func (s *ScreenHome) initCli() {
func (s *ScreenHome) toggleCli() {
if s.layout.Contains(s.cli) {
s.layout.Delete(s.cli)
s.layout.ActivateWidget(s.columns)
} else {
s.layout.Add(s.cli)
s.cli.SetVisible(true)
s.layout.ActivateWidget(s.cli)
}
}
func (s *ScreenHome) hideCli() {
@@ -346,7 +346,13 @@ func (s *ScreenHome) cliGetPds(args ...string) bool {
}
go func() {
defer func() { s.isLoading = false }()
pds, err := s.r.GetPDS(args[1])
var pds *models.Pds
var err error
if s.activePds != nil && string(s.activePds.AtId) == args[1] {
pds, err = s.r.ReloadPds(args[1])
} else {
pds, err = s.r.GetPDS(args[1])
}
if err != nil {
s.Log(err.Error())
return
@@ -355,7 +361,7 @@ func (s *ScreenHome) cliGetPds(args ...string) bool {
return
}
s.doOpen = false
s.cli.Log("Retrieved: %s (%s)", pds.AtId, pds.Did)
slog.Default().Debug(fmt.Sprintf("Retrieved: %s (%s) at %s", pds.AtId, pds.Did, time.Now().Format(time.RFC3339)))
s.activePds = pds
s.updatePdsListing()
n, err := s.pdsListing.GetActiveNode()
@@ -425,11 +431,14 @@ func (s *ScreenHome) cliSendStatus(args ...string) bool {
s.isLoading = true
go func() {
defer func() { s.isLoading = false }()
if !s.r.Auth.HasAuth() {
if !s.r.Auth.HasAuth(s.activePds.Did) {
s.Log("Not authorized. Run `authpds`")
return
}
s.r.SendToPDS()
err := s.r.SendToPDS(s.activePds.Did)
if err != nil {
s.Log("Error sending status: %w", err)
}
}()
return true
}
@@ -438,6 +447,7 @@ func (s *ScreenHome) updatePdsListing() {
s.pdsListing.SetTitle(fmt.Sprintf("─ %s (%s)", s.activePds.AtId.String(), s.activePds.Did.String()))
s.pdsListing.Clear()
nsidList := s.activePds.NSIDStringList()
var tree []*wd.TreeNode
for i, v := range nsidList {
t := wd.NewTreeNode(v, v)
nsid := s.activePds.NSIDs[i]
@@ -460,8 +470,9 @@ func (s *ScreenHome) updatePdsListing() {
c := wd.NewTreeNode(label, rIds[j])
t.AddChild(c)
}
s.pdsListing.Add(t)
tree = append(tree, t)
}
s.pdsListing.SetTree(tree)
s.layout.ActivateWidget(s.columns)
s.columns.ActivateWidget(s.pdsListing)
s.pdsListing.SetActive(true)