Foto del profilo: uno schema dei nomi proprio (#38)
Alberto ha deciso che le foto del profilo stanno dentro ogni account, in
<account>\profilo. Con un solo schema generale bastava cambiarlo perché
finissero insieme ai post: ora hanno il loro schema, come le raccolte in
evidenza, predefinito {account}\profilo\{data}_{ora}_{codice}_{n}, senza la
cartella dell'anno.
Impostazioni > Generali mostra il terzo campo con la cartella nel risultato
e colora solo il campo sbagliato. Un salvataggio che non manda il terzo
schema tiene quello salvato. Importazione e ricostruzione del database
riconoscono la cartella; prove nuove per nomi, impostazioni, salvataggio,
importazione e ricostruzione. Schermata confrontata con il mockup 08.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
305791f57b
commit
72deb212a7
19 files changed
+340
-69
No files matched your search
@@ -57,7 +57,7 @@ public sealed record NamingPreviewFileDto(string Name, string Kind);
|
||||
|
||||
public sealed record NamingPreviewFolderDto(IReadOnlyList<string> Path, IReadOnlyList<NamingPreviewFileDto> Files);
|
||||
|
||||
/// <summary>The «Risultato» tree of mockup 08 and the problems of the two schemes.</summary>
|
||||
/// <summary>The «Risultato» tree of mockup 08 and the problems of the three schemes.</summary>
|
||||
public sealed record NamingPreviewDto(string AccountFolder, IReadOnlyList<NamingPreviewFolderDto> Folders, IReadOnlyList<string> Errors, IReadOnlyList<string> Warnings);
|
||||
|
||||
/// <summary>Impostazioni, Generali (mockup 08).</summary>
|
||||
@@ -71,8 +71,10 @@ public sealed record GeneralSettingsDto(
|
||||
bool CanChangeDataFolder,
|
||||
string NamingScheme,
|
||||
string HighlightScheme,
|
||||
string ProfilePictureScheme,
|
||||
string DefaultNamingScheme,
|
||||
string DefaultHighlightScheme,
|
||||
string DefaultProfilePictureScheme,
|
||||
IReadOnlyList<string> Placeholders,
|
||||
bool SetFileTime,
|
||||
NamingPreviewDto Preview,
|
||||
@@ -80,10 +82,14 @@ public sealed record GeneralSettingsDto(
|
||||
bool KeepInTray,
|
||||
string Language);
|
||||
|
||||
/// <summary>Saves Impostazioni, Generali. A null <see cref="LibraryFolder"/> keeps the library folder.</summary>
|
||||
public sealed record GeneralSettingsRequest(string? LibraryFolder, string NamingScheme, string HighlightScheme, bool SetFileTime, bool? Autostart, bool? KeepInTray);
|
||||
/// <summary>
|
||||
/// Saves Impostazioni, Generali. A null <see cref="LibraryFolder"/> keeps the library folder; a null
|
||||
/// <see cref="ProfilePictureScheme"/> keeps the scheme of profile pictures.
|
||||
/// </summary>
|
||||
public sealed record GeneralSettingsRequest(string? LibraryFolder, string NamingScheme, string HighlightScheme, bool SetFileTime, bool? Autostart, bool? KeepInTray, string? ProfilePictureScheme = null);
|
||||
|
||||
public sealed record NamingRequest(string? NamingScheme, string? HighlightScheme);
|
||||
/// <summary>The schemes to preview; a null <see cref="ProfilePictureScheme"/> stands for the default one.</summary>
|
||||
public sealed record NamingRequest(string? NamingScheme, string? HighlightScheme, string? ProfilePictureScheme = null);
|
||||
|
||||
/// <summary><see cref="Which"/>: library or data.</summary>
|
||||
public sealed record PickFolderRequest(string Which);
|
||||
|
||||
@@ -38,8 +38,14 @@ public static class SettingsApi
|
||||
{
|
||||
var d = Deps.From(services);
|
||||
var body = await ApiHttp.BodyAsync(context, FebeJsonContext.Default.GeneralSettingsRequest).ConfigureAwait(false);
|
||||
var general = Validate(NamingScheme.Validate(body.NamingScheme, forHighlights: false), "Schema");
|
||||
var highlight = Validate(NamingScheme.Validate(body.HighlightScheme, forHighlights: true), "Schema per le raccolte in evidenza");
|
||||
var general = Validate(NamingScheme.Validate(body.NamingScheme, NamingSchemeUse.General), NamingSchemeUse.General);
|
||||
var highlight = Validate(NamingScheme.Validate(body.HighlightScheme, NamingSchemeUse.Highlight), NamingSchemeUse.Highlight);
|
||||
|
||||
// A request without the scheme of profile pictures keeps the stored one.
|
||||
var profile = body.ProfilePictureScheme is { } profileText
|
||||
? Validate(NamingScheme.Validate(profileText, NamingSchemeUse.ProfilePicture), NamingSchemeUse.ProfilePicture)
|
||||
: (await LibrarySettings.LoadAsync(d.Storage.Settings, d.Library.Layout.Root, ct).ConfigureAwait(false)).Naming.ProfilePicture;
|
||||
var naming = new LibraryNaming(general, highlight, profile);
|
||||
var caps = SystemApi.Capabilities(context, d.Options, d.Shell, d.Browser, d.Clock);
|
||||
var root = d.Library.Layout.Root;
|
||||
if (!string.IsNullOrWhiteSpace(body.LibraryFolder) && !SamePath(body.LibraryFolder, root))
|
||||
@@ -52,7 +58,7 @@ public static class SettingsApi
|
||||
root = await ChangeLibraryRootAsync(d, body.LibraryFolder, ct).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await new LibrarySettings(root, new LibraryNaming(general, highlight), body.SetFileTime).SaveAsync(d.Storage.Settings, ct).ConfigureAwait(false);
|
||||
await new LibrarySettings(root, naming, body.SetFileTime).SaveAsync(d.Storage.Settings, ct).ConfigureAwait(false);
|
||||
if (caps.Autostart && body.Autostart is { } autostart)
|
||||
{
|
||||
await d.Shell.SetAutostartAsync(autostart, ct).ConfigureAwait(false);
|
||||
@@ -67,7 +73,7 @@ public static class SettingsApi
|
||||
if (d.Services.GetService(typeof(Febe.Core.Library.LibraryIngest)) is Febe.Core.Library.LibraryIngest ingest)
|
||||
{
|
||||
// The scheme and a new library folder (desktop) hold for the next downloads, without a restart.
|
||||
ingest.Apply(new LibraryNaming(general, highlight), body.SetFileTime);
|
||||
ingest.Apply(naming, body.SetFileTime);
|
||||
ingest.UseLayout(d.Library.Layout);
|
||||
}
|
||||
d.Changes.Publish(new LibraryChange(d.Clock.Now, null, "settings"));
|
||||
@@ -78,7 +84,8 @@ public static class SettingsApi
|
||||
{
|
||||
var body = await ApiHttp.BodyAsync(context, FebeJsonContext.Default.NamingRequest).ConfigureAwait(false);
|
||||
var sample = await SampleAccountAsync(storage, ct).ConfigureAwait(false);
|
||||
return ApiHttp.Json(Preview(NamingPreview.Build(body.NamingScheme, body.HighlightScheme, clock.LocalZone, sample)), FebeJsonContext.Default.NamingPreviewDto);
|
||||
var profile = body.ProfilePictureScheme ?? NamingScheme.DefaultProfilePicture;
|
||||
return ApiHttp.Json(Preview(NamingPreview.Build(body.NamingScheme, body.HighlightScheme, profile, clock.LocalZone, sample)), FebeJsonContext.Default.NamingPreviewDto);
|
||||
});
|
||||
|
||||
endpoints.MapPost("/api/settings/pick-folder", async (HttpContext context, IServiceProvider services, CancellationToken ct) =>
|
||||
@@ -268,11 +275,13 @@ public static class SettingsApi
|
||||
!caps.FoldersReadOnly && (dataChange?.CanChange ?? false),
|
||||
settings.Naming.General.Text,
|
||||
settings.Naming.Highlight.Text,
|
||||
settings.Naming.ProfilePicture.Text,
|
||||
NamingScheme.DefaultGeneral,
|
||||
NamingScheme.DefaultHighlight,
|
||||
NamingScheme.DefaultProfilePicture,
|
||||
NamingScheme.Placeholders,
|
||||
settings.SetFileTimeToPublication,
|
||||
Preview(NamingPreview.Build(settings.Naming.General.Text, settings.Naming.Highlight.Text, d.Clock.LocalZone, sample)),
|
||||
Preview(NamingPreview.Build(settings.Naming.General.Text, settings.Naming.Highlight.Text, settings.Naming.ProfilePicture.Text, d.Clock.LocalZone, sample)),
|
||||
autostart,
|
||||
tray,
|
||||
"it");
|
||||
@@ -297,14 +306,14 @@ public static class SettingsApi
|
||||
?? "nome.utente";
|
||||
}
|
||||
|
||||
private static NamingScheme Validate(NamingSchemeValidation validation, string name)
|
||||
private static NamingScheme Validate(NamingSchemeValidation validation, NamingSchemeUse use)
|
||||
{
|
||||
if (validation.IsValid)
|
||||
{
|
||||
return validation.Scheme!;
|
||||
}
|
||||
|
||||
throw new BadRequestException(string.Join(" ", validation.Errors.Select(e => $"{name}: {e}")));
|
||||
throw new BadRequestException(string.Join(" ", validation.Errors.Select(e => NamingPreview.Prefix(use) + e)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in new issue
Block a user