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:
1 parent
1c30054e3d
commit
cf6f849cc1
72 files changed
+5785
-259
No files matched your search
@@ -1,12 +1,11 @@
|
||||
@page "/accesso-negato"
|
||||
@attribute [ExcludeFromInteractiveRouting]
|
||||
@layout AuthLayout
|
||||
<KhPageTitle Text="@T["Pages.AccessDenied.PageTitle"]" />
|
||||
|
||||
<PageTitle>Khaemhat · accesso negato</PageTitle>
|
||||
|
||||
<main class="kh-construction">
|
||||
<section class="hero">
|
||||
<h1>Accesso negato</h1>
|
||||
<p class="lead">Il tuo profilo non ha il permesso per questa pagina, oppure il modulo non è compreso nella licenza.</p>
|
||||
<ul class="links"><li><a href="/">Torna alla pagina iniziale</a></li></ul>
|
||||
</section>
|
||||
</main>
|
||||
<div class="kh-message">
|
||||
<KhIcon Name="lock" Class="lg" />
|
||||
<h1>@T["Pages.AccessDenied.Title"]</h1>
|
||||
<p class="lead">@T["Pages.AccessDenied.Lead"]</p>
|
||||
<a class="btn" href="./">@T["Common.BackHome"]</a>
|
||||
</div>
|
||||
@@ -0,0 +1,76 @@
|
||||
@page "/anagrafiche/{*Rest}"
|
||||
@page "/crm/{*Rest}"
|
||||
@page "/vendite/{*Rest}"
|
||||
@page "/acquisti/{*Rest}"
|
||||
@page "/magazzino/{*Rest}"
|
||||
@page "/contabilita/{*Rest}"
|
||||
@page "/scadenzario/{*Rest}"
|
||||
@page "/fatturazione-elettronica/{*Rest}"
|
||||
@page "/cespiti/{*Rest}"
|
||||
@page "/servizi/{*Rest}"
|
||||
@page "/canali/{*Rest}"
|
||||
@page "/report/{*Rest}"
|
||||
@page "/tabelle/{*Rest}"
|
||||
@page "/automazioni/{*Rest}"
|
||||
@page "/amministrazione/{*Rest}"
|
||||
@attribute [Authorize]
|
||||
@inject ShellSession Session
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
@* The menu shows every area the licence and the permissions allow (SPEC §10.2); the areas of later milestones land
|
||||
here, which says when they arrive and what they will hold. Each real page replaces its route as it is built. *@
|
||||
<KhPageTitle Text="@Title" Icon="@(Area?.Icon)" />
|
||||
|
||||
@if (Area is null || !Session.CanSee(Area))
|
||||
{
|
||||
<div class="kh-message">
|
||||
<KhIcon Name="lock" Class="lg" />
|
||||
<h1>@T["Pages.AccessDenied.Title"]</h1>
|
||||
<p class="lead">@T["Pages.AccessDenied.Lead"]</p>
|
||||
<a class="btn" href="./">@T["Common.BackHome"]</a>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="kh-message">
|
||||
<KhIcon Name="@Area.Icon" Class="lg" />
|
||||
<h1>@Title</h1>
|
||||
<p class="lead">@(Area.Milestone is { } milestone ? T.Format("Pages.ComingSoon.Lead", milestone) : T["Pages.ComingSoon.LeadUnknown"])</p>
|
||||
@if (Area.Children.Count > 0)
|
||||
{
|
||||
<p class="muted">@T["Pages.ComingSoon.Areas"]</p>
|
||||
<ul class="kh-chips">
|
||||
@foreach (var child in Area.Children)
|
||||
{
|
||||
<li class="chip">@T[child.Key]</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
<div class="kh-actions">
|
||||
<a class="btn" href="./">@T["Common.BackHome"]</a>
|
||||
<a class="btn ghost" href="@(HelpLinks.DefaultBaseUrl + "Roadmap")" target="_blank" rel="noopener">@T["Pages.ComingSoon.Roadmap"]</a>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
/// <summary>The rest of the address, after the area.</summary>
|
||||
[Parameter]
|
||||
public string? Rest { get; set; }
|
||||
|
||||
private MenuItem? Area { get; set; }
|
||||
|
||||
private MenuItem? Entry { get; set; }
|
||||
|
||||
private string Title => Entry is null ? T["Pages.ComingSoon.Title"] : T[Entry.Key];
|
||||
|
||||
// A tab keeps its page alive and has one address, so the address is read once.
|
||||
/// <inheritdoc />
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await Session.EnsureLoadedAsync();
|
||||
var path = "/" + Navigation.ToBaseRelativePath(Navigation.Uri).Split('?', '#')[0];
|
||||
Area = MenuCatalog.FindArea(path);
|
||||
Entry = MenuCatalog.Find(path);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,21 @@
|
||||
@page "/Error"
|
||||
@attribute [ExcludeFromInteractiveRouting]
|
||||
@layout AuthLayout
|
||||
@using System.Diagnostics
|
||||
|
||||
@* The error code shown to people is the trace id, the same one written in the log (SPEC §9.5). *@
|
||||
<PageTitle>Khaemhat · errore</PageTitle>
|
||||
<PageTitle>@T["Pages.Error.PageTitle"] · @T["Common.ProductName"]</PageTitle>
|
||||
|
||||
<main class="kh-construction">
|
||||
<section class="hero">
|
||||
<h1>Si è verificato un errore</h1>
|
||||
<p class="lead">La richiesta non è stata completata. Se il problema si ripete, comunica all'amministratore il codice qui sotto.</p>
|
||||
@if (!string.IsNullOrEmpty(TraceId))
|
||||
{
|
||||
<p class="build">Codice errore: <code>@TraceId</code></p>
|
||||
}
|
||||
<ul class="links"><li><a href="/">Torna alla pagina iniziale</a></li></ul>
|
||||
</section>
|
||||
</main>
|
||||
<div class="kh-message">
|
||||
<KhIcon Name="alert" Class="lg" />
|
||||
<h1>@T["Pages.Error.Title"]</h1>
|
||||
<p class="lead">@T["Pages.Error.Lead"]</p>
|
||||
@if (!string.IsNullOrEmpty(TraceId))
|
||||
{
|
||||
<p class="muted">@T["Pages.Error.Code"] <code>@TraceId</code></p>
|
||||
}
|
||||
<a class="btn" href="./">@T["Common.BackHome"]</a>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[CascadingParameter]
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
@@ -12,10 +12,10 @@
|
||||
@inject NavigationManager Navigation
|
||||
@inject TimeProvider Clock
|
||||
|
||||
<PageTitle>Accedi · Khaemhat</PageTitle>
|
||||
<PageTitle>@T["Auth.Login.Title"] · @T["Common.ProductName"]</PageTitle>
|
||||
|
||||
<h1>Accedi</h1>
|
||||
<p class="sub">Scegli l'azienda e inserisci le credenziali.</p>
|
||||
<h1>@T["Auth.Login.Title"]</h1>
|
||||
<p class="sub">@T["Auth.Login.Subtitle"]</p>
|
||||
|
||||
@foreach (var message in Errors)
|
||||
{
|
||||
@@ -23,24 +23,24 @@
|
||||
}
|
||||
|
||||
<EditForm Model="Input" method="post" FormName="login" OnSubmit="SubmitAsync" class="kh-form">
|
||||
<label for="company">Azienda</label>
|
||||
<label for="company">@T["Auth.Login.Company"]</label>
|
||||
<InputSelect id="company" @bind-Value="Input.CompanyCode">
|
||||
<option value="">Nessuna (account di istanza)</option>
|
||||
<option value="">@T["Auth.Login.NoCompany"]</option>
|
||||
@foreach (var company in AvailableCompanies)
|
||||
{
|
||||
<option value="@company.Code">@company.Name (@company.Code)</option>
|
||||
<option value="@company.Code">@T.Format("Auth.Login.CompanyOption", company.Name, company.Code)</option>
|
||||
}
|
||||
</InputSelect>
|
||||
|
||||
<label for="user">Nome utente</label>
|
||||
<label for="user">@T["Auth.Login.UserName"]</label>
|
||||
<InputText id="user" @bind-Value="Input.UserName" autocomplete="username" autofocus required />
|
||||
|
||||
<label for="password">Password</label>
|
||||
<label for="password">@T["Auth.Login.Password"]</label>
|
||||
<InputText id="password" type="password" @bind-Value="Input.Password" autocomplete="current-password" required />
|
||||
|
||||
<label class="check"><InputCheckbox @bind-Value="Input.Remember" /> Ricordami su questo dispositivo</label>
|
||||
<label class="check"><InputCheckbox @bind-Value="Input.Remember" /> @T["Auth.Login.Remember"]</label>
|
||||
|
||||
<button type="submit" class="kh-btn primary">Accedi</button>
|
||||
<button type="submit" class="kh-btn primary">@T["Auth.Login.Submit"]</button>
|
||||
</EditForm>
|
||||
|
||||
@if (TrialNotice is not null)
|
||||
@@ -77,11 +77,11 @@
|
||||
var license = Licenses.Current;
|
||||
if (license.Kind == LicenseKind.Trial)
|
||||
{
|
||||
TrialNotice = $"Licenza in modalità prova: restano {license.DaysLeft(Clock.GetUtcNow().UtcDateTime)} giorni, con i moduli Base e Contabilità e {license.MaxConcurrentUsers} utenti collegati.";
|
||||
TrialNotice = T.Format("Auth.Login.Trial", license.DaysLeft(Clock.GetUtcNow().UtcDateTime), license.MaxConcurrentUsers);
|
||||
}
|
||||
else if (license.Status != LicenseStatus.Valid)
|
||||
{
|
||||
TrialNotice = "La licenza è scaduta: rivolgiti all'amministratore.";
|
||||
TrialNotice = T["Auth.Login.Expired"];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@
|
||||
Input.Password = null;
|
||||
if (!result.Succeeded || result.Cookie is null)
|
||||
{
|
||||
Errors = LoginFlow.Messages(result.Error);
|
||||
Errors = LoginFlow.Messages(T, Policy, result.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
@inject NavigationManager Navigation
|
||||
@inject TimeProvider Clock
|
||||
|
||||
<PageTitle>Cambio password · Khaemhat</PageTitle>
|
||||
<PageTitle>@T["Auth.PasswordChange.PageTitle"] · @T["Common.ProductName"]</PageTitle>
|
||||
|
||||
<h1>Scegli una nuova password</h1>
|
||||
<p class="sub">Al primo accesso, o dopo una password provvisoria, serve una password personale.</p>
|
||||
<h1>@T["Auth.PasswordChange.Title"]</h1>
|
||||
<p class="sub">@T["Auth.PasswordChange.Subtitle"]</p>
|
||||
|
||||
@foreach (var message in Errors)
|
||||
{
|
||||
@@ -18,22 +18,22 @@
|
||||
}
|
||||
|
||||
<EditForm Model="Input" method="post" FormName="password-change" OnSubmit="SubmitAsync" class="kh-form">
|
||||
<label for="current">Password attuale o provvisoria</label>
|
||||
<label for="current">@T["Auth.PasswordChange.Current"]</label>
|
||||
<InputText id="current" type="password" @bind-Value="Input.Current" autocomplete="current-password" autofocus required />
|
||||
|
||||
<label for="new">Nuova password</label>
|
||||
<label for="new">@T["Auth.PasswordChange.New"]</label>
|
||||
<InputText id="new" type="password" @bind-Value="Input.New" autocomplete="new-password" required />
|
||||
|
||||
<label for="confirm">Ripeti la nuova password</label>
|
||||
<label for="confirm">@T["Auth.PasswordChange.Confirm"]</label>
|
||||
<InputText id="confirm" type="password" @bind-Value="Input.Confirm" autocomplete="new-password" required />
|
||||
|
||||
<ul class="kh-rules">
|
||||
<li>Almeno @Policy.MinimumLength caratteri</li>
|
||||
<li>Almeno tre tipi tra minuscole, maiuscole, cifre e simboli</li>
|
||||
<li>Diversa dal nome utente e dalle ultime @Policy.HistorySize password</li>
|
||||
<li>@T.Format("Auth.PasswordChange.RuleLength", Policy.MinimumLength)</li>
|
||||
<li>@T["Auth.PasswordChange.RuleKinds"]</li>
|
||||
<li>@T.Format("Auth.PasswordChange.RuleHistory", Policy.HistorySize)</li>
|
||||
</ul>
|
||||
|
||||
<button type="submit" class="kh-btn primary">Salva e continua</button>
|
||||
<button type="submit" class="kh-btn primary">@T["Auth.PasswordChange.Submit"]</button>
|
||||
</EditForm>
|
||||
|
||||
@code {
|
||||
@@ -70,7 +70,7 @@
|
||||
|
||||
if (!string.Equals(Input.New, Input.Confirm, StringComparison.Ordinal))
|
||||
{
|
||||
Errors = ["Le due nuove password non coincidono."];
|
||||
Errors = [T["Auth.PasswordChange.Mismatch"]];
|
||||
Clear();
|
||||
return;
|
||||
}
|
||||
@@ -79,7 +79,7 @@
|
||||
Clear();
|
||||
if (!result.Succeeded || result.Cookie is null)
|
||||
{
|
||||
Errors = LoginFlow.Messages(result.Error);
|
||||
Errors = LoginFlow.Messages(T, Policy, result.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
@inject NavigationManager Navigation
|
||||
@inject TimeProvider Clock
|
||||
|
||||
<PageTitle>Verifica in due passaggi · Khaemhat</PageTitle>
|
||||
<PageTitle>@T["Auth.Totp.Title"] · @T["Common.ProductName"]</PageTitle>
|
||||
|
||||
<h1>Verifica in due passaggi</h1>
|
||||
<p class="sub">Inserisci il codice a 6 cifre dell'app di autenticazione.</p>
|
||||
<h1>@T["Auth.Totp.Title"]</h1>
|
||||
<p class="sub">@T["Auth.Totp.Subtitle"]</p>
|
||||
|
||||
@foreach (var message in Errors)
|
||||
{
|
||||
@@ -18,15 +18,15 @@
|
||||
}
|
||||
|
||||
<EditForm Model="Input" method="post" FormName="totp" OnSubmit="SubmitAsync" class="kh-form">
|
||||
<label for="code">Codice</label>
|
||||
<label for="code">@T["Auth.Totp.Code"]</label>
|
||||
<InputText id="code" class="otp" @bind-Value="Input.Code" inputmode="numeric" autocomplete="one-time-code" maxlength="20" autofocus required />
|
||||
<div class="row">
|
||||
<button type="submit" class="kh-btn primary">Verifica</button>
|
||||
<span class="hint">Oppure un codice di recupero (XXXX-XXXX)</span>
|
||||
<button type="submit" class="kh-btn primary">@T["Auth.Totp.Submit"]</button>
|
||||
<span class="hint">@T["Auth.Totp.RecoveryHint"]</span>
|
||||
</div>
|
||||
</EditForm>
|
||||
|
||||
<div class="kh-alert info">Il codice cambia ogni 30 secondi. L'autenticazione a due fattori è obbligatoria per amministratori e super utente.</div>
|
||||
<div class="kh-alert info">@T["Auth.Totp.Info"]</div>
|
||||
|
||||
@code {
|
||||
[CascadingParameter]
|
||||
@@ -64,7 +64,7 @@
|
||||
Input.Code = null;
|
||||
if (!result.Succeeded || result.Cookie is null)
|
||||
{
|
||||
Errors = LoginFlow.Messages(result.Error);
|
||||
Errors = LoginFlow.Messages(T, Policy, result.Error);
|
||||
if (result.Error == SecurityErrors.AccountLocked)
|
||||
{
|
||||
SessionCookie.Clear(HttpContext);
|
||||
|
||||
@@ -7,24 +7,24 @@
|
||||
@inject NavigationManager Navigation
|
||||
@inject TimeProvider Clock
|
||||
|
||||
<PageTitle>Configura la verifica in due passaggi · Khaemhat</PageTitle>
|
||||
<PageTitle>@T["Auth.TotpSetup.PageTitle"] · @T["Common.ProductName"]</PageTitle>
|
||||
|
||||
@if (RecoveryCodes is not null)
|
||||
{
|
||||
<h1>Codici di recupero</h1>
|
||||
<p class="sub">Conservali in un luogo sicuro: ognuno vale una volta sola, al posto del codice dell'app, se perdi il telefono. Non verranno mostrati di nuovo.</p>
|
||||
<h1>@T["Auth.TotpSetup.RecoveryTitle"]</h1>
|
||||
<p class="sub">@T["Auth.TotpSetup.RecoveryText"]</p>
|
||||
<ul class="kh-codes">
|
||||
@foreach (var recovery in RecoveryCodes)
|
||||
{
|
||||
<li><code>@recovery</code></li>
|
||||
}
|
||||
</ul>
|
||||
<a class="kh-btn primary" href="@NextUrl">Ho salvato i codici, continua</a>
|
||||
<a class="kh-btn primary" href="@NextUrl">@T["Auth.TotpSetup.RecoveryDone"]</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
<h1>Configura la verifica in due passaggi</h1>
|
||||
<p class="sub">Aggiungi l'account a un'app di autenticazione (Google Authenticator, Microsoft Authenticator, Aegis, 2FAS...) e inserisci il primo codice.</p>
|
||||
<h1>@T["Auth.TotpSetup.Title"]</h1>
|
||||
<p class="sub">@T["Auth.TotpSetup.Subtitle"]</p>
|
||||
|
||||
@foreach (var message in Errors)
|
||||
{
|
||||
@@ -34,17 +34,17 @@ else
|
||||
@if (Setup is not null)
|
||||
{
|
||||
<dl class="kh-secret">
|
||||
<dt>Chiave da inserire nell'app</dt>
|
||||
<dt>@T["Auth.TotpSetup.Secret"]</dt>
|
||||
<dd><code>@Grouped(Setup.Secret)</code></dd>
|
||||
<dt>Sul telefono</dt>
|
||||
<dd><a href="@Setup.ProvisioningUri">Apri nell'app di autenticazione</a></dd>
|
||||
<dt>@T["Auth.TotpSetup.Phone"]</dt>
|
||||
<dd><a href="@Setup.ProvisioningUri">@T["Auth.TotpSetup.OpenInApp"]</a></dd>
|
||||
</dl>
|
||||
}
|
||||
|
||||
<EditForm Model="Input" method="post" FormName="totp-setup" OnSubmit="SubmitAsync" class="kh-form">
|
||||
<label for="code">Primo codice dell'app</label>
|
||||
<label for="code">@T["Auth.TotpSetup.FirstCode"]</label>
|
||||
<InputText id="code" class="otp" @bind-Value="Input.Code" inputmode="numeric" autocomplete="one-time-code" maxlength="6" autofocus required />
|
||||
<button type="submit" class="kh-btn primary">Attiva</button>
|
||||
<button type="submit" class="kh-btn primary">@T["Auth.TotpSetup.Submit"]</button>
|
||||
</EditForm>
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ else
|
||||
Input.Code = null;
|
||||
if (!result.Succeeded || result.Cookie is null || codes is null)
|
||||
{
|
||||
Errors = LoginFlow.Messages(result.Error);
|
||||
Errors = LoginFlow.Messages(T, Policy, result.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
@page "/not-found"
|
||||
@layout MainLayout
|
||||
<KhPageTitle Text="@T["Pages.NotFound.PageTitle"]" />
|
||||
|
||||
<PageTitle>Khaemhat · pagina non trovata</PageTitle>
|
||||
|
||||
<main class="kh-construction">
|
||||
<section class="hero">
|
||||
<h1>Pagina non trovata</h1>
|
||||
<p class="lead">L'indirizzo richiesto non esiste.</p>
|
||||
<ul class="links"><li><a href="/">Torna alla pagina iniziale</a></li></ul>
|
||||
</section>
|
||||
</main>
|
||||
<div class="kh-message">
|
||||
<KhIcon Name="search" Class="lg" />
|
||||
<h1>@T["Pages.NotFound.Title"]</h1>
|
||||
<p class="lead">@T["Pages.NotFound.Lead"]</p>
|
||||
<a class="btn" href="./">@T["Common.BackHome"]</a>
|
||||
</div>
|
||||
@@ -0,0 +1,393 @@
|
||||
@page "/profilo"
|
||||
@attribute [Authorize]
|
||||
@using System.Globalization
|
||||
@using Khaemhat.Application.Preferences
|
||||
@using Khaemhat.Application.Security
|
||||
@using Khaemhat.Web.Security
|
||||
@implements IAsyncDisposable
|
||||
@inject ShellSession Session
|
||||
@inject ThemeService Theme
|
||||
@inject ToastService Toasts
|
||||
@inject DialogService Dialogs
|
||||
@inject SessionStore Sessions
|
||||
@inject AuthenticationStateProvider Authentication
|
||||
|
||||
@* "Il mio profilo" (SPEC §10.6, §11.12, mockup 008). Every change is shown at once on the page (preview) and kept only
|
||||
with Save; leaving the page without saving puts the saved preferences back. *@
|
||||
<KhPageTitle Text="@T["Pages.Profile.Title"]" Icon="user" />
|
||||
|
||||
<div class="phead">
|
||||
<div>
|
||||
<h1>@T["Pages.Profile.Title"]</h1>
|
||||
<div class="sub">@T["Pages.Profile.Subtitle"]</div>
|
||||
</div>
|
||||
<div class="grow"></div>
|
||||
@if (_section is AppearanceSection or StartSection)
|
||||
{
|
||||
<div class="toolbar">
|
||||
<button type="button" class="btn ghost" @onclick="DefaultsAsync">@T["Pages.Profile.Defaults"]</button>
|
||||
<button type="button" class="btn" disabled="@(!IsModified)" @onclick="UndoAsync"><KhIcon Name="undo" /> @T["Pages.Profile.Undo"]</button>
|
||||
<button type="button" class="btn primary" disabled="@(!IsModified)" @onclick="SaveAsync"><KhIcon Name="save" /> @T["Pages.Profile.Save"]</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<section class="panel">
|
||||
<div class="tabs i" role="tablist">
|
||||
@foreach (var (id, icon, key) in Sections)
|
||||
{
|
||||
<a class="tab @(id == _section ? "active" : null)" role="tab" aria-selected="@(id == _section)" href="@("profilo?scheda=" + id)">
|
||||
<KhIcon Name="@icon" /> @T[key]
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
|
||||
@switch (_section)
|
||||
{
|
||||
case AppearanceSection:
|
||||
<div class="fgroups">
|
||||
<fieldset class="fgroup wide">
|
||||
<legend class="fgh"><KhIcon Name="contrast" /> @T["Pages.Profile.Theme"]</legend>
|
||||
<div class="kh-choices">
|
||||
@foreach (var theme in Enum.GetValues<ThemeMode>())
|
||||
{
|
||||
<button type="button" class="themecard @(Draft.Theme == theme ? "on" : null)" aria-pressed="@(Draft.Theme == theme)"
|
||||
@onclick="() => ChangeAsync(Draft with { Theme = theme })">
|
||||
<span class="pv kh-pv-@UserPreferences.ThemeName(theme)" aria-hidden="true">
|
||||
<span class="tb"></span><span class="sb"></span>
|
||||
<span class="ct"><i></i><i></i><i></i></span>
|
||||
</span>
|
||||
<span class="lbl">
|
||||
@if (Draft.Theme == theme)
|
||||
{
|
||||
<KhIcon Name="check-circle" Class="sm" />
|
||||
}
|
||||
@T["Pages.Profile.Theme." + theme]
|
||||
@if (theme == ThemeMode.Auto)
|
||||
{
|
||||
<span class="muted">@T["Pages.Profile.Theme.AutoHint"]</span>
|
||||
}
|
||||
</span>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="fgroup wide">
|
||||
<legend class="fgh"><KhIcon Name="palette" /> @T["Pages.Profile.Accent"]</legend>
|
||||
<div class="swatches kh-choices">
|
||||
@foreach (var accent in UserPreferences.Accents)
|
||||
{
|
||||
<button type="button" class="sw @(Draft.Accent == accent ? "on" : null)" aria-pressed="@(Draft.Accent == accent)"
|
||||
@onclick="() => ChangeAsync(Draft with { Accent = accent })">
|
||||
<span class="c kh-acc-@accent" aria-hidden="true"><i></i></span>
|
||||
<span class="n">
|
||||
@if (Draft.Accent == accent)
|
||||
{
|
||||
<KhIcon Name="check" Class="sm" />
|
||||
}
|
||||
@T["Pages.Profile.Accent." + accent]
|
||||
</span>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="fgroup">
|
||||
<legend class="fgh"><KhIcon Name="columns" /> @T["Pages.Profile.Density"]</legend>
|
||||
<div class="kh-seg" role="radiogroup" aria-label="@T["Pages.Profile.Density"]">
|
||||
@foreach (var density in Enum.GetValues<Density>())
|
||||
{
|
||||
<button type="button" role="radio" class="@(Draft.Density == density ? "on" : null)" aria-checked="@(Draft.Density == density)"
|
||||
@onclick="() => ChangeAsync(Draft with { Density = density })">@T["Pages.Profile.Density." + density]</button>
|
||||
}
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="fgroup">
|
||||
<legend class="fgh"><KhIcon Name="edit" /> @T["Pages.Profile.TextSize"]</legend>
|
||||
<div class="kh-seg" role="radiogroup" aria-label="@T["Pages.Profile.TextSize"]">
|
||||
@foreach (var size in UserPreferences.TextSizes)
|
||||
{
|
||||
<button type="button" role="radio" class="@(Draft.TextSize == size ? "on" : null)" aria-checked="@(Draft.TextSize == size)"
|
||||
@onclick="() => ChangeAsync(Draft with { TextSize = size })">@T.Format("Pages.Profile.TextSize.Value", size)</button>
|
||||
}
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="fgroup">
|
||||
<legend class="fgh"><KhIcon Name="sidebar" /> @T["Pages.Profile.Menu"]</legend>
|
||||
<div class="kh-seg" role="radiogroup" aria-label="@T["Pages.Profile.Menu"]">
|
||||
@foreach (var (value, key) in MenuChoices)
|
||||
{
|
||||
<button type="button" role="radio" class="@(Draft.MenuCollapsed == value ? "on" : null)" aria-checked="@(Draft.MenuCollapsed == value)"
|
||||
@onclick="() => ChangeAsync(Draft with { MenuCollapsed = value })">@T[key]</button>
|
||||
}
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="fgroup wide">
|
||||
<legend class="fgh"><KhIcon Name="settings" /> @T["Pages.Profile.Options"]</legend>
|
||||
<div class="kh-switches">
|
||||
<KhSwitchRow Label="@T["Pages.Profile.Options.TabularNumbers"]" Hint="@T["Pages.Profile.Options.TabularNumbersHint"]"
|
||||
Value="Draft.TabularNumbers" ValueChanged="v => ChangeAsync(Draft with { TabularNumbers = v })" />
|
||||
<KhSwitchRow Label="@T["Pages.Profile.Options.ReducedMotion"]" Hint="@T["Pages.Profile.Options.ReducedMotionHint"]"
|
||||
Value="Draft.ReducedMotion" ValueChanged="v => ChangeAsync(Draft with { ReducedMotion = v })" />
|
||||
<KhSwitchRow Label="@T["Pages.Profile.Options.Tooltips"]" Hint="@T["Pages.Profile.Options.TooltipsHint"]"
|
||||
Value="Draft.Tooltips" ValueChanged="v => ChangeAsync(Draft with { Tooltips = v })" />
|
||||
<KhSwitchRow Label="@T["Pages.Profile.Options.RowHover"]" Hint="@T["Pages.Profile.Options.RowHoverHint"]"
|
||||
Value="Draft.RowHover" ValueChanged="v => ChangeAsync(Draft with { RowHover = v })" />
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="callout info kh-inset"><KhIcon Name="info" /> <span>@T["Pages.Profile.Preview"]</span></div>
|
||||
break;
|
||||
|
||||
case StartSection:
|
||||
<div class="fgroups">
|
||||
<fieldset class="fgroup wide">
|
||||
<legend class="fgh"><KhIcon Name="home" /> @T["Pages.Profile.Start"]</legend>
|
||||
<div class="kh-radios" role="radiogroup" aria-label="@T["Pages.Profile.Start"]">
|
||||
@foreach (var start in Enum.GetValues<StartPage>())
|
||||
{
|
||||
<label class="chk">
|
||||
<input type="radio" name="kh-start" checked="@(Draft.StartPage == start)"
|
||||
@onchange="() => ChangeAsync(Draft with { StartPage = start })" />
|
||||
@T["Pages.Profile.Start." + start]
|
||||
</label>
|
||||
}
|
||||
</div>
|
||||
@if (Draft.StartPage == StartPage.Page)
|
||||
{
|
||||
<div class="f kh-pick">
|
||||
<label for="kh-start-path">@T["Pages.Profile.Start.PagePick"]</label>
|
||||
<select id="kh-start-path" class="kh-input" value="@Draft.StartPath"
|
||||
@onchange="e => ChangeAsync(Draft with { StartPath = e.Value as string })">
|
||||
@foreach (var item in StartChoices)
|
||||
{
|
||||
<option value="@item.Href">@T[item.Key]</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
}
|
||||
<KhSwitchRow Label="@T["Pages.Profile.Start.ShowDashboard"]" Value="Draft.ShowDashboard"
|
||||
ValueChanged="v => ChangeAsync(Draft with { ShowDashboard = v })" />
|
||||
</fieldset>
|
||||
</div>
|
||||
break;
|
||||
|
||||
case SessionsSection:
|
||||
<div class="pb">
|
||||
<p class="muted">@T["Pages.Profile.Sessions.Intro"]</p>
|
||||
<table class="kh-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">@T["Pages.Profile.Sessions.Device"]</th>
|
||||
<th scope="col">@T["Pages.Profile.Sessions.Address"]</th>
|
||||
<th scope="col">@T["Pages.Profile.Sessions.Company"]</th>
|
||||
<th scope="col">@T["Pages.Profile.Sessions.SignedIn"]</th>
|
||||
<th scope="col">@T["Pages.Profile.Sessions.LastSeen"]</th>
|
||||
<th scope="col"><span class="sr-only">@T["Pages.Profile.Sessions.Revoke"]</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in _sessions)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<KhIcon Name="monitor" Class="sm" /> @DeviceOf(item.UserAgent)
|
||||
@if (item.Id == _currentSessionId)
|
||||
{
|
||||
<span class="badge green">@T["Pages.Profile.Sessions.Current"]</span>
|
||||
}
|
||||
</td>
|
||||
<td class="mono">@item.IpAddress</td>
|
||||
<td>@(item.CompanyCode ?? T["Pages.Profile.Sessions.InstanceAccount"])</td>
|
||||
<td class="kh-nowrap">@T.DateTime(item.CreatedAt, TimeZoneInfo.Local)</td>
|
||||
<td class="kh-nowrap">@T.DateTime(item.LastSeenAt, TimeZoneInfo.Local)</td>
|
||||
<td>
|
||||
@if (item.Id != _currentSessionId)
|
||||
{
|
||||
<button type="button" class="btn danger" @onclick="() => RevokeAsync(item)"><KhIcon Name="logout" /> @T["Pages.Profile.Sessions.Revoke"]</button>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
@if (_sessions.Any(s => s.Id != _currentSessionId))
|
||||
{
|
||||
<div><button type="button" class="btn danger" @onclick="RevokeOthersAsync"><KhIcon Name="logout" /> @T["Pages.Profile.Sessions.RevokeOthers"]</button></div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p class="muted">@T["Pages.Profile.Sessions.None"]</p>
|
||||
}
|
||||
</div>
|
||||
break;
|
||||
|
||||
default:
|
||||
<div class="pb">
|
||||
@foreach (var scope in Enum.GetValues<ShortcutScope>())
|
||||
{
|
||||
<h2 class="kh-h2">@T["Pages.Profile.Shortcuts." + scope]</h2>
|
||||
<table class="kh-table">
|
||||
<thead><tr><th scope="col">@T["Pages.Profile.Shortcuts.Keys"]</th><th scope="col">@T["Pages.Profile.Shortcuts.Action"]</th></tr></thead>
|
||||
<tbody>
|
||||
@foreach (var shortcut in KeyboardShortcuts.All.Where(s => s.Scope == scope))
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@foreach (var keys in shortcut.Keys)
|
||||
{
|
||||
<kbd>@keys</kbd>
|
||||
}
|
||||
</td>
|
||||
<td>@T[shortcut.TextKey]</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
<p class="muted">@T["Pages.Profile.Shortcuts.BrowserNote"]</p>
|
||||
</div>
|
||||
break;
|
||||
}
|
||||
</section>
|
||||
|
||||
@code {
|
||||
private const string AppearanceSection = "aspetto";
|
||||
private const string StartSection = "pagina-iniziale";
|
||||
private const string ShortcutsSection = "scorciatoie";
|
||||
private const string SessionsSection = "sessioni";
|
||||
|
||||
private static readonly (string Id, string Icon, string Key)[] Sections =
|
||||
[
|
||||
(AppearanceSection, "palette", "Pages.Profile.Tabs.Appearance"),
|
||||
(StartSection, "home", "Pages.Profile.Tabs.Start"),
|
||||
(SessionsSection, "monitor", "Pages.Profile.Tabs.Sessions"),
|
||||
(ShortcutsSection, "keyboard", "Pages.Profile.Tabs.Shortcuts"),
|
||||
];
|
||||
|
||||
private static readonly (bool? Value, string Key)[] MenuChoices =
|
||||
[
|
||||
(null, "Pages.Profile.Menu.Auto"),
|
||||
(false, "Pages.Profile.Menu.Expanded"),
|
||||
(true, "Pages.Profile.Menu.Collapsed"),
|
||||
];
|
||||
|
||||
private string _section = AppearanceSection;
|
||||
private IReadOnlyList<SessionSummary> _sessions = [];
|
||||
private SessionOwner? _owner;
|
||||
private long _currentSessionId;
|
||||
|
||||
/// <summary>The section: <c>aspetto</c>, <c>pagina-iniziale</c>, <c>sessioni</c>, <c>scorciatoie</c>.</summary>
|
||||
[SupplyParameterFromQuery(Name = "scheda")]
|
||||
public string? Section { get; set; }
|
||||
|
||||
/// <summary>The tab of the page, to show the modified mark.</summary>
|
||||
[CascadingParameter]
|
||||
public KhTab? Tab { get; set; }
|
||||
|
||||
private UserPreferences Draft { get; set; } = UserPreferences.Default;
|
||||
|
||||
private bool IsModified => Draft != Session.Preferences;
|
||||
|
||||
private IEnumerable<MenuItem> StartChoices => MenuCatalog.All.Where(i => i.Milestone is null && Session.CanSee(i));
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await Session.EnsureLoadedAsync();
|
||||
Draft = Session.Preferences;
|
||||
var user = (await Authentication.GetAuthenticationStateAsync()).User;
|
||||
_owner = SessionCookie.OwnerOf(user);
|
||||
_ = long.TryParse(user.FindFirst(SessionCookie.SessionIdClaim)?.Value, NumberStyles.None, CultureInfo.InvariantCulture, out _currentSessionId);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
_section = Sections.Any(s => s.Id == Section) ? Section! : AppearanceSection;
|
||||
if (_section == SessionsSection)
|
||||
{
|
||||
await LoadSessionsAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadSessionsAsync() =>
|
||||
_sessions = _owner is null ? [] : await Sessions.ListAsync(_owner);
|
||||
|
||||
private async Task RevokeAsync(SessionSummary item)
|
||||
{
|
||||
if (_owner is null || !await Dialogs.ConfirmAsync(new(T["Pages.Profile.Sessions.RevokeTitle"], T["Pages.Profile.Sessions.RevokeText"],
|
||||
T["Pages.Profile.Sessions.Revoke"], T["Common.Cancel"], Danger: true)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await Sessions.RevokeAsync(_owner, item.Id, "user");
|
||||
Toasts.Show(ToastKind.Success, T["Pages.Profile.Sessions.Revoked"]);
|
||||
await LoadSessionsAsync();
|
||||
}
|
||||
|
||||
private async Task RevokeOthersAsync()
|
||||
{
|
||||
if (_owner is null || !await Dialogs.ConfirmAsync(new(T["Pages.Profile.Sessions.RevokeTitle"], T["Pages.Profile.Sessions.RevokeOthersText"],
|
||||
T["Pages.Profile.Sessions.RevokeOthers"], T["Common.Cancel"], Danger: true)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var count = await Sessions.RevokeAllAsync(_owner, "user", _currentSessionId);
|
||||
Toasts.Show(ToastKind.Success, T.Format("Pages.Profile.Sessions.RevokedMany", count));
|
||||
await LoadSessionsAsync();
|
||||
}
|
||||
|
||||
// A short name of the browser and system from the user agent: enough to recognise a device, not a full parser.
|
||||
private static readonly (string Marker, string Name)[] Browsers = [("Edg/", "Edge"), ("OPR/", "Opera"), ("Firefox/", "Firefox"), ("Chrome/", "Chrome"), ("Safari/", "Safari")];
|
||||
private static readonly string[] Systems = ["Windows", "Android", "iPhone", "iPad", "Mac OS", "Linux"];
|
||||
|
||||
private string DeviceOf(string? userAgent)
|
||||
{
|
||||
var browser = userAgent is null ? null : Browsers.FirstOrDefault(b => userAgent.Contains(b.Marker, StringComparison.Ordinal)).Name;
|
||||
var system = userAgent is null ? null : Systems.FirstOrDefault(s => userAgent.Contains(s, StringComparison.Ordinal));
|
||||
return browser is null && system is null
|
||||
? T["Pages.Profile.Sessions.Unknown"]
|
||||
: string.Join(" · ", new[] { browser, system }.Where(x => x is not null));
|
||||
}
|
||||
|
||||
private async Task ChangeAsync(UserPreferences next)
|
||||
{
|
||||
if (next.StartPage == StartPage.Page && !UserPreferences.IsLocalPath(next.StartPath))
|
||||
{
|
||||
next = next with { StartPath = StartChoices.FirstOrDefault()?.Href ?? "/" };
|
||||
}
|
||||
|
||||
Draft = next;
|
||||
Tab?.SetModified(IsModified);
|
||||
await Theme.PreviewAsync(Draft);
|
||||
}
|
||||
|
||||
private async Task SaveAsync()
|
||||
{
|
||||
await Theme.ApplyAsync(Draft);
|
||||
Draft = Session.Preferences;
|
||||
Tab?.SetModified(false);
|
||||
Toasts.Show(ToastKind.Success, T["Pages.Profile.Saved"], T["Pages.Profile.SavedText"]);
|
||||
}
|
||||
|
||||
private Task UndoAsync() => ChangeAsync(Session.Preferences);
|
||||
|
||||
private Task DefaultsAsync() => ChangeAsync(UserPreferences.Default);
|
||||
|
||||
/// <inheritdoc />
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
// Closing the tab without saving: the page goes back to the saved look.
|
||||
if (IsModified)
|
||||
{
|
||||
await Theme.PreviewAsync(Session.Preferences);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user