diff --git a/i18n/en/Admin.resx b/i18n/en/Admin.resx index 3e741800..90626969 100644 --- a/i18n/en/Admin.resx +++ b/i18n/en/Admin.resx @@ -1124,6 +1124,15 @@ Show the videos as cards List Show the videos as a list + Board + Show the videos in two lanes: published, and sent from a workspace + Published + Every render this server holds, newest first + Workspace + Renders a PC's workspace made and sent here; those not sent yet stay on that PC + Sent + Sent from the workspace of {0}{0} a computer's name + Version {0}{0} a project version number Selected: {0}{0} a count Select this video Select every video shown diff --git a/i18n/en/Tooltips.resx b/i18n/en/Tooltips.resx index 5ddb3ff5..7f55fbd6 100644 --- a/i18n/en/Tooltips.resx +++ b/i18n/en/Tooltips.resx @@ -1075,6 +1075,13 @@ Select the video; Ctrl and Shift add to the selection Select one video only to do this Only on the server: not on this PC + Show the videos in two lanes: published, and in the workspace + Renders filed in this PC's archive or on the server, newest first + Renders made in the workspace: not sent yet, or sent and still in its exports + Sent to the archive; the file is still in the workspace + Sent to the server; the file is still in the workspace + Rendered in the workspace and sent to the archive: play it or show it here + Rendered in the workspace and sent to the server: play it or show it here Where Copy to folder puts videos; not inside the archive or the workspace Choose the videos folder Open the videos folder in Explorer diff --git a/i18n/en/Videos.resx b/i18n/en/Videos.resx index 017b7824..7e5114a0 100644 --- a/i18n/en/Videos.resx +++ b/i18n/en/Videos.resx @@ -35,6 +35,14 @@ Title Grid List + Board + Published + Workspace + Sent + Version {0}{0} a project version number + Video + Still + Image sequence Selected: {0}{0} a count No videos Server not reachable diff --git a/i18n/it/Admin.it.resx b/i18n/it/Admin.it.resx index 32ddb648..2fc3ffc1 100644 --- a/i18n/it/Admin.it.resx +++ b/i18n/it/Admin.it.resx @@ -1116,6 +1116,15 @@ Mostra i video come schede Elenco Mostra i video come elenco + Bacheca + Mostra i video in due colonne: pubblicati e inviati da uno spazio di lavoro + Pubblicati + Tutti i render di questo server, dal più recente + Spazio di lavoro + Render fatti nello spazio di lavoro di un PC e inviati qui; quelli non ancora inviati restano su quel PC + Inviato + Inviato dallo spazio di lavoro di {0} + Versione {0} Selezionati: {0} Seleziona questo video Seleziona tutti i video mostrati diff --git a/i18n/it/Tooltips.it.resx b/i18n/it/Tooltips.it.resx index da7e30e2..ab1948fb 100644 --- a/i18n/it/Tooltips.it.resx +++ b/i18n/it/Tooltips.it.resx @@ -1057,6 +1057,13 @@ Seleziona il video; Ctrl e Maiusc aggiungono alla selezione Seleziona un solo video per farlo Solo sul server: non su questo PC + Mostra i video in due colonne: pubblicati e nello spazio di lavoro + Render archiviati nell'archivio di questo PC o sul server, dal più recente + Render fatti nello spazio di lavoro: non ancora inviati, o inviati e ancora nelle sue esportazioni + Inviato all'archivio; il file è ancora nello spazio di lavoro + Inviato al server; il file è ancora nello spazio di lavoro + Renderizzato nello spazio di lavoro e inviato all'archivio: riproducilo o mostralo qui + Renderizzato nello spazio di lavoro e inviato al server: riproducilo o mostralo qui Non connesso a un server: sono elencati solo i video di questo PC Il Chronos del server non ha la libreria video; aggiornalo per vederne i video Mostra il file in Esplora file diff --git a/i18n/it/Videos.it.resx b/i18n/it/Videos.it.resx index a2bb8c71..0e678d0e 100644 --- a/i18n/it/Videos.it.resx +++ b/i18n/it/Videos.it.resx @@ -35,6 +35,14 @@ Titolo Griglia Elenco + Bacheca + Pubblicati + Spazio di lavoro + Inviato + Versione {0} + Video + Fotogramma + Sequenza di immagini Selezionati: {0} Nessun video Server non raggiungibile diff --git a/src/Chronos.App/DesignTime/SampleData.cs b/src/Chronos.App/DesignTime/SampleData.cs index f7e88cc8..ff723449 100644 --- a/src/Chronos.App/DesignTime/SampleData.cs +++ b/src/Chronos.App/DesignTime/SampleData.cs @@ -518,17 +518,22 @@ public sealed class SampleData DateTimeOffset created, string? project = null) => new(id, sequence, preset, codec, width, height, fps, seconds, bytes, created, "nas", null, null, null, RenderKind.Video, title, first, project, project is null ? null : 3, VideoStates.Ok, [], $"{first:yyyy-MM-dd} {title} - {preset}.mp4"); + var lakeVertical = Guid.CreateVersion7(); + var lakeCreated = Now.AddDays(-30); IReadOnlyList server = [ OnServer(Guid.CreateVersion7(), _sunrise, "Sunrise over Superga", new DateTime(2026, 7, 2, 5, 12, 0), "4K HEVC", "hevc", 3840, 2160, 24, 120, 3_960_000_000L, Now.AddHours(-6)), OnServer(cometVideo.Id, comet.Id, comet.DisplayTitle, comet.FirstCapture!.Value, cometVideo.PresetName, "hevc", 3840, 2160, 24, 41.9, cometVideo.Bytes, cometVideo.Created), - OnServer(Guid.CreateVersion7(), _lakeComo, "Lake Como storm", new DateTime(2026, 8, 21, 16, 30, 0), "Vertical 1080p", "h264", 1080, 1920, 30, 48.3, 248_000_000L, - Now.AddDays(-30), project: "Vertical social"), + OnServer(lakeVertical, _lakeComo, "Lake Como storm", new DateTime(2026, 8, 21, 16, 30, 0), "Vertical 1080p", "h264", 1080, 1920, 30, 48.3, 248_000_000L, + lakeCreated, project: "Vertical social"), ]; var milan = await LocalAsync("Milan skyline dusk"); var gif = Path.Combine(_services.Environment.DataDirectory, "workspace-sample", "exports", $"{milan.FirstCapture:yyyy-MM-dd} {milan.DisplayTitle} - GIF preview.gif"); WriteStandIn(gif); + // A render the workspace sent to the server, whose file is still in its exports: the Board's Workspace lane, as sent. + var vertical = Path.Combine(_services.Environment.DataDirectory, "workspace-sample", "exports", "2026-08-21 Lake Como storm - Vertical 1080p.mp4"); + WriteStandIn(vertical); IReadOnlyList workspace = [ new() @@ -551,6 +556,27 @@ public sealed class SampleData WorkspaceProjectId = Guid.CreateVersion7(), ProjectName = "Social cut", }, + new() + { + Id = lakeVertical, + SequenceId = _lakeComo, + Title = "Lake Como storm", + PresetName = "Vertical 1080p", + Codec = "h264", + Width = 1080, + Height = 1920, + Fps = 30, + DurationSeconds = 48.3, + Bytes = 248_000_000L, + Created = lakeCreated, + Kind = RenderKind.Video, + FileName = Path.GetFileName(vertical), + LocalPath = vertical, + IsWorkspaceSent = true, + WorkspaceProjectId = Guid.CreateVersion7(), + WorkspaceServerHome = true, + ProjectName = "Vertical social", + }, ]; videos.ServerVideos = () => new VideoServer(VideoServerState.Available, () => new SampleRemoteVideos(server), CanEdit: true, CanDelete: true); diff --git a/src/Chronos.App/Infrastructure/AppSettings.cs b/src/Chronos.App/Infrastructure/AppSettings.cs index c9d5a02a..101d7af4 100644 --- a/src/Chronos.App/Infrastructure/AppSettings.cs +++ b/src/Chronos.App/Infrastructure/AppSettings.cs @@ -22,6 +22,9 @@ public enum LibraryLayout /// Year bands with photos per month above the card grid. Timeline, + + /// The Videos section's two lanes, Published and Workspace (the Library has no board). + Board, } /// Rendering quality profile (Settings › Rendering). @@ -164,7 +167,10 @@ public sealed class AppSettings public LibraryLayout LibraryLayout { get; set; } = LibraryLayout.Grid; public SequenceSort LibrarySort { get; set; } = SequenceSort.Newest; - /// The Videos section as cards () or as a list (). + /// + /// The Videos section as cards (), as a list () or as the + /// Board (). + /// public LibraryLayout VideosLayout { get; set; } = LibraryLayout.Grid; // ---- Rendering ---- diff --git a/src/Chronos.App/Infrastructure/Formatting.cs b/src/Chronos.App/Infrastructure/Formatting.cs index 28c307de..d80952e9 100644 --- a/src/Chronos.App/Infrastructure/Formatting.cs +++ b/src/Chronos.App/Infrastructure/Formatting.cs @@ -5,10 +5,16 @@ namespace Chronos.App.Infrastructure; /// Culture-aware number, size and duration formatting for the UI. public static class Formatting { + /// U+00A0, which joins a number to its unit. + public const char NoBreakSpace = '\u00A0'; + /// Localized "{0} KB" formats from bytes to petabytes (BRIEF §16: sizes follow the language, "96,2 Go"). private static readonly string[] ByteUnits = ["Common.Size.B", "Common.Size.KB", "Common.Size.MB", "Common.Size.GB", "Common.Size.TB", "Common.Size.PB"]; - /// 1,536 → "1.5 KB" (decimal units, as Explorer shows for drives). + /// + /// 1,536 → "1.5 KB" (decimal units, as Explorer shows for drives), the number and its unit held together by a no-break + /// space (U+00A0) so a wrapped or trimmed line never parts them (issue #28). + /// public static string Bytes(long bytes) { double value = bytes; @@ -19,7 +25,7 @@ public static class Formatting unit++; } var format = unit == 0 || value >= 100 ? "0" : "0.#"; - return Loc.L(ByteUnits[unit], value.ToString(format, Loc.Culture)); + return Loc.L(ByteUnits[unit], value.ToString(format, Loc.Culture)).Replace(' ', NoBreakSpace); } public static string Count(long n) => n.ToString("N0", Loc.Culture); diff --git a/src/Chronos.App/Sections/VideosView.xaml b/src/Chronos.App/Sections/VideosView.xaml index a3d30a92..ac51d371 100644 --- a/src/Chronos.App/Sections/VideosView.xaml +++ b/src/Chronos.App/Sections/VideosView.xaml @@ -101,6 +101,70 @@ + + + + + + + + + + + + + + + + + +
@@ -160,7 +171,11 @@ export async function render(root, { api, setMeta, actions, onEvent }) { cursor = page.next ?? null; if (!more) total = page.total ?? null; learn(page.items); - if (more) { + if (more && view === "board") { + // A lane's cards stay newest first: the board is drawn again with the page added. + rows = rows.concat(page.items); + draw(); + } else if (more) { rows = rows.concat(page.items); itemsHost.insertAdjacentHTML("beforeend", page.items.map(itemHtml).join("")); watchImages(itemsHost); @@ -260,7 +275,7 @@ export async function render(root, { api, setMeta, actions, onEvent }) { } function draw() { - itemsHost.className = `seq-items video-items ${view === "list" ? "rows" : "cards"}`; + itemsHost.className = `seq-items video-items ${view === "list" ? "rows" : view === "board" ? "board" : "cards"}`; itemsHost.setAttribute("role", "listbox"); itemsHost.setAttribute("aria-multiselectable", "true"); itemsHost.setAttribute("aria-label", t("Admin.Videos.Title")); @@ -274,6 +289,14 @@ export async function render(root, { api, setMeta, actions, onEvent }) { syncSelection(); return; } + if (view === "board") { + itemsHost.innerHTML = boardHtml(); + applyStrings(itemsHost); + watchImages(itemsHost); + grid.restore(); + syncSelection(); + return; + } const head = view === "list" ? ``; } + // On the board: the project and its version, then preset · codec · length · size, then kind · date (issue #28's order). + if (view === "board") { + return `
+ ${thumb}${check} + + ${escapeHtml(v.sequenceTitle)} + ${v.projectName ? `${escapeHtml(projectText(v))}` : ""} + ${escapeHtml(cardText(v))} + ${escapeHtml(`${kindText(kind)} · ${formatDateTime(v.created)}`)} + ${workspace ? sentChip(v) : ""}${stateChips(v)} +
`; + } return `
${thumb}${check} @@ -580,6 +630,30 @@ function formatText(v) { return parts.join(" · "); } +/** + * The board's lane of a video: "workspace" for a render a PC's workspace made and sent here (it names its project, and a + * machine other than this server produced it), else "published". Every video is also in Published: the server holds it. + */ +export function boardLane(v, serverName) { + const producer = String(v.producedBy ?? ""); + return v.projectId && producer && producer !== String(serverName ?? "") ? "workspace" : "published"; +} + +/** "Social cut · Version 3": the project rendered and its version. */ +function projectText(v) { + return v.projectVersionNumber ? `${v.projectName} · ${t("Admin.Videos.Version", formatNumber(v.projectVersionNumber))}` : v.projectName; +} + +/** "4K archive · HEVC · 0:41 · 1.4 GB": the preset first, then the codec, the length (none for a still) and the size. */ +function cardText(v) { + return [v.presetName, codecLabel(v.codec), videoKind(v) === "still" ? "" : clock(v.durationSeconds), formatBytes(v.bytes)].filter(Boolean).join(" · "); +} + +/** Sent, from which PC's workspace. */ +function sentChip(v) { + return ` ${escapeHtml(t("Admin.Videos.State.Sent"))}`; +} + function presetText(v) { return v.projectName ? `${v.presetName} · ${v.projectName}${v.projectVersionNumber ? ` v${v.projectVersionNumber}` : ""}` : v.presetName; } @@ -627,7 +701,8 @@ function clock(seconds) { function storedView() { try { - return localStorage.getItem(VIEW_KEY) === "list" ? "list" : "cards"; + const stored = localStorage.getItem(VIEW_KEY); + return stored === "list" || stored === "board" ? stored : "cards"; } catch { return "cards"; } diff --git a/src/Chronos.Ui/Icons/Icons.xaml b/src/Chronos.Ui/Icons/Icons.xaml index 9b50f05e..9bf4e8ca 100644 --- a/src/Chronos.Ui/Icons/Icons.xaml +++ b/src/Chronos.Ui/Icons/Icons.xaml @@ -108,6 +108,7 @@ + diff --git a/tests/Chronos.App.Tests/Archive/ArchiveLanguageTests.cs b/tests/Chronos.App.Tests/Archive/ArchiveLanguageTests.cs index c7a988be..70148df3 100644 --- a/tests/Chronos.App.Tests/Archive/ArchiveLanguageTests.cs +++ b/tests/Chronos.App.Tests/Archive/ArchiveLanguageTests.cs @@ -45,8 +45,8 @@ public sealed class ArchiveLanguageTests var tree = ArchiveTree.Build(Main, ArchiveAvailability.Online, [harbour]); var year = new ArchiveTreeRowViewModel(tree.Root.Children[0], ArchiveAvailability.Online, _ => { }); var sequence = new ArchiveTreeRowViewModel(tree.Root.Children[0].Children[0], ArchiveAvailability.Online, _ => { }); - Assert.Equal("Construction cam · weekly · 3,600 photos · 72 GB", sequence.RowToolTip); - Assert.Equal("2026 · 1 sequence · 72 GB · Right arrow opens the year, Left arrow closes it", year.RowToolTip); + Assert.Equal("Construction cam · weekly · 3,600 photos · 72\u00A0GB", sequence.RowToolTip); + Assert.Equal("2026 · 1 sequence · 72\u00A0GB · Right arrow opens the year, Left arrow closes it", year.RowToolTip); try { Loc.SetCulture(CultureInfo.GetCultureInfo("he")); diff --git a/tests/Chronos.App.Tests/Archive/ArchiveLogicTests.cs b/tests/Chronos.App.Tests/Archive/ArchiveLogicTests.cs index cb5cf339..00cf5afe 100644 --- a/tests/Chronos.App.Tests/Archive/ArchiveLogicTests.cs +++ b/tests/Chronos.App.Tests/Archive/ArchiveLogicTests.cs @@ -45,8 +45,8 @@ public sealed class ArchiveLogicTests Assert.Equal("ChronosArchive", tree.Root.Title); Assert.SequenceEqual(new[] { "2026", "2025", "Undated" }, tree.Root.Children.Select(n => n.Title)); Assert.SequenceEqual(new[] { "Harbour", "Comet" }, tree.Root.Children[0].Children.Select(n => n.Title)); - Assert.Equal("3,600 photos · 72 GB", tree.Root.Children[0].Children[0].Detail); - Assert.Equal("2 sequences · 72 GB", tree.Root.Children[0].Detail); + Assert.Equal("3,600 photos · 72\u00A0GB", tree.Root.Children[0].Children[0].Detail); + Assert.Equal("2 sequences · 72\u00A0GB", tree.Root.Children[0].Detail); // Collapsed years show only themselves; expanding one reveals its sequences. Assert.Equal(4, tree.Visible().Count); @@ -137,7 +137,7 @@ public sealed class ArchiveLogicTests var stats = Stats(); var years = ArchiveFigures.StorageByYear(stats); Assert.SequenceEqual(new[] { "2024", "2026" }, years.Select(b => b.Label)); - Assert.Equal("2.1 TB", years[1].ValueText); + Assert.Equal("2.1\u00A0TB", years[1].ValueText); var cameras = ArchiveFigures.ByCamera(stats); Assert.Equal(ArchiveFigures.TopCameras + 1, cameras.Count); @@ -176,7 +176,7 @@ public sealed class ArchiveLogicTests var tiles = ArchiveFigures.Tiles(Stats()); Assert.Equal(5, tiles.Count); Assert.Equal("10,000", tiles[0].Value); - Assert.Equal("9.4 TB", tiles[2].Value); + Assert.Equal("9.4\u00A0TB", tiles[2].Value); Assert.Equal("6", tiles[3].Value); Assert.Equal("cameras · 8 formats", tiles[3].Caption); Assert.Equal(Formatting.LeftToRight("2024 – 2026"), tiles[4].Value, "a year range keeps its order in right-to-left text"); diff --git a/tests/Chronos.App.Tests/Import/CardPoolTests.cs b/tests/Chronos.App.Tests/Import/CardPoolTests.cs index ee3582e5..6b803a58 100644 --- a/tests/Chronos.App.Tests/Import/CardPoolTests.cs +++ b/tests/Chronos.App.Tests/Import/CardPoolTests.cs @@ -42,10 +42,10 @@ public sealed class CardPoolTests Assert.Equal("New card", pool[0].StateText); Assert.Equal("EOS R5 · card A", pool[1].Title); Assert.Equal("Known card", pool[1].StateText); - Assert.Equal("128 GB · 96.2 GB used", pool[1].Subtitle); - Assert.Equal("128 GB · serial 3F2A-9C11 · Canon EOS R5 #0431", pool[1].IdentityText); + Assert.Equal("128\u00A0GB · 96.2\u00A0GB used", pool[1].Subtitle); + Assert.Equal("128\u00A0GB · serial 3F2A-9C11 · Canon EOS R5 #0431", pool[1].IdentityText); Assert.Equal(SourceKind.Drive, pool[2].Kind); - Assert.Equal("no DCIM · 1.8 TB free", pool[2].Subtitle); + Assert.Equal("no DCIM · 1.8\u00A0TB free", pool[2].Subtitle); Assert.False(pool[3].IsInserted); Assert.Null(pool[3].Root); Assert.Equal("Canon EOS R5 · not inserted", pool[3].Subtitle); @@ -72,8 +72,8 @@ public sealed class CardPoolTests public void TheEntryTooltipCarriesTheStateAndTheWholeSubtitle() { var pool = CardPool.Build([CardA, Usb], [Known(CardA, "EOS R5 · card A", DateTimeOffset.UtcNow)], @"D:\Shoots\2026"); - Assert.Equal("Known card · 128 GB · 96.2 GB used", pool[0].ToolTip); - Assert.Equal("no DCIM · 1.8 TB free", pool[1].ToolTip); + Assert.Equal("Known card · 128\u00A0GB · 96.2\u00A0GB used", pool[0].ToolTip); + Assert.Equal("no DCIM · 1.8\u00A0TB free", pool[1].ToolTip); Assert.Equal(@"Folder · D:\Shoots\2026", pool[2].ToolTip); } diff --git a/tests/Chronos.App.Tests/Import/ImportPlansTests.cs b/tests/Chronos.App.Tests/Import/ImportPlansTests.cs index 025f0b95..12ce5786 100644 --- a/tests/Chronos.App.Tests/Import/ImportPlansTests.cs +++ b/tests/Chronos.App.Tests/Import/ImportPlansTests.cs @@ -40,11 +40,11 @@ public sealed class ImportPlansTests Assert.Equal(80_000_000L, totals.FreeAfter); Assert.True(totals.HasEnoughSpace); Assert.Equal(TimeSpan.FromSeconds(3), totals.Estimate); - Assert.Equal("3 sessions · 7 photos · 120 MB · about 3 s", totals.Text); - Assert.Equal("3 sessions · 7 photos · 120 MB", totals.SummaryText); + Assert.Equal("3 sessions · 7 photos · 120\u00A0MB · about 3 s", totals.Text); + Assert.Equal("3 sessions · 7 photos · 120\u00A0MB", totals.SummaryText); Assert.Equal("1 duplicate", totals.DuplicatesText); Assert.Equal("Import 5 photos", totals.ImportText); - Assert.Equal("80 MB free after import", totals.SpaceText); + Assert.Equal("80\u00A0MB free after import", totals.SpaceText); } [Test] @@ -52,7 +52,7 @@ public sealed class ImportPlansTests { var totals = ImportPlans.Totals(ThreeSessions(available: 100_000_000), verify: false); Assert.False(totals.HasEnoughSpace); - Assert.Equal("20 MB missing", totals.SpaceText); + Assert.Equal("20\u00A0MB missing", totals.SpaceText); Assert.Equal(string.Empty, ImportPlans.Totals(ThreeSessions(available: null), verify: false).SpaceText); Assert.Equal(TimeSpan.FromSeconds(2), ImportPlans.Totals(ThreeSessions(), verify: false).Estimate); } @@ -105,7 +105,7 @@ public sealed class ImportPlansTests Assert.Equal("Adds to · 2026/2026-09-29 Canon EOS R5", rows[1].TargetText); Assert.Equal("2026-09-28 Canon EOS R5", rows[0].DefaultTitle); Assert.Equal("Canon EOS R5", rows[0].CameraText); - Assert.Equal("96 MB", rows[0].SizeText); + Assert.Equal("96\u00A0MB", rows[0].SizeText); Assert.Contains("6:02", rows[0].TimeText); Assert.Equal("Server", ImportPlans.Sessions(plan, ImportDestinationKind.Server, new HashSet())[0].TargetText); } @@ -140,7 +140,7 @@ public sealed class ImportPlansTests Assert.True(details.Rows.Single(r => r.Source.EndsWith("0007.CR2", StringComparison.Ordinal)).IsSkipped); Assert.Equal(3, details.Conflicts.Count); Assert.Contains("IMG_0099.CR2", details.Conflicts[0]); - Assert.Equal("7 files · copy 5 (120 MB) · 1 imported before · 1 duplicate", details.TotalsText); + Assert.Equal("7 files · copy 5 (120\u00A0MB) · 1 imported before · 1 duplicate", details.TotalsText); var folder = ImportPlans.Details(plan, ImportDestinationKind.Folder, verify: true); Assert.Equal("2026/2026-09-28 Canon EOS R5/" + plan.Sessions[0].Items[0].FileName, folder.Rows[1].Destination); diff --git a/tests/Chronos.App.Tests/Import/SampleCardsTests.cs b/tests/Chronos.App.Tests/Import/SampleCardsTests.cs index e16dc78c..315ab589 100644 --- a/tests/Chronos.App.Tests/Import/SampleCardsTests.cs +++ b/tests/Chronos.App.Tests/Import/SampleCardsTests.cs @@ -26,7 +26,7 @@ public sealed class SampleCardsTests(TestContext context) var pool = CardPool.Build(devices.Devices, await db.MediaCards.ListAsync(context.Cancellation), null, contents); Assert.SequenceEqual(new[] { SourceKind.Card, SourceKind.Card, SourceKind.Drive, SourceKind.Card }, pool.Select(s => s.Kind)); Assert.Equal("EOS R5 · card A", pool[0].Title); - Assert.Equal("128 GB · serial 3F2A-9C11 · Canon EOS R5 #0431", pool[0].IdentityText); + Assert.Equal("128\u00A0GB · serial 3F2A-9C11 · Canon EOS R5 #0431", pool[0].IdentityText); Assert.Equal("Canon EOS R5 · 50 photos", pool[0].ToastText); Assert.Contains("50 photos", pool[0].Subtitle); Assert.Equal("SONY", pool[1].Title); diff --git a/tests/Chronos.App.Tests/Jobs/JobListModelTests.cs b/tests/Chronos.App.Tests/Jobs/JobListModelTests.cs index 6a43d7a5..4f6b24c9 100644 --- a/tests/Chronos.App.Tests/Jobs/JobListModelTests.cs +++ b/tests/Chronos.App.Tests/Jobs/JobListModelTests.cs @@ -172,7 +172,7 @@ public sealed class JobListModelTests Assert.Equal("Render · Harbour sunset · 2,232 / 3,600 · 11.3 fps · 2 min left", JobText.Bar(running)); Assert.Equal("2 min", JobText.Left(running, 0)); // Imports and verifies count bytes; scans count folders; frame jobs read in fps (owner review 1). - Assert.Equal("118 B/s", JobText.Speed(JobKind.Import, 118)); + Assert.Equal("118\u00A0B/s", JobText.Speed(JobKind.Import, 118)); Assert.Equal(JobText.Speed(JobKind.Verify, 57_000_000), Loc.L("Jobs.Speed.Bytes", Formatting.Bytes(57_000_000))); Assert.Equal("4/s", JobText.Speed(JobKind.Scan, 4)); Assert.Equal("1.7 fps", JobText.Speed(JobKind.Proxies, 1.7)); diff --git a/tests/Chronos.App.Tests/Settings/SettingsLogicTests.cs b/tests/Chronos.App.Tests/Settings/SettingsLogicTests.cs index c0ac58c0..3384ba7c 100644 --- a/tests/Chronos.App.Tests/Settings/SettingsLogicTests.cs +++ b/tests/Chronos.App.Tests/Settings/SettingsLogicTests.cs @@ -565,7 +565,7 @@ public sealed class SettingsLogicTests pending.SetResult(new WorkspaceUsage(MediaBytes: 9_000_000_000, TotalBytes: 12_400_000_000, TrashBytes: 1_200_000_000, TrashItems: 3)); await measuring; Assert.False(rows.IsMeasuring); - Assert.Equal(("12.4 GB used", "3 items, 1.2 GB"), (rows.UsageText, rows.TrashText)); + Assert.Equal(("12.4\u00A0GB used", "3 items, 1.2\u00A0GB"), (rows.UsageText, rows.TrashText)); Assert.True(rows.HasUsageText); Assert.True(rows.HasTrash); Assert.True(rows.EmptyTrashCommand.CanExecute(null)); @@ -573,13 +573,13 @@ public sealed class SettingsLogicTests workspace.Measure = _ => Task.FromResult(new WorkspaceUsage(0, 4_000, 0, 0)); await rows.MeasureAsync(); - Assert.Equal(("4 KB used", "Nothing in trash"), (rows.UsageText, rows.TrashText)); + Assert.Equal(("4\u00A0KB used", "Nothing in trash"), (rows.UsageText, rows.TrashText)); Assert.False(rows.HasTrash); Assert.False(rows.EmptyTrashCommand.CanExecute(null)); Assert.Equal(Loc.L("Tooltips.Settings.Workspace.EmptyTrash.Disabled"), rows.EmptyTrashToolTip); workspace.Measure = _ => Task.FromResult(new WorkspaceUsage(0, 1_000, 2_000, 1)); await rows.MeasureAsync(); - Assert.Equal("1 item, 2 KB", rows.TrashText); + Assert.Equal("1 item, 2\u00A0KB", rows.TrashText); } [Test] @@ -600,7 +600,7 @@ public sealed class SettingsLogicTests Assert.True(firstToken.IsCancellationRequested, "the older measure is told to stop"); first.SetResult(new WorkspaceUsage(0, 9_000_000_000, 0, 5)); await older; - Assert.Equal(("2 MB used", false, false), (rows.UsageText, rows.HasTrash, rows.IsMeasuring)); + Assert.Equal(("2\u00A0MB used", false, false), (rows.UsageText, rows.HasTrash, rows.IsMeasuring)); workspace.Measure = _ => Task.FromException(new IOException("the drive went away")); await rows.MeasureAsync(); @@ -631,9 +631,9 @@ public sealed class SettingsLogicTests Assert.Equal((Loc.L("Settings.Workspace.TrashPlan.Action"), Loc.L("Tooltips.Settings.Workspace.TrashPlan.Action"), Loc.L("Tooltips.Settings.Workspace.TrashPlan.Keep")), (request.ActionText, request.ActionToolTip, request.SafeToolTip)); var lines = request.Detail!.Split(Environment.NewLine); - Assert.Equal(("Entries: 8", "Size: 36 MB"), (lines[0], lines[1])); + Assert.Equal(("Entries: 8", "Size: 36\u00A0MB"), (lines[0], lines[1])); // The newest entries are named, the rest counted. - Assert.Equal(Loc.L("Settings.Workspace.TrashPlan.Item", items[7].Name, "8 MB", Formatting.Date(items[7].Trashed)), lines[2]); + Assert.Equal(Loc.L("Settings.Workspace.TrashPlan.Item", items[7].Name, "8\u00A0MB", Formatting.Date(items[7].Trashed)), lines[2]); Assert.Equal(2 + DeletePlansListed + 1, lines.Length); Assert.Equal(Loc.Plural("Archive.Delete.More", 2), lines[^1]); @@ -642,7 +642,7 @@ public sealed class SettingsLogicTests workspace.Measure = _ => Task.FromResult(new WorkspaceUsage(0, 14_000_000, 0, 0)); await rows.EmptyTrashAsync(); Assert.Same(plan, Assert.Contains(workspace.Emptied, _ => true)); - Assert.Equal((Loc.L("Settings.Workspace.TrashEmptied"), "36 MB", false), Assert.Contains(workspace.Notices, _ => true)); + Assert.Equal((Loc.L("Settings.Workspace.TrashEmptied"), "36\u00A0MB", false), Assert.Contains(workspace.Notices, _ => true)); Assert.Equal("Nothing in trash", rows.TrashText); // An empty trash asks nothing. @@ -666,7 +666,7 @@ public sealed class SettingsLogicTests var (_, rows, _) = WorkspaceRows(workspace); await rows.EmptyTrashAsync(); Assert.Equal((Loc.L("Settings.Workspace.TrashNotEmptied"), Loc.L("Errors.Workspace.TrashChanged"), true), Assert.Contains(workspace.Notices, _ => true)); - Assert.Equal("1 item, 1 KB", rows.TrashText); + Assert.Equal("1 item, 1\u00A0KB", rows.TrashText); workspace.Notices.Clear(); workspace.Empty = _ => throw new UnauthorizedAccessException("denied"); diff --git a/tests/Chronos.App.Tests/Videos/VideosSectionTests.cs b/tests/Chronos.App.Tests/Videos/VideosSectionTests.cs index 96d3b89a..55adc2d3 100644 --- a/tests/Chronos.App.Tests/Videos/VideosSectionTests.cs +++ b/tests/Chronos.App.Tests/Videos/VideosSectionTests.cs @@ -8,11 +8,14 @@ using Chronos.App.Settings; using Chronos.App.Shell; using Chronos.App.Tests.Windows; using Chronos.App.Videos; +using Chronos.App.Workspace; using Chronos.Core.Localization; using Chronos.Core.Model; +using Chronos.Core.Project; using Chronos.Core.Windows.Shell; using Chronos.Data.Archiving.Jobs; using Chronos.Data.Videos; +using Chronos.Data.Workspaces; using Chronos.Protocol; using Chronos.Testing; using Chronos.Ui.Controls; @@ -200,6 +203,88 @@ public sealed class VideoSourcesTests } } + [Test] + public void TheBoardPutsEachRenderInTheLaneOfWhereItIs() + { + var local = Local(Guid.CreateVersion7(), Harbour, "Harbour sunset", 100); + var remote = Server(Guid.CreateVersion7(), Comet, "Comet", 300); + var unsent = Unsent(Guid.CreateVersion7(), Comet); + // Sent from the workspace to this PC's archive: the archive's entry under Published, its file still in exports/ under Workspace. + var sent = Unsent(local.Id, Harbour) with { IsUnsent = false, IsWorkspaceSent = true, Created = local.Created, Title = "Harbour sunset" }; + + Assert.Equal(VideoLane.Published, VideoBoard.LaneOf(local)); + Assert.Equal(VideoLane.Published, VideoBoard.LaneOf(remote)); + Assert.Equal(VideoLane.Workspace, VideoBoard.LaneOf(unsent)); + Assert.Equal(VideoLane.Workspace, VideoBoard.LaneOf(sent)); + + // The list has one row per render: the sent one is the archive's. + var merged = VideoSources.Merge([local], [remote], [unsent, sent]); + Assert.SequenceEqual([local.Id, remote.Id, unsent.Id], merged.Select(e => e.Id)); + Assert.False(merged.Any(e => e.IsWorkspaceSent)); + + // Newest first in each lane whatever the list's order; the list's filters narrow both lanes. + var (published, workspace) = VideoBoard.Split(merged, [sent], new VideoFilter { Sort = VideoSorts.Title }); + Assert.SequenceEqual([local.Id, remote.Id], published.Select(e => e.Id)); + Assert.SequenceEqual([unsent.Id, sent.Id], workspace.Select(e => e.Id)); + Assert.True(workspace[1].IsWorkspaceSent); + var harbour = VideoBoard.Split(merged, [sent], new VideoFilter { SequenceId = Harbour }); + Assert.SequenceEqual([local.Id], harbour.Published.Select(e => e.Id)); + Assert.SequenceEqual([sent.Id], harbour.Workspace.Select(e => e.Id)); + Assert.Empty(VideoBoard.Split(merged, [sent], new VideoFilter { Text = "instagram" }).Published); + // This PC holds a sent render's file; it is not the server's, nor waiting to be sent. + Assert.True(new VideoFilter { Source = VideoSourceFilter.Local }.Matches(sent)); + Assert.False(new VideoFilter { Source = VideoSourceFilter.NotSent }.Matches(sent)); + Assert.False(new VideoFilter { Source = VideoSourceFilter.Server }.Matches(sent)); + + // Its chip says it was sent, worded for its project's home. + Assert.Contains(VideoText.States(sent), s => s.Text == Loc.L("Videos.State.Sent") && s.ToolTip == Loc.L("Tooltips.Videos.Sent")); + Assert.Contains(VideoText.States(sent with { WorkspaceServerHome = true }), s => s.ToolTip == Loc.L("Tooltips.Videos.Sent.Server")); + Assert.Equal(Loc.L("Tooltips.Videos.SentRow"), new VideoRowViewModel(sent).ToolTip); + Assert.False(new VideoRowViewModel(sent).CanSend); + Assert.True(new VideoRowViewModel(unsent).CanSend); + } + + [Test] + public void AWorkspaceLedgerEntryReadsAsSentOrNot() + { + var home = new BundleHome(BundleHome.ArchiveKind, Harbour); + var project = new WorkspaceEntry(Guid.CreateVersion7(), Harbour, "Social cut", false, home, "Harbour sunset", true, DateTimeOffset.UtcNow); + var render = new WorkspaceRenderEntry(Guid.CreateVersion7(), Guid.CreateVersion7(), "harbour.mp4", new string('a', 64), 1_000, "Instagram", "h264", 1080, 1920, 30, 12, + project.ProjectId, null, null, DateTimeOffset.UtcNow); + + var pending = VideoSources.FromWorkspace(render, project, @"C:\ws\exports\harbour.mp4", exists: true); + Assert.True(pending is { IsUnsent: true, IsWorkspaceSent: false, Missing: false, ProjectName: "Social cut" }); + var sent = VideoSources.FromWorkspace(render.AsSent(DateTimeOffset.UtcNow), project, @"C:\ws\exports\harbour.mp4", exists: true); + Assert.True(sent is { IsUnsent: false, IsWorkspaceSent: true, HasLocalFile: true }); + Assert.Equal(VideoLane.Workspace, VideoBoard.LaneOf(sent)); + // A failed send waits to be sent again. + Assert.True(VideoSources.FromWorkspace(render.AsFailed("no"), project, @"C:\ws\exports\harbour.mp4", exists: false) is { IsUnsent: true, Missing: true }); + } + + [Test] + public void ACardStartsWithItsPresetAndKeepsSizesWhole() + { + var video = Local(Guid.CreateVersion7(), Harbour, "Harbour sunset", 100) with { PresetName = "4K archive", Codec = "hevc", DurationSeconds = 41, Bytes = 1_400_000_000 }; + // Issue #28: "4K archive · HEVC · 0:41 · 1.4 GB", the number and its unit held together by a no-break space. + var size = Formatting.Bytes(video.Bytes); + Assert.True(size.Contains('\u00A0', StringComparison.Ordinal) && !size.Contains(' ', StringComparison.Ordinal), size); + Assert.Equal(string.Join(Loc.Separator, "4K archive", "HEVC", VideoText.Duration(video), size), VideoText.Card(video)); + Assert.Equal(VideoText.Card(video), new VideoRowViewModel(video).CardText); + var still = video with { Kind = RenderKind.Still, PresetName = "Frame 512", Codec = null, DurationSeconds = 0, Bytes = 3_400_000 }; + Assert.Equal(string.Join(Loc.Separator, "Frame 512", Formatting.Bytes(still.Bytes)), VideoText.Card(still), "no codec, no duration"); + Assert.False(Formatting.Bytes(999).Contains(' ', StringComparison.Ordinal)); + + // A Board card names the project and its version when known. + Assert.Equal(string.Empty, VideoText.Project(video)); + Assert.Equal("Social cut", VideoText.Project(video with { ProjectName = "Social cut" })); + Assert.Equal("Social cut" + Loc.Separator + Loc.L("Videos.Version", "3"), VideoText.Project(video with { ProjectName = "Social cut", ProjectVersionNumber = 3 })); + var row = new VideoRowViewModel(video with { ProjectName = "Social cut", ProjectVersionNumber = 3 }); + Assert.True(row.HasProject); + Assert.Equal(Loc.L("Videos.Kind.One.Video") + Loc.Separator + row.DateText, row.BoardFactsText); + Assert.Equal(3, VideoSources.FromServer(new VideoDto(Guid.CreateVersion7(), Comet, "4K", "h264", 1, 1, 1, 1, 1, DateTimeOffset.UtcNow, "nas", null, null, null, + RenderKind.Video, "Comet", null, "Social cut", 3, VideoStates.Ok, [])).ProjectVersionNumber); + } + [Test] public void ACopyToTheVideosFolderEndsWithAToast() { @@ -505,6 +590,105 @@ public sealed class VideosSectionTests(TestContext context) Assert.True(shell.Settings.OpenVideosFolderCommand.CanExecute(null)); }); + [Test] + public Task TheBoardShowsPublishedAndWorkspaceLanes() => WithSectionAsync(async (shell, section, library, _) => + { + var folder = context.CreateTempDirectory("videos-board"); + var unsentFile = Path.Combine(folder, "comet-instagram.mp4"); + var sentFile = Path.Combine(folder, "harbour-4k.mp4"); + File.WriteAllBytes(unsentFile, [1]); + File.WriteAllBytes(sentFile, [1]); + var project = Guid.CreateVersion7(); + var unsent = new VideoEntry + { + Id = Guid.CreateVersion7(), + SequenceId = library.Items[1].Render.SequenceId, + Title = "Comet", + PresetName = "Instagram", + Codec = "h264", + Bytes = 10, + Created = DateTimeOffset.UtcNow, + Kind = RenderKind.Video, + FileName = "comet-instagram.mp4", + LocalPath = unsentFile, + IsUnsent = true, + WorkspaceProjectId = project, + ProjectName = "Social cut", + }; + // The archive's first render, sent from the workspace, its file still in exports/. + var archived = library.Items[0].Render; + var sent = unsent with + { + Id = archived.Id, + SequenceId = archived.SequenceId, + Title = "Harbour sunset", + PresetName = archived.PresetName, + Created = archived.Created, + FileName = "harbour-4k.mp4", + LocalPath = sentFile, + IsUnsent = false, + IsWorkspaceSent = true, + }; + section.WorkspaceRenders = _ => Task.FromResult>([unsent, sent]); + await section.RefreshAsync(); + + // The list and the cards: one row per render, the sent one being the archive's. + Assert.Equal(library.Items.Count + 1, section.Rows.Count); + Assert.Equal(sent.Id, Assert.NotNull(section.SentEntries.SingleOrDefault()).Id); + Assert.False(section.IsBoard); + + // The Board: kept for the next run, Published beside Workspace, newest first, a count per lane. + section.LayoutIndex = 2; + Assert.True(section.IsBoard); + Assert.Equal(LibraryLayout.Board, shell.Services.Settings.VideosLayout); + Assert.Equal(2, new VideosViewModel(shell).LayoutIndex, "a new section opens on the Board"); + Assert.SequenceEqual(library.Items.OrderByDescending(i => i.Render.Created).Select(i => i.Render.Id), section.PublishedRows.Select(r => r.Entry.Id)); + Assert.SequenceEqual([unsent.Id, sent.Id], section.WorkspaceRows.Select(r => r.Entry.Id)); + Assert.Equal((Formatting.Count(3), Formatting.Count(2)), (section.PublishedCountText, section.WorkspaceCountText)); + Assert.Same(section.Rows.Single(r => r.Entry.Id == unsent.Id), section.WorkspaceRows[0]); + var sentRow = section.WorkspaceRows[1]; + Assert.True(sentRow.Entry.IsWorkspaceSent); + Assert.False(ReferenceEquals(section.Rows.Single(r => r.Entry.Id == sent.Id), sentRow), "a row of its own beside the archive's"); + + // The sent row's actions: Play, Show in folder and Open in Edit (its home is this PC's archive); no copy, delete or send. + Assert.True(section.PlayCommand.CanExecute(sentRow)); + Assert.True(section.ShowInFolderCommand.CanExecute(sentRow)); + Assert.True(section.OpenInEditCommand.CanExecute(sentRow)); + Assert.False(section.SendCommand.CanExecute(sentRow)); + Assert.Equal(Loc.L("Tooltips.Videos.SentRow"), section.CopyBlocker([sentRow])); + Assert.Equal(Loc.L("Tooltips.Videos.SentRow"), section.DeleteBlocker([sentRow])); + Assert.True(section.SendCommand.CanExecute(section.WorkspaceRows[0]), "the unsent one sends"); + + // Selected on the Board, it is part of the selection; off the Board, it is let go. + sentRow.IsSelected = true; + Assert.True(section.HasSelection); + Assert.Contains(sentRow, section.SelectedRows); + Assert.Equal(Loc.L("Videos.Selected", Formatting.Count(1)), section.SelectionText); + section.LayoutIndex = 0; + Assert.False(sentRow.IsSelected); + Assert.False(section.HasSelection); + section.LayoutIndex = 2; + + // The list's filters narrow both lanes; none kept is the section's empty state. + section.SearchText = "instagram"; + Assert.SequenceEqual([unsent.Id], section.WorkspaceRows.Select(r => r.Entry.Id)); + Assert.Empty(section.PublishedRows); + Assert.True(section.IsPublishedEmpty, "the lane says it is empty"); + section.SearchText = "no such video"; + Assert.True(section.IsNoMatch); + Assert.False(section.IsPublishedEmpty || section.IsWorkspaceEmpty, "one empty state, not three"); + section.SearchText = string.Empty; + + // Laid out: both lanes' headings and cards, with the card's line starting with the preset (issue #28). + var view = new VideosView { DataContext = section }; + Layout(view, 1400); + var texts = Descendants(view).OfType().Where(t => t.ActualWidth > 0).Select(t => t.Text).ToList(); + Assert.Contains(Loc.L("Videos.Lane.Published"), texts); + Assert.Contains(Loc.L("Videos.Lane.Workspace"), texts); + Assert.Contains(sentRow.CardText, texts); + Assert.True(sentRow.CardText.StartsWith(sent.PresetName + Loc.Separator, StringComparison.Ordinal), sentRow.CardText); + }); + private static void Layout(System.Windows.FrameworkElement view, double width = 1200) { view.Measure(new System.Windows.Size(width, 800)); diff --git a/tests/Chronos.Server.Tests/Hosting/AdminVideosTests.cs b/tests/Chronos.Server.Tests/Hosting/AdminVideosTests.cs index dd4b4742..5fffbfc0 100644 --- a/tests/Chronos.Server.Tests/Hosting/AdminVideosTests.cs +++ b/tests/Chronos.Server.Tests/Hosting/AdminVideosTests.cs @@ -48,12 +48,16 @@ public sealed partial class AdminVideosTests(TestContext context) var page = await server.Client.GetStringAsync("/admin/pages/videos.js"); var calls = ApiCall().Matches(page).Select(m => (Method: m.Groups[1].Value, Target: m.Groups[2].Value)).ToList(); Assert.True(calls.Count >= 4, string.Join(", ", calls)); - // Reads the list, the server's videos folder and a filtered sequence's title; writes only the videos' delete and copy: - // no settings, no project, no render, no job of its own. + // Reads the list, the server's videos folder, its name (the board's lanes) and a filtered sequence's title; writes only + // the videos' delete and copy: no settings, no project, no render, no job of its own. foreach (var (method, target) in calls) { Assert.True(method is "get" or "post", $"api.{method}({target}"); - if (method == "get") Assert.True(target is "listQuery(" or @"""/api/v1/server/settings""" or "`/api/v1/sequences/${encodeURIComponent(id)}`", target); + if (method == "get") + { + Assert.True(target is "listQuery(" or @"""/api/v1/server/settings""" or @"""/api/v1/server/info""" or "`/api/v1/sequences/${encodeURIComponent(id)}`", + target); + } else Assert.True(target is @"""/api/v1/videos/copy""" or @"""/api/v1/videos/delete""", target); } Assert.Contains("return `/api/v1/videos?${p}`;", page); @@ -103,6 +107,29 @@ public sealed partial class AdminVideosTests(TestContext context) Assert.Equal("missing", VideoStates.Missing); } + [Test] + public async Task TheBoardShowsPublishedAndWorkspaceLanes() + { + await using var server = await TestServer.StartAsync(context); + var page = await server.Client.GetStringAsync("/admin/pages/videos.js"); + // A third view beside cards and list, kept like them; its icon is the panel's. + Assert.Contains(@"data-view=""board"" aria-pressed=""${view === ""board""}"" data-i18n-title=""Admin.Videos.View.Board.Tip""", page); + Assert.Contains(@"return stored === ""list"" || stored === ""board"" ? stored : ""cards"";", page); + Assert.Contains(" board: ` (Date.parse(b.created) - Date.parse(a.created))", page); + Assert.Contains(@"return lane(""Published"", newest, false) + lane(""Workspace"", sent, true);", page); + Assert.Contains(@"${escapeHtml(formatNumber(items.length))}", page); + Assert.Contains("export function boardLane(v, serverName)", page); + Assert.Contains(@"return v.projectId && producer && producer !== String(serverName ?? """") ? ""workspace"" : ""published"";", page); + Assert.Contains(@"${workspace ? sentChip(v) : """"}${stateChips(v)}", page); + // The server's name comes from its public info, the name its own renders carry. + Assert.Contains(@"api.get(""/api/v1/server/info"").then((info) => {", page); + var css = await server.Client.GetStringAsync("/admin/admin.css"); + Assert.Contains(".seq-items.board { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));", css); + } + [Test] public async Task TheVideosStringsAreInEnglishAndItalian() { @@ -117,7 +144,8 @@ public sealed partial class AdminVideosTests(TestContext context) // The keys the pages build from a value. keys.AddRange(VideoSorts.All.Select(s => $"Admin.Videos.Sort.{char.ToUpperInvariant(s[0])}{s[1..]}")); keys.AddRange(["Admin.Videos.Kind.Video", "Admin.Videos.Kind.Still", "Admin.Videos.Kind.Sequence", "Admin.Trash.Kind.Videos", "Admin.Nav.Videos", "Admin.Nav.Videos.Tip", - "Admin.Settings.VideosPath", "Admin.Settings.VideosPath.Tip", "Admin.Job.Kind.VideoCopy"]); + "Admin.Settings.VideosPath", "Admin.Settings.VideosPath.Tip", "Admin.Job.Kind.VideoCopy", "Admin.Videos.Lane.Published", "Admin.Videos.Lane.Published.Tip", + "Admin.Videos.Lane.Workspace", "Admin.Videos.Lane.Workspace.Tip"]); keys.AddRange(Regex.Matches(trash + sequence, @"""(Admin\.(?:Trash\.[A-Za-z]*Video[A-Za-z]*|Videos\.[A-Za-z.]+)(?:\.[A-Za-z]+)*)""").Select(m => m.Groups[1].Value)); Assert.Contains("Admin.Trash.RestoredVideo", keys); Assert.Contains("Admin.Videos.AllVideos.Tip", keys);