feat: implement Excel export functionality for monthly timesheets with template support

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Marco 2026-04-24 10:45:44 +02:00
commit e872fe200b
13 changed files with 584 additions and 0 deletions

View file

@ -13,6 +13,7 @@ using WorkTracker.Components;
using WorkTracker.Configuration;
using WorkTracker.Services.Auth;
using WorkTracker.Services.Festivities;
using WorkTracker.Services.Exports;
using WorkTracker.Services.Settings;
using WorkTracker.Services.Storage;
using WorkTracker.Services.WorkDays;
@ -74,6 +75,8 @@ builder.Services.AddScoped<IAppSettingsService, CouchbaseLiteAppSettingsService>
builder.Services.AddScoped<AppThemeState>();
builder.Services.AddSingleton<IAuthService, CouchbaseLiteAuthService>();
builder.Services.AddSingleton<IItalianFestivitySource, ItalianFestivitySource>();
builder.Services.AddSingleton<IMonthlyTimesheetExcelExporter, MonthlyTimesheetExcelExporter>();
builder.Services.AddScoped<IMonthlyTimesheetExcelExportService, MonthlyTimesheetExcelExportService>();
builder.Services.AddScoped<IWorkDayService, CouchbaseLiteWorkDayService>();
builder.Services.AddHostedService<SingleUserSeedService>();
@ -245,6 +248,22 @@ app.MapGet("/healthz", [AllowAnonymous] (HttpContext context, IOptions<AppAuthOp
});
});
app.MapGet("/api/monthly-timesheet/{year:int}/{month:int}/excel", async (
int year,
int month,
bool includePreview,
IMonthlyTimesheetExcelExportService exportService,
CancellationToken cancellationToken) =>
{
if (month is < 1 or > 12)
{
return Results.BadRequest("Month must be between 1 and 12.");
}
var file = await exportService.ExportAsync(year, month, includePreview, cancellationToken);
return Results.File(file.Content, file.ContentType, file.FileName);
}).RequireAuthorization();
// Development-only endpoint to reset the seeded Admin password (protected by secret in URL)
if (app.Environment.IsDevelopment())
{