diff --git a/src/Anubis.Server/Assets/app.css b/src/Anubis.Server/Assets/app.css index f72ad25..d040a84 100644 --- a/src/Anubis.Server/Assets/app.css +++ b/src/Anubis.Server/Assets/app.css @@ -203,6 +203,10 @@ code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-siz height: 40px; border: 1px solid var(--control); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 14px; padding: 0 12px; } +textarea { + border: 1px solid var(--control); border-radius: 8px; background: var(--surface); color: var(--text); + font-family: ui-monospace, Consolas, monospace; font-size: 13.5px; padding: 8px 12px; resize: vertical; +} .currency select { appearance: none; padding: 0 40px 0 16px; font-weight: 550; cursor: pointer; } .select-chevron { position: absolute; right: 14px; top: 12px; pointer-events: none; color: var(--text-2); } diff --git a/src/Anubis.Server/Components/Pages/Impostazioni.razor b/src/Anubis.Server/Components/Pages/Impostazioni.razor index 99ce779..091ecf4 100644 --- a/src/Anubis.Server/Components/Pages/Impostazioni.razor +++ b/src/Anubis.Server/Components/Pages/Impostazioni.razor @@ -3,6 +3,7 @@ @inject AnubisHost Host @inject ShellData Shell @inject SecondFactorDrafts Drafts +@inject Anubis.Core.IClock Clock Impostazioni · Anubis @@ -24,7 +25,7 @@ }
@@ -55,6 +56,51 @@

Gli importi in dollari usano il cambio del giorno, che arriva con i dati di mercato. Fino ad allora restano in euro.

+
+

Dati

+ @if (Host.Services!.MarketData is not { } market) + { +

@(Shell.IsDemo ? "Nella modalità dimostrativa i dati di mercato non si scaricano." : "La raccolta dei dati di mercato è spenta (ANUBIS_MARKET_DATA).")

+ } + else + { +
+
Prezzi crypto in diretta
@(market.LiveConnected ? "collegati" : "non collegati")
+
Ultimo giro dello storico
@(market.LastHistoryRun is { } run ? Format.ShortDate(run, Shell.Now, Shell.Zone) : "in corso o non ancora fatto")
+
+ } + @if (_sources.Count > 0) + { +

Fonti

+
+ + + + @foreach (var s in _sources) + { + + + + + + + } + +
FonteStatoUltima rispostaNote
@SourceName(s.Source)@(!s.Enabled ? "spenta" : s.LastError is null ? "attiva" : "in errore")@(s.LastSuccessAt is { } at ? Format.ShortDate(at, Shell.Now, Shell.Zone) : "—")@(s.LastError ?? s.Note)
+
+ } +

Rapporto sulla qualità dei dati degli ultimi 30 giorni

+ +

Riunioni di Fed e BCE

+
+ + + + + + +
+

Sicurezza

@if (Shell.IsDemo) @@ -171,6 +217,8 @@ @code { private readonly List _appearance = []; + private IReadOnlyList _sources = []; + private SettingValue _meetings = new(SettingsStore.CentralBankMeetings.Key, "", false, null); private List _history = []; private IReadOnlyList _backups = []; private bool _hasSecondFactor; @@ -193,6 +241,8 @@ _appearance.Add(await services.Settings.GetAsync(SettingsStore.Theme.Key, ct)); _appearance.Add(await services.Settings.GetAsync(SettingsStore.Currency.Key, ct)); _history = await services.Settings.HistoryAsync(null, 50, ct); + _meetings = await services.Settings.GetAsync(SettingsStore.CentralBankMeetings.Key, ct); + _sources = await new Anubis.Data.SourceStateStore(services.Db, Clock).ListAsync(ct); _backups = services.Backups.List(); var user = HttpContext!.User; _hasSecondFactor = CurrentUser.HasSecondFactor(user); @@ -210,10 +260,29 @@ "segreto" => "La chiave è scaduta: ricarica la pagina e aggiungi di nuovo Anubis nell'app.", "salvataggio" => "Il salvataggio non è riuscito. Controlla lo spazio libero nella cartella dei dati.", "impostazione" => "Questa impostazione non si può cambiare così.", + "riunioni" => "L'elenco delle riunioni non è valido: una riga per riunione, con FED o BCE e la data, per esempio «FED 2027-01-27».", "bot" => "Comando non ammesso nello stato attuale del bot.", _ => PasswordMessages.For(Errore), }; + private static string SourceName(string source) => source switch + { + "okx" => "OKX Europe (crypto)", + "alpaca" => "Alpaca (azioni, conto di prova)", + "storico" => "Storico giornaliero delle crypto", + "storico_azioni" => "Storico giornaliero delle azioni", + "binance" => "Archivi Binance (ricerca)", + "ecb" => "Cambi della BCE", + "forexfactory" => "Calendario economico (Forex Factory)", + "fred" => "Date dei dati USA (FRED)", + "finnhub" => "Date delle trimestrali (Finnhub)", + "central_banks" => "Riunioni di Fed e BCE", + "alternative.me" => "Indice di paura e avidità", + "cboe" => "VIX (Cboe)", + "okx_derivatives" => "Funding e interesse aperto di BTC (OKX)", + _ => source, + }; + private static string Label(string? value) => value switch { null => "—", diff --git a/src/Anubis.Server/Forms.cs b/src/Anubis.Server/Forms.cs index f4a1eeb..9f05537 100644 --- a/src/Anubis.Server/Forms.cs +++ b/src/Anubis.Server/Forms.cs @@ -151,11 +151,16 @@ internal static partial class Forms private static async Task SetSettingAsync(string key, IFormCollection form, AnubisHost host, HttpContext context, CancellationToken ct) { var back = Back(form, "/impostazioni"); - if (key != SettingsStore.Theme.Key && key != SettingsStore.Currency.Key) + if (key != SettingsStore.Theme.Key && key != SettingsStore.Currency.Key && key != SettingsStore.CentralBankMeetings.Key) { return Results.Redirect(With(back, "errore", "impostazione")); } + if (key == SettingsStore.CentralBankMeetings.Key && Anubis.Data.CentralBanks.Check(form["valore"].ToString()) is not null) + { + return Results.Redirect(With(back, "errore", "riunioni")); + } + var result = await Endpoints.SetSettingAsync(host, key, form["valore"].ToString(), context, ct).ConfigureAwait(false); return Results.Redirect(result is IStatusCodeHttpResult { StatusCode: StatusCodes.Status204NoContent } ? back : With(back, "errore", "impostazione")); } diff --git a/tests/Anubis.Tests/MarketDataServerTests.cs b/tests/Anubis.Tests/MarketDataServerTests.cs index 10673d4..1404628 100644 --- a/tests/Anubis.Tests/MarketDataServerTests.cs +++ b/tests/Anubis.Tests/MarketDataServerTests.cs @@ -47,6 +47,25 @@ public sealed class MarketDataServerTests var report = await server.TextAsync("/api/data/quality?format=md"); StringAssert.Contains(report, "# Qualità dei dati"); StringAssert.Contains(report, "| alpaca | no |"); + + // The settings page says which source is off and why, and edits the central bank list. + var page = await server.TextAsync("/impostazioni"); + StringAssert.Contains(page, "Alpaca (azioni, conto di prova)"); + StringAssert.Contains(page, "mancano le chiavi del conto di prova Alpaca"); + StringAssert.Contains(page, "FED 2026-12-09"); + using (var wrong = await server.PostFormAsync("/impostazioni", "/azioni/impostazioni/calendar.central_banks", ("valore", "FED il 9 dicembre"), + ("ritorno", "/impostazioni#dati"))) + { + Assert.AreEqual("/impostazioni?errore=riunioni#dati", ServerHarness.Location(wrong)); + } + + using (var right = await server.PostFormAsync("/impostazioni", "/azioni/impostazioni/calendar.central_banks", ("valore", "FED 2027-01-27\r\nBCE 2027-02-04"), + ("ritorno", "/impostazioni#dati"))) + { + Assert.AreEqual("/impostazioni#dati", ServerHarness.Location(right)); + } + + StringAssert.Contains(await server.TextAsync("/impostazioni"), "BCE 2027-02-04"); } [TestMethod]