feat: implement Excel export functionality for monthly timesheets with template support
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
parent
0d5b48b891
commit
e872fe200b
13 changed files with 584 additions and 0 deletions
19
Program.cs
19
Program.cs
|
|
@ -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())
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue