web: seznam Moje hlášení

Závady nahlášené přihlášeným uživatelem od nejnovějších: filtr podle stavu,
stránkování, štítky stavů, kategorie a místo z číselníků a čas v českém
pásmu. Položka v menu a site.js pro automatické odeslání filtru (bez
inline skriptů kvůli CSP).

Refs #22
This commit is contained in:
PatTheEvil committed 2026-12-02 13:50:01 +01:00
1 parent 6208fd3baf
commit 2fe939ba5c
10 files changed
+217

No files matched your search

+18
View File
@@ -45,3 +45,21 @@ public sealed record ForgotPasswordRequest(string Email);
public sealed record ResetPasswordRequest(string Token, string NewPassword);
public sealed record UpdateProfileRequest(string FirstName, string LastName, string? Phone, bool EmailNotificationsEnabled);
/// <summary>Stránkovaný seznam z API: <c>{ items, totalCount, page, pageSize }</c>.</summary>
public sealed record PagedResult<T>(IReadOnlyList<T> Items, int TotalCount, int Page, int PageSize)
{
public int PageCount => PageSize <= 0 ? 0 : (int)Math.Ceiling(TotalCount / (double)PageSize);
}
public sealed record CategoryDto(int Id, string Name, string? Description, bool IsActive);
public sealed record BuildingDto(int Id, string Code, string Name, string? Address, bool IsActive);
/// <summary>Závada v seznamu. Kategorie a budova jsou jen ID – názvy doplňuje web z číselníků.</summary>
public sealed record IssueSummary(
int Id, string Title, int CategoryId, int? BuildingId, string? LocationDetail, string Status,
string Priority, int ReporterId, int? AssigneeId, DateTimeOffset CreatedAt);
/// <summary>Filtry <c>GET /api/v1/issues</c>; prázdné hodnoty se do dotazu neposílají.</summary>
public sealed record IssueListQuery(string? Status = null, bool Mine = false, string Sort = "newest", int Page = 1, int PageSize = 20);
+28
View File
@@ -1,4 +1,6 @@
using System.Globalization;
using System.Net.Http.Json;
using Microsoft.AspNetCore.WebUtilities;
namespace Helpdesk.Web.Api;
@@ -17,6 +19,32 @@ public sealed class HelpdeskApiClient(HttpClient http)
return await ApiResponse.ReadAsync<UserDto>(response, ct);
}
public async Task<PagedResult<IssueSummary>> GetIssuesAsync(IssueListQuery query, CancellationToken ct)
{
var parameters = new Dictionary<string, string?>
{
["status"] = query.Status,
["mine"] = query.Mine ? "true" : null,
["sort"] = query.Sort,
["page"] = query.Page.ToString(CultureInfo.InvariantCulture),
["pageSize"] = query.PageSize.ToString(CultureInfo.InvariantCulture),
};
using var response = await http.GetAsync(QueryHelpers.AddQueryString("api/v1/issues", parameters.Where(p => !string.IsNullOrEmpty(p.Value))), ct);
return await ApiResponse.ReadAsync<PagedResult<IssueSummary>>(response, ct);
}
public async Task<IReadOnlyList<CategoryDto>> GetIssueCategoriesAsync(CancellationToken ct)
{
using var response = await http.GetAsync("api/v1/issue-categories", ct);
return await ApiResponse.ReadAsync<List<CategoryDto>>(response, ct);
}
public async Task<IReadOnlyList<BuildingDto>> GetBuildingsAsync(CancellationToken ct)
{
using var response = await http.GetAsync("api/v1/buildings", ct);
return await ApiResponse.ReadAsync<List<BuildingDto>>(response, ct);
}
/// <summary>Odhlásí ze všech zařízení – API zneplatní všechny tokeny uživatele.</summary>
public async Task LogoutAllAsync(CancellationToken ct)
{