feat(admin): Library pages on the web panel (owner review 2, R6)
The web panel now manages the library without editing it: the owner can browse and view sequences and photos, delete sequences and photos into the archive's trash, restore or empty the trash and run mass operations, as R6 asks, on top of the engine endpoints of the previous commit. - Library page right after the Dashboard: search, Year/Camera/Status/Tag filters fed by a new GET /api/v1/sequences/facets, sort, cards or list (remembered per browser), lazy cover thumbnails, Load more by cursor, multi-select with Shift ranges and "Select all N" of the filter, and a sticky bar for the selection: Analyse, Proxies, Thumbnails, Verify, Tags (add/remove), Export CSV (client-side) and Delete (dry run, list of what moves to the trash, then the move). Filters live in the address, so Back from a sequence finds them again. - Sequence view (#/library?id=): inline title, tags, rating and notes, facts, photos in pages of 500 with content-visibility, a photo viewer (proxy, arrows, Esc, Exif facts), Set cover, Download original, Delete photos (typing the count above 20 photos), Delete sequence, renders to download. No video editing controls. - Trash view (#/library?view=trash, also linked from Archive): entries, Restore, and Empty (dry run, list, the localised word typed, the plan's fingerprint sent back, the job followed to its end). - Live updates from sequenceChanged and jobState; keyboard grid (one tab stop, arrows, Space, Shift+Space, Enter, Ctrl+A, Esc); RTL, dark theme. - GET /sequences takes rendered=true|false for the Status filter. - ui.js: confirmDialog's typed confirmation by name, word or count, with a list of what the action concerns; formDialog. api.js: putBytes for the web upload, which the Library imports on demand (upload.js, optional). - New web icons from icons.py (Image for the Library, trash, grid/list, arrows, stars, cover); directional glyphs mirror in right-to-left pages. - Strings in en and it; tests for the facets (both dialects), the rendered filter, the menu, the modules and the on-demand upload import. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 029cf334f66cb6fa1265b96a6f8faff2964c11ea)
This commit is contained in:
1 parent
51782a3ada
commit
aa1d4913a3
23 files changed
+2540
-31
No files matched your search
@@ -242,6 +242,57 @@ public sealed class LibraryTests(TestContext context)
|
||||
using (var unknown = await editor.GetAsync($"/api/v1/sequences/{Guid.CreateVersion7()}/thumb")) await unknown.ExpectErrorAsync(HttpStatusCode.NotFound, "not_found");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TheLibraryFiltersOfferTheArchivesYearsCamerasAndTags()
|
||||
{
|
||||
// The panel's Year, Camera and Tag menus list what the archive has, each with its count, in the values the listing takes.
|
||||
await using var server = await TestServer.StartAsync(context);
|
||||
var archive = server.Services.GetRequiredService<ServerArchive>();
|
||||
var (viewer, _, _) = await server.UserAsync("vera", "viewer");
|
||||
Sequence Seq(DateTime? first, string? make, string? model, params string[] tags) => new()
|
||||
{
|
||||
Id = Guid.CreateVersion7(),
|
||||
ArchiveId = archive.Id,
|
||||
Folder = $"2026/{Guid.NewGuid():N}",
|
||||
CameraMake = make,
|
||||
CameraModel = model,
|
||||
FirstCapture = first,
|
||||
LastCapture = first?.AddHours(1),
|
||||
Tags = tags,
|
||||
UpdatedAt = DateTimeOffset.UtcNow,
|
||||
};
|
||||
var sony = Seq(new DateTime(2025, 3, 4), "SONY", "ILCE-7M4") with { RenderedCount = 2 };
|
||||
foreach (var s in new[]
|
||||
{
|
||||
Seq(new DateTime(2024, 5, 1), "Canon", "Canon EOS R5", "Night", "roof"), Seq(new DateTime(2025, 1, 2), "Canon", "Canon EOS R5", "night"), sony,
|
||||
Seq(new DateTime(2023, 8, 9), "NIKON CORPORATION", "NIKON Z 8"), Seq(null, null, null),
|
||||
})
|
||||
await server.Database.Sequences.UpsertAsync(s);
|
||||
|
||||
LibraryFacetsDto facets;
|
||||
using (var response = await viewer.GetAsync("/api/v1/sequences/facets")) facets = await response.ReadAsync(ProtocolJson.Default.LibraryFacetsDto);
|
||||
Assert.SequenceEqual([new FacetDto("2025", 2), new FacetDto("2024", 1), new FacetDto("2023", 1)], facets.Years);
|
||||
// Labelled as the desktop names cameras: the brand once.
|
||||
Assert.SequenceEqual([new FacetDto("Canon EOS R5", 2, "Canon EOS R5"), new FacetDto("ILCE-7M4", 1, "SONY ILCE-7M4"), new FacetDto("NIKON Z 8", 1, "Nikon Z 8")],
|
||||
facets.Cameras);
|
||||
Assert.SequenceEqual([new FacetDto("Night", 2), new FacetDto("roof", 1)], facets.Tags);
|
||||
|
||||
async Task<int> CountAsync(string query)
|
||||
{
|
||||
using var page = await viewer.GetAsync($"/api/v1/sequences?{query}");
|
||||
return (await page.ReadAsync(ProtocolJson.Default.PageSequenceDto)).Items.Count;
|
||||
}
|
||||
|
||||
Assert.Equal(2, await CountAsync("year=2025"));
|
||||
Assert.Equal(1, await CountAsync("camera=ILCE-7M4"));
|
||||
Assert.Equal(2, await CountAsync("tag=night"));
|
||||
// The Status menu's Rendered and Not rendered.
|
||||
Assert.Equal(1, await CountAsync("rendered=true"));
|
||||
Assert.Equal(4, await CountAsync("rendered=false"));
|
||||
using var unknown = await viewer.GetAsync("/api/v1/sequences/facets/x");
|
||||
Assert.Equal(HttpStatusCode.NotFound, unknown.StatusCode);
|
||||
}
|
||||
|
||||
/// <summary>A thumbnail once its pass has drawn it (404 until then).</summary>
|
||||
private static async Task<byte[]> ThumbnailAsync(HttpClient client, string url)
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@ using Chronos.Testing;
|
||||
namespace Chronos.Server.Tests.Hosting;
|
||||
|
||||
[Category("server")]
|
||||
public sealed class SystemEndpointTests(TestContext context)
|
||||
public sealed partial class SystemEndpointTests(TestContext context)
|
||||
{
|
||||
[Test]
|
||||
public async Task HealthReportsOk()
|
||||
@@ -141,21 +141,69 @@ public sealed class SystemEndpointTests(TestContext context)
|
||||
var index = await server.Client.GetStringAsync("/admin/");
|
||||
// The page container is not a live region: only toasts and form errors announce themselves.
|
||||
Assert.True(!index.Contains("aria-live", StringComparison.Ordinal), index);
|
||||
var seen = await ModulesAsync(server);
|
||||
Assert.True(seen.Count >= 17, string.Join(", ", seen.Keys));
|
||||
// The Library's views (owner review 2, R6) are modules of their own under pages/library.
|
||||
foreach (var module in new[] { "pages/library.js", "pages/library/sequence.js", "pages/library/trash.js", "pages/library/shared.js" })
|
||||
Assert.True(seen.ContainsKey(module), module);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AdminPanelListsTheLibraryAndLoadsTheWebUploadOnlyWhenItIsThere()
|
||||
{
|
||||
// Owner review 2, R6: the Library comes right after the Dashboard. The web upload (R3) is a module of its own that the
|
||||
// Library imports on demand, so the panel works with or without it.
|
||||
await using var server = await TestServer.StartAsync(context);
|
||||
var app = await server.Client.GetStringAsync("/admin/app.js");
|
||||
var top = MenuPages(app)[0];
|
||||
Assert.SequenceEqual(["dashboard", "library"], top.Take(2));
|
||||
var icons = await server.Client.GetStringAsync("/admin/icons.js");
|
||||
var strings = Assert.NotNull(await server.Client.GetFromJsonAsync("/api/v1/i18n/it", ProtocolJson.Default.DictionaryStringString));
|
||||
foreach (var page in MenuPages(app).SelectMany(group => group))
|
||||
{
|
||||
Assert.Contains($" {page}: `<svg", icons);
|
||||
var name = $"Admin.Nav.{char.ToUpperInvariant(page[0])}{page[1..]}";
|
||||
Assert.True(strings.ContainsKey(name) && strings.ContainsKey(name + ".Tip"), name);
|
||||
}
|
||||
|
||||
var modules = await ModulesAsync(server);
|
||||
Assert.Contains(@"import(""../upload.js"")", modules["pages/library.js"]);
|
||||
foreach (var (module, source) in modules)
|
||||
{
|
||||
var folder = module.Contains('/', StringComparison.Ordinal) ? module[..(module.LastIndexOf('/') + 1)] : string.Empty;
|
||||
foreach (Match import in StaticImport().Matches(source))
|
||||
Assert.True(Resolve(folder, import.Groups[1].Value) != "upload.js", $"{module} imports upload.js statically");
|
||||
}
|
||||
using var upload = await server.Client.GetAsync("/admin/upload.js");
|
||||
if (upload.StatusCode == HttpStatusCode.OK)
|
||||
Assert.True(Regex.IsMatch(await upload.Content.ReadAsStringAsync(), @"export (?:async )?function openUpload\("), "upload.js exports openUpload");
|
||||
else
|
||||
Assert.Equal(HttpStatusCode.NotFound, upload.StatusCode);
|
||||
}
|
||||
|
||||
/// <summary>The admin panel's modules from app.js and the menu's pages along their static imports, with their source.</summary>
|
||||
private static async Task<Dictionary<string, string>> ModulesAsync(TestServer server)
|
||||
{
|
||||
var app = await server.Client.GetStringAsync("/admin/app.js");
|
||||
var pending = new Queue<string>(MenuPages(app).SelectMany(group => group).Select(p => $"pages/{p}.js").Prepend("app.js"));
|
||||
var seen = new HashSet<string>(StringComparer.Ordinal);
|
||||
var seen = new Dictionary<string, string>(StringComparer.Ordinal);
|
||||
while (pending.TryDequeue(out var module))
|
||||
{
|
||||
if (!seen.Add(module)) continue;
|
||||
if (seen.ContainsKey(module)) continue;
|
||||
using var response = await server.Client.GetAsync("/admin/" + module);
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode, module);
|
||||
var source = await response.Content.ReadAsStringAsync();
|
||||
seen[module] = source;
|
||||
var folder = module.Contains('/', StringComparison.Ordinal) ? module[..(module.LastIndexOf('/') + 1)] : string.Empty;
|
||||
foreach (Match import in Regex.Matches(await response.Content.ReadAsStringAsync(), @"from ""(\.{1,2}/[^""]+)"""))
|
||||
foreach (Match import in StaticImport().Matches(source))
|
||||
pending.Enqueue(Resolve(folder, import.Groups[1].Value));
|
||||
}
|
||||
Assert.True(seen.Count >= 13, string.Join(", ", seen));
|
||||
return seen;
|
||||
}
|
||||
|
||||
[GeneratedRegex(@"from ""(\.{1,2}/[^""]+)""")]
|
||||
private static partial Regex StaticImport();
|
||||
|
||||
[Test]
|
||||
public async Task AdminPanelDocksSettingsAtTheFootAndFoldsAboutIntoIt()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user