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
@@ -174,6 +174,15 @@ internal static partial class Endpoints
|
||||
"text/csv; charset=utf-8", $"anubis-operazioni-{day}.csv");
|
||||
});
|
||||
|
||||
// The technical logs of the data folder as one zip (SPEC 13.6, "Diario e sistema"). They are redacted when
|
||||
// written (JsonLog); only the files the log writer names, read while it keeps writing the newest one.
|
||||
api.MapGet("/registri.zip", (AnubisHost host, ShellData shell, IClock clock) =>
|
||||
{
|
||||
var folder = host.Config.Data.Logs;
|
||||
var day = TimeZoneInfo.ConvertTime(clock.UtcNow, shell.Zone).ToString("yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);
|
||||
return Results.File(LogArchive(folder), "application/zip", $"anubis-registri-{day}.zip");
|
||||
});
|
||||
|
||||
// The external sources and the live feed: what is on, what is off and why (SPEC 4.4).
|
||||
api.MapGet("/data/sources", async (AnubisHost host, IClock clock, CancellationToken ct) =>
|
||||
{
|
||||
@@ -219,6 +228,32 @@ internal static partial class Endpoints
|
||||
|
||||
internal static IResult Error(int status, string code, string message) => Results.Json(new ApiError(code, message), _json, statusCode: status);
|
||||
|
||||
/// <summary>The daily log files (anubis-*.log) of a folder in a zip, newest first; an empty zip when there are none yet.</summary>
|
||||
internal static byte[] LogArchive(string folder)
|
||||
{
|
||||
using var buffer = new MemoryStream();
|
||||
using (var zip = new System.IO.Compression.ZipArchive(buffer, System.IO.Compression.ZipArchiveMode.Create, leaveOpen: true))
|
||||
{
|
||||
var files = Directory.Exists(folder) ? Directory.EnumerateFiles(folder, "anubis-*.log").OrderDescending(StringComparer.Ordinal).ToList() : [];
|
||||
foreach (var file in files)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var source = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||
var entry = zip.CreateEntry(Path.GetFileName(file), System.IO.Compression.CompressionLevel.Optimal);
|
||||
using var target = entry.Open();
|
||||
source.CopyTo(target);
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
// A file removed by the rotation in the meantime: the others still go.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return buffer.ToArray();
|
||||
}
|
||||
|
||||
private static async ValueTask<object?> CsrfFilterAsync(EndpointFilterInvocationContext context, EndpointFilterDelegate next)
|
||||
{
|
||||
var http = context.HttpContext;
|
||||
|
||||
Reference in new issue
Block a user