feat(server): web server, interface shell, demo mode and Docker image (refs #11 #12 #13 #14 #15 #16 #17)
Phase 1 completed on top of the library foundations: - Server: startup state machine (config, first run, database down, schema, identity, ready) with an error page that retries by itself; the configured database is the only one ever opened, and a vanished SQLite file is never recreated. REST API and status WebSocket; session cookie auth, CSRF on every form and write call; desktop and demo answer only the computer itself. - Interface: static Blazor rendering with plain forms (no interactive runtime), menu, top bar and phone bottom bar as in the mockups, light and dark themes with appendix C tokens and a contrast test, Panoramica, Diario, Rischio, Impostazioni; service pages for sign-in, first access, desktop first run and the database error page with its choices. - Demo mode (tasks seed-demo): appendix F in a database of its own under the temp folder, frozen clock, never touches the configured installation. - Docker: entrypoint gives /data to PUID:PGID and drops root with setpriv, HEALTHCHECK through bash /dev/tcp; proven with SQLite, PostgreSQL, a wrong configuration and a database that goes away and comes back. - tasks screenshots drives the installed Edge/Chrome through DevTools for exact 1440 and 390 pixel shots; anubis db export|import on the command line. Fixes from the independent review: return paths without control characters, Host check against DNS rebinding, attempt limit counted before the check and also on the error-page password, one-use TOTP codes and a code to switch the second factor off, error-page choices serialized with the startup loop, identity checked before migrating, restore restarts with "Ferma tutto" on, damaged archives reported instead of crashing. Running the server tests on PostgreSQL exposed pages rendered before their data arrived; data-loading components now load first (LoadedComponent). Decisions in ADR 0007. Tests: 100 on SQLite and on PostgreSQL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
53ca01b7c3
commit
f9d71559e8
71 files changed
+5853
-80
No files matched your search
@@ -0,0 +1,118 @@
|
||||
@inherits LoadedLayout
|
||||
@inject ShellData Shell
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
@* The shell of SPEC 13.4: menu on the left (collapsible, remembered), top bar with state and commands, on phones a
|
||||
bottom bar with five entries. Rendered on the server; app.js keeps state and freshness live over the WebSocket. *@
|
||||
<div class="shell" data-shell>
|
||||
<nav class="sidebar" aria-label="Menu principale">
|
||||
<div class="brand">
|
||||
<a class="brand-link" href="/">
|
||||
<img class="logo logo-light" src="/brand/anubis.svg" alt="" width="28" height="28" />
|
||||
<img class="logo logo-dark" src="/brand/anubis-dark.svg" alt="" width="28" height="28" />
|
||||
<span class="brand-name">Anubis</span>
|
||||
</a>
|
||||
<button type="button" class="icon-button collapse" data-collapse aria-label="Comprimi il menu" aria-expanded="true">
|
||||
<Icon Name="collapse" Class="when-open" /><Icon Name="expand" Class="when-closed" />
|
||||
</button>
|
||||
</div>
|
||||
@foreach (var group in Menu.Groups)
|
||||
{
|
||||
<ul class="nav-group">
|
||||
@foreach (var item in group)
|
||||
{
|
||||
<li>
|
||||
<a class="nav-item @(IsActive(item.Path) ? "active" : null)" href="@item.Path" aria-current="@(IsActive(item.Path) ? "page" : null)" title="@item.Label">
|
||||
<Icon Name="@item.Icon" /><span class="nav-label">@item.Label</span>
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
</nav>
|
||||
|
||||
<div class="main">
|
||||
<header class="topbar">
|
||||
<div class="topbar-title">
|
||||
<a class="phone-brand" href="/">
|
||||
<img class="logo logo-light" src="/brand/anubis.svg" alt="" width="24" height="24" />
|
||||
<img class="logo logo-dark" src="/brand/anubis-dark.svg" alt="" width="24" height="24" />
|
||||
<span>Anubis</span>
|
||||
</a>
|
||||
<span class="phone-bot" data-live="bot" data-state="@_shell.Bot"><span class="dot"></span><span data-live="bot-short">@_shell.BotShort</span></span>
|
||||
<h1>@Menu.Title(_path)</h1>
|
||||
<p class="status-line">
|
||||
<span data-live="now">@_shell.Now</span>. <span data-live="age" data-age="@_shell.AgeSeconds">Dati aggiornati @Format.Ago(TimeSpan.FromSeconds(_shell.AgeSeconds))</span>.
|
||||
</p>
|
||||
</div>
|
||||
<div class="topbar-actions">
|
||||
<span class="pill pill-bot" data-live="bot" data-state="@_shell.Bot"><span class="dot"></span><span data-live="bot-label">@_shell.BotLabel</span></span>
|
||||
<span class="pill pill-mode"><Icon Name="flask" Size="16" />Simulazione: nessun soldo reale</span>
|
||||
<form class="currency" method="post" action="/azioni/impostazioni/appearance.currency">
|
||||
<AntiforgeryToken />
|
||||
<input type="hidden" name="ritorno" value="@_back" />
|
||||
<label class="sr-only" for="valuta">Valuta di visualizzazione</label>
|
||||
<select id="valuta" name="valore" data-autosubmit>
|
||||
<option value="EUR" selected="@(_shell.Currency == "EUR")">EUR</option>
|
||||
<option value="USD" selected="@(_shell.Currency == "USD")">USD</option>
|
||||
</select>
|
||||
<Icon Name="chevron" Size="16" Class="select-chevron" />
|
||||
<noscript><button class="btn btn-small" type="submit">Cambia</button></noscript>
|
||||
</form>
|
||||
@if (_shell.Bot == "paused")
|
||||
{
|
||||
<form method="post" action="/azioni/bot/riprendi"><AntiforgeryToken /><input type="hidden" name="ritorno" value="@_back" /><button class="btn" type="submit"><Icon Name="play" Size="18" />Riprendi</button></form>
|
||||
}
|
||||
else if (_shell.Bot == "active")
|
||||
{
|
||||
<form method="post" action="/azioni/bot/pausa"><AntiforgeryToken /><input type="hidden" name="ritorno" value="@_back" /><button class="btn" type="submit"><Icon Name="pause" Size="18" />Metti in pausa</button></form>
|
||||
}
|
||||
<form class="stop-form" method="post" action="/azioni/bot/ferma"><AntiforgeryToken /><input type="hidden" name="ritorno" value="@_back" /><button class="btn btn-danger" type="submit" data-confirm="Ferma tutto: il bot non apre né gestisce nuove operazioni finché non lo riattivi dalla pagina Rischio. Confermi?" disabled="@(_shell.Bot == "stopped")"><Icon Name="stop" Size="18" />Ferma tutto</button></form>
|
||||
</div>
|
||||
</header>
|
||||
<div class="mode-band"><Icon Name="flask" Size="16" />Simulazione: nessun soldo reale</div>
|
||||
<div class="stale-notice" data-stale hidden role="status"><Icon Name="alert" Size="16" /><span data-stale-text>Collegamento interrotto.</span></div>
|
||||
|
||||
<main class="page" id="contenuto">
|
||||
@Body
|
||||
<footer class="page-footer">
|
||||
@if (Shell.IsDemo)
|
||||
{
|
||||
<p>Modalità dimostrativa. Numeri, titoli e notizie sono dati di esempio.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>Anubis @AnubisInfo.Version</p>
|
||||
}
|
||||
</footer>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<nav class="bottombar" aria-label="Menu del telefono">
|
||||
@foreach (var item in Menu.Phone)
|
||||
{
|
||||
<a class="bottom-item @(IsActive(item.Path) ? "active" : null)" href="@item.Path" aria-current="@(IsActive(item.Path) ? "page" : null)">
|
||||
<Icon Name="@item.Icon" Size="22" /><span>@item.Label</span>
|
||||
</a>
|
||||
}
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private ShellSnapshot _shell = null!;
|
||||
private string _path = "/";
|
||||
private string _back = "/";
|
||||
|
||||
[CascadingParameter]
|
||||
public HttpContext? HttpContext { get; set; }
|
||||
|
||||
protected override async Task LoadAsync()
|
||||
{
|
||||
_shell = await Shell.SnapshotAsync(HttpContext?.RequestAborted ?? CancellationToken.None);
|
||||
var uri = new Uri(Navigation.Uri);
|
||||
_path = uri.AbsolutePath;
|
||||
_back = uri.PathAndQuery;
|
||||
}
|
||||
|
||||
private bool IsActive(string path) => path == "/" ? _path == "/" : _path.StartsWith(path, StringComparison.Ordinal);
|
||||
}
|
||||
Reference in new issue
Block a user