Skip to content

Commit

Permalink
Add behaviour for when DirInfo is nil, clean up UI
Browse files Browse the repository at this point in the history
  • Loading branch information
rk1274 committed Oct 23, 2024
1 parent fdae4a6 commit 49a6360
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
22 changes: 17 additions & 5 deletions server/static/wrstat/src/Filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,23 @@ const stringSort = new Intl.Collator().compare,
onChange={e => setAge(+e.target.value)}
>
<option value="0">All</option>
<option value="1">unused size (1 month)</option>
<option value="7">unused size (5 year)</option>
<option value="12">unchanged size (1 year)</option>
<option value="16">unchanged size (7 years)</option>
</select>
<option value="1">unused files (1 month)</option>
<option value="2">unused files (2 months)</option>
<option value="3">unused files (6 months)</option>
<option value="4">unused files (1 year)</option>
<option value="5">unused files (2 years)</option>
<option value="6">unused files (3 years)</option>
<option value="7">unused files (5 years)</option>
<option value="8">unused files (7 years)</option>
<option value="9">unchanged files (1 month)</option>
<option value="10">unchanged files (2 months)</option>
<option value="11">unchanged files (6 months)</option>
<option value="12">unchanged files (1 year)</option>
<option value="13">unchanged files (2 year)</option>
<option value="14">unchanged files (3 year)</option>
<option value="15">unchanged files (5 year)</option>
<option value="16">unchanged files (7 years)</option>
</select> <br />
<label>Size</label>
<Minmax
max={usage.reduce((max, curr) => Math.max(max, curr.UsageSize), 0)}
Expand Down
13 changes: 5 additions & 8 deletions server/static/wrstat/src/TreeDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,23 @@ const TreedetailsComponent = ({ details, ...rest}: { details: Child | null} & Re
</tr>
<tr>
<th>Accessed</th>
<td>{formatDate(details.atime)}</td>
<td>{details.atime ? formatDate(details.atime): ""}</td>
</tr>
<tr>
<th>Modifed</th>
<td>{formatDate(details.mtime)}</td>
<td>{details.mtime ? formatDate(details.mtime): ""}</td>
</tr>
<tr>
<th>Groups</th>
<td><div>{details.groups.join(", ")}</div></td>
<td><div>{details.groups ? details.groups.join(", "): ""}</div></td>
</tr>
<tr>
<th>Users</th>
<td><div>{details.users.join(", ")}</div></td>
<td><div>{details.users ? details.users.join(", "): ""}</div></td>
</tr>
<tr>
<th>Filetypes</th>
<td><div>{details.filetypes.join(", ")}</div></td>
</tr>
<tr>
<th>tesssting</th>
<td><div>{details.filetypes ? details.filetypes.join(", "): ""}</div></td>
</tr>
</tbody>
</table>
Expand Down
8 changes: 6 additions & 2 deletions server/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 49a6360

Please sign in to comment.