More work

This commit is contained in:
2026-02-18 19:08:29 -06:00
parent 009d5701d2
commit 4066197ec1
3 changed files with 57 additions and 21 deletions

View File

@@ -421,7 +421,12 @@ func (s *ScreenHome) cliSendStatus(args ...string) bool {
} }
func (s *ScreenHome) updatePdsListing() { func (s *ScreenHome) updatePdsListing() {
s.pdsListing.SetTitle(fmt.Sprintf("─ %s (%s)", s.activePds.AtId.String(), s.activePds.Did.String())) isAuth := s.r.Auth.HasAuth(s.activePds.Did)
auth := '🔒'
if isAuth {
auth = '🔓'
}
s.pdsListing.SetTitle(fmt.Sprintf("%c %s (%s)", auth, s.activePds.AtId.String(), s.activePds.Did.String()))
s.pdsListing.Clear() s.pdsListing.Clear()
nsidList := s.activePds.NSIDStringList() nsidList := s.activePds.NSIDStringList()
var tree []*wd.TreeNode var tree []*wd.TreeNode
@@ -472,6 +477,15 @@ func (s *ScreenHome) selectPdsListingEntry(tn *wd.TreeNode) bool {
} }
func (s *ScreenHome) changePdsList(tn *wd.TreeNode) bool { func (s *ScreenHome) changePdsList(tn *wd.TreeNode) bool {
auth := s.r.Auth.HasAuth(s.activePds.Did)
if auth {
if tn.Depth() == 0 {
s.pdsListing.SetHintText("(A)dd New Record")
} else {
s.pdsListing.SetHintText("(A)dd New Record; (D)elete Record")
}
}
upd := s.updateJsonView(tn) upd := s.updateJsonView(tn)
upd = s.updateStatusPathBlock(tn) upd = s.updateStatusPathBlock(tn)
return upd return upd
@@ -483,6 +497,7 @@ func (s *ScreenHome) updateStatusPathBlock(tn *wd.TreeNode) bool {
func (s *ScreenHome) updateJsonView(tn *wd.TreeNode) bool { func (s *ScreenHome) updateJsonView(tn *wd.TreeNode) bool {
// TODO: Update JSON View // TODO: Update JSON View
auth := s.r.Auth.HasAuth(s.activePds.Did)
if tn.Depth() == 0 { if tn.Depth() == 0 {
nsid, err := syntax.ParseNSID(tn.Value()) nsid, err := syntax.ParseNSID(tn.Value())
if err != nil { if err != nil {
@@ -491,9 +506,13 @@ func (s *ScreenHome) updateJsonView(tn *wd.TreeNode) bool {
} }
recordIds := s.activePds.GetRecordIdsFor(nsid) recordIds := s.activePds.GetRecordIdsFor(nsid)
s.jsonContent.SetValue(recordIds) s.jsonContent.SetValue(recordIds)
s.jsonContent.SetEditable(false)
// We don't set the jsonContent to editable, but allow creation of
// new objects
return true return true
} else { } else {
s.jsonContent.SetValue(s.activePds.Records[tn.Value()]) s.jsonContent.SetValue(s.activePds.Records[tn.Value()])
s.jsonContent.SetEditable(auth)
} }
return true return true
} }
@@ -593,19 +612,20 @@ func (s *ScreenHome) deleteCurrentRecord() bool {
if len(tnPath) != 2 { if len(tnPath) != 2 {
return false return false
} }
//tnLabelPath := tn.GetLabelPath() tnLabelPath := tn.GetLabelPath()
nsid, err := syntax.ParseNSID(tnPath[0]) nsid, err := syntax.ParseNSID(tnPath[0])
if err != nil { if err != nil {
s.Log("error parsing NSID from %s: %w", tnPath[0], err) s.Log("error parsing NSID from %s: %w", tnPath[0], err)
return false return false
} }
rkey := tnPath[1] rkey := tnPath[1]
/*
if err := s.r.DeleteRecord(s.activePds.Did, nsid, rkey); err != nil { if err := s.r.DeleteRecord(s.activePds.Did, nsid, rkey); err != nil {
s.Log("error deleting record: %w", err) s.Log("error deleting record: %w", err)
} }
/* */
s.alert.SetTitle("Confirm Deletion") s.alert.SetTitle("Confirm Deletion")
s.alert.SetMessage(fmt.Sprintf("Are you sure you want to delete this record?\n%s %s\nThis cannot be undone.", tnLabelPath[0], tnLabelPath[1])) s.alert.SetMessage(fmt.Sprintf("Are you sure you want to delete this record?\n%s: %s\nThis cannot be undone.", tnLabelPath[0], tnLabelPath[1]))
s.alert.SetVisible(true) s.alert.SetVisible(true)
s.alert.SetActive(true) s.alert.SetActive(true)
s.alert.SetOkPressed(func() bool { s.alert.SetOkPressed(func() bool {
@@ -619,6 +639,7 @@ func (s *ScreenHome) deleteCurrentRecord() bool {
s.alert.SetActive(false) s.alert.SetActive(false)
return true return true
}) })
*/ s.alert.SetPos(w.Coord{X: s.w / 4, Y: s.h / 4})
s.alert.HandleResize(w.Coord{X: s.w / 4, Y: s.h / 4}.ResizeEvent())
return true return true
} }

View File

@@ -167,7 +167,10 @@ func (w *JsonContent) Draw(screen tcell.Screen) {
if w.editable { if w.editable {
var key, val string var key, val string
pts := strings.Split(txt, ":")
if len(pts) == 2 {
key, val = pts[0], pts[1]
}
wh.DrawText(w.x, y, key, st.Dim(dim).Bold(!dim), screen) wh.DrawText(w.x, y, key, st.Dim(dim).Bold(!dim), screen)
st = st.Reverse(true) st = st.Reverse(true)
wh.DrawText(w.x, y, val, st.Dim(dim).Bold(!dim), screen) wh.DrawText(w.x, y, val, st.Dim(dim).Bold(!dim), screen)

View File

@@ -40,6 +40,8 @@ type TreeBrowser struct {
searching bool searching bool
searchStr string searchStr string
hintText string
logger func(string, ...any) logger func(string, ...any)
m sync.Mutex m sync.Mutex
@@ -160,6 +162,13 @@ func (w *TreeBrowser) Draw(screen tcell.Screen) {
th.BorderFilled(x, y, x+w.w, y+w.h, w.border, dS, screen) th.BorderFilled(x, y, x+w.w, y+w.h, w.border, dS, screen)
} }
} }
if w.hintText != "" {
if brdSz == 0 {
brdSz = 1
}
wh.DrawText(x+1, y+w.h, w.hintText, dS, screen)
}
x, y = x+1, y+1 x, y = x+1, y+1
h := w.h - brdSz h := w.h - brdSz
ln := len(w.list) ln := len(w.list)
@@ -487,6 +496,9 @@ func (w *TreeBrowser) getCurrentLine() string {
return w.list[w.cursor] return w.list[w.cursor]
} }
func (w *TreeBrowser) SetHintText(txt string) { w.hintText = txt }
func (w *TreeBrowser) ClearHintText(txt string) { w.hintText = "" }
/* /*
* Tree Node * Tree Node
*/ */