@using LANCommander.Server.Models @using LANCommander.UI.Services @inject UploadTracker UploadTracker @inject IMessageService MessageService @inject INotificationService NotificationService @inject ModalService ModalService @implements IDisposable @if (UploadTracker.ActiveUploads.Any()) {
@foreach (var upload in UploadTracker.ActiveUploads.Values.ToList()) {
@upload.FileName @if (upload.Status == UploadStatus.Complete && upload.Type == UploadType.Import && !string.IsNullOrEmpty(upload.CompletedObjectKey)) {
}
Uploads
} @code { bool _popoverVisible; NotificationRef? _activeNotificationRef; int ActiveCount => UploadTracker.ActiveUploads.Values.Count(u => u.Status == UploadStatus.Uploading); protected override void OnInitialized() { UploadTracker.OnStateChanged += HandleStateChanged; UploadTracker.OnUploadCompleted += HandleUploadCompleted; } private void HandleStateChanged() { InvokeAsync(StateHasChanged); } private async Task HandleUploadCompleted(BackgroundUploadInfo info) { if (info.Type == UploadType.Import && !string.IsNullOrEmpty(info.CompletedObjectKey)) { var objectKey = info.CompletedObjectKey; var notificationKey = $"import-ready-{objectKey}"; var config = new NotificationConfig { Key = notificationKey, Message = "Import Ready", Description = $"\"{info.FileName}\" has finished uploading and is ready to import.", Duration = 0, NotificationType = NotificationType.Success, Btn = CreateImportNotificationButton(objectKey, notificationKey), }; _activeNotificationRef = await NotificationService.Open(config); } else if (info.Type == UploadType.Archive) { MessageService.Success($"\"{info.FileName}\" uploaded successfully!"); } } private RenderFragment CreateImportNotificationButton(string objectKey, string notificationKey) => builder => { builder.OpenComponent