(control) Sort upload listing results

Improve the UX of the sideload GUI by sorting the results in a sensible fashion, first by whether it's a directory, then by its filename.

The change also changes the timestamp rendering to a more human-readable format than full ISO-8601.
This commit is contained in:
Viktor Lofgren 2024-02-15 09:13:40 +01:00
parent 8f91156d80
commit 8021bd0aae
6 changed files with 11 additions and 7 deletions

View File

@ -15,7 +15,7 @@ for more information on how to set this up.
<label class="form-check-label" for="{{name}}">{{name}}{{#if directory}}/{{/if}}</label> <label class="form-check-label" for="{{name}}">{{name}}{{#if directory}}/{{/if}}</label>
</td> </td>
<td>{{#unless directory}}{{size}}{{/unless}}</td> <td>{{#unless directory}}{{size}}{{/unless}}</td>
<td>{{lastModifiedTime}}</td> <td title={{lastModifiedTime}}>{{shortTimestamp lastModifiedTime}}</td>
</tr> </tr>
{{/each}} {{/each}}
{{#unless uploadDirContents.items}} {{#unless uploadDirContents.items}}

View File

@ -25,7 +25,7 @@
<label class="form-check-label" for="{{name}}">{{name}}{{#if directory}}/{{/if}}</label> <label class="form-check-label" for="{{name}}">{{name}}{{#if directory}}/{{/if}}</label>
</td> </td>
<td>{{#unless directory}}{{size}}{{/unless}}</td> <td>{{#unless directory}}{{size}}{{/unless}}</td>
<td>{{lastModifiedTime}}</td> <td title={{lastModifiedTime}}>{{shortTimestamp lastModifiedTime}}</td>
</tr> </tr>
{{/each}} {{/each}}
{{#unless uploadDirContents.items}} {{#unless uploadDirContents.items}}

View File

@ -1,7 +1,7 @@
<h1 class="my-3">Sideload Reddit</h1> <h1 class="my-3">Sideload Reddit</h1>
<div class="my-3 p-3 border bg-light"> <div class="my-3 p-3 border bg-light">
This will index a pushshift.io dump from the Reddit API into index. This will index a pushshift.io "top-n subreddits" dump from the Reddit API into index.
</div> </div>
<form method="post" action="actions/sideload-reddit" onsubmit="return confirm('Confirm sideloading')"> <form method="post" action="actions/sideload-reddit" onsubmit="return confirm('Confirm sideloading')">
<div class="my-3 py-3"> <div class="my-3 py-3">
@ -14,7 +14,7 @@ This will index a pushshift.io dump from the Reddit API into index.
<label class="form-check-label" for="{{name}}">{{name}}{{#if directory}}/{{/if}}</label> <label class="form-check-label" for="{{name}}">{{name}}{{#if directory}}/{{/if}}</label>
</td> </td>
<td>{{#unless directory}}{{size}}{{/unless}}</td> <td>{{#unless directory}}{{size}}{{/unless}}</td>
<td>{{lastModifiedTime}}</td> <td title={{lastModifiedTime}}>{{shortTimestamp lastModifiedTime}}</td>
</tr> </tr>
{{/each}} {{/each}}
{{#unless uploadDirContents.items}} {{#unless uploadDirContents.items}}

View File

@ -18,7 +18,7 @@ information how to do this.
<label class="form-check-label" for="{{name}}">{{name}}{{#if directory}}/{{/if}}</label> <label class="form-check-label" for="{{name}}">{{name}}{{#if directory}}/{{/if}}</label>
</td> </td>
<td>{{#unless directory}}{{size}}{{/unless}}</td> <td>{{#unless directory}}{{size}}{{/unless}}</td>
<td>{{lastModifiedTime}}</td> <td title={{lastModifiedTime}}>{{shortTimestamp lastModifiedTime}}</td>
</tr> </tr>
{{/each}} {{/each}}
{{#unless uploadDirContents.items}} {{#unless uploadDirContents.items}}

View File

@ -17,7 +17,7 @@ A warc export can be created using e.g. wget: <p>
<label class="form-check-label" for="{{name}}">{{name}}{{#if directory}}/{{/if}}</label> <label class="form-check-label" for="{{name}}">{{name}}{{#if directory}}/{{/if}}</label>
</td> </td>
<td>{{#unless directory}}{{size}}{{/unless}}</td> <td>{{#unless directory}}{{size}}{{/unless}}</td>
<td>{{lastModifiedTime}}</td> <td title={{lastModifiedTime}}>{{shortTimestamp lastModifiedTime}}</td>
</tr> </tr>
{{/each}} {{/each}}
{{#unless uploadDirContents.items}} {{#unless uploadDirContents.items}}

View File

@ -16,6 +16,7 @@ import java.nio.file.Path;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Comparator;
public class SideloadService { public class SideloadService {
private final ExecutorActorControlService actorControlService; private final ExecutorActorControlService actorControlService;
@ -61,7 +62,10 @@ public class SideloadService {
public RpcUploadDirContents listUploadDir() throws IOException { public RpcUploadDirContents listUploadDir() throws IOException {
Path uploadDir = WmsaHome.getUploadDir(); Path uploadDir = WmsaHome.getUploadDir();
try (var items = Files.list(uploadDir)) { try (var items = Files.list(uploadDir).sorted(
Comparator.comparing((Path d) -> Files.isDirectory(d)).reversed()
.thenComparing(path -> path.getFileName().toString())
)) {
var builder = RpcUploadDirContents.newBuilder().setPath(uploadDir.toString()); var builder = RpcUploadDirContents.newBuilder().setPath(uploadDir.toString());
var iter = items.iterator(); var iter = items.iterator();