From 49a6360e05ce7ae3682fad7afaec4fc1d797a060 Mon Sep 17 00:00:00 2001 From: Rosie Kern Date: Wed, 23 Oct 2024 13:05:31 +0100 Subject: [PATCH] Add behaviour for when DirInfo is nil, clean up UI --- server/static/wrstat/src/Filter.tsx | 22 +++++++++++++++++----- server/static/wrstat/src/TreeDetails.tsx | 13 +++++-------- server/tree.go | 8 ++++++-- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/server/static/wrstat/src/Filter.tsx b/server/static/wrstat/src/Filter.tsx index e682cd7..e80537b 100644 --- a/server/static/wrstat/src/Filter.tsx +++ b/server/static/wrstat/src/Filter.tsx @@ -90,11 +90,23 @@ const stringSort = new Intl.Collator().compare, onChange={e => setAge(+e.target.value)} > - - - - - + + + + + + + + + + + + + + + + +
Math.max(max, curr.UsageSize), 0)} diff --git a/server/static/wrstat/src/TreeDetails.tsx b/server/static/wrstat/src/TreeDetails.tsx index d74e4f2..c0c4a9e 100644 --- a/server/static/wrstat/src/TreeDetails.tsx +++ b/server/static/wrstat/src/TreeDetails.tsx @@ -49,26 +49,23 @@ const TreedetailsComponent = ({ details, ...rest}: { details: Child | null} & Re Accessed - {formatDate(details.atime)} + {details.atime ? formatDate(details.atime): ""} Modifed - {formatDate(details.mtime)} + {details.mtime ? formatDate(details.mtime): ""} Groups -
{details.groups.join(", ")}
+
{details.groups ? details.groups.join(", "): ""}
Users -
{details.users.join(", ")}
+
{details.users ? details.users.join(", "): ""}
Filetypes -
{details.filetypes.join(", ")}
- - - tesssting +
{details.filetypes ? details.filetypes.join(", "): ""}
diff --git a/server/tree.go b/server/tree.go index ea7c123..acdca7b 100644 --- a/server/tree.go +++ b/server/tree.go @@ -158,14 +158,18 @@ func (s *Server) getTree(c *gin.Context) { return } - c.JSON(http.StatusOK, s.diToTreeElement(di, filter, allowedGIDs)) + c.JSON(http.StatusOK, s.diToTreeElement(di, filter, allowedGIDs, path)) } // diToTreeElement converts the given dguta.DirInfo to our own TreeElement. It // has to do additional database queries to find out if di's children have // children. If results don't belong to at least one of the allowedGIDs, they // will be marked as NoAuth and won't include child info. -func (s *Server) diToTreeElement(di *dguta.DirInfo, filter *dguta.Filter, allowedGIDs map[uint32]bool) *TreeElement { +func (s *Server) diToTreeElement(di *dguta.DirInfo, filter *dguta.Filter, allowedGIDs map[uint32]bool, path string) *TreeElement { + s.Logger.Println("di in diToTreeElement: ", di) + if di == nil { + return &TreeElement{Path: path} + } te := s.ddsToTreeElement(di.Current, allowedGIDs) te.Areas = s.areas te.HasChildren = len(di.Children) > 0