Build the Panoramica and Diario e sistema screens as in the mockups (refs #51)
Panoramica now follows mockup 01. Below "Finora" and "Adesso e dopo" it shows: - the two account cards with the invested/cash bar and a 30-day trend; - the four risk limits; - the open positions by value; - the strategies; - the news, learning and system tiles. On the phone it follows mockup 09: Conti as a list, four positions with "Vedi le altre", and two limits. Outside the demo, news and learning say they are not active yet (Phases 7 and 8). The next moves are the scheduler's moves only, no longer every interval job. Diario e sistema follows mockup 08: - the diary grouped by day, with search and filter chips (plain links, no JavaScript) and older days on request; - how each component is doing; - the scheduled jobs; - the host's processor, memory and disk; - the technical logs as a zip, for signed-in users only. In demo mode the screens show the values of appendix F.10. Tests cover the demo figures, the filters and search, and the logs download. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
84c540786c
commit
e96ca70a1a
11 files changed
+1666
-85
No files matched your search
@@ -5,86 +5,157 @@
|
||||
|
||||
<PageTitle>Diario e sistema · Anubis</PageTitle>
|
||||
|
||||
<div class="columns">
|
||||
<section class="panel">
|
||||
<h2>Diario</h2>
|
||||
@if (_entries.Count == 0)
|
||||
@{
|
||||
var d = _diary;
|
||||
var s = _system;
|
||||
}
|
||||
<div class="journal-columns">
|
||||
<section class="panel journal" aria-labelledby="diario">
|
||||
<div class="journal-head">
|
||||
<h2 id="diario">Diario</h2>
|
||||
<form class="search journal-search" method="get" action="/diario" role="search">
|
||||
@if (d.Filter != "tutto")
|
||||
{
|
||||
<input type="hidden" name="tipo" value="@d.Filter" />
|
||||
}
|
||||
<Icon Name="search" Size="16" />
|
||||
<label class="visually-hidden" for="cerca-diario">Cerca nel diario</label>
|
||||
<input id="cerca-diario" type="search" name="cerca" value="@d.Search" placeholder="Cerca nel diario" maxlength="100" />
|
||||
</form>
|
||||
</div>
|
||||
<nav class="chips" aria-label="Tipo di voce">
|
||||
@foreach (var (key, label, _) in DiaryView.Filters)
|
||||
{
|
||||
<a href="@d.Link(filter: key, range: DiaryView.DefaultRange)" class="chip @(key == d.Filter ? "on" : null)" aria-current="@(key == d.Filter ? "true" : null)">@label</a>
|
||||
}
|
||||
</nav>
|
||||
@if (d.Search is { } search)
|
||||
{
|
||||
<p class="note">Ancora nessuna voce.</p>
|
||||
<p class="note journal-found">
|
||||
@(d.Days.Sum(x => x.Entries.Count) switch { 0 => "Nessuna voce", 1 => "Una voce", var n => $"{n} voci" }) con «@search»@(d.Truncated ? $", le {DiaryView.MaxSearchResults} più recenti" : "").
|
||||
<a href="@(new DiaryView([], d.Filter, null, DiaryView.DefaultRange, false, false).Link())">Togli la ricerca</a>
|
||||
</p>
|
||||
}
|
||||
else
|
||||
@if (d.IsEmpty && d.Search is null)
|
||||
{
|
||||
<div class="table-wrap">
|
||||
<table class="table">
|
||||
<thead><tr><th scope="col">Quando</th><th scope="col">Tipo</th><th scope="col">Voce</th></tr></thead>
|
||||
<tbody>
|
||||
@foreach (var e in _entries)
|
||||
{
|
||||
<tr><td class="nowrap">@Format.ShortDate(e.At, Shell.Now, Shell.Zone)</td><td>@e.Kind</td><td>@e.Text</td></tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<p class="note">@(d.Filter == "tutto" ? "Ancora nessuna voce. Qui il bot scrive ogni decisione, ordine e controllo, in parole semplici, appena succede." : "Nessuna voce di questo tipo finora.")</p>
|
||||
}
|
||||
@foreach (var day in d.Days)
|
||||
{
|
||||
<h3 class="journal-day">@day.Heading</h3>
|
||||
<ol class="journal-list">
|
||||
@foreach (var e in day.Entries)
|
||||
{
|
||||
<li class="@(e.Attention ? "attention-entry" : null)">
|
||||
<time datetime="@e.At.ToString("o", CultureInfo.InvariantCulture)">@TimeZoneInfo.ConvertTime(e.At, Shell.Zone).ToString("HH:mm", CultureInfo.InvariantCulture)</time>
|
||||
<Icon Name="@e.Icon" Size="18" Class="journal-icon" />
|
||||
<div class="journal-text">
|
||||
<p>@if (e.Lead is { } lead) {<strong>@lead</strong>}@foreach (var piece in e.Main) {if (piece.Class is { } css) {<strong class="@css">@piece.Text</strong>} else {@piece.Text}}</p>
|
||||
@if (e.Rest is { } rest)
|
||||
{
|
||||
<p class="journal-rest">@rest</p>
|
||||
}
|
||||
@if (e.Trade is { } trade)
|
||||
{
|
||||
<a href="/operazioni?cerca=@Uri.EscapeDataString(trade)">Perché l'ho comprata e venduta</a>
|
||||
}
|
||||
</div>
|
||||
<span class="journal-kind">@e.Kind</span>
|
||||
</li>
|
||||
}
|
||||
</ol>
|
||||
}
|
||||
@if (d.HasOlder)
|
||||
{
|
||||
<div class="journal-more"><a class="btn" href="@d.Link(range: d.Range + 7)">Mostra i giorni precedenti</a></div>
|
||||
}
|
||||
</section>
|
||||
<section class="panel">
|
||||
<h2>Sistema</h2>
|
||||
<dl class="facts">
|
||||
<dt>Versione</dt><dd>@AnubisInfo.Version</dd>
|
||||
<dt>Piattaforma</dt><dd>@(Host.Config.Platform == PlatformKind.Docker ? "Docker" : "Desktop")</dd>
|
||||
<dt>Database</dt><dd>@(Host.Config.Db?.Engine == DbEngine.Postgres ? "PostgreSQL" : "SQLite") · risponde</dd>
|
||||
<dt>In funzione da</dt><dd>@Format.Ago(Shell.Now - _since).Replace(" fa", "", StringComparison.Ordinal)</dd>
|
||||
</dl>
|
||||
<h3 class="list-title">Lavori in programma</h3>
|
||||
<ul class="moves">
|
||||
@foreach (var job in _upcoming)
|
||||
{
|
||||
<li><span class="move-time">@Format.ShortDate(job.DueUtc, Shell.Now, Shell.Zone)</span><span>@job.Description</span></li>
|
||||
}
|
||||
</ul>
|
||||
@if (_jobs.Count > 0)
|
||||
{
|
||||
<h3 class="list-title">Ultimi lavori</h3>
|
||||
<ul class="moves moves-past">
|
||||
@foreach (var job in _jobs)
|
||||
|
||||
<div class="journal-side">
|
||||
<section class="panel" aria-labelledby="sistema">
|
||||
<div class="panel-head">
|
||||
<h2 id="sistema">Come sta il sistema</h2>
|
||||
<span class="status-pill @(s.AllWell ? "gain" : "attention")"><Icon Name="@(s.AllWell ? "check" : "alert")" Size="16" />@(s.AllWell ? "Tutto regolare" : "Qualcosa da controllare")</span>
|
||||
</div>
|
||||
<ul class="system-parts">
|
||||
@foreach (var part in s.Parts)
|
||||
{
|
||||
<li><span class="move-time">@(job.Finished is { } f ? Format.ShortDate(f, Shell.Now, Shell.Zone) : "—")</span><span>@job.Description: @Outcome(job.Outcome)</span></li>
|
||||
<li class="@PartClass(part.State)">
|
||||
<Icon Name="@PartIcon(part.State)" Size="16" />
|
||||
<span><strong>@part.Name</strong><span>@part.Detail</span></span>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section class="panel" aria-labelledby="lavori">
|
||||
<h2 id="lavori">Lavori in programma</h2>
|
||||
@if (s.Jobs.Count == 0)
|
||||
{
|
||||
<p class="note">Nessun lavoro in programma: il pianificatore parte con il motore.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<ul class="moves job-list">
|
||||
@foreach (var job in s.Jobs)
|
||||
{
|
||||
<li><span class="move-time">@job.Time</span><span>@job.Text</span></li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
</section>
|
||||
|
||||
<section class="plain host" aria-labelledby="computer">
|
||||
<h2 id="computer">Il computer che lo ospita</h2>
|
||||
@foreach (var r in s.Resources)
|
||||
{
|
||||
<div class="limit">
|
||||
<div class="limit-line"><span>@r.Label</span><span><strong>@r.Value</strong>@if (r.Of is { } of) {<span class="muted"> su @of</span>}</span></div>
|
||||
<span class="usage @(r.Share >= 0.85m ? "high" : null)"><span style="width: @Css(r.Share * 100m)%"></span></span>
|
||||
</div>
|
||||
}
|
||||
<p class="note">@s.Running</p>
|
||||
<a class="btn" href="/api/registri.zip" download><Icon Name="download" Size="18" />Scarica i registri tecnici</a>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private List<(DateTimeOffset At, string Kind, string Text)> _entries = [];
|
||||
private List<(string Description, DateTimeOffset? Finished, string? Outcome)> _jobs = [];
|
||||
private IReadOnlyList<UpcomingRun> _upcoming = [];
|
||||
private DateTimeOffset _since;
|
||||
private DiaryView _diary = null!;
|
||||
private SystemView _system = null!;
|
||||
|
||||
[CascadingParameter]
|
||||
public HttpContext? HttpContext { get; set; }
|
||||
|
||||
[SupplyParameterFromQuery(Name = "tipo")]
|
||||
public string? Tipo { get; set; }
|
||||
|
||||
[SupplyParameterFromQuery(Name = "cerca")]
|
||||
public string? Cerca { get; set; }
|
||||
|
||||
[SupplyParameterFromQuery(Name = "giorni")]
|
||||
public string? Giorni { get; set; }
|
||||
|
||||
protected override async Task LoadAsync()
|
||||
{
|
||||
var ct = HttpContext?.RequestAborted ?? CancellationToken.None;
|
||||
var services = Host.Services!;
|
||||
(_entries, _jobs) = await services.Db.ReadAsync(async s =>
|
||||
{
|
||||
var entries = await s.QueryAsync("SELECT occurred_at, kind, message FROM journal ORDER BY occurred_at DESC LIMIT 200",
|
||||
r => (r.Moment("occurred_at"), r.Text("kind"), r.Text("message")));
|
||||
var jobs = await s.QueryAsync("SELECT description, last_finished_at, last_outcome FROM jobs ORDER BY last_finished_at DESC",
|
||||
r => (r.Text("description"), r.MomentOrNull("last_finished_at"), r.TextOrNull("last_outcome")));
|
||||
return (entries, jobs);
|
||||
}, ct);
|
||||
_upcoming = services.Scheduler.Upcoming(10);
|
||||
_since = Host.Status.Since;
|
||||
_diary = await DiaryView.LoadAsync(Host.Services!.Db, Tipo, Cerca, Giorni, Shell.Now, Shell.Zone, ct);
|
||||
_system = await SystemView.LoadAsync(Host, Shell, ct);
|
||||
}
|
||||
|
||||
private static string Outcome(string? outcome) => outcome switch
|
||||
private static string PartClass(PartState state) => state switch
|
||||
{
|
||||
"succeeded" => "fatto",
|
||||
"failed" => "non riuscito",
|
||||
"skipped" => "saltato, orario superato",
|
||||
_ => "in attesa",
|
||||
PartState.Ok => "ok",
|
||||
PartState.Warn => "warn",
|
||||
_ => "off",
|
||||
};
|
||||
|
||||
private static string PartIcon(PartState state) => state switch
|
||||
{
|
||||
PartState.Ok => "tick",
|
||||
PartState.Warn => "alert",
|
||||
_ => "clock",
|
||||
};
|
||||
|
||||
private static string Css(decimal value) => Math.Round(value, 3).ToString("0.###", CultureInfo.InvariantCulture);
|
||||
}
|
||||
Reference in new issue
Block a user