feat(app): complete the Library: timeline, saved views, quick and mass actions, remote cards
The Library gets a third layout (year bands of photos per month over the card grid; a month narrows to its year and scrolls to it), saved views stored as app-scope settings rows, hover quick actions on cards and rows (open, analyse, render the sequence's preset, sync), the full mass actions bar (analyse, proxies, verify, tags, rating, move, upload, download, delete into the trash, CSV) with each button's reason when it cannot run, and, while signed in, the server's sequences without a local copy as remote cards filterable by origin. Delete shows the engine's dry run behind a typed confirmation and offers Undo; the Archive manager gets Delete… and a Trash dialog that restores sequences. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
27 files changed
+2582
-422
No files matched your search
@@ -0,0 +1,91 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Titano.Core.Diagnostics;
|
||||
using Titano.Core.Localization;
|
||||
using Titano.Data.Repositories;
|
||||
|
||||
namespace Titano.App.Library;
|
||||
|
||||
/// <summary>A named set of Library filters and sort ("Night, 4K, not analysed"), BRIEF §12.2.</summary>
|
||||
public sealed record SavedView
|
||||
{
|
||||
public const int MaxName = 40;
|
||||
|
||||
public required Guid Id { get; init; }
|
||||
public required string Name { get; init; }
|
||||
public string? Text { get; init; }
|
||||
public int? Year { get; init; }
|
||||
public string? Camera { get; init; }
|
||||
public StatusFilter Status { get; init; }
|
||||
public string? Tag { get; init; }
|
||||
public OriginFilter Origin { get; init; }
|
||||
public SequenceSort Sort { get; init; } = SequenceSort.Newest;
|
||||
|
||||
public static SavedView Of(Guid id, string name, LibraryFilter filter) => new()
|
||||
{
|
||||
Id = id,
|
||||
Name = name.Trim(),
|
||||
Text = string.IsNullOrWhiteSpace(filter.Text) ? null : filter.Text.Trim(),
|
||||
Year = filter.Year,
|
||||
Camera = filter.Camera,
|
||||
Status = filter.Status,
|
||||
Tag = filter.Tag,
|
||||
Origin = filter.Origin,
|
||||
Sort = filter.Sort,
|
||||
};
|
||||
|
||||
public LibraryFilter ToFilter() => new() { Text = Text, Year = Year, Camera = Camera, Status = Status, Tag = Tag, Origin = Origin, Sort = Sort };
|
||||
|
||||
/// <summary>The Library shows exactly this view (search text compared trimmed and case-insensitively).</summary>
|
||||
public bool Matches(LibraryFilter filter) =>
|
||||
string.Equals(Text ?? string.Empty, filter.Text?.Trim() ?? string.Empty, StringComparison.OrdinalIgnoreCase)
|
||||
&& Year == filter.Year && Camera == filter.Camera && Status == filter.Status && Tag == filter.Tag && Origin == filter.Origin && Sort == filter.Sort;
|
||||
|
||||
/// <summary>The problem of a view name, localized; null when it can be used.</summary>
|
||||
/// <param name="others">Names of the other saved views (a name is used once).</param>
|
||||
public static string? Validate(string? name, IEnumerable<string> others)
|
||||
{
|
||||
var trimmed = name?.Trim() ?? string.Empty;
|
||||
if (trimmed.Length == 0) return Loc.L("Library.Views.Error.Empty");
|
||||
if (trimmed.Length > MaxName || trimmed.Any(char.IsControl)) return Loc.L("Library.Views.Error.Long", MaxName);
|
||||
return others.Contains(trimmed, StringComparer.CurrentCultureIgnoreCase) ? Loc.L("Library.Views.Error.Taken") : null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Saved views as app-scope settings rows (<c>library.view.<id></c>), one row per view.</summary>
|
||||
public sealed class SavedViewStore(SettingsRepository settings)
|
||||
{
|
||||
private const string Prefix = "library.view.";
|
||||
|
||||
/// <summary>Every saved view by name; unreadable rows are skipped.</summary>
|
||||
public async Task<IReadOnlyList<SavedView>> ListAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
var views = new List<SavedView>();
|
||||
foreach (var (key, json) in await settings.ListAsync(SettingScope.App, null, cancellationToken))
|
||||
{
|
||||
if (!key.StartsWith(Prefix, StringComparison.Ordinal)) continue;
|
||||
try
|
||||
{
|
||||
if (JsonSerializer.Deserialize(json, SavedViewJson.Default.SavedView) is { } view) views.Add(view);
|
||||
}
|
||||
catch (JsonException ex)
|
||||
{
|
||||
Log.Warning("library", $"Saved view {key} is unreadable", ex);
|
||||
}
|
||||
}
|
||||
return [.. views.OrderBy(v => v.Name, StringComparer.CurrentCultureIgnoreCase)];
|
||||
}
|
||||
|
||||
/// <summary>Adds the view or replaces the one with its id.</summary>
|
||||
public Task SaveAsync(SavedView view, CancellationToken cancellationToken = default) =>
|
||||
settings.SetAsync(SettingScope.App, null, Key(view.Id), view, SavedViewJson.Default.SavedView, cancellationToken);
|
||||
|
||||
public Task<bool> DeleteAsync(Guid id, CancellationToken cancellationToken = default) => settings.DeleteAsync(SettingScope.App, null, Key(id), cancellationToken);
|
||||
|
||||
private static string Key(Guid id) => Prefix + id.ToString("N");
|
||||
}
|
||||
|
||||
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
||||
UseStringEnumConverter = true)]
|
||||
[JsonSerializable(typeof(SavedView))]
|
||||
internal sealed partial class SavedViewJson : JsonSerializerContext;
|
||||
Reference in new issue
Block a user