Files
Heimdall/src/Heimdall.Web/Components/Pages/NotificationsPage.razor
T
arnaud.dartois e042b832d8
Heimdall Gitea / Detect CI scope (push) Successful in 6s
Heimdall Gitea / Build and tests (push) Successful in 26m44s
Heimdall Gitea / Publish versioned release (push) Skipped
Heimdall Gitea / Build and scan server image (push) Successful in 7m47s
Heimdall Gitea / Build and scan agent image (push) Successful in 11m47s
Heimdall Gitea / Publish Docker Hub latest tags (push) Successful in 2m3s
Heimdall Gitea / Build and scan NVIDIA Agent image (push) Successful in 17m11s
Heimdall Gitea / CI policy (push) Successful in 2s
fix(web): open a notification center from the header (#307)
## Résumé
La cloche du bandeau ouvre `/notifications`, qui affiche les notifications du compte courant et permet leur lecture individuelle ou globale.

Closes #302

## Validation
- `dotnet restore tests/Heimdall.Web.Tests/Heimdall.Web.Tests.csproj --locked-mode` : réussi.
- Tests bUnit ciblés `NotificationsPageTests` : 2/2 réussis; suite Web Release : 438/438 réussis avant merge concurrent de `main`.
- Build Web Release : 0 avertissement, 0 erreur avant le merge concurrent.
- Compose jetable `heimdall-notifications-acceptance-20261108140737-223989` : événement synthétique, isolation Admin/Viewer, lecture simple/globale, refus anonyme et compteur 0 vérifiés via API.
- Navigateur Orca : clic de la cloche depuis `/profile`, contenu et badge sur `/notifications`, lecture simple et état vide Viewer vérifiés. `/events` n’a pas été chargé.
- Nettoyage vérifié : conteneurs/volumes/réseaux absents et tags exacts supprimés pour les projets jetables. Voir le commentaire de l’issue pour les noms et tags.
- Après merge concurrent de `main`, deux reruns locaux ont échoué par manque de ressources (`Out of memory`), pas par échec de test. CI du commit courant à surveiller avant fusion.

Reviewed-on: #307
Co-authored-by: Arnaud Dartois <admin@tordais.cc>
2026-11-08 18:57:33 +01:00

89 lines
2.6 KiB
Plaintext

@page "/notifications"
@using Heimdall.Application.DTOs
@attribute [Authorize]
@layout MainLayout
@inject HeimdallApiClient Api
@inject NotificationsHubClient Hub
@inject UiText Text
@inject ISnackbar Snackbar
<MudText Typo="Typo.h1" Class="mb-4">@Text["NotificationsPage_Title"]</MudText>
@if (_loading)
{
<MudProgressLinear Indeterminate="true" />
}
else if (_failed)
{
<MudAlert Severity="Severity.Error">@Text["NotificationsPage_Failed"]</MudAlert>
}
else if (_items.Count == 0)
{
<MudAlert Severity="Severity.Info">@Text["NotificationsPage_Empty"]</MudAlert>
}
else
{
<div class="d-flex justify-end mb-3">
<MudButton Variant="Variant.Outlined" Disabled="@(!_items.Any(x => !x.IsRead))" OnClick="MarkAllReadAsync">
@Text["NotificationsPage_MarkAllRead"]
</MudButton>
</div>
@foreach (var item in _items)
{
<MudPaper Class="pa-4 mb-2" Elevation="1">
<div class="d-flex justify-space-between align-start">
<div>
<MudText Typo="Typo.h6">@item.Title</MudText>
<MudText>@item.Message</MudText>
<MudText Typo="Typo.caption" Color="Color.Secondary">@item.CreatedAt.ToLocalTime().ToString("g")</MudText>
</div>
@if (!item.IsRead)
{
<MudButton Variant="Variant.Text" OnClick="@(() => MarkReadAsync(item.Id))">@Text["NotificationsPage_MarkRead"]</MudButton>
}
</div>
</MudPaper>
}
}
@code {
private List<NotificationDto> _items = [];
private bool _loading = true;
private bool _failed;
protected override async Task OnInitializedAsync() => await LoadAsync();
private async Task LoadAsync()
{
_loading = true;
_failed = false;
try
{
var result = await Api.GetNotificationsAsync();
_items = result?.Items.ToList() ?? [];
_failed = result is null;
}
catch (HttpRequestException) { _failed = true; }
finally { _loading = false; }
}
private async Task MarkReadAsync(Guid id)
{
if (await Api.MarkNotificationAsReadAsync(id))
{
await LoadAsync();
await Hub.RefreshUnreadCountAsync();
}
else Snackbar.Add(Text["NotificationsPage_UpdateFailed"], Severity.Error);
}
private async Task MarkAllReadAsync()
{
if (await Api.MarkAllNotificationsAsReadAsync())
{
await LoadAsync();
await Hub.RefreshUnreadCountAsync();
}
else Snackbar.Add(Text["NotificationsPage_UpdateFailed"], Severity.Error);
}
}