PDFs erzeugen

This commit is contained in:
MarcWieland
2026-06-26 22:41:23 +02:00
parent 42a97a36b4
commit 4a69095f30
7 changed files with 635 additions and 0 deletions
@@ -9,6 +9,7 @@
@inject IUserNotificationService UserNotificationService
@inject HttpClient Http
@inject IDialogService DialogService
@inject NavigationManager NavigationManager
@implements IDisposable
<PageTitle>Benutzerverwaltung Timetracker</PageTitle>
@@ -131,6 +132,12 @@ else
Size="Size.Small"
OnClick="@(() => OpenResetPasswordDialog(context))" />
</MudTooltip>
<MudTooltip Text="Stundenzettel (PDF) herunterladen">
<MudIconButton Icon="@Icons.Material.Filled.PictureAsPdf"
Color="Color.Info"
Size="Size.Small"
OnClick="@(() => DownloadUserPdf(context))" />
</MudTooltip>
@if (context.Username != "marc")
{
<MudIconButton Icon="@Icons.Material.Filled.DeleteOutline"
@@ -297,4 +304,19 @@ else
}
}
}
private async Task DownloadUserPdf(User user)
{
var options = new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall, FullWidth = true };
var dialog = await DialogService.ShowAsync<MonthSelectorDialog>($"Stundenzettel für {user.Username}", options);
var result = await dialog.Result;
if (result != null && !result.Canceled && result.Data is MonthSelectorDialog.MonthSelectorResult data)
{
int year = data.Year;
int month = data.Month;
NavigationManager.NavigateTo($"api/tracker/export/month/pdf?userId={user.Id}&year={year}&month={month}", forceLoad: true);
}
}
}
@@ -33,6 +33,10 @@ else
</MudText>
</MudStack>
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="0">
<MudTooltip Text="Stundenzettel (PDF) herunterladen">
<MudIconButton Icon="@Icons.Material.Filled.PictureAsPdf"
Style="color: var(--mud-palette-primary-text)" OnClick="ExportMonthPdf" />
</MudTooltip>
<MudTooltip Text="Monat als Excel exportieren">
<MudIconButton Icon="@Icons.Material.Filled.Download"
Style="color: var(--mud-palette-primary-text)" OnClick="ExportMonthExcel" />
@@ -333,6 +337,11 @@ else
NavigationManager.NavigateTo($"api/tracker/export/month?year={_year}&month={_month}", forceLoad: true);
}
private void ExportMonthPdf()
{
NavigationManager.NavigateTo($"api/tracker/export/month/pdf?userId={_userId}&year={_year}&month={_month}", forceLoad: true);
}
private static string FormatTs(TimeSpan ts, bool sign = false)
{
var neg = ts < TimeSpan.Zero;