Rifiniture (M8): avvisi su striscia, notifiche di Windows e Telegram con controllo dello spazio su disco; «Esporta l'elenco» della libreria; avvisi e ricette sospese in Attività; guida per il wiki in docs/guida
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
This commit is contained in:
50 files changed
+3980
-28
No files matched your search
@@ -1,5 +1,7 @@
|
||||
using System.Globalization;
|
||||
using System.Text.Json;
|
||||
using Febe.Core.Abstractions;
|
||||
using Febe.Core.Alerts;
|
||||
using Febe.Core.Domain;
|
||||
using Febe.Core.Engine;
|
||||
using Febe.Core.Storage;
|
||||
@@ -24,6 +26,9 @@ public static class ActivityApi
|
||||
endpoints.MapGet("/api/engine/incidents", async (IIncidentHistory history, IClock clock, CancellationToken ct) =>
|
||||
ApiHttp.Json(await IncidentsAsync(history, clock, ct).ConfigureAwait(false), FebeJsonContext.Default.IncidentListDto));
|
||||
|
||||
endpoints.MapGet("/api/alerts", async (IFebeStorage storage, IClock clock, CancellationToken ct) =>
|
||||
ApiHttp.Json(await AlertsAsync(storage, clock, ct).ConfigureAwait(false), FebeJsonContext.Default.AlertListDto));
|
||||
|
||||
endpoints.MapGet("/api/browser/preview", async (IBrowserPreview preview, CancellationToken ct) =>
|
||||
{
|
||||
var frame = await preview.GetLatestAsync(ct).ConfigureAwait(false);
|
||||
@@ -78,6 +83,37 @@ public static class ActivityApi
|
||||
return new IncidentListDto(dtos, throttles, advice);
|
||||
}
|
||||
|
||||
/// <summary>The alerts of the last <see cref="HistoryDays"/> days (at most 50), from the timeline.</summary>
|
||||
public static async Task<AlertListDto> AlertsAsync(IFebeStorage storage, IClock clock, CancellationToken ct)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(storage);
|
||||
ArgumentNullException.ThrowIfNull(clock);
|
||||
var now = clock.Now;
|
||||
var zone = clock.LocalZone;
|
||||
var events = await storage.Events.ListAsync(
|
||||
new EventQuery { From = now - TimeSpan.FromDays(HistoryDays), Codes = AlertCatalog.Codes, Limit = 50 },
|
||||
ct).ConfigureAwait(false);
|
||||
var items = events.Select(e =>
|
||||
{
|
||||
var kind = AlertCatalog.KindOf(e.Code);
|
||||
return new AlertItemDto(
|
||||
e.Id,
|
||||
ApiMapping.Local(e.At, now, zone),
|
||||
kind is { } k ? JsonNamingPolicy.CamelCase.ConvertName(k.ToString()) : "deliveryFailed",
|
||||
e.Severity switch
|
||||
{
|
||||
EventSeverity.Error => "error",
|
||||
EventSeverity.Warning => "warning",
|
||||
EventSeverity.Success => "success",
|
||||
_ => "info",
|
||||
},
|
||||
kind is { } known ? AlertCatalog.Title(known) : "Avviso non inviato",
|
||||
kind is { } alert ? AlertCatalog.FromEvent(alert, e, zone).Message : e.Message,
|
||||
e.AccountId);
|
||||
}).ToList();
|
||||
return new AlertListDto(items, HistoryDays);
|
||||
}
|
||||
|
||||
public static string Level(SignalLevel level) => level switch
|
||||
{
|
||||
SignalLevel.Throttle => "throttle",
|
||||
|
||||
@@ -39,6 +39,22 @@ public static class EngineApi
|
||||
return ApiHttp.Json(new ResumeDto(result.Resumed, result.Message), FebeJsonContext.Default.ResumeDto);
|
||||
});
|
||||
|
||||
// «Riattiva» a recipe suspended after three unknown formats (or targets not found) in a row.
|
||||
endpoints.MapPost("/api/engine/recipes/{recipe}/resume", async (string recipe, IEngineControl control, CancellationToken ct) =>
|
||||
{
|
||||
if (!Enum.TryParse<RecipeKind>(recipe, ignoreCase: true, out var kind) || !Enum.IsDefined(kind))
|
||||
{
|
||||
throw new BadRequestException("Ricetta sconosciuta.");
|
||||
}
|
||||
|
||||
var resumed = await control.ResumeRecipeAsync(kind, ct).ConfigureAwait(false);
|
||||
return ApiHttp.Json(
|
||||
new ResumeDto(resumed, resumed
|
||||
? "Ricetta riattivata: riprende alla prossima sessione. Se il formato è ancora sconosciuto, si sospende di nuovo dopo tre volte."
|
||||
: "Questa ricetta non era sospesa."),
|
||||
FebeJsonContext.Default.ResumeDto);
|
||||
});
|
||||
|
||||
// «Apri il browser» on Windows: the window of the browser comes to the front.
|
||||
endpoints.MapPost("/api/browser/show", async (IBrowserWindow browser, BrowserUseTracker tracker, IClock clock, CancellationToken ct) =>
|
||||
{
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace Febe.Web.Api;
|
||||
[JsonSerializable(typeof(BeginDrivingRequest))]
|
||||
[JsonSerializable(typeof(FinishDto))]
|
||||
[JsonSerializable(typeof(IncidentListDto))]
|
||||
[JsonSerializable(typeof(AlertListDto))]
|
||||
[JsonSerializable(typeof(BrowserPreviewDto))]
|
||||
[JsonSerializable(typeof(DuplicateCountsDto))]
|
||||
[JsonSerializable(typeof(GeneralSettingsDto))]
|
||||
|
||||
@@ -32,6 +32,16 @@ public sealed record IncidentDto(
|
||||
/// <param name="Advice">«Tre rallentamenti in sette giorni»: the proposal of spec §7.6, or null.</param>
|
||||
public sealed record IncidentListDto(IReadOnlyList<IncidentDto> Items, int ThrottlesLastWeek, string? Advice);
|
||||
|
||||
/// <summary>
|
||||
/// A line of the «Avvisi» list of Attività (spec §13.3): an alert or a failed delivery. <see cref="Kind"/>:
|
||||
/// verification, disconnection, throttleStop, throttleEnd, backfillDone, unknownFormat, recipeSuspended, diskLow,
|
||||
/// deliveryFailed. <see cref="Level"/>: error, warning, success, info.
|
||||
/// </summary>
|
||||
public sealed record AlertItemDto(long Id, LocalTimeDto At, string Kind, string Level, string Title, string Message, long? AccountId);
|
||||
|
||||
/// <summary><c>GET /api/alerts</c>: the alerts of the last <see cref="Days"/> days, newest first.</summary>
|
||||
public sealed record AlertListDto(IReadOnlyList<AlertItemDto> Items, int Days);
|
||||
|
||||
/// <summary>The preview of Febe's browser: <see cref="Frame"/> is the address of the JPEG (with a version), or null.</summary>
|
||||
public sealed record BrowserPreviewDto(bool HasFrame, string? Url, long? At, string? Frame);
|
||||
|
||||
|
||||
@@ -152,9 +152,9 @@ public static class SettingsApi
|
||||
}
|
||||
|
||||
var token = body.RemoveTelegramToken ? null : string.IsNullOrWhiteSpace(body.TelegramToken) ? stored.TelegramToken : body.TelegramToken.Trim();
|
||||
if (token is not null && (token.Length > 200 || token.Any(char.IsWhiteSpace)))
|
||||
if (token is not null && !TelegramClient.IsValidToken(token))
|
||||
{
|
||||
throw new BadRequestException("Il gettone del bot non è valido: copialo per intero dal messaggio di BotFather, senza spazi.");
|
||||
throw new BadRequestException("Il gettone del bot non è valido: copialo per intero dal messaggio di BotFather (cifre, due punti, poi una lunga serie di lettere), senza spazi.");
|
||||
}
|
||||
|
||||
var e = body.Events;
|
||||
@@ -186,7 +186,7 @@ public static class SettingsApi
|
||||
throw new BadRequestException("Scrivi il gettone del bot e l'identificativo della chat, salva, poi invia la prova.");
|
||||
}
|
||||
|
||||
var sender = d.Services.GetService(typeof(IAlertTestSender)) as IAlertTestSender ?? new TelegramNotAvailableYet();
|
||||
var sender = d.Services.GetService(typeof(IAlertTestSender)) as IAlertTestSender ?? new NoTelegramSender();
|
||||
var result = await sender.SendTelegramTestAsync(settings, ct).ConfigureAwait(false);
|
||||
return ApiHttp.Json(new AlertTestDto(result.Sent, result.Message), FebeJsonContext.Default.AlertTestDto);
|
||||
});
|
||||
@@ -522,7 +522,7 @@ public static class SettingsApi
|
||||
SystemApi.Capabilities(context, d.Options, d.Shell, d.Browser, d.Clock).Notifications,
|
||||
settings.TelegramChatId,
|
||||
!string.IsNullOrWhiteSpace(settings.TelegramToken),
|
||||
sender is not null and not TelegramNotAvailableYet);
|
||||
sender is not null and not NoTelegramSender);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------- Dati
|
||||
|
||||
@@ -492,6 +492,20 @@ public static class DemoSeeder
|
||||
withNews == 0 ? "Giro dei profili che segui: nessuna novità" : $"Giro dei profili che segui: {withNews} contenuti nuovi", null));
|
||||
}
|
||||
|
||||
// The alerts of the last days (Attività, «Avvisi»): the throttle of three days ago (as DemoIncidentHistory) and
|
||||
// its end, and the backfills completed in the last two weeks.
|
||||
var throttle = LocalCalendar.StartOfDay(today.AddDays(-3), zone) + TimeSpan.FromHours(18.4);
|
||||
var throttleEnd = throttle + TimeSpan.FromHours(1);
|
||||
events.Add(Event(throttle, EventSeverity.Warning, Core.Engine.EngineEventCodes.ThrottleStop,
|
||||
$"Instagram ha chiesto di rallentare (segnale http-429). Ho chiuso la sessione e mi fermo per 1 ora, fino {Core.Engine.ItalianText.AtDay(throttleEnd, throttle, zone)}. Poi i tetti restano dimezzati per 48 ore.", null));
|
||||
events.Add(Event(throttleEnd, EventSeverity.Info, Core.Engine.EngineEventCodes.ThrottleEnd,
|
||||
$"Fine del fermo per rallentamento. Riprendo con i tetti dimezzati fino {Core.Engine.ItalianText.AtDay(throttleEnd + TimeSpan.FromHours(48), throttleEnd, zone)}.", null));
|
||||
foreach (var (spec, account) in accounts.Where(a => a.Account.BackfillCompletedAt is { } done && done > now - TimeSpan.FromDays(14) && done < now))
|
||||
{
|
||||
events.Add(Event(account.BackfillCompletedAt!.Value, EventSeverity.Success, Core.Engine.EngineEventCodes.BackfillCompleted,
|
||||
$"Storico di @{account.Username} completato: {Core.Engine.ItalianText.Count(spec.Posts, "post", "post")} in libreria. Da ora lo tengo aggiornato.", account.Id));
|
||||
}
|
||||
|
||||
foreach (var e in events.OrderBy(e => e.At))
|
||||
{
|
||||
await storage.Events.AppendAsync(e, ct).ConfigureAwait(false);
|
||||
|
||||
@@ -26,6 +26,12 @@ public interface IEngineControl
|
||||
|
||||
/// <summary>Accounts were added, removed or changed: the engine brings its queue in step.</summary>
|
||||
Task NotifyAccountsChangedAsync(CancellationToken ct);
|
||||
|
||||
/// <summary>
|
||||
/// «Riattiva» a recipe suspended after three problems in a row (unknown formats, targets not found). False when it
|
||||
/// was not suspended or there is no engine.
|
||||
/// </summary>
|
||||
Task<bool> ResumeRecipeAsync(RecipeKind recipe, CancellationToken ct) => Task.FromResult(false);
|
||||
}
|
||||
|
||||
/// <summary>The commands of the interface on the real engine.</summary>
|
||||
@@ -41,6 +47,8 @@ public sealed class EngineHostControl(EngineHost host) : IEngineControl
|
||||
public Task RequestFollowingListAsync(CancellationToken ct) => host.RequestFollowingListAsync(ct);
|
||||
|
||||
public Task NotifyAccountsChangedAsync(CancellationToken ct) => host.NotifyAccountsChangedAsync(ct);
|
||||
|
||||
public Task<bool> ResumeRecipeAsync(RecipeKind recipe, CancellationToken ct) => host.ResumeRecipeAsync(recipe, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -68,7 +68,7 @@ public static class FebeWeb
|
||||
services.TryAddSingleton<IConnectionService, UnavailableConnectionService>();
|
||||
services.TryAddSingleton<IBrowserPreview, NoBrowserPreview>();
|
||||
services.TryAddSingleton<IIncidentHistory>(sp => new StoredIncidentHistory(sp.GetRequiredService<IFebeStorage>()));
|
||||
services.TryAddSingleton<IAlertTestSender, TelegramNotAvailableYet>();
|
||||
services.TryAddSingleton<IAlertTestSender, NoTelegramSender>();
|
||||
services.TryAddSingleton<IDataFolderChange, FixedDataFolder>();
|
||||
services.TryAddSingleton<FolderSizes>();
|
||||
services.TryAddSingleton<RebuildJob>();
|
||||
|
||||
@@ -17,7 +17,7 @@ Qui sotto le convenzioni per chi continua il lavoro (composizione di Server e De
|
||||
| `Library/` | `FebeLibrary` (archivio + disposizione, `HashIndex`, `DownloadDuplicates`), `LibraryChanges`, esportazione CSV, collegamenti a Instagram, nomi utente, `IDataFolderChange`, `FolderSizes`, `RebuildJob` |
|
||||
| `Connection/` | Contratto condiviso con il lato server del collegamento: `IConnectionService`, `IConfigurationProblems`, `PROTOCOLLO.md` (vista remota `/api/vista`); `UnavailableConnectionService` è il ripiego |
|
||||
| `Import/` | `ImportHub`: l'`ImportService` registrato dalla composizione, oppure uno costruito sulla libreria |
|
||||
| `Native/` | `INativeShell` (funzioni del sistema) e `IBrowserWindow` (finestra del browser), con le versioni «niente» |
|
||||
| `Native/` | `INativeShell` (funzioni del sistema) e `IBrowserWindow` (finestra del browser), con le versioni «niente»; `NativeShellAlertChannel`: le notifiche di Windows come canale degli avvisi |
|
||||
| `Demo/` | Modalità dimostrativa: dati finti coerenti, motore finto con scene, guscio finto |
|
||||
| `wwwroot/` | Interfaccia: HTML, CSS, moduli ES senza framework né build |
|
||||
|
||||
@@ -60,7 +60,7 @@ Tutti con un ripiego registrato con `TryAdd`; la composizione registra i propri
|
||||
| `IEngineSettingsControl` | `StoredEngineSettingsControl`: salva le impostazioni del motore nell'archivio | `new EngineHostSettingsControl(engineHost)`: le applica anche al motore che gira |
|
||||
| `IBrowserPreview` | `NoBrowserPreview` (nessuna anteprima) | Chi ha il browser: `GetLatestAsync` restituisce l'ultima schermata JPEG (`BrowserFrame`) con l'indirizzo |
|
||||
| `IIncidentHistory` | `StoredIncidentHistory` (dall'archivio) | Di solito nessuno |
|
||||
| `IAlertTestSender` (Core) | `TelegramNotAvailableYet`: nessun messaggio parte, la risposta lo dice | M8, l'invio vero dei messaggi Telegram |
|
||||
| `IAlertTestSender` (Core) | `NoTelegramSender`: nessun messaggio parte (dimostrazione, prove), la risposta lo dice | La composizione: `TelegramAlertChannel` (Core, `Alerts/Telegram.cs`), lo stesso canale che usa `AlertService` |
|
||||
| `IDataFolderChange` | `FixedDataFolder`: la cartella dei dati non si cambia dall'interfaccia | Desktop (M6): sposta la cartella al riavvio |
|
||||
| `ImportService` (Core) | `ImportHub` ne costruisce uno sulla libreria (Docker: solo sotto `FebeWebOptions.ImportRoot`, di serie `/importa`; desktop: qualsiasi cartella) | La composizione, se vuole opzioni diverse (ffmpeg, cartella sorgente) |
|
||||
|
||||
@@ -102,13 +102,15 @@ sono anche `day` (`aaaa-mm-gg`) e `clock` calcolati sul fuso di Febe.
|
||||
| `GET /api/library?cursor=&direction=older\|newer&limit=` | Una finestra di tessere, con `older`/`newer` per continuare; filtri `kind`, `accounts`, `from`, `to`, `provenance`, `q` |
|
||||
| `GET /api/library/tiles?ids=` | Tessere per chiave |
|
||||
| `GET /api/thumbnails/{chiave}`, `GET /api/media/{id}/file[?download=1]` | Miniature (immutabili) e file (con range) |
|
||||
| `GET /api/entries/{id}`, `POST /api/entries/delete`, `/export`, `/{id}/open-on-instagram`, `POST /api/media/show-in-folder` | Visualizzatore, eliminazione (`remember` o `allowReturn`), CSV |
|
||||
| `GET /api/entries/{id}`, `POST /api/entries/delete`, `/export`, `/{id}/open-on-instagram`, `POST /api/media/show-in-folder` | Visualizzatore, eliminazione (`remember` o `allowReturn`), CSV (`{ ids }` per la selezione, `{ query }` per il filtro della pagina: «Esporta l'elenco» nella riga degli strumenti) |
|
||||
| `GET /api/accounts`, `GET /api/accounts/{id}`, `GET /{id}/history` | Elenco con conteggi, scheda, cronologia |
|
||||
| `POST /api/accounts/{id}/plan`, `PUT /{id}/settings`, `POST /{id}/keep-updated`, `/pause`, `/resume`, `/check-now`, `/remove`, `/pick-folder`, `/open-on-instagram` | Impostazioni dell'account e comandi |
|
||||
| `GET /api/following`, `POST /api/following/read`, `POST /api/accounts/parse`, `POST /api/accounts` | Dialogo «Aggiungi account» |
|
||||
| `GET /accesso`, `POST /api/accesso`, `POST /api/uscita` | Accesso con password |
|
||||
| `GET /api/connection`, `POST /api/connection/begin` (`{ openLogin }`), `/finish`, `/cancel`, `/disconnect` | Collegamento a Instagram (`IConnectionService`, §6.4): stato `notConnected`, `connected`, `verificationRequired`, `browserUnavailable` |
|
||||
| `GET /api/engine/incidents` | Incidenti degli ultimi 14 giorni (rallentamenti, verifiche, arresti), con un consiglio dopo 3 rallentamenti in 7 giorni |
|
||||
| `POST /api/engine/recipes/{ricetta}/resume` | «Riattiva» una ricetta sospesa dopo tre problemi di fila (`IEngineControl.ResumeRecipeAsync`: metodo con un'implementazione predefinita che risponde «non era sospesa», così le altre implementazioni non cambiano). Attività mostra le ricette sospese da `snapshot.suspendedRecipes` |
|
||||
| `GET /api/alerts` | Avvisi degli ultimi 14 giorni (§13.3, sezione «Avvisi» di Attività): righe della cronologia con i codici di `AlertCatalog.Codes`, compresi gli avvisi non arrivati |
|
||||
| `GET /api/browser/preview`, `GET /api/browser/preview/frame` | Anteprima del browser in Attività: indirizzo e immagine JPEG (`no-store`, 404 se non c'è) |
|
||||
| `GET /api/duplicates/count`, `GET /api/duplicates?after=`, `POST /api/duplicates/{pairId}` (`{ decision, applyToAll }`) | Doppioni dopo uno scaricamento (§9.5): `keepLarger`, `keepExisting`, `keepBoth`; niente si decide da solo |
|
||||
| `GET/PUT /api/settings/general`, `POST /api/settings/naming-preview`, `/pick-folder`, `/data-folder` | Cartelle (cambio della libreria solo desktop), schema dei nomi con anteprima, tema, avvio, area di notifica |
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
using Febe.Core.Alerts;
|
||||
|
||||
namespace Febe.Web.Native;
|
||||
|
||||
/// <summary>
|
||||
/// Windows notifications as an alert channel (spec §12, §13.3): <see cref="INativeShell.NotifyAsync"/> with the title
|
||||
/// and the message of the alert. On when the shell can notify (the desktop) and «Notifiche di Windows» is on; in
|
||||
/// Docker <see cref="BrowserShell"/> cannot notify and the channel stays silent.
|
||||
/// </summary>
|
||||
public sealed class NativeShellAlertChannel(INativeShell shell) : IAlertChannel
|
||||
{
|
||||
private readonly INativeShell _shell = shell ?? throw new ArgumentNullException(nameof(shell));
|
||||
|
||||
public string Name => "notifica di Windows";
|
||||
|
||||
public bool IsEnabled(AlertSettings settings)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(settings);
|
||||
return _shell.CanNotify && settings.WindowsNotifications;
|
||||
}
|
||||
|
||||
public async Task<AlertDelivery> SendAsync(Alert alert, AlertSettings settings, CancellationToken ct)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(alert);
|
||||
try
|
||||
{
|
||||
await _shell.NotifyAsync(alert.Title, alert.Message, ct).ConfigureAwait(false);
|
||||
return AlertDelivery.Ok;
|
||||
}
|
||||
catch (OperationCanceledException) when (ct.IsCancellationRequested)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
return new AlertDelivery(false, $"Windows non ha mostrato la notifica ({ex.GetType().Name})");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -339,6 +339,13 @@ input[type=range].cursore::-webkit-slider-thumb{-webkit-appearance:none;width:16
|
||||
input[type=range].cursore::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:var(--superficie);border:1.5px solid var(--testo-2)}
|
||||
input[type=range].cursore:focus-visible{outline:2px solid var(--accento);outline-offset:3px}
|
||||
.grandezza{display:flex;align-items:center;gap:8px;color:var(--testo-2)}
|
||||
.btn.solo-icona{padding:0 8px}
|
||||
/* Libreria: when the tools do not fit in one row (a duplicates link, a narrow screen above 1000 px) the group on
|
||||
the right goes to a second row instead of squeezing the kind chips into a column. */
|
||||
@media (min-width:1001px){
|
||||
.strumenti:has(> div > .filtri){flex-wrap:wrap;row-gap:10px}
|
||||
.strumenti .filtri{flex-wrap:nowrap;flex-shrink:0}
|
||||
}
|
||||
|
||||
/* menu a comparsa */
|
||||
.menu{position:fixed;z-index:60;min-width:200px;max-width:340px;max-height:min(420px,70vh);overflow:auto;background:var(--superficie);border:1px solid var(--bordo);border-radius:var(--r-pannello);box-shadow:var(--ombra-menu);padding:6px}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// Attività (mockups 06 and 11, spec §7.9): what the engine is doing now with a still frame of the browser every few
|
||||
// seconds, the strip of the day, «Limiti di oggi» with the four main budgets and «Tutti i tetti», the queue with
|
||||
// «verso le» times, «Appena fatto» with the outcomes, and the stops of the last days. It updates by itself from the
|
||||
// event stream (the demo asks every 30 seconds). The red strip of a stop is drawn by the page frame.
|
||||
// «verso le» times, «Appena fatto» with the outcomes, the stops of the last days and the alerts (spec §13.3: also the
|
||||
// ones that are not stops, like a backfill completed or a disk almost full). It updates by itself from the event
|
||||
// stream (the demo asks every 30 seconds). The red strip of a stop is drawn by the page frame.
|
||||
|
||||
import { api, withCarried } from '../core/api.js';
|
||||
import { h, icon, fill } from '../core/dom.js';
|
||||
@@ -22,10 +23,12 @@ export default {
|
||||
const today = h('section.blocco');
|
||||
const budgets = h('section.blocco');
|
||||
const lists = h('div.due-colonne');
|
||||
const suspended = h('div');
|
||||
const incidents = h('section.blocco');
|
||||
const alerts = h('section.blocco', { hidden: true });
|
||||
// On this page «Riprendi» is in the title row: the red strip keeps only «Apri il browser» (mockup 11).
|
||||
page.root.dataset.pagina = 'attivita';
|
||||
fill(page.body, h('div.attivita', now, today, budgets, lists, notice, incidents));
|
||||
fill(page.body, h('div.attivita', now, suspended, today, budgets, lists, notice, incidents, alerts));
|
||||
|
||||
let latest = null;
|
||||
page.onEngine((state) => {
|
||||
@@ -35,17 +38,20 @@ export default {
|
||||
drawToday(today, state);
|
||||
drawBudgets(budgets, state);
|
||||
drawLists(lists, state);
|
||||
drawSuspended(suspended, state);
|
||||
preview.update(state);
|
||||
});
|
||||
|
||||
async function loadSide() {
|
||||
try {
|
||||
const [counts, history] = await Promise.all([
|
||||
const [counts, history, recent] = await Promise.all([
|
||||
api('/api/duplicates/count', { signal: page.signal }),
|
||||
api('/api/engine/incidents', { signal: page.signal }),
|
||||
api('/api/alerts', { signal: page.signal }),
|
||||
]);
|
||||
drawNotice(notice, counts);
|
||||
drawIncidents(incidents, history);
|
||||
drawAlerts(alerts, recent);
|
||||
} catch (error) {
|
||||
if (error.name !== 'AbortError') showError(error);
|
||||
}
|
||||
@@ -287,6 +293,56 @@ function drawNotice(box, counts) {
|
||||
h('a.btn.piccolo', { href: withCarried('/doppioni') }, t('attivita.decidi'))));
|
||||
}
|
||||
|
||||
/** Recipes suspended after three problems in a row (unknown formats, targets not found): what to do, «Riattiva». */
|
||||
function drawSuspended(box, state) {
|
||||
const items = state.snapshot.suspendedRecipes || [];
|
||||
if (!items.length) {
|
||||
box.replaceChildren();
|
||||
return;
|
||||
}
|
||||
fill(box, items.map((r) => h('div.avviso.rosso.avviso-azione', { style: { marginBottom: '10px' } },
|
||||
icon('octagon-alert', 's'),
|
||||
h('span', t('attivita.sospesa', { nome: r.name })),
|
||||
h('button.btn.piccolo', {
|
||||
type: 'button',
|
||||
onclick: async () => {
|
||||
try {
|
||||
const result = await api(`/api/engine/recipes/${encodeURIComponent(r.recipe)}/resume`, { method: 'POST' });
|
||||
toast(result.message, result.resumed ? '' : 'errore');
|
||||
refreshEngine();
|
||||
} catch (error) {
|
||||
showError(error);
|
||||
}
|
||||
},
|
||||
}, t('attivita.riattiva')))));
|
||||
}
|
||||
|
||||
const ALERT_LOOK = {
|
||||
error: { icon: 'octagon-alert', label: 'rosso' },
|
||||
warning: { icon: 'triangle-alert', label: 'ambra' },
|
||||
success: { icon: 'circle-check', label: 'verde' },
|
||||
info: { icon: 'bell', label: '' },
|
||||
};
|
||||
|
||||
/** «Avvisi»: every alert of the last days, the same ones Telegram and Windows get. Hidden while there are none. */
|
||||
function drawAlerts(box, recent) {
|
||||
const items = (recent && recent.items) || [];
|
||||
box.hidden = !items.length;
|
||||
if (!items.length) {
|
||||
box.replaceChildren();
|
||||
return;
|
||||
}
|
||||
fill(box,
|
||||
h('div.testa-blocco', h('h2', t('attivita.avvisi')), h('span.muto', t('attivita.avvisiAiuto', { giorni: recent.days }))),
|
||||
h('div.pannello', h('ul.elenco-attivita.largo', items.map((i) => {
|
||||
const look = ALERT_LOOK[i.level] || ALERT_LOOK.info;
|
||||
return h('li',
|
||||
h('span.quando.dati', capitalize(at(i.at))),
|
||||
h('div.chi-cosa', h('b', i.title), h('span', i.message)),
|
||||
label(t(`attivita.livelliAvviso.${i.level}`), look.label, look.icon));
|
||||
}))));
|
||||
}
|
||||
|
||||
function drawIncidents(box, history) {
|
||||
const items = history.items || [];
|
||||
fill(box,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Libreria (mockup 01, spec §4.6): every entry by publication day, filters by kind, account, period and provenance,
|
||||
// search by account name and caption, tile size, multiple selection to export or delete, viewer on click.
|
||||
// «Esporta l'elenco» in the tools row exports what the filter shows (spec §4.8: CSV with «;», UTF-8 with BOM).
|
||||
|
||||
import { api, download, withCarried } from '../core/api.js';
|
||||
import { caps } from '../core/context.js';
|
||||
@@ -91,6 +92,8 @@ export default {
|
||||
const size = local.get('libreria.tessere', 160);
|
||||
const slider = h('input.cursore', { type: 'range', min: '96', max: '300', step: '4', value: String(size), 'aria-label': t('libreria.grandezza') });
|
||||
const selectButton = h('button.btn', { type: 'button', 'aria-pressed': 'false' }, icon('circle-check'), h('span', t('libreria.seleziona')));
|
||||
// Icon only, like the tile size: the row of the mockup has no room for one more label.
|
||||
const exportButton = h('button.btn.nudo.piccolo.solo-icona.solo-largo', { type: 'button', title: t('libreria.esportaAiuto'), 'aria-label': t('libreria.esporta') }, icon('file-down'));
|
||||
// Probable duplicates after a download wait for Alberto (spec §9.5): a short link to their review.
|
||||
const duplicates = h('a.btn.nudo.piccolo.doppioni-link', { href: withCarried('/doppioni'), hidden: true });
|
||||
api('/api/duplicates/count', { signal: page.signal }).then((counts) => {
|
||||
@@ -104,6 +107,7 @@ export default {
|
||||
filtersButton,
|
||||
h('div.destra',
|
||||
duplicates,
|
||||
exportButton,
|
||||
h('div.grandezza.solo-largo', { title: t('libreria.grandezza') }, icon('grid-3x3', 's'), slider, icon('square', 's')),
|
||||
selectButton)));
|
||||
|
||||
@@ -287,6 +291,7 @@ export default {
|
||||
}
|
||||
|
||||
selectButton.addEventListener('click', () => setSelecting(!mosaic.selecting));
|
||||
exportButton.addEventListener('click', () => exportFiltered());
|
||||
|
||||
async function exportSelected() {
|
||||
try {
|
||||
@@ -297,6 +302,18 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
async function exportFiltered() {
|
||||
exportButton.disabled = true;
|
||||
try {
|
||||
await download('/api/entries/export', { query: apiQuery(state, today()) }, 'febe-elementi.csv');
|
||||
toast(t(filtersActive() ? 'libreria.esportatoFiltro' : 'libreria.esportato'));
|
||||
} catch (error) {
|
||||
showError(error);
|
||||
} finally {
|
||||
exportButton.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteSelected() {
|
||||
const ids = [...mosaic.selected];
|
||||
const removed = await confirmDelete(ids);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Impostazioni, Notifiche (spec §13.3): which events notify, Windows notifications (desktop only), Telegram with the
|
||||
// bot token (masked, never shown again once saved, never logged) and the chat identifier, and «Invia una prova».
|
||||
// The Telegram sender arrives with milestone M8: until then the server answers plainly that nothing was sent.
|
||||
// Telegram: one HTTPS call from the server (TelegramAlertChannel); where no sender is registered (demonstration) the
|
||||
// page says that no message leaves.
|
||||
|
||||
import { api } from '../core/api.js';
|
||||
import { h, icon, fill } from '../core/dom.js';
|
||||
|
||||
@@ -131,6 +131,10 @@
|
||||
"nessunoTesto": "Cambia o togli un filtro per vedere altro.",
|
||||
"togliFiltri": "Togli i filtri",
|
||||
"doppioni": "1 doppione da decidere|{n} doppioni da decidere",
|
||||
"esporta": "Esporta l'elenco",
|
||||
"esportaAiuto": "Esporta l'elenco: un file CSV con gli elementi mostrati dai filtri di adesso, che si apre in Excel",
|
||||
"esportato": "Elenco esportato: il file CSV è nei download del browser.",
|
||||
"esportatoFiltro": "Elenco degli elementi filtrati esportato: il file CSV è nei download del browser.",
|
||||
"tessera": "{tipo} di @{account}, {quando}",
|
||||
"tesseraFile": "{n} file",
|
||||
"tesseraDurata": "video di {durata}",
|
||||
@@ -530,6 +534,11 @@
|
||||
"aperto": "In corso",
|
||||
"risolto": "Risolto {quando}",
|
||||
"fermoFino": "Fermo fino {quando}",
|
||||
"avvisi": "Avvisi",
|
||||
"sospesa": "«{nome}» è sospeso: tre risposte di fila in un formato non riconosciuto, o un comando non trovato nella pagina. Instagram potrebbe essere cambiato: serve un campione nuovo con la sonda (guida, «Problemi comuni»), poi riattivalo.",
|
||||
"riattiva": "Riattiva",
|
||||
"avvisiAiuto": "Gli ultimi {giorni} giorni: gli stessi che arrivano su Telegram e nelle notifiche, se li hai attivati in Impostazioni, Notifiche.",
|
||||
"livelliAvviso": { "error": "Fermo", "warning": "Attenzione", "success": "Fatto", "info": "Informazione" },
|
||||
"doppioni": "1 doppione probabile dopo gli ultimi scaricamenti aspetta la tua scelta.|{n} doppioni probabili dopo gli ultimi scaricamenti aspettano la tua scelta.",
|
||||
"decidi": "Decidi",
|
||||
"chiesto": "Chiesto da te"
|
||||
@@ -721,7 +730,7 @@
|
||||
"soloWindows": "Solo versione Windows",
|
||||
"prova": "Invia una prova",
|
||||
"telegram": "Telegram",
|
||||
"telegramAiuto": "Facoltativo. Crea un bot con BotFather, scrivigli un messaggio, poi copia qui il suo gettone e l'identificativo della chat.",
|
||||
"telegramAiuto": "Facoltativo. Crea un bot con BotFather, scrivigli un messaggio, poi copia qui il suo gettone e l'identificativo della chat: la guida, alla pagina «Avvisi e Telegram», spiega come.",
|
||||
"gettone": "Gettone del bot",
|
||||
"gettoneSalvato": "Gettone salvato: per cambiarlo scrivine uno nuovo",
|
||||
"gettoneVuoto": "Incolla il gettone di BotFather",
|
||||
@@ -730,7 +739,7 @@
|
||||
"chat": "Identificativo della chat",
|
||||
"chatEsempio": "Per esempio 123456789",
|
||||
"gettoneNota": "Il gettone resta nella cartella dei dati di Febe: non finisce nei registri e non viene più mostrato.",
|
||||
"nonAncora": "L'invio dei messaggi Telegram arriva con una prossima versione di Febe: per ora le impostazioni si salvano soltanto."
|
||||
"nonAncora": "Questa istanza di Febe non invia messaggi Telegram (dimostrazione o prova): le impostazioni si salvano soltanto."
|
||||
},
|
||||
"dati": {
|
||||
"cartella": "Cartella dei dati",
|
||||
|
||||
Reference in new issue
Block a user