feat: application shell, localized texts and user preferences (M3, part 1)

The pages built so far now live inside the shell of the mockups instead of the
M0 placeholder, every interface text comes from Resources/it-IT, and each user
keeps their own look and start page.

- Shell: top bar, collapsible side menu with fly-out sub-menus, status bar and
  tabs that keep each page alive (page type and route values per tab, so a tab
  never shows another page); at most 12 tabs, least-used clean tab evicted.
- One shortcut table with Alt variants for the combinations browsers keep
  (Ctrl+W, Ctrl+Tab, Ctrl+N); command palette for pages and commands.
- ITexts over embedded JSON; tests forbid literal texts in .razor components
  and check that every key used exists.
- User settings in sys_user_settings / user_settings; theme written on the
  server; profile page with live preview, start page, sessions and shortcuts.
- Home, coming-soon pages for later milestones, localized sign-in and error
  pages; ADR 0020; wiki, CHANGELOG, STATUS and data model updated.

Refs #25 #26 #31 #33

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-11 16:44:59 +01:00
1 parent 1c30054e3d
commit cf6f849cc1
72 files changed
+5785 -259

No files matched your search

+93 -33
View File
@@ -1,42 +1,102 @@
@page "/"
@attribute [Authorize]
@using Khaemhat.Application.Licensing
@using Khaemhat.Core.Common
@inject ProductVersion Version
@inject ILicenseGate Licenses
@using Khaemhat.Application.Modules
@inject ShellSession Session
@inject TimeProvider Clock
@* Placeholder until the shell of M3 (SPEC §20): who is signed in, in which company, with which licence. Texts move to
the it-IT resources with the localization of M3. *@
<PageTitle>Khaemhat</PageTitle>
@* The home page of SPEC §10.2 until the widget dashboard of mockup 004 (issue #30): who is signed in, the licence,
the company and the areas the user can open, with the milestone of those still to come. *@
<KhPageTitle Text="@T["Pages.Home.Title"]" Icon="home" />
<main class="kh-construction">
<section class="hero">
<img class="mark" src="icon.svg" alt="" width="96" height="96" />
<h1>Khaemhat <span class="ver">v @Version.MajorMinor</span></h1>
<AuthorizeView>
<p class="lead">Benvenuto, <strong>@context.User.FindFirst(SessionCookie.DisplayNameClaim)?.Value</strong>
(@LevelLabel(context.User.FindFirst(SessionCookie.LevelClaim)?.Value))
@if (context.User.FindFirst(SessionCookie.CompanyClaim)?.Value is { } company)
{
<span> · azienda <strong>@company</strong></span>
}
</p>
</AuthorizeView>
<p class="state">Accesso, utenti, ruoli, licenze e log sono pronti; le schermate di lavoro arrivano con l'interfaccia della milestone 3.
Licenza: @(Licenses.Current.Kind == LicenseKind.Trial ? "prova" : Licenses.Current.Licensee) · moduli @string.Join(", ", Licenses.Current.Modules.Order())</p>
<form method="post" action="/logout" class="links">
<AntiforgeryToken />
<button type="submit" class="kh-btn ghost">Esci</button>
</form>
<p class="build">Versione @Version.Full</p>
</section>
</main>
<div class="phead">
<div>
<h1>@Greeting</h1>
<div class="sub">@T.Format("Pages.Home.Today", Today)</div>
</div>
</div>
<div class="cols cols-3 kh-home-tiles">
<div class="tile acc">
<div class="t"><KhIcon Name="key" Class="sm" /> @T["Pages.Home.LicenseTile"]</div>
<div class="v">@(License.Kind == LicenseKind.Trial ? T["Pages.Home.LicenseTrial"] : T["Pages.Home.LicenseFull"])</div>
<div class="d">@LicenseDetail</div>
</div>
<div class="tile">
<div class="t"><KhIcon Name="layers" Class="sm" /> @T["Pages.Home.ModulesTile"]</div>
<div class="v">@T.Format("Pages.Home.ModulesText", License.Modules.Count, ModuleRegistry.Default.Modules.Count)</div>
<div class="d">@(License.Modules.Count == 0 ? T["Pages.Home.ModulesNone"] : string.Join(" · ", License.Modules.Order(StringComparer.Ordinal)))</div>
</div>
<div class="tile">
<div class="t"><KhIcon Name="building" Class="sm" /> @T["Pages.Home.CompanyTile"]</div>
<div class="v">@(Session.Company?.Name ?? T["Pages.Home.CompanyNone"])</div>
<div class="d">@Session.Company?.Code</div>
</div>
</div>
<section class="panel" aria-labelledby="kh-home-areas">
<div class="ph"><KhIcon Name="grid" /> <span id="kh-home-areas">@T["Pages.Home.AreasTitle"]</span></div>
<div class="pb">
<p class="muted">@T["Pages.Home.AreasHint"]</p>
<div class="kh-areas">
@foreach (var area in Areas)
{
<a class="kh-area" href="@area.Href.TrimStart('/')">
<span class="ico-box"><KhIcon Name="@area.Icon" /></span>
<span class="grow">@T[area.Key]</span>
@if (area.Milestone is { } milestone)
{
<span class="badge gray">@T.Format("Pages.Home.Coming", milestone)</span>
}
</a>
}
</div>
</div>
</section>
<div class="callout info"><KhIcon Name="info" /> <span>@T["Pages.Home.DashboardSoon"]</span></div>
@code {
private static string LevelLabel(string? level) => level switch
private LicenseState License => Session.Licenses.Current;
private IEnumerable<MenuItem> Areas =>
MenuCatalog.Sections.SelectMany(s => s.Items).Where(i => i.Href != "/" && Session.CanSee(i));
private string Today => Clock.GetLocalNow().ToString("dddd d MMMM yyyy", T.Culture);
private string Greeting
{
"SuperUser" => "super utente",
"Administrator" => "amministratore",
_ => "utente",
};
get
{
var key = Clock.GetLocalNow().Hour switch
{
< 13 => "Pages.Home.Greeting",
< 18 => "Pages.Home.GreetingAfternoon",
_ => "Pages.Home.GreetingEvening",
};
return T.Format(key, FirstName);
}
}
private string FirstName => Session.DisplayName.Split(' ', StringSplitOptions.RemoveEmptyEntries).FirstOrDefault() ?? Session.DisplayName;
private string LicenseDetail
{
get
{
var parts = new List<string>();
if (License.Licensee is { Length: > 0 } licensee)
{
parts.Add(T.Format("Pages.Home.LicenseLicensee", licensee));
}
parts.Add(License.DaysLeft(Clock.GetUtcNow().UtcDateTime) is { } days
? T.Format("Pages.Home.LicenseDaysLeft", days)
: T["Pages.Home.LicenseUnlimited"]);
return string.Join(" · ", parts);
}
}
/// <inheritdoc />
protected override Task OnInitializedAsync() => Session.EnsureLoadedAsync();
}