mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-01 22:01:10 +00:00
Adds real time media libraries scan progress update via SignalR
This commit is contained in:
1 parent
d70b2dcaa0
commit
e0d61802df
71 files changed
+1292
-131
No files matched your search
+4
-1
@@ -18,10 +18,13 @@ public static class MediaLibraryScanProgressMapping
|
||||
public static MediaLibraryScanProgressResponse ToResponse(this MediaLibraryScanProgress domainValueObject)
|
||||
{
|
||||
return new MediaLibraryScanProgressResponse(
|
||||
domainValueObject.ScanId.Value,
|
||||
domainValueObject.UserId.Value,
|
||||
domainValueObject.LibraryId.Value,
|
||||
domainValueObject.TotalJobs,
|
||||
domainValueObject.CompletedJobs,
|
||||
domainValueObject.CurrentJobProgress.Value?.ToResponse(),
|
||||
domainValueObject.Status,
|
||||
domainValueObject.Status.ToString(),
|
||||
domainValueObject.OverallProgressPercentage
|
||||
);
|
||||
}
|
||||
|
||||
+9
-2
@@ -4,6 +4,7 @@ using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Progress;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Exceptions;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate;
|
||||
@@ -20,14 +21,17 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Events;
|
||||
/// </summary>
|
||||
public class LibraryScanFailedDomainEventHandler : INotificationHandler<LibraryScanFailedDomainEvent>
|
||||
{
|
||||
private readonly IMediaLibraryScanProgressNotifier _debouncedLibraryScanProgressNotifier;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LibraryScanCancelledDomainEventHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="unitOfWork">Injected unit of work for interacting with the data access layer repositories.</param>
|
||||
public LibraryScanFailedDomainEventHandler(IUnitOfWork unitOfWork)
|
||||
/// <param name="debouncedLibraryScanProgressNotifier">Injected service for notifying media libraries scan progress changes to third parties.</param>
|
||||
public LibraryScanFailedDomainEventHandler(IMediaLibraryScanProgressNotifier debouncedLibraryScanProgressNotifier, IUnitOfWork unitOfWork)
|
||||
{
|
||||
_debouncedLibraryScanProgressNotifier = debouncedLibraryScanProgressNotifier;
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
@@ -41,7 +45,8 @@ public class LibraryScanFailedDomainEventHandler : INotificationHandler<LibraryS
|
||||
ILibraryScanRepository libraryScanRepository = _unitOfWork.GetRepository<ILibraryScanRepository>();
|
||||
|
||||
// get the library scan from the repository
|
||||
ErrorOr<LibraryScanEntity?> getLibraryScansResult = await libraryScanRepository.GetByIdAsync(domainEvent.ScanId.Value, cancellationToken).ConfigureAwait(false);
|
||||
ErrorOr<LibraryScanEntity?> getLibraryScansResult = await libraryScanRepository.GetByIdAsync(
|
||||
domainEvent.MediaLibraryScanCompositeId.ScanId.Value, cancellationToken).ConfigureAwait(false);
|
||||
if (getLibraryScansResult.IsError)
|
||||
throw new EventualConsistencyException(getLibraryScansResult.FirstError, getLibraryScansResult.Errors);
|
||||
if (getLibraryScansResult.Value is null)
|
||||
@@ -64,6 +69,8 @@ public class LibraryScanFailedDomainEventHandler : INotificationHandler<LibraryS
|
||||
throw new EventualConsistencyException(updateLibraryScanResult.FirstError, updateLibraryScanResult.Errors);
|
||||
|
||||
await _unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
|
||||
// notify SignalR clients that the library scan failed
|
||||
await _debouncedLibraryScanProgressNotifier.SendLibraryScanFailedEventAsync(domainEvent.MediaLibraryScanCompositeId, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-5
@@ -4,13 +4,13 @@ using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Progress;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Exceptions;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Cancellation;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Progress;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Mediator;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -25,6 +25,7 @@ public class LibraryScanFinishedDomainEventHandler : INotificationHandler<Librar
|
||||
{
|
||||
private readonly IMediaLibrariesScanProgressTracker _mediaLibrariesScanProgressTracker;
|
||||
private readonly IMediaLibrariesScanCancellationTracker _mediaLibrariesScanCancellationTracker;
|
||||
private readonly IMediaLibraryScanProgressNotifier _debouncedLibraryScanProgressNotifier;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
/// <summary>
|
||||
@@ -32,14 +33,17 @@ public class LibraryScanFinishedDomainEventHandler : INotificationHandler<Librar
|
||||
/// </summary>
|
||||
/// <param name="mediaLibrariesScanProgressTracker">Injected service for tracking the progress of media library scans.</param>
|
||||
/// <param name="mediaLibrariesScanCancellationTracker">Injected tracker used for canceling media library scans.</param>
|
||||
/// <param name="debouncedLibraryScanProgressNotifier">Injected service for notifying media libraries scan progress changes to third parties.</param>
|
||||
/// <param name="unitOfWork">Injected unit of work for interacting with the data access layer repositories.</param>
|
||||
public LibraryScanFinishedDomainEventHandler(
|
||||
IMediaLibrariesScanProgressTracker mediaLibrariesScanProgressTracker,
|
||||
IMediaLibrariesScanCancellationTracker mediaLibrariesScanCancellationTracker,
|
||||
IMediaLibraryScanProgressNotifier debouncedLibraryScanProgressNotifier,
|
||||
IUnitOfWork unitOfWork)
|
||||
{
|
||||
_mediaLibrariesScanProgressTracker = mediaLibrariesScanProgressTracker;
|
||||
_mediaLibrariesScanCancellationTracker = mediaLibrariesScanCancellationTracker;
|
||||
_debouncedLibraryScanProgressNotifier = debouncedLibraryScanProgressNotifier;
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
@@ -53,7 +57,8 @@ public class LibraryScanFinishedDomainEventHandler : INotificationHandler<Librar
|
||||
ILibraryScanRepository libraryScanRepository = _unitOfWork.GetRepository<ILibraryScanRepository>();
|
||||
|
||||
// get the library scan from the repository
|
||||
ErrorOr<LibraryScanEntity?> getLibraryScansResult = await libraryScanRepository.GetByIdAsync(domainEvent.ScanId.Value, cancellationToken).ConfigureAwait(false);
|
||||
ErrorOr<LibraryScanEntity?> getLibraryScansResult = await libraryScanRepository.GetByIdAsync(
|
||||
domainEvent.MediaLibraryScanCompositeId.ScanId.Value, cancellationToken).ConfigureAwait(false);
|
||||
if (getLibraryScansResult.IsError)
|
||||
throw new EventualConsistencyException(getLibraryScansResult.FirstError, getLibraryScansResult.Errors);
|
||||
if (getLibraryScansResult.Value is null)
|
||||
@@ -76,8 +81,11 @@ public class LibraryScanFinishedDomainEventHandler : INotificationHandler<Librar
|
||||
|
||||
await _unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// mark the scan progress as completed, and remove its cancellation tracking
|
||||
_mediaLibrariesScanProgressTracker.UpdateScanProgress(MediaLibraryScanCompositeId.Create(domainEvent.ScanId, domainEvent.UserId));
|
||||
_mediaLibrariesScanCancellationTracker.RemoveScan(MediaLibraryScanCompositeId.Create(domainEvent.ScanId, domainEvent.UserId));
|
||||
// mark the scan progress as finished
|
||||
_mediaLibrariesScanProgressTracker.UpdateScanProgress(libraryScanDomainResult.Value.LibraryId, domainEvent.MediaLibraryScanCompositeId);
|
||||
// notify SignalR clients that the library scan finished
|
||||
await _debouncedLibraryScanProgressNotifier.SendLibraryScanFinishedEventAsync(domainEvent.MediaLibraryScanCompositeId, cancellationToken).ConfigureAwait(false);
|
||||
// only when everything is done, this needs to be called in order to dispose cancellation token sources, etc
|
||||
_mediaLibrariesScanCancellationTracker.RemoveScan(domainEvent.MediaLibraryScanCompositeId);
|
||||
}
|
||||
}
|
||||
+10
-4
@@ -1,7 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Progress;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Progress;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Mediator;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -15,14 +15,19 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Events;
|
||||
public class LibraryScanJobProgressChangedDomainEventHandler : INotificationHandler<LibraryScanJobProgressChangedDomainEvent>
|
||||
{
|
||||
private readonly IMediaLibrariesScanProgressTracker _mediaLibrariesScanProgressTracker;
|
||||
private readonly IMediaLibraryScanProgressNotifier _debouncedLibraryScanProgressNotifier;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LibraryScanJobProgressChangedDomainEventHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibrariesScanProgressTracker">Injected tracker used for media library scans progress.</param>
|
||||
public LibraryScanJobProgressChangedDomainEventHandler(IMediaLibrariesScanProgressTracker mediaLibrariesScanProgressTracker)
|
||||
/// <param name="debouncedLibraryScanProgressNotifier">Injected service for notifying media libraries scan progress changes to third parties.</param>
|
||||
public LibraryScanJobProgressChangedDomainEventHandler(
|
||||
IMediaLibrariesScanProgressTracker mediaLibrariesScanProgressTracker,
|
||||
IMediaLibraryScanProgressNotifier debouncedLibraryScanProgressNotifier)
|
||||
{
|
||||
_mediaLibrariesScanProgressTracker = mediaLibrariesScanProgressTracker;
|
||||
_debouncedLibraryScanProgressNotifier = debouncedLibraryScanProgressNotifier;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -32,7 +37,8 @@ public class LibraryScanJobProgressChangedDomainEventHandler : INotificationHand
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public async ValueTask Handle(LibraryScanJobProgressChangedDomainEvent domainEvent, CancellationToken cancellationToken)
|
||||
{
|
||||
_mediaLibrariesScanProgressTracker.UpdateScanJobProgress(MediaLibraryScanCompositeId.Create(domainEvent.ScanId, domainEvent.UserId), domainEvent.Progress);
|
||||
await Task.CompletedTask;
|
||||
_mediaLibrariesScanProgressTracker.UpdateScanJobProgress(domainEvent.LibraryId, domainEvent.MediaLibraryScanCompositeId, domainEvent.Progress);
|
||||
// notify SignalR clients that the library scan progress changed
|
||||
await _debouncedLibraryScanProgressNotifier.SendLibraryProgressUpdateEventAsync(domainEvent.MediaLibraryScanCompositeId, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
+10
-4
@@ -1,7 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Progress;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Progress;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Mediator;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -15,14 +15,19 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Events;
|
||||
public class LibraryScanProgressChangedDomainEventHandler : INotificationHandler<LibraryScanProgressChangedDomainEvent>
|
||||
{
|
||||
private readonly IMediaLibrariesScanProgressTracker _mediaLibrariesScanProgressTracker;
|
||||
private readonly IMediaLibraryScanProgressNotifier _debouncedLibraryScanProgressNotifier;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LibraryScanProgressChangedDomainEventHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibrariesScanProgressTracker">Injected tracker used for media library scans progress.</param>
|
||||
public LibraryScanProgressChangedDomainEventHandler(IMediaLibrariesScanProgressTracker mediaLibrariesScanProgressTracker)
|
||||
/// <param name="debouncedLibraryScanProgressNotifier">Injected service for notifying media libraries scan progress changes to third parties.</param>
|
||||
public LibraryScanProgressChangedDomainEventHandler(
|
||||
IMediaLibrariesScanProgressTracker mediaLibrariesScanProgressTracker,
|
||||
IMediaLibraryScanProgressNotifier debouncedLibraryScanProgressNotifier)
|
||||
{
|
||||
_mediaLibrariesScanProgressTracker = mediaLibrariesScanProgressTracker;
|
||||
_debouncedLibraryScanProgressNotifier = debouncedLibraryScanProgressNotifier;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -32,7 +37,8 @@ public class LibraryScanProgressChangedDomainEventHandler : INotificationHandler
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public async ValueTask Handle(LibraryScanProgressChangedDomainEvent domainEvent, CancellationToken cancellationToken)
|
||||
{
|
||||
_mediaLibrariesScanProgressTracker.UpdateScanProgress(MediaLibraryScanCompositeId.Create(domainEvent.ScanId, domainEvent.UserId));
|
||||
await Task.CompletedTask;
|
||||
_mediaLibrariesScanProgressTracker.UpdateScanProgress(domainEvent.LibraryId, domainEvent.MediaLibraryScanCompositeId);
|
||||
// notify SignalR clients that the library scan progress changed
|
||||
await _debouncedLibraryScanProgressNotifier.SendLibraryProgressUpdateEventAsync(domainEvent.MediaLibraryScanCompositeId, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.MediaLibrary.Management.Progress;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for the class used to notify SignalR clients about changes in the progress of a media library scan.
|
||||
/// </summary>
|
||||
public interface IMediaLibraryScanProgressNotifier
|
||||
{
|
||||
/// <summary>
|
||||
/// Notifies the SignalR clients about a change in the progress of a media library scan.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibraryScanCompositeId">The object representing the unique identifier for the media library scan whose progress changed.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
Task SendLibraryProgressUpdateEventAsync(MediaLibraryScanCompositeId mediaLibraryScanCompositeId, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Notifies the SignalR clients about the completion of a media library scan.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibraryScanCompositeId">The object representing the unique identifier for the media library scan that completed.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
Task SendLibraryScanFinishedEventAsync(MediaLibraryScanCompositeId mediaLibraryScanCompositeId, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Notifies the SignalR clients about the failure of a media library scan.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibraryScanCompositeId">The object representing the unique identifier for the media library scan that failed.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
Task SendLibraryScanFailedEventAsync(MediaLibraryScanCompositeId mediaLibraryScanCompositeId, CancellationToken cancellationToken);
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.MediaLibrary.Management.Queries.GetRunningLibraryScans;
|
||||
|
||||
/// <summary>
|
||||
/// Query for getting the list of ongoing media library scans.
|
||||
/// </summary>
|
||||
public record GetRunningLibraryScansQuery : IRequest<ErrorOr<IEnumerable<MediaLibraryScanProgressResponse>>>;
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Progress;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Mediator;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.MediaLibrary.Management.Queries.GetRunningLibraryScans;
|
||||
|
||||
/// <summary>
|
||||
/// Handler for the query to get the ongoing media library scans.
|
||||
/// </summary>
|
||||
public class GetRunningLibraryScansQueryHandler : IRequestHandler<GetRunningLibraryScansQuery, ErrorOr<IEnumerable<MediaLibraryScanProgressResponse>>>
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
private readonly IMediaLibrariesScanProgressTracker _mediaLibrariesScanProgressTracker;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetRunningLibraryScansQueryHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibrariesScanProgressTracker">Injected service for tracking the progress of media library scans.</param>
|
||||
/// <param name="authorizationService">Injected service for authorization related functionality.</param>
|
||||
/// <param name="currentUserService">Injected service to retrieve the current user information.</param>
|
||||
/// <param name="unitOfWork">Injected unit of work for interacting with the data access layer repositories.</param>
|
||||
public GetRunningLibraryScansQueryHandler(
|
||||
IMediaLibrariesScanProgressTracker mediaLibrariesScanProgressTracker,
|
||||
IAuthorizationService authorizationService,
|
||||
ICurrentUserService currentUserService,
|
||||
IUnitOfWork unitOfWork)
|
||||
{
|
||||
_mediaLibrariesScanProgressTracker = mediaLibrariesScanProgressTracker;
|
||||
_authorizationService = authorizationService;
|
||||
_currentUserService = currentUserService;
|
||||
_unitOfWork = unitOfWork;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the query to get the ongoing media library scans.
|
||||
/// </summary>
|
||||
/// <param name="request">The request to be handled.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="MediaLibraryScanProgress"/>, or an error message.
|
||||
/// </returns>
|
||||
public async ValueTask<ErrorOr<IEnumerable<MediaLibraryScanProgressResponse>>> Handle(GetRunningLibraryScansQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
// get the ongoing library scans from the repository
|
||||
ILibraryScanRepository libraryScanRepository = _unitOfWork.GetRepository<ILibraryScanRepository>();
|
||||
ErrorOr<IEnumerable<LibraryScanEntity>> getRunningScansResult = await libraryScanRepository.GetRunningScansAsync(cancellationToken).ConfigureAwait(false);
|
||||
if (getRunningScansResult.IsError)
|
||||
return getRunningScansResult.Errors;
|
||||
|
||||
// filter the library scans by what the user is allowed to see
|
||||
LibraryScanEntity[] userRunningRepositoryLibraryScans = [];
|
||||
// admins can see all libraries
|
||||
if (!await _authorizationService.IsInRoleAsync(_currentUserService.UserId!.Value, "Admin", cancellationToken).ConfigureAwait(false))
|
||||
userRunningRepositoryLibraryScans = getRunningScansResult.Value.ToArray();
|
||||
else // for regular users, only take the libraries that belong to them
|
||||
userRunningRepositoryLibraryScans = getRunningScansResult.Value
|
||||
.Where(libraryScan => libraryScan.UserId == _currentUserService.UserId).ToArray();
|
||||
|
||||
// for each of the filtered library scans, get their progress
|
||||
List<MediaLibraryScanProgressResponse> libraryScanProgresses = [];
|
||||
IEnumerable<ErrorOr<LibraryScan>> userRunningDomainLibraryScans = userRunningRepositoryLibraryScans.ToDomainEntities();
|
||||
foreach (ErrorOr<LibraryScan> userRunningDomainLibraryScan in userRunningDomainLibraryScans)
|
||||
{
|
||||
if (userRunningDomainLibraryScan.IsError)
|
||||
return userRunningDomainLibraryScan.Errors;
|
||||
else
|
||||
{
|
||||
ErrorOr<MediaLibraryScanProgress> getLibraryScanProgressResult = _mediaLibrariesScanProgressTracker.GetScanProgress(
|
||||
MediaLibraryScanCompositeId.Create(userRunningDomainLibraryScan.Value.Id, userRunningDomainLibraryScan.Value.UserId));
|
||||
if (getLibraryScanProgressResult.IsError)
|
||||
return getLibraryScanProgressResult.Errors;
|
||||
libraryScanProgresses.Add(getLibraryScanProgressResult.Value.ToResponse());
|
||||
}
|
||||
}
|
||||
|
||||
return ErrorOrFactory.From(libraryScanProgresses.AsEnumerable());
|
||||
}
|
||||
}
|
||||
+11
-6
@@ -1,5 +1,4 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
@@ -9,6 +8,9 @@ namespace Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
/// <summary>
|
||||
/// Represents a media library scan progress response.
|
||||
/// </summary>
|
||||
/// <param name="ScanId">The object representing the unique identifier of the media library scan.</param>
|
||||
/// <param name="UserId">The object representing the unique identifier of the user initiating this media library scan.</param>
|
||||
/// <param name="LibraryId">The object representing the unique identifier of the media library that is scanned.</param>
|
||||
/// <param name="TotalJobs">The total number of jobs to be processed by the scan.</param>
|
||||
/// <param name="CompletedJobs">The number of jobs that have been processed.</param>
|
||||
/// <param name="CurrentJobProgress">The progress of the currently processing job.</param>
|
||||
@@ -16,9 +18,12 @@ namespace Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
/// <param name="OverallProgressPercentage">The ratio between the number of processed jobs and the total number of jobs to process, as percentage.</param>
|
||||
[DebuggerDisplay("TotalJobs: {TotalJobs} CompletedJobs: {CompletedJobs}")]
|
||||
public record MediaLibraryScanProgressResponse(
|
||||
int TotalJobs,
|
||||
int CompletedJobs,
|
||||
MediaLibraryScanJobProgressResponse? CurrentJobProgress,
|
||||
LibraryScanJobStatus Status,
|
||||
decimal OverallProgressPercentage
|
||||
Guid ScanId,
|
||||
Guid UserId,
|
||||
Guid LibraryId,
|
||||
int TotalJobs,
|
||||
int CompletedJobs,
|
||||
MediaLibraryScanJobProgressResponse? CurrentJobProgress,
|
||||
string Status,
|
||||
decimal OverallProgressPercentage
|
||||
);
|
||||
+2
-2
@@ -12,13 +12,13 @@ namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Lib
|
||||
/// Domain event raised when a libary scan has failed.
|
||||
/// </summary>
|
||||
/// <param name="Id">The unique identifier of the domain event.</param>
|
||||
/// <param name="ScanId">The unique identifier of the failed media library scan.</param>
|
||||
/// <param name="LibraryId">The unique identifier of the library whose scan has failed.</param>
|
||||
/// <param name="MediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
/// <param name="OccurredOnUtc">The date and time when the domain event occurred.</param>
|
||||
[DebuggerDisplay("Id: {Id}")]
|
||||
public record LibraryScanFailedDomainEvent(
|
||||
Guid Id,
|
||||
ScanId ScanId,
|
||||
LibraryId LibraryId,
|
||||
MediaLibraryScanCompositeId MediaLibraryScanCompositeId,
|
||||
DateTime OccurredOnUtc
|
||||
) : IDomainEvent;
|
||||
+2
-6
@@ -1,8 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
@@ -13,13 +11,11 @@ namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Lib
|
||||
/// Domain event raised when a libary scan is finished.
|
||||
/// </summary>
|
||||
/// <param name="Id">The unique identifier of the domain event.</param>
|
||||
/// <param name="ScanId">The object representing the unique identifier of the media library scan.</param>
|
||||
/// <param name="UserId">The object representing the unique identifier of the user that started the library scan whose progress changes.</param>
|
||||
/// <param name="MediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
/// <param name="OccurredOnUtc">The date and time when the domain event occurred.</param>
|
||||
[DebuggerDisplay("ScanId: {ScanId}; UserId: {UserId}")]
|
||||
public record LibraryScanFinishedDomainEvent(
|
||||
Guid Id,
|
||||
ScanId ScanId,
|
||||
UserId UserId,
|
||||
MediaLibraryScanCompositeId MediaLibraryScanCompositeId,
|
||||
DateTime OccurredOnUtc
|
||||
) : IDomainEvent;
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
@@ -12,15 +12,15 @@ namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Lib
|
||||
/// Domain event raised when a libary's scan job progress changes.
|
||||
/// </summary>
|
||||
/// <param name="Id">The unique identifier of the domain event.</param>
|
||||
/// <param name="ScanId">The object representing the unique identifier of the media library scan.</param>
|
||||
/// <param name="UserId">The object representing the unique identifier of the user that started the library scan whose progress changes.</param>
|
||||
/// <param name="LibraryId">The object representing the unique identifier of the media library being scanned.</param>
|
||||
/// <param name="MediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
/// <param name="Progress">The object representing the new media library scan job progress.</param>
|
||||
/// <param name="OccurredOnUtc">The date and time when the domain event occurred.</param>
|
||||
[DebuggerDisplay("ScanId: {ScanId}; UserId: {UserId}")]
|
||||
public record LibraryScanJobProgressChangedDomainEvent(
|
||||
Guid Id,
|
||||
ScanId ScanId,
|
||||
UserId UserId,
|
||||
LibraryId LibraryId,
|
||||
MediaLibraryScanCompositeId MediaLibraryScanCompositeId,
|
||||
MediaLibraryScanJobProgress Progress,
|
||||
DateTime OccurredOnUtc
|
||||
) : IDomainEvent;
|
||||
+5
-6
@@ -2,7 +2,6 @@
|
||||
using Lumina.Domain.Common.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
@@ -13,13 +12,13 @@ namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Lib
|
||||
/// Domain event raised when a libary's scan progress changes.
|
||||
/// </summary>
|
||||
/// <param name="Id">The unique identifier of the domain event.</param>
|
||||
/// <param name="ScanId">The object representing the unique identifier of the media library scan.</param>
|
||||
/// <param name="UserId">The object representing the unique identifier of the user that started the library scan whose progress changes.</param>
|
||||
/// <param name="LibraryId">The object representing the unique identifier of the media library being scanned.</param>
|
||||
/// <param name="MediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
/// <param name="OccurredOnUtc">The date and time when the domain event occurred.</param>
|
||||
[DebuggerDisplay("ScanId: {ScanId}; UserId: {UserId}")]
|
||||
[DebuggerDisplay("ScanId: {MediaLibraryScanCompositeId.ScanId}; UserId: {MediaLibraryScanCompositeId.UserId}")]
|
||||
public record LibraryScanProgressChangedDomainEvent(
|
||||
Guid Id,
|
||||
ScanId ScanId,
|
||||
UserId UserId,
|
||||
LibraryId LibraryId,
|
||||
MediaLibraryScanCompositeId MediaLibraryScanCompositeId,
|
||||
DateTime OccurredOnUtc
|
||||
) : IDomainEvent;
|
||||
+1
-1
@@ -86,7 +86,7 @@ internal class MediaLibraryScanningService : IMediaLibraryScanningService
|
||||
|
||||
// count total jobs in the chain by traversing the job graph
|
||||
int totalJobs = CountTotalJobs(jobs);
|
||||
_mediaLibrariesScanProgressTracker.InitializeScanProgress(MediaLibraryScanCompositeId.Create(scan.Id, scan.UserId), totalJobs);
|
||||
_mediaLibrariesScanProgressTracker.InitializeScanProgress(scan.LibraryId, MediaLibraryScanCompositeId.Create(scan.Id, scan.UserId), totalJobs);
|
||||
|
||||
// enqueue the jobs on the channel from where they will be processed
|
||||
foreach (IMediaLibraryScanJob job in jobs)
|
||||
|
||||
+16
-3
@@ -1,5 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
#endregion
|
||||
|
||||
@@ -13,25 +14,28 @@ public interface IMediaLibrariesScanProgressTracker
|
||||
/// <summary>
|
||||
/// Initializes the the progress tracking of a media library scan.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The object representing the unique identifier of the media library being scanned.</param>
|
||||
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
/// <param name="totalJobs">The total number of jobs that this media library scan contains.</param>
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
ErrorOr<Created> InitializeScanProgress(MediaLibraryScanCompositeId mediaLibraryScanCompositeId, int totalJobs);
|
||||
ErrorOr<Created> InitializeScanProgress(LibraryId libraryId, MediaLibraryScanCompositeId mediaLibraryScanCompositeId, int totalJobs);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the progress tracking of the media library scan by incrementing the number of completed scan jobs.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The object representing the unique identifier of the media library being scanned.</param>
|
||||
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
ErrorOr<Updated> UpdateScanProgress(MediaLibraryScanCompositeId mediaLibraryScanCompositeId);
|
||||
ErrorOr<Updated> UpdateScanProgress(LibraryId libraryId, MediaLibraryScanCompositeId mediaLibraryScanCompositeId);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the progress tracking of the media library scan by incrementing the number of completed items of a scan job.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The object representing the unique identifier of the media library being scanned.</param>
|
||||
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
/// <param name="progress">The object representing the progress of the media library scan job.</param>
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
ErrorOr<Updated> UpdateScanJobProgress(MediaLibraryScanCompositeId mediaLibraryScanCompositeId, MediaLibraryScanJobProgress progress);
|
||||
ErrorOr<Updated> UpdateScanJobProgress(LibraryId libraryId, MediaLibraryScanCompositeId mediaLibraryScanCompositeId, MediaLibraryScanJobProgress progress);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the progress of a media library scan.
|
||||
@@ -41,4 +45,13 @@ public interface IMediaLibrariesScanProgressTracker
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a <see cref="MediaLibraryScanProgress"/>, or an error message.
|
||||
/// </returns>
|
||||
ErrorOr<MediaLibraryScanProgress> GetScanProgress(MediaLibraryScanCompositeId mediaLibraryScanCompositeId);
|
||||
|
||||
/// <summary>
|
||||
/// Removes the progress of a media library scan.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a <see cref="MediaLibraryScanProgress"/>, or an error message.
|
||||
/// </returns>
|
||||
ErrorOr<MediaLibraryScanProgress> RemoveScanProgress(MediaLibraryScanCompositeId mediaLibraryScanCompositeId);
|
||||
}
|
||||
+30
-3
@@ -3,6 +3,7 @@ using ErrorOr;
|
||||
using Lumina.Domain.Common.Enums.MediaLibrary;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using System.Collections.Concurrent;
|
||||
#endregion
|
||||
@@ -19,16 +20,20 @@ internal class MediaLibrariesScanProgressTracker : IMediaLibrariesScanProgressTr
|
||||
/// <summary>
|
||||
/// Initializes the the progress tracking of a media library scan.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The object representing the unique identifier of the media library being scanned.</param>
|
||||
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
/// <param name="totalJobs">The total number of jobs that this media library scan contains.</param>
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public ErrorOr<Created> InitializeScanProgress(MediaLibraryScanCompositeId mediaLibraryScanCompositeId, int totalJobs)
|
||||
public ErrorOr<Created> InitializeScanProgress(LibraryId libraryId, MediaLibraryScanCompositeId mediaLibraryScanCompositeId, int totalJobs)
|
||||
{
|
||||
ErrorOr<MediaLibraryScanJobProgress> createLibraryScanJobProgressResult = MediaLibraryScanJobProgress.Create(0, 0, "Initializing");
|
||||
if (createLibraryScanJobProgressResult.IsError)
|
||||
return createLibraryScanJobProgressResult.Errors;
|
||||
|
||||
ErrorOr<MediaLibraryScanProgress> createScanProgressResult = MediaLibraryScanProgress.Create(
|
||||
mediaLibraryScanCompositeId.ScanId,
|
||||
mediaLibraryScanCompositeId.UserId,
|
||||
libraryId,
|
||||
completedJobs: 0,
|
||||
totalJobs: totalJobs,
|
||||
LibraryScanJobStatus.Pending,
|
||||
@@ -45,13 +50,17 @@ internal class MediaLibrariesScanProgressTracker : IMediaLibrariesScanProgressTr
|
||||
/// <summary>
|
||||
/// Updates the progress tracking of the media library scan by incrementing the number of completed scan jobs.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The object representing the unique identifier of the media library being scanned.</param>
|
||||
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public ErrorOr<Updated> UpdateScanProgress(MediaLibraryScanCompositeId mediaLibraryScanCompositeId)
|
||||
public ErrorOr<Updated> UpdateScanProgress(LibraryId libraryId, MediaLibraryScanCompositeId mediaLibraryScanCompositeId)
|
||||
{
|
||||
if (_scanProgresses.TryGetValue(mediaLibraryScanCompositeId, out MediaLibraryScanProgress? progress))
|
||||
{
|
||||
ErrorOr<MediaLibraryScanProgress> createScanProgressResult = MediaLibraryScanProgress.Create(
|
||||
mediaLibraryScanCompositeId.ScanId,
|
||||
mediaLibraryScanCompositeId.UserId,
|
||||
libraryId,
|
||||
progress.CompletedJobs + 1,
|
||||
progress.TotalJobs,
|
||||
progress.CompletedJobs + 1 == progress.TotalJobs ? LibraryScanJobStatus.Completed : LibraryScanJobStatus.Running,
|
||||
@@ -68,14 +77,18 @@ internal class MediaLibrariesScanProgressTracker : IMediaLibrariesScanProgressTr
|
||||
/// <summary>
|
||||
/// Updates the progress tracking of the media library scan by incrementing the number of completed items of a scan job.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The object representing the unique identifier of the media library being scanned.</param>
|
||||
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
/// <param name="progress">The object representing the progress of the media library scan job.</param>
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public ErrorOr<Updated> UpdateScanJobProgress(MediaLibraryScanCompositeId mediaLibraryScanCompositeId, MediaLibraryScanJobProgress progress)
|
||||
public ErrorOr<Updated> UpdateScanJobProgress(LibraryId libraryId, MediaLibraryScanCompositeId mediaLibraryScanCompositeId, MediaLibraryScanJobProgress progress)
|
||||
{
|
||||
if (_scanProgresses.TryGetValue(mediaLibraryScanCompositeId, out MediaLibraryScanProgress? scanProgress))
|
||||
{
|
||||
ErrorOr<MediaLibraryScanProgress> createScanProgressResult = MediaLibraryScanProgress.Create(
|
||||
mediaLibraryScanCompositeId.ScanId,
|
||||
mediaLibraryScanCompositeId.UserId,
|
||||
libraryId,
|
||||
scanProgress.CompletedJobs,
|
||||
scanProgress.TotalJobs,
|
||||
scanProgress.Status,
|
||||
@@ -103,4 +116,18 @@ internal class MediaLibrariesScanProgressTracker : IMediaLibrariesScanProgressTr
|
||||
return progress;
|
||||
return Errors.LibraryScanning.LibraryScanNotFound;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the progress of a media library scan.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibraryScanCompositeId">Model for tracking media library scans.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a <see cref="MediaLibraryScanProgress"/>, or an error message.
|
||||
/// </returns>
|
||||
public ErrorOr<MediaLibraryScanProgress> RemoveScanProgress(MediaLibraryScanCompositeId mediaLibraryScanCompositeId)
|
||||
{
|
||||
if (_scanProgresses.TryRemove(mediaLibraryScanCompositeId, out MediaLibraryScanProgress? progress))
|
||||
return progress;
|
||||
return Errors.LibraryScanning.LibraryScanNotFound;
|
||||
}
|
||||
}
|
||||
+10
-1
@@ -10,7 +10,7 @@ namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Lib
|
||||
/// <summary>
|
||||
/// Value Object for the composite unique identifier of a media library scan.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("ScanId: {ScanId}; UserId: {UserId}")]
|
||||
[DebuggerDisplay("ScanId: {ScanId.Value}; UserId: {UserId.Value}")]
|
||||
public sealed class MediaLibraryScanCompositeId : ValueObject
|
||||
{
|
||||
/// <summary>
|
||||
@@ -51,4 +51,13 @@ public sealed class MediaLibraryScanCompositeId : ValueObject
|
||||
yield return ScanId;
|
||||
yield return UserId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Customized ToString() method.
|
||||
/// </summary>
|
||||
/// <returns>Custom string value showing relevant data for current class.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{ScanId}-{UserId}";
|
||||
}
|
||||
}
|
||||
+43
-3
@@ -4,6 +4,8 @@ using Lumina.Domain.Common.Enums.MediaLibrary;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
@@ -16,6 +18,21 @@ namespace Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Lib
|
||||
[DebuggerDisplay("CompletedJobs: {CompletedJobs}; TotalJobs: {TotalJobs}; CurrentJobProgress: {CurrentJobProgress}")]
|
||||
public sealed class MediaLibraryScanProgress : ValueObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the object representing the unique identifier of the media library scan.
|
||||
/// </summary>
|
||||
public ScanId ScanId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the object representing the unique identifier of the media library that is scanned.
|
||||
/// </summary>
|
||||
public LibraryId LibraryId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the object representing the unique identifier of the user initiating this media library scan.
|
||||
/// </summary>
|
||||
public UserId UserId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of completed jobs of the media library scan job.
|
||||
/// </summary>
|
||||
@@ -44,12 +61,25 @@ public sealed class MediaLibraryScanProgress : ValueObject
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MediaLibraryScanProgress"/> class.
|
||||
/// </summary>
|
||||
/// <param name="scanId">The object representing the unique identifier of the media library scan.</param>
|
||||
/// <param name="userId">The object representing the unique identifier of the user initiating this media library scan.</param>
|
||||
/// <param name="libraryId">The object representing the unique identifier of the media library that is scanned.</param>
|
||||
/// <param name="completedJobs">The number of completed jobs of the media library scan job.</param>
|
||||
/// <param name="totalJobs">The total number of jobs of the media library scan job.</param>
|
||||
/// <param name="status">The status of the media library scan.</param>
|
||||
/// <param name="currentJobProgress">The optional current job progress of the media library scan.</param>
|
||||
private MediaLibraryScanProgress(int completedJobs, int totalJobs, LibraryScanJobStatus status, Optional<MediaLibraryScanJobProgress> currentJobProgress)
|
||||
private MediaLibraryScanProgress(
|
||||
ScanId scanId,
|
||||
UserId userId,
|
||||
LibraryId libraryId,
|
||||
int completedJobs,
|
||||
int totalJobs,
|
||||
LibraryScanJobStatus status,
|
||||
Optional<MediaLibraryScanJobProgress> currentJobProgress)
|
||||
{
|
||||
ScanId = scanId;
|
||||
LibraryId = libraryId;
|
||||
UserId = userId;
|
||||
CompletedJobs = completedJobs;
|
||||
TotalJobs = totalJobs;
|
||||
CurrentJobProgress = currentJobProgress;
|
||||
@@ -59,6 +89,9 @@ public sealed class MediaLibraryScanProgress : ValueObject
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="MediaLibraryScanProgress"/> class.
|
||||
/// </summary>
|
||||
/// <param name="scanId">The object representing the unique identifier of the media library scan.</param>
|
||||
/// <param name="userId">The object representing the unique identifier of the user initiating this media library scan.</param>
|
||||
/// <param name="libraryId">The object representing the unique identifier of the media library that is scanned.</param>
|
||||
/// <param name="completedJobs">The number of completed jobs of the media library scan job.</param>
|
||||
/// <param name="totalJobs">The total number of jobs of the media library scan job.</param>
|
||||
/// <param name="status">The status of the media library scan.</param>
|
||||
@@ -66,7 +99,14 @@ public sealed class MediaLibraryScanProgress : ValueObject
|
||||
/// <returns>
|
||||
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="MediaLibraryScanProgress"/>, or an error message.
|
||||
/// </returns>
|
||||
public static ErrorOr<MediaLibraryScanProgress> Create(int completedJobs, int totalJobs, LibraryScanJobStatus status, Optional<MediaLibraryScanJobProgress> currentJobProgress)
|
||||
public static ErrorOr<MediaLibraryScanProgress> Create(
|
||||
ScanId scanId,
|
||||
UserId userId,
|
||||
LibraryId libraryId,
|
||||
int completedJobs,
|
||||
int totalJobs,
|
||||
LibraryScanJobStatus status,
|
||||
Optional<MediaLibraryScanJobProgress> currentJobProgress)
|
||||
{
|
||||
if (totalJobs <= 0)
|
||||
return Errors.LibraryScanning.TotalScanJobsCountMustBePositive;
|
||||
@@ -75,7 +115,7 @@ public sealed class MediaLibraryScanProgress : ValueObject
|
||||
if (completedJobs > totalJobs)
|
||||
return Errors.LibraryScanning.CompletedScanJobsCountCantExceedTotalScanJobsCount;
|
||||
|
||||
return new MediaLibraryScanProgress(completedJobs, totalJobs, status, currentJobProgress);
|
||||
return new MediaLibraryScanProgress(scanId, userId, libraryId, completedJobs, totalJobs, status, currentJobProgress);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -5,6 +5,7 @@ using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization.Policies.Over18;
|
||||
using Lumina.Application.Common.Infrastructure.Security;
|
||||
using Lumina.Application.Common.Infrastructure.Time;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Progress;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Services.Scanning.Queue;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Cancellation;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
||||
@@ -17,6 +18,7 @@ using Lumina.Infrastructure.Core.Authorization.Policies.Over18;
|
||||
using Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Cancellation;
|
||||
using Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.Common;
|
||||
using Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.WrittenContent.Books;
|
||||
using Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Progress;
|
||||
using Lumina.Infrastructure.Core.Security;
|
||||
using Lumina.Infrastructure.Core.Time;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@@ -65,6 +67,8 @@ public static class InfrastructureLayerServices
|
||||
services.AddTransient<IHashComparerJob, HashComparerJob>();
|
||||
services.AddTransient<IGoodReadsMetadataScrapJob, GoodReadsMetadataScrapJob>();
|
||||
services.AddTransient<IRepositoryMetadataSaveJob, RepositoryMetadataSaveJob>();
|
||||
|
||||
services.AddSingleton<IMediaLibraryScanProgressNotifier, DebouncedMediaLibraryScanProgressNotifier>();
|
||||
return services;
|
||||
}
|
||||
}
|
||||
@@ -34,13 +34,12 @@ public static class SharedConfiguration
|
||||
configuration.AddJsonFile("appsettings.shared.Development.json", optional: true, reloadOnChange: true);
|
||||
configuration.AddEnvironmentVariables(); // environment variables should override the configuration files
|
||||
|
||||
// bind the common settings section
|
||||
// bind the appsettings sections
|
||||
services.AddOptions<CommonSettingsModel>()
|
||||
.Bind(configuration.GetRequiredSection(CommonSettingsModel.SECTION_NAME))
|
||||
.ValidateFluently()
|
||||
.ValidateOnStart();
|
||||
|
||||
// bind the database connection string section
|
||||
services.AddOptions<DatabaseSettingsModel>()
|
||||
.Bind(configuration.GetRequiredSection(DatabaseSettingsModel.SECTION_NAME))
|
||||
.ValidateFluently()
|
||||
@@ -56,6 +55,11 @@ public static class SharedConfiguration
|
||||
.ValidateFluently()
|
||||
.ValidateOnStart();
|
||||
|
||||
services.AddOptions<CorsSettingsModel>()
|
||||
.Bind(configuration.GetRequiredSection(CorsSettingsModel.SECTION_NAME))
|
||||
.ValidateFluently()
|
||||
.ValidateOnStart();
|
||||
|
||||
services.AddOptions<EncryptionSettingsModel>()
|
||||
.Bind(configuration.GetRequiredSection(EncryptionSettingsModel.SECTION_NAME))
|
||||
.ValidateFluently()
|
||||
|
||||
@@ -22,5 +22,7 @@ public static partial class Errors
|
||||
public static Error JwtExpiryMinutesMustBePositive => Error.Validation(description: nameof(JwtExpiryMinutesMustBePositive));
|
||||
public static Error JwtIssuerCannotBeEmpty => Error.Validation(description: nameof(JwtIssuerCannotBeEmpty));
|
||||
public static Error JwtAudienceCannotBeEmpty => Error.Validation(description: nameof(JwtAudienceCannotBeEmpty));
|
||||
public static Error CorsOriginsCannotBeEmpty => Error.Validation(description: nameof(CorsOriginsCannotBeEmpty));
|
||||
public static Error CorsOriginIsInvalid => Error.Validation(description: nameof(CorsOriginIsInvalid));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Infrastructure.Common.Models.Configuration;
|
||||
|
||||
/// <summary>
|
||||
/// Model for deserializing media settings.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{SECTION_NAME}")]
|
||||
public class CorsSettingsModel
|
||||
{
|
||||
public const string SECTION_NAME = "CorsSettings";
|
||||
|
||||
/// <summary>
|
||||
/// The allowed hosts in regards to cross-origin resource sharing rules.
|
||||
/// </summary>
|
||||
public required string[] AllowedOrigins { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FluentValidation;
|
||||
using Lumina.Infrastructure.Common.Models.Configuration;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Infrastructure.Common.Validators;
|
||||
|
||||
/// <summary>
|
||||
/// Validates the needed validation rules for the JwtSettings application configuration settings section.
|
||||
/// </summary>
|
||||
public class CorsSettingsModelValidator : AbstractValidator<CorsSettingsModel>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes validation rules for CORS configuration
|
||||
/// </summary>
|
||||
public CorsSettingsModelValidator()
|
||||
{
|
||||
RuleFor(x => x.AllowedOrigins)
|
||||
.NotEmpty()
|
||||
.WithMessage(Errors.Errors.Configuration.CorsOriginsCannotBeEmpty.Description)
|
||||
.ForEach(originRule =>
|
||||
{
|
||||
originRule.NotEmpty()
|
||||
.WithMessage(Errors.Errors.Configuration.CorsOriginsCannotBeEmpty.Description)
|
||||
.Must(BeValidOrigin)
|
||||
.WithMessage(Errors.Errors.Configuration.CorsOriginIsInvalid.Description);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates individual origin format
|
||||
/// </summary>
|
||||
private bool BeValidOrigin(string origin)
|
||||
{
|
||||
if (origin == "*")
|
||||
return true; // wildcard allowed without credentials
|
||||
return Uri.TryCreate(origin, UriKind.Absolute, out Uri? uri) && (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps) && !origin.EndsWith('/');
|
||||
}
|
||||
}
|
||||
+13
-9
@@ -58,24 +58,25 @@ internal sealed class FileSystemDiscoveryJob : MediaLibraryScanJob, IFileSystemD
|
||||
parentsPayloadsExecuted++; // increment the number of parents that finished their execution and called this job
|
||||
// only execute this job's payload when it has no parents, or when all the parents finished their execution
|
||||
if (Parents.Count == 0 || parentsPayloadsExecuted == Parents.Count)
|
||||
{
|
||||
// this needs to be wrapped in a task because even though this job is processed in a "fire and forget" async manner, it still does synchronous
|
||||
// file system processing that takes time, and would block the processing of scan jobs in the in-memory queue
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
Status = LibraryScanJobStatus.Running;
|
||||
await Task.Delay(25000);
|
||||
Console.WriteLine("started file discovering");
|
||||
// see docs/technical/achitecture/architecture-knowledge-management/architecture-decision-log/architecture-decission-record-0001.md for details:
|
||||
await using AsyncServiceScope asyncServiceScope = _serviceScopeFactory.CreateAsyncScope();
|
||||
IUnitOfWork? unitOfWork = asyncServiceScope.ServiceProvider.GetService<IUnitOfWork>();
|
||||
IPublisher? publisher = asyncServiceScope.ServiceProvider.GetService<IPublisher>();
|
||||
ILibraryRepository libraryRepository = unitOfWork!.GetRepository<ILibraryRepository>();
|
||||
MediaLibraryScanCompositeId compositeKey = MediaLibraryScanCompositeId.Create(ScanId, UserId);
|
||||
|
||||
// get the library from the repository
|
||||
ErrorOr<LibraryEntity?> getLibraryResult = await libraryRepository.GetByIdAsync(LibraryId.Value, cancellationToken).ConfigureAwait(false);
|
||||
if (getLibraryResult.IsError || getLibraryResult.Value is null)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -83,7 +84,7 @@ internal sealed class FileSystemDiscoveryJob : MediaLibraryScanJob, IFileSystemD
|
||||
ErrorOr<Library> domainLibraryResult = getLibraryResult.Value.ToDomainEntity();
|
||||
if (domainLibraryResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -91,18 +92,18 @@ internal sealed class FileSystemDiscoveryJob : MediaLibraryScanJob, IFileSystemD
|
||||
ErrorOr<MediaLibraryScanJobProgress> scanJobProgressResult = MediaLibraryScanJobProgress.Create(0, domainLibraryResult.Value.ContentLocations.Count, "DiscoveringFiles");
|
||||
if (scanJobProgressResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
await publisher!.Publish(new LibraryScanJobProgressChangedDomainEvent(
|
||||
Guid.NewGuid(), ScanId, UserId, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
Guid.NewGuid(), LibraryId, compositeKey, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// recursively get the file system tree for each of the media library content locations
|
||||
List<FileSystemTreeNode> contentLocationTrees = [];
|
||||
foreach (FileSystemPathId contentLocation in domainLibraryResult.Value.ContentLocations)
|
||||
{
|
||||
await Task.Delay(5000);
|
||||
await Task.Delay(1000);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
ErrorOr<FileSystemTreeNode> treeResult = BuildTree(contentLocation, includeHiddenElements: true, cancellationToken);
|
||||
if (treeResult.IsError)
|
||||
@@ -118,14 +119,16 @@ internal sealed class FileSystemDiscoveryJob : MediaLibraryScanJob, IFileSystemD
|
||||
scanJobProgressResult.Value.CompletedItems + 1, domainLibraryResult.Value.ContentLocations.Count, "DiscoveringFiles");
|
||||
if (scanJobProgressResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(
|
||||
Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
await publisher!.Publish(new LibraryScanJobProgressChangedDomainEvent(
|
||||
Guid.NewGuid(), ScanId, UserId, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
Guid.NewGuid(), LibraryId, compositeKey, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
// this job finished, increment the number of processed jobs progress
|
||||
await publisher!.Publish(new LibraryScanProgressChangedDomainEvent(Guid.NewGuid(), ScanId, UserId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
await publisher!.Publish(new LibraryScanProgressChangedDomainEvent(
|
||||
Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
Console.WriteLine("ended file discovering");
|
||||
Status = LibraryScanJobStatus.Completed;
|
||||
|
||||
@@ -133,6 +136,7 @@ internal sealed class FileSystemDiscoveryJob : MediaLibraryScanJob, IFileSystemD
|
||||
foreach (IMediaLibraryScanJob children in Children)
|
||||
await children.ExecuteAsync(id, contentLocationTrees, cancellationToken).ConfigureAwait(false);
|
||||
}, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
||||
+16
-11
@@ -13,6 +13,7 @@ using Mediator;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
@@ -54,12 +55,13 @@ internal sealed class HashComparerJob : MediaLibraryScanJob, IHashComparerJob
|
||||
IUnitOfWork? unitOfWork = asyncServiceScope.ServiceProvider.GetService<IUnitOfWork>();
|
||||
IPublisher? publisher = asyncServiceScope.ServiceProvider.GetService<IPublisher>();
|
||||
ILibraryRepository libraryRepository = unitOfWork!.GetRepository<ILibraryRepository>();
|
||||
MediaLibraryScanCompositeId compositeKey = MediaLibraryScanCompositeId.Create(ScanId, UserId);
|
||||
|
||||
// get the library from the repository
|
||||
ErrorOr<LibraryEntity?> getLibraryResult = await libraryRepository.GetByIdAsync(LibraryId.Value, cancellationToken).ConfigureAwait(false);
|
||||
if (getLibraryResult.IsError || getLibraryResult.Value is null)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -67,38 +69,41 @@ internal sealed class HashComparerJob : MediaLibraryScanJob, IHashComparerJob
|
||||
ErrorOr<Library> domainLibraryResult = getLibraryResult.Value.ToDomainEntity();
|
||||
if (domainLibraryResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// set the initial progress of the scan job
|
||||
ErrorOr<MediaLibraryScanJobProgress> scanJobProgressResult = MediaLibraryScanJobProgress.Create(0, domainLibraryResult.Value.ContentLocations.Count, "ComparingFileHashes");
|
||||
ErrorOr<MediaLibraryScanJobProgress> scanJobProgressResult = MediaLibraryScanJobProgress.Create(0, 50, "ComparingFileHashes");
|
||||
//ErrorOr<MediaLibraryScanJobProgress> scanJobProgressResult = MediaLibraryScanJobProgress.Create(0, domainLibraryResult.Value.ContentLocations.Count, "ComparingFileHashes");
|
||||
if (scanJobProgressResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
await publisher!.Publish(new LibraryScanJobProgressChangedDomainEvent(
|
||||
Guid.NewGuid(), ScanId, UserId, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
Guid.NewGuid(), LibraryId, compositeKey, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
List<int> ints = [1, 2, 3];
|
||||
List<int> ints = Enumerable.Range(0, 50).ToList();
|
||||
foreach (int nr in ints)
|
||||
{
|
||||
await Task.Delay(5400);
|
||||
await Task.Delay(100);
|
||||
// increment the number of processed elements progress
|
||||
scanJobProgressResult = MediaLibraryScanJobProgress.Create(
|
||||
scanJobProgressResult.Value.CompletedItems + 1, domainLibraryResult.Value.ContentLocations.Count, "ComparingFileHashes");
|
||||
nr, 50, "ComparingFileHashes");
|
||||
//scanJobProgressResult.Value.CompletedItems + 1, domainLibraryResult.Value.ContentLocations.Count, "ComparingFileHashes");
|
||||
if (scanJobProgressResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
await publisher!.Publish(new LibraryScanJobProgressChangedDomainEvent(
|
||||
Guid.NewGuid(), ScanId, UserId, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
Guid.NewGuid(), LibraryId, compositeKey, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
// this job finished, increment the number of processed jobs progress
|
||||
await publisher!.Publish(new LibraryScanProgressChangedDomainEvent(Guid.NewGuid(), ScanId, UserId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
await publisher!.Publish(new LibraryScanProgressChangedDomainEvent(
|
||||
Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
Status = LibraryScanJobStatus.Completed;
|
||||
Console.WriteLine("ended file hashing");
|
||||
// call each linked child with the obtained payload
|
||||
|
||||
+13
-8
@@ -46,6 +46,7 @@ internal sealed class RepositoryMetadataDiscoveryJob : MediaLibraryScanJob, IRep
|
||||
parentsPayloadsExecuted++; // increment the number of parents that finished their execution and called this job
|
||||
// only execute this job's payload when it has no parents, or when all the parents finished their execution
|
||||
if (Parents.Count == 0 || parentsPayloadsExecuted == Parents.Count)
|
||||
{
|
||||
// this needs to be wrapped in a task because even though this job is processed in a "fire and forget" async manner, it still does synchronous
|
||||
// file system processing that takes time, and would block the processing of scan jobs in the in-memory queue
|
||||
await Task.Run(async () =>
|
||||
@@ -57,12 +58,13 @@ internal sealed class RepositoryMetadataDiscoveryJob : MediaLibraryScanJob, IRep
|
||||
IUnitOfWork? unitOfWork = asyncServiceScope.ServiceProvider.GetService<IUnitOfWork>();
|
||||
IPublisher? publisher = asyncServiceScope.ServiceProvider.GetService<IPublisher>();
|
||||
ILibraryRepository libraryRepository = unitOfWork!.GetRepository<ILibraryRepository>();
|
||||
MediaLibraryScanCompositeId compositeKey = MediaLibraryScanCompositeId.Create(ScanId, UserId);
|
||||
|
||||
// get the library from the repository
|
||||
ErrorOr<LibraryEntity?> getLibraryResult = await libraryRepository.GetByIdAsync(LibraryId.Value, cancellationToken).ConfigureAwait(false);
|
||||
if (getLibraryResult.IsError || getLibraryResult.Value is null)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -70,7 +72,7 @@ internal sealed class RepositoryMetadataDiscoveryJob : MediaLibraryScanJob, IRep
|
||||
ErrorOr<Library> domainLibraryResult = getLibraryResult.Value.ToDomainEntity();
|
||||
if (domainLibraryResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -78,36 +80,39 @@ internal sealed class RepositoryMetadataDiscoveryJob : MediaLibraryScanJob, IRep
|
||||
ErrorOr<MediaLibraryScanJobProgress> scanJobProgressResult = MediaLibraryScanJobProgress.Create(0, domainLibraryResult.Value.ContentLocations.Count, "RetrievingPastScanData");
|
||||
if (scanJobProgressResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
await publisher!.Publish(new LibraryScanJobProgressChangedDomainEvent(
|
||||
Guid.NewGuid(), ScanId, UserId, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
Guid.NewGuid(), LibraryId, compositeKey, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
List<int> ints = [1, 2, 3];
|
||||
foreach (int nr in ints)
|
||||
{
|
||||
await Task.Delay(5400);
|
||||
await Task.Delay(1000);
|
||||
// increment the number of processed elements progress
|
||||
scanJobProgressResult = MediaLibraryScanJobProgress.Create(
|
||||
scanJobProgressResult.Value.CompletedItems + 1, domainLibraryResult.Value.ContentLocations.Count, "RetrievingPastScanData");
|
||||
if (scanJobProgressResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
await publisher!.Publish(
|
||||
new LibraryScanFailedDomainEvent(Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
await publisher!.Publish(new LibraryScanJobProgressChangedDomainEvent(
|
||||
Guid.NewGuid(), ScanId, UserId, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
Guid.NewGuid(), LibraryId, compositeKey, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
// this job finished, increment the number of processed jobs progress
|
||||
await publisher!.Publish(new LibraryScanProgressChangedDomainEvent(Guid.NewGuid(), ScanId, UserId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
await publisher!.Publish(new LibraryScanProgressChangedDomainEvent(
|
||||
Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
Status = LibraryScanJobStatus.Completed;
|
||||
Console.WriteLine("ended repo discovering");
|
||||
// call each linked child with the obtained payload
|
||||
foreach (IMediaLibraryScanJob children in Children)
|
||||
await children.ExecuteAsync(id, ints, cancellationToken).ConfigureAwait(false);
|
||||
}, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
||||
+11
-8
@@ -46,6 +46,7 @@ internal sealed class RepositoryMetadataSaveJob : MediaLibraryScanJob, IReposito
|
||||
parentsPayloadsExecuted++; // increment the number of parents that finished their execution and called this job
|
||||
// only execute this job's payload when it has no parents, or when all the parents finished their execution
|
||||
if (Parents.Count == 0 || parentsPayloadsExecuted == Parents.Count)
|
||||
{
|
||||
// this needs to be wrapped in a task because even though this job is processed in a "fire and forget" async manner, it still does synchronous
|
||||
// file system processing that takes time, and would block the processing of scan jobs in the in-memory queue
|
||||
await Task.Run(async () =>
|
||||
@@ -57,12 +58,13 @@ internal sealed class RepositoryMetadataSaveJob : MediaLibraryScanJob, IReposito
|
||||
IUnitOfWork? unitOfWork = asyncServiceScope.ServiceProvider.GetService<IUnitOfWork>();
|
||||
IPublisher? publisher = asyncServiceScope.ServiceProvider.GetService<IPublisher>();
|
||||
ILibraryRepository libraryRepository = unitOfWork!.GetRepository<ILibraryRepository>();
|
||||
MediaLibraryScanCompositeId compositeKey = MediaLibraryScanCompositeId.Create(ScanId, UserId);
|
||||
|
||||
// get the library from the repository
|
||||
ErrorOr<LibraryEntity?> getLibraryResult = await libraryRepository.GetByIdAsync(LibraryId.Value, cancellationToken).ConfigureAwait(false);
|
||||
if (getLibraryResult.IsError || getLibraryResult.Value is null)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -70,7 +72,7 @@ internal sealed class RepositoryMetadataSaveJob : MediaLibraryScanJob, IReposito
|
||||
ErrorOr<Library> domainLibraryResult = getLibraryResult.Value.ToDomainEntity();
|
||||
if (domainLibraryResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -78,34 +80,35 @@ internal sealed class RepositoryMetadataSaveJob : MediaLibraryScanJob, IReposito
|
||||
ErrorOr<MediaLibraryScanJobProgress> scanJobProgressResult = MediaLibraryScanJobProgress.Create(0, domainLibraryResult.Value.ContentLocations.Count, "SavingScanData");
|
||||
if (scanJobProgressResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
await publisher!.Publish(new LibraryScanJobProgressChangedDomainEvent(
|
||||
Guid.NewGuid(), ScanId, UserId, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
Guid.NewGuid(), LibraryId, compositeKey, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
List<int> ints = [1, 2, 3];
|
||||
foreach (int nr in ints)
|
||||
{
|
||||
await Task.Delay(5400);
|
||||
await Task.Delay(500);
|
||||
// increment the number of processed elements progress
|
||||
scanJobProgressResult = MediaLibraryScanJobProgress.Create(
|
||||
scanJobProgressResult.Value.CompletedItems + 1, domainLibraryResult.Value.ContentLocations.Count, "SavingScanData");
|
||||
if (scanJobProgressResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
await publisher!.Publish(new LibraryScanJobProgressChangedDomainEvent(
|
||||
Guid.NewGuid(), ScanId, UserId, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
Guid.NewGuid(), LibraryId, compositeKey, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
// this job finished, and it's the last in the chain, the scan is completed
|
||||
Status = LibraryScanJobStatus.Completed;
|
||||
await publisher!.Publish(new LibraryScanFinishedDomainEvent(Guid.NewGuid(), ScanId, UserId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
await publisher!.Publish(new LibraryScanFinishedDomainEvent(Guid.NewGuid(), compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
Console.WriteLine("ended repo saving");
|
||||
// this should always be the last job in the directed acyclic job graph, so no linked child to call further
|
||||
}, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
||||
+16
-11
@@ -14,6 +14,7 @@ using Mediator;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
@@ -55,12 +56,13 @@ internal sealed class GoodReadsMetadataScrapJob : MediaLibraryScanJob, IGoodRead
|
||||
IUnitOfWork? unitOfWork = asyncServiceScope.ServiceProvider.GetService<IUnitOfWork>();
|
||||
IPublisher? publisher = asyncServiceScope.ServiceProvider.GetService<IPublisher>();
|
||||
ILibraryRepository libraryRepository = unitOfWork!.GetRepository<ILibraryRepository>();
|
||||
MediaLibraryScanCompositeId compositeKey = MediaLibraryScanCompositeId.Create(ScanId, UserId);
|
||||
|
||||
// get the library from the repository
|
||||
ErrorOr<LibraryEntity?> getLibraryResult = await libraryRepository.GetByIdAsync(LibraryId.Value, cancellationToken).ConfigureAwait(false);
|
||||
if (getLibraryResult.IsError || getLibraryResult.Value is null)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -68,38 +70,41 @@ internal sealed class GoodReadsMetadataScrapJob : MediaLibraryScanJob, IGoodRead
|
||||
ErrorOr<Library> domainLibraryResult = getLibraryResult.Value.ToDomainEntity();
|
||||
if (domainLibraryResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// set the initial progress of the scan job
|
||||
ErrorOr<MediaLibraryScanJobProgress> scanJobProgressResult = MediaLibraryScanJobProgress.Create(0, domainLibraryResult.Value.ContentLocations.Count, "GoodReadsDownload");
|
||||
ErrorOr<MediaLibraryScanJobProgress> scanJobProgressResult = MediaLibraryScanJobProgress.Create(0, 20, "GoodReadsMetadataDownload");
|
||||
//ErrorOr<MediaLibraryScanJobProgress> scanJobProgressResult = MediaLibraryScanJobProgress.Create(0, domainLibraryResult.Value.ContentLocations.Count, "GoodReadsMetadataDownload");
|
||||
if (scanJobProgressResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
await publisher!.Publish(new LibraryScanJobProgressChangedDomainEvent(
|
||||
Guid.NewGuid(), ScanId, UserId, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
Guid.NewGuid(), LibraryId, compositeKey, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
List<int> ints = [1, 2, 3];
|
||||
List<int> ints = Enumerable.Range(0, 20).ToList();
|
||||
foreach (int nr in ints)
|
||||
{
|
||||
await Task.Delay(5400);
|
||||
await Task.Delay(100);
|
||||
// increment the number of processed elements progress
|
||||
scanJobProgressResult = MediaLibraryScanJobProgress.Create(
|
||||
scanJobProgressResult.Value.CompletedItems + 1, domainLibraryResult.Value.ContentLocations.Count, "GoodReadsMetadataDownload");
|
||||
nr, 20, "GoodReadsMetadataDownload");
|
||||
//scanJobProgressResult.Value.CompletedItems + 1, domainLibraryResult.Value.ContentLocations.Count, "GoodReadsMetadataDownload");
|
||||
if (scanJobProgressResult.IsError)
|
||||
{
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), ScanId, LibraryId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
await publisher!.Publish(new LibraryScanFailedDomainEvent(Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
await publisher!.Publish(new LibraryScanJobProgressChangedDomainEvent(
|
||||
Guid.NewGuid(), ScanId, UserId, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
Guid.NewGuid(), LibraryId, compositeKey, scanJobProgressResult.Value, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
// this job finished, increment the number of processed jobs progress
|
||||
await publisher!.Publish(new LibraryScanProgressChangedDomainEvent(Guid.NewGuid(), ScanId, UserId, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
await publisher!.Publish(new LibraryScanProgressChangedDomainEvent(
|
||||
Guid.NewGuid(), LibraryId, compositeKey, DateTime.UtcNow), cancellationToken).ConfigureAwait(false);
|
||||
Status = LibraryScanJobStatus.Completed;
|
||||
Console.WriteLine("ended goodreads metadata");
|
||||
// call each linked child with the obtained payload
|
||||
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Progress;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Enums.MediaLibrary;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Progress;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Progress;
|
||||
|
||||
/// <summary>
|
||||
/// Class used to notify SignalR clients about changes in the progress of a media library scan.
|
||||
/// </summary>
|
||||
public sealed class DebouncedMediaLibraryScanProgressNotifier : IMediaLibraryScanProgressNotifier
|
||||
{
|
||||
private readonly IHubContext<MediaLibraryScanProgressHub> _hubContext;
|
||||
private readonly IMediaLibrariesScanProgressTracker _mediaLibrariesScanProgressTracker;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DebouncedMediaLibraryScanProgressNotifier"/> class.
|
||||
/// </summary>
|
||||
/// <param name="hubContext">SignalR hub context abstraction.</param>
|
||||
/// <param name="mediaLibrariesScanProgressTracker">Injected service for tracking the progress of media library scans.</param>
|
||||
public DebouncedMediaLibraryScanProgressNotifier(IHubContext<MediaLibraryScanProgressHub> hubContext, IMediaLibrariesScanProgressTracker mediaLibrariesScanProgressTracker)
|
||||
{
|
||||
_hubContext = hubContext;
|
||||
_mediaLibrariesScanProgressTracker = mediaLibrariesScanProgressTracker;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies the SignalR clients about a change in the progress of a media library scan.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibraryScanCompositeId">The object representing the unique identifier for the media library scan whose progress changed.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public async Task SendLibraryProgressUpdateEventAsync(MediaLibraryScanCompositeId mediaLibraryScanCompositeId, CancellationToken cancellationToken)
|
||||
{
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
ErrorOr<MediaLibraryScanProgress> progressResult = _mediaLibrariesScanProgressTracker.GetScanProgress(mediaLibraryScanCompositeId);
|
||||
|
||||
if (!progressResult.IsError)
|
||||
{
|
||||
MediaLibraryScanProgressResponse progress = progressResult.Value.ToResponse();
|
||||
await _hubContext.Clients.Group(mediaLibraryScanCompositeId.ToString()).SendAsync("libraryScanProgressUpdateEvent", progress, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies the SignalR clients about the completion of a media library scan.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibraryScanCompositeId">The object representing the unique identifier for the media library scan that completed.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public async Task SendLibraryScanFinishedEventAsync(MediaLibraryScanCompositeId mediaLibraryScanCompositeId, CancellationToken cancellationToken)
|
||||
{
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
ErrorOr<MediaLibraryScanProgress> progressResult = _mediaLibrariesScanProgressTracker.RemoveScanProgress(mediaLibraryScanCompositeId);
|
||||
|
||||
if (!progressResult.IsError)
|
||||
{
|
||||
MediaLibraryScanProgressResponse progress = progressResult.Value.ToResponse();
|
||||
await _hubContext.Clients.Group(mediaLibraryScanCompositeId.ToString()).SendAsync("libraryScanFinishedEvent", progress, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies the SignalR clients about the failure of a media library scan.
|
||||
/// </summary>
|
||||
/// <param name="mediaLibraryScanCompositeId">The object representing the unique identifier for the media library scan that failed.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public async Task SendLibraryScanFailedEventAsync(MediaLibraryScanCompositeId mediaLibraryScanCompositeId, CancellationToken cancellationToken)
|
||||
{
|
||||
if (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
ErrorOr<MediaLibraryScanProgress> progressResult = _mediaLibrariesScanProgressTracker.RemoveScanProgress(mediaLibraryScanCompositeId);
|
||||
|
||||
if (!progressResult.IsError)
|
||||
{
|
||||
MediaLibraryScanProgressResponse progress = progressResult.Value.ToResponse();
|
||||
await _hubContext.Clients.Group(mediaLibraryScanCompositeId.ToString()).SendAsync(
|
||||
"libraryScanFailedEvent", progress with { Status = LibraryScanJobStatus.Failed.ToString() }, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Progress;
|
||||
|
||||
/// <summary>
|
||||
/// SignalR hub for managing real-time media library scan progress updates.
|
||||
/// </summary>
|
||||
public class MediaLibraryScanProgressHub : Hub
|
||||
{
|
||||
/// <summary>
|
||||
/// Subscribes the current connection to scan progress notifications for a specific scan operation.
|
||||
/// </summary>
|
||||
/// <param name="scanId">Unique identifier of the scan operation.</param>
|
||||
/// <param name="userId">Unique identifier of the requesting user.</param>
|
||||
public async Task SubscribeToScan(Guid scanId, Guid userId)
|
||||
{
|
||||
await Groups.AddToGroupAsync(Context.ConnectionId, $"{scanId}-{userId}");
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,8 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FluentValidation" Version="11.10.0" />
|
||||
<PackageReference Include="Konscious.Security.Cryptography.Argon2" Version="1.3.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Core" Version="1.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.0" />
|
||||
|
||||
+11
-5
@@ -3,6 +3,7 @@ using FastEndpoints;
|
||||
using FastEndpoints.Swagger;
|
||||
using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Presentation.Api.Common.Authentication;
|
||||
using MessagePack;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -201,13 +202,18 @@ public static class PresentationApiLayerServices
|
||||
|
||||
services.AddCors(corsOptions =>
|
||||
{
|
||||
corsOptions.AddPolicy("AllowAll",
|
||||
corsPolicyBuilder => corsPolicyBuilder
|
||||
.AllowAnyOrigin()
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader());
|
||||
corsOptions.AddPolicy("SecurePolicy",
|
||||
corsPolicyBuilder => corsPolicyBuilder
|
||||
.WithOrigins(configuration.GetValue<string[]>("CorsSettings:AllowedOrigins") ?? [])
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader()
|
||||
.AllowCredentials());
|
||||
});
|
||||
|
||||
services.AddSignalR()
|
||||
.AddMessagePackProtocol(messagePackHubProtocolOptions =>
|
||||
messagePackHubProtocolOptions.SerializerOptions = MessagePackSerializerOptions.Standard.WithSecurity(MessagePackSecurity.UntrustedData));
|
||||
|
||||
services.AddScoped<ICurrentUserService, HttpContextCurrentUserService>();
|
||||
|
||||
return services;
|
||||
|
||||
@@ -19,6 +19,7 @@ public static partial class ApiRoutes
|
||||
public const string SCAN_LIBRARIES = "/libraries/scans";
|
||||
public const string SCAN_LIBRARY = "/libraries/{id}/scans";
|
||||
public const string LIBRARY_SCAN_PROGRESS = "/libraries/{libraryId}/scans/{scanId}/progress";
|
||||
public const string GET_RUNNING_LIBRARIES_SCAN = "/libraries/scans/running";
|
||||
public const string CANCEL_LIBRARIES_SCAN = "/libraries/scans/cancel";
|
||||
public const string CANCEL_LIBRARY_SCAN = "/libraries/{libraryId}/scans/{scanId}/cancel";
|
||||
}
|
||||
|
||||
+7
-1
@@ -32,6 +32,9 @@ public class GetLibraryScanProgressEndpointSummary : Summary<GetLibraryScanProgr
|
||||
RequestParam(r => r.LibraryId, "The Id of the media library whose scan progress is requested. Required.");
|
||||
RequestParam(r => r.ScanId, "The Id of the media library scan whose progress is requested. Required.");
|
||||
|
||||
ResponseParam<MediaLibraryScanProgressResponse>(r => r.ScanId, "The object representing the unique identifier of the media library scan.");
|
||||
ResponseParam<MediaLibraryScanProgressResponse>(r => r.UserId, "The object representing the unique identifier of the user initiating this media library scan.");
|
||||
ResponseParam<MediaLibraryScanProgressResponse>(r => r.LibraryId, "The object representing the unique identifier of the media library that is scanned.");
|
||||
ResponseParam<MediaLibraryScanProgressResponse>(r => r.TotalJobs, "The total number of jobs to be processed by the scan.");
|
||||
ResponseParam<MediaLibraryScanProgressResponse>(r => r.CompletedJobs, "The number of jobs that have been processed.");
|
||||
ResponseParam<MediaLibraryScanProgressResponse>(r => r.CurrentJobProgress, "The progress of the currently processing job.");
|
||||
@@ -39,6 +42,9 @@ public class GetLibraryScanProgressEndpointSummary : Summary<GetLibraryScanProgr
|
||||
ResponseParam<MediaLibraryScanProgressResponse>(r => r.OverallProgressPercentage, "The ratio between the number of processed jobs and the total number of jobs to process, as percentage.");
|
||||
|
||||
Response(200, "The progress of the media library scan is returned.", example: new MediaLibraryScanProgressResponse(
|
||||
ScanId: Guid.NewGuid(),
|
||||
UserId: Guid.NewGuid(),
|
||||
LibraryId: Guid.NewGuid(),
|
||||
TotalJobs: 10,
|
||||
CompletedJobs: 4,
|
||||
CurrentJobProgress: new MediaLibraryScanJobProgressResponse(
|
||||
@@ -47,7 +53,7 @@ public class GetLibraryScanProgressEndpointSummary : Summary<GetLibraryScanProgr
|
||||
CurrentOperation: "Comparing file hashes",
|
||||
ProgressPercentage: 50
|
||||
),
|
||||
Status: LibraryScanJobStatus.Running,
|
||||
Status: LibraryScanJobStatus.Running.ToString(),
|
||||
OverallProgressPercentage: 40
|
||||
));
|
||||
|
||||
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Queries.GetRunningLibraryScans;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.Management;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Common;
|
||||
using Mediator;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.Management.GetRunningLibraryScans;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/libraries/scans/running</c> route.
|
||||
/// </summary>
|
||||
public class GetRunningLibraryScansEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
private readonly ISender _sender;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetRunningLibraryScansEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="sender">Injected service for mediating commands and queries.</param>
|
||||
public GetRunningLibraryScansEndpoint(ISender sender)
|
||||
{
|
||||
_sender = sender;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the API endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
Verbs(Http.GET);
|
||||
Routes(ApiRoutes.Libraries.GET_RUNNING_LIBRARIES_SCAN);
|
||||
Version(1);
|
||||
DontCatchExceptions();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of ongoing media libraries scans.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(EmptyRequest _, CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<IEnumerable<MediaLibraryScanProgressResponse>> result = await _sender.Send(new GetRunningLibraryScansQuery(), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ using Lumina.DataAccess.Core.UoW;
|
||||
using Lumina.Domain.Common.DependencyInjection;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
|
||||
using Lumina.Infrastructure.Common.DependencyInjection;
|
||||
using Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Progress;
|
||||
using Lumina.Presentation.Api.Common.DependencyInjection;
|
||||
using Lumina.Presentation.Api.Common.Middlewares;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
@@ -93,12 +94,14 @@ public class Program
|
||||
}
|
||||
}
|
||||
|
||||
app.UseCors("AllowAll");
|
||||
app.UseRouting();
|
||||
app.UseCors("SecurePolicy");
|
||||
|
||||
//app.UseExceptionHandler("/error"); // uses a middleware which re-executes the request to the error path
|
||||
|
||||
//app.UseHttpsRedirection();
|
||||
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
app.UseRateLimiter();
|
||||
|
||||
@@ -123,8 +126,8 @@ public class Program
|
||||
.WithDotNetFlag(true);
|
||||
});
|
||||
|
||||
// add the middleware that fires domain events and ensures eventual transactional consistency
|
||||
app.UseMiddleware<EventualConsistencyMiddleware>();
|
||||
// add the middleware that fires domain events and ensures eventual transactional consistency, but NOT for long-polling/WebSockets stuff like SignalR, which would keep the db locked
|
||||
app.UseWhen(ctx => !ctx.Request.Path.StartsWithSegments("/scanProgressHub"), app => app.UseMiddleware<EventualConsistencyMiddleware>());
|
||||
|
||||
// create a directory relative to the application's startup directory, and use it to store static files that are served at the /media route on the API
|
||||
string mediaRootDirectoryPathSetting = app.Configuration.GetValue<string>("MediaSettings:RootDirectory") ?? string.Empty;
|
||||
@@ -149,6 +152,8 @@ public class Program
|
||||
RequestPath = "/media"
|
||||
});
|
||||
|
||||
app.MapHub<MediaLibraryScanProgressHub>("/scanProgressHub");
|
||||
|
||||
await app.RunAsync().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
@@ -51,5 +51,17 @@
|
||||
"Application": "LuminaApi"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
"AllowedHosts": "*",
|
||||
"CorsSettings": {
|
||||
"AllowedOrigins": [
|
||||
"http://localhost:5012"
|
||||
]
|
||||
},
|
||||
"Kestrel": {
|
||||
"Endpoints": {
|
||||
"Http": {
|
||||
"Url": "http://localhost:5214"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.Models.Libraries;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a media library scan job progress model.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("CompletedItems: {CompletedItems}; TotalItems: {TotalItems}")]
|
||||
public class LibraryScanJobProgressModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the number of completed items of the media library scan job.
|
||||
/// </summary>
|
||||
public int CompletedItems { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the total number of items of the media library scan job.
|
||||
/// </summary>
|
||||
public int TotalItems { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the current operation being performed by the media library scan job.
|
||||
/// </summary>
|
||||
public string? CurrentOperation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ratio between the total number and the completed number of items, as a percentage.
|
||||
/// </summary>
|
||||
public decimal ProgressPercentage { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Common.Models.Libraries;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a media library scan progress model.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("ScanId: {ScanId}; UserId: {UserId}; LibraryId: {LibraryId}")]
|
||||
public class LibraryScanProgressModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the unique identifier of the media library scan.
|
||||
/// </summary>
|
||||
public Guid ScanId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the unique identifier of the user initiating this media library scan.
|
||||
/// </summary>
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the unique identifier of the media library that is scanned.
|
||||
/// </summary>
|
||||
public Guid LibraryId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of completed jobs of the media library scan job.
|
||||
/// </summary>
|
||||
public int CompletedJobs { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the total number of jobs of the media library scan job.
|
||||
/// </summary>
|
||||
public int TotalJobs { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional current job progress of the media library scan.
|
||||
/// </summary>
|
||||
public LibraryScanJobProgressModel? CurrentJobProgress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the status of the media library scan.
|
||||
/// </summary>
|
||||
public string? Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ratio between the total number and the completed number of jobs, as a percentage.
|
||||
/// </summary>
|
||||
public decimal OverallProgressPercentage { get; set; }
|
||||
}
|
||||
+11
@@ -114,6 +114,17 @@ public class LibraryManagementController : Controller
|
||||
return Json(new { success = true });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of ongoing media library scans.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
[HttpGet("api-get-running-library-scans")]
|
||||
public async Task<IActionResult> GetRunningLibraryScans(CancellationToken cancellationToken = default)
|
||||
{
|
||||
LibraryScanProgressModel[] response = await _apiHttpClient.GetAsync<LibraryScanProgressModel[]>($"libraries/scans/running/", cancellationToken).ConfigureAwait(false);
|
||||
return Json(new { success = true, data = response });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initiates the scan of all media libraries.
|
||||
/// </summary>
|
||||
|
||||
+6
@@ -585,4 +585,10 @@
|
||||
<data name="CompletedScanJobsCountCantExceedTotalScanJobsCount" xml:space="preserve">
|
||||
<value>Anzahl der abgeschlossenen Scan-Aufträge darf die Gesamtanzahl der Scan-Aufträge nicht überschreiten!</value>
|
||||
</data>
|
||||
<data name="CorsOriginsCannotBeEmpty" xml:space="preserve">
|
||||
<value>CORS-Origins dürfen nicht leer sein!</value>
|
||||
</data>
|
||||
<data name="CorsOriginIsInvalid" xml:space="preserve">
|
||||
<value>Ungültiger CORS-Origin!</value>
|
||||
</data>
|
||||
</root>
|
||||
+6
@@ -585,4 +585,10 @@
|
||||
<data name="CompletedScanJobsCountCantExceedTotalScanJobsCount" xml:space="preserve">
|
||||
<value>Completed scan jobs count can't exceed total scan jobs count!</value>
|
||||
</data>
|
||||
<data name="CorsOriginsCannotBeEmpty" xml:space="preserve">
|
||||
<value>CORS origins cannot be empty!</value>
|
||||
</data>
|
||||
<data name="CorsOriginIsInvalid" xml:space="preserve">
|
||||
<value>CORS origin is invalid!</value>
|
||||
</data>
|
||||
</root>
|
||||
+6
@@ -585,4 +585,10 @@
|
||||
<data name="CompletedScanJobsCountCantExceedTotalScanJobsCount" xml:space="preserve">
|
||||
<value>¡El número de trabajos de escaneo completados no puede exceder el número total de trabajos de escaneo!</value>
|
||||
</data>
|
||||
<data name="CorsOriginsCannotBeEmpty" xml:space="preserve">
|
||||
<value>¡Las origines CORS no pueden estar vacías!</value>
|
||||
</data>
|
||||
<data name="CorsOriginIsInvalid" xml:space="preserve">
|
||||
<value>¡Origen CORS no válido!</value>
|
||||
</data>
|
||||
</root>
|
||||
+6
@@ -585,4 +585,10 @@
|
||||
<data name="CompletedScanJobsCountCantExceedTotalScanJobsCount" xml:space="preserve">
|
||||
<value>Le nombre de tâches de scan terminées ne peut pas dépasser le nombre total de tâches de scan !</value>
|
||||
</data>
|
||||
<data name="CorsOriginsCannotBeEmpty" xml:space="preserve">
|
||||
<value>Les origines CORS ne peuvent pas être vides !</value>
|
||||
</data>
|
||||
<data name="CorsOriginIsInvalid" xml:space="preserve">
|
||||
<value>Origine CORS invalide !</value>
|
||||
</data>
|
||||
</root>
|
||||
+6
@@ -585,4 +585,10 @@
|
||||
<data name="CompletedScanJobsCountCantExceedTotalScanJobsCount" xml:space="preserve">
|
||||
<value>Il numero dei lavori di scansione completati non può superare il numero totale dei lavori di scansione!</value>
|
||||
</data>
|
||||
<data name="CorsOriginsCannotBeEmpty" xml:space="preserve">
|
||||
<value>Le origini CORS non possono essere vuote!</value>
|
||||
</data>
|
||||
<data name="CorsOriginIsInvalid" xml:space="preserve">
|
||||
<value>Origine CORS non valida!</value>
|
||||
</data>
|
||||
</root>
|
||||
+6
@@ -585,4 +585,10 @@
|
||||
<data name="CompletedScanJobsCountCantExceedTotalScanJobsCount" xml:space="preserve">
|
||||
<value>完了したスキャンジョブ数は合計スキャンジョブ数を超えることはできません!</value>
|
||||
</data>
|
||||
<data name="CorsOriginsCannotBeEmpty" xml:space="preserve">
|
||||
<value>CORSオリジンは空ではいけません!</value>
|
||||
</data>
|
||||
<data name="CorsOriginIsInvalid" xml:space="preserve">
|
||||
<value>CORSオリジンが無効です!</value>
|
||||
</data>
|
||||
</root>
|
||||
+6
@@ -585,4 +585,10 @@
|
||||
<data name="CompletedScanJobsCountCantExceedTotalScanJobsCount" xml:space="preserve">
|
||||
<value>Completed scan jobs count can't exceed total scan jobs count!</value>
|
||||
</data>
|
||||
<data name="CorsOriginsCannotBeEmpty" xml:space="preserve">
|
||||
<value>CORS origins cannot be empty!</value>
|
||||
</data>
|
||||
<data name="CorsOriginIsInvalid" xml:space="preserve">
|
||||
<value>CORS origin is invalid!</value>
|
||||
</data>
|
||||
</root>
|
||||
+6
@@ -585,4 +585,10 @@
|
||||
<data name="CompletedScanJobsCountCantExceedTotalScanJobsCount" xml:space="preserve">
|
||||
<value>Numărul de job-uri de scanare completate nu poate depăși numărul total de job-uri de scanare!</value>
|
||||
</data>
|
||||
<data name="CorsOriginsCannotBeEmpty" xml:space="preserve">
|
||||
<value>Originile CORS nu pot fi goale!</value>
|
||||
</data>
|
||||
<data name="CorsOriginIsInvalid" xml:space="preserve">
|
||||
<value>Origine CORS invalidă!</value>
|
||||
</data>
|
||||
</root>
|
||||
+6
@@ -585,4 +585,10 @@
|
||||
<data name="CompletedScanJobsCountCantExceedTotalScanJobsCount" xml:space="preserve">
|
||||
<value>Количество завершенных заданий сканирования не может превышать общее количество заданий сканирования!</value>
|
||||
</data>
|
||||
<data name="CorsOriginsCannotBeEmpty" xml:space="preserve">
|
||||
<value>Список CORS-источников не может быть пустым!</value>
|
||||
</data>
|
||||
<data name="CorsOriginIsInvalid" xml:space="preserve">
|
||||
<value>Недействительный CORS-источник!</value>
|
||||
</data>
|
||||
</root>
|
||||
+6
@@ -585,4 +585,10 @@
|
||||
<data name="CompletedScanJobsCountCantExceedTotalScanJobsCount" xml:space="preserve">
|
||||
<value>已完成扫描任务数量不能超过扫描任务总数!</value>
|
||||
</data>
|
||||
<data name="CorsOriginsCannotBeEmpty" xml:space="preserve">
|
||||
<value>CORS来源不能为空!</value>
|
||||
</data>
|
||||
<data name="CorsOriginIsInvalid" xml:space="preserve">
|
||||
<value>CORS来源无效!</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -135,6 +135,9 @@
|
||||
<data name="BookSeries" xml:space="preserve">
|
||||
<value>Buchreihe</value>
|
||||
</data>
|
||||
<data name="Canceled" xml:space="preserve">
|
||||
<value>Abgebrochen</value>
|
||||
</data>
|
||||
<data name="CancelScan" xml:space="preserve">
|
||||
<value>Scan Abbrechen</value>
|
||||
</data>
|
||||
@@ -147,6 +150,9 @@
|
||||
<data name="ComparingFileHashes" xml:space="preserve">
|
||||
<value>Datei-Hashes werden verglichen...</value>
|
||||
</data>
|
||||
<data name="Completed" xml:space="preserve">
|
||||
<value>Abgeschlossen</value>
|
||||
</data>
|
||||
<data name="Concert" xml:space="preserve">
|
||||
<value>Konzert</value>
|
||||
</data>
|
||||
@@ -171,6 +177,9 @@
|
||||
<data name="Enabled" xml:space="preserve">
|
||||
<value>Aktiviert</value>
|
||||
</data>
|
||||
<data name="Failed" xml:space="preserve">
|
||||
<value>Fehlgeschlagen</value>
|
||||
</data>
|
||||
<data name="FilmFranchise" xml:space="preserve">
|
||||
<value>Filmfranchise</value>
|
||||
</data>
|
||||
|
||||
@@ -135,6 +135,9 @@
|
||||
<data name="BookSeries" xml:space="preserve">
|
||||
<value>Book Series</value>
|
||||
</data>
|
||||
<data name="Canceled" xml:space="preserve">
|
||||
<value>Canceled</value>
|
||||
</data>
|
||||
<data name="CancelScan" xml:space="preserve">
|
||||
<value>Cancel Scan</value>
|
||||
</data>
|
||||
@@ -147,6 +150,9 @@
|
||||
<data name="ComparingFileHashes" xml:space="preserve">
|
||||
<value>Comparing file hashes...</value>
|
||||
</data>
|
||||
<data name="Completed" xml:space="preserve">
|
||||
<value>Completed</value>
|
||||
</data>
|
||||
<data name="Concert" xml:space="preserve">
|
||||
<value>Concert</value>
|
||||
</data>
|
||||
@@ -171,6 +177,9 @@
|
||||
<data name="Enabled" xml:space="preserve">
|
||||
<value>Enabled</value>
|
||||
</data>
|
||||
<data name="Failed" xml:space="preserve">
|
||||
<value>Failed</value>
|
||||
</data>
|
||||
<data name="FilmFranchise" xml:space="preserve">
|
||||
<value>Film Franchise</value>
|
||||
</data>
|
||||
|
||||
@@ -135,6 +135,9 @@
|
||||
<data name="BookSeries" xml:space="preserve">
|
||||
<value>Serie de Libros</value>
|
||||
</data>
|
||||
<data name="Canceled" xml:space="preserve">
|
||||
<value>Cancelado</value>
|
||||
</data>
|
||||
<data name="CancelScan" xml:space="preserve">
|
||||
<value>Cancelar Escaneo</value>
|
||||
</data>
|
||||
@@ -147,6 +150,9 @@
|
||||
<data name="ComparingFileHashes" xml:space="preserve">
|
||||
<value>Se están comparando hashes de archivos...</value>
|
||||
</data>
|
||||
<data name="Completed" xml:space="preserve">
|
||||
<value>Completado</value>
|
||||
</data>
|
||||
<data name="Concert" xml:space="preserve">
|
||||
<value>Concierto</value>
|
||||
</data>
|
||||
@@ -171,6 +177,9 @@
|
||||
<data name="Enabled" xml:space="preserve">
|
||||
<value>Activado</value>
|
||||
</data>
|
||||
<data name="Failed" xml:space="preserve">
|
||||
<value>Fallido</value>
|
||||
</data>
|
||||
<data name="FilmFranchise" xml:space="preserve">
|
||||
<value>Franquicia Cinematográfica</value>
|
||||
</data>
|
||||
|
||||
@@ -135,6 +135,9 @@
|
||||
<data name="BookSeries" xml:space="preserve">
|
||||
<value>Série de Livres</value>
|
||||
</data>
|
||||
<data name="Canceled" xml:space="preserve">
|
||||
<value>Annulé</value>
|
||||
</data>
|
||||
<data name="CancelScan" xml:space="preserve">
|
||||
<value>Annuler Le Scan</value>
|
||||
</data>
|
||||
@@ -147,6 +150,9 @@
|
||||
<data name="ComparingFileHashes" xml:space="preserve">
|
||||
<value>Comparer les hachages de fichiers...</value>
|
||||
</data>
|
||||
<data name="Completed" xml:space="preserve">
|
||||
<value>Terminé</value>
|
||||
</data>
|
||||
<data name="Concert" xml:space="preserve">
|
||||
<value>Concert</value>
|
||||
</data>
|
||||
@@ -171,6 +177,9 @@
|
||||
<data name="Enabled" xml:space="preserve">
|
||||
<value>Activé</value>
|
||||
</data>
|
||||
<data name="Failed" xml:space="preserve">
|
||||
<value>Échec</value>
|
||||
</data>
|
||||
<data name="FilmFranchise" xml:space="preserve">
|
||||
<value>Franchise Cinématographique</value>
|
||||
</data>
|
||||
|
||||
@@ -135,6 +135,9 @@
|
||||
<data name="BookSeries" xml:space="preserve">
|
||||
<value>Serie di Libri</value>
|
||||
</data>
|
||||
<data name="Canceled" xml:space="preserve">
|
||||
<value>Annullato</value>
|
||||
</data>
|
||||
<data name="CancelScan" xml:space="preserve">
|
||||
<value>Annulla Scansione</value>
|
||||
</data>
|
||||
@@ -147,6 +150,9 @@
|
||||
<data name="ComparingFileHashes" xml:space="preserve">
|
||||
<value>Si stanno confrontando gli hash dei file...</value>
|
||||
</data>
|
||||
<data name="Completed" xml:space="preserve">
|
||||
<value>Completato</value>
|
||||
</data>
|
||||
<data name="Concert" xml:space="preserve">
|
||||
<value>Concerto</value>
|
||||
</data>
|
||||
@@ -171,6 +177,9 @@
|
||||
<data name="Enabled" xml:space="preserve">
|
||||
<value>Attivato</value>
|
||||
</data>
|
||||
<data name="Failed" xml:space="preserve">
|
||||
<value>Fallito</value>
|
||||
</data>
|
||||
<data name="FilmFranchise" xml:space="preserve">
|
||||
<value>Franchise Cinematografico</value>
|
||||
</data>
|
||||
|
||||
@@ -135,6 +135,9 @@
|
||||
<data name="BookSeries" xml:space="preserve">
|
||||
<value>本シリーズ</value>
|
||||
</data>
|
||||
<data name="Canceled" xml:space="preserve">
|
||||
<value>キャンセル済み</value>
|
||||
</data>
|
||||
<data name="CancelScan" xml:space="preserve">
|
||||
<value>スキャンを中止</value>
|
||||
</data>
|
||||
@@ -147,6 +150,9 @@
|
||||
<data name="ComparingFileHashes" xml:space="preserve">
|
||||
<value>ファイルのハッシュを比較中...</value>
|
||||
</data>
|
||||
<data name="Completed" xml:space="preserve">
|
||||
<value>完了</value>
|
||||
</data>
|
||||
<data name="Concert" xml:space="preserve">
|
||||
<value>コンサート</value>
|
||||
</data>
|
||||
@@ -171,6 +177,9 @@
|
||||
<data name="Enabled" xml:space="preserve">
|
||||
<value>有効</value>
|
||||
</data>
|
||||
<data name="Failed" xml:space="preserve">
|
||||
<value>失敗</value>
|
||||
</data>
|
||||
<data name="FilmFranchise" xml:space="preserve">
|
||||
<value>映画フランチャイズ</value>
|
||||
</data>
|
||||
|
||||
@@ -135,6 +135,9 @@
|
||||
<data name="BookSeries" xml:space="preserve">
|
||||
<value>Book Series</value>
|
||||
</data>
|
||||
<data name="Canceled" xml:space="preserve">
|
||||
<value>Canceled</value>
|
||||
</data>
|
||||
<data name="CancelScan" xml:space="preserve">
|
||||
<value>Cancel Scan</value>
|
||||
</data>
|
||||
@@ -147,6 +150,9 @@
|
||||
<data name="ComparingFileHashes" xml:space="preserve">
|
||||
<value>Comparing file hashes...</value>
|
||||
</data>
|
||||
<data name="Completed" xml:space="preserve">
|
||||
<value>Completed</value>
|
||||
</data>
|
||||
<data name="Concert" xml:space="preserve">
|
||||
<value>Concert</value>
|
||||
</data>
|
||||
@@ -171,6 +177,9 @@
|
||||
<data name="Enabled" xml:space="preserve">
|
||||
<value>Enabled</value>
|
||||
</data>
|
||||
<data name="Failed" xml:space="preserve">
|
||||
<value>Failed</value>
|
||||
</data>
|
||||
<data name="FilmFranchise" xml:space="preserve">
|
||||
<value>Film Franchise</value>
|
||||
</data>
|
||||
|
||||
@@ -135,6 +135,9 @@
|
||||
<data name="BookSeries" xml:space="preserve">
|
||||
<value>Serie de Cărți</value>
|
||||
</data>
|
||||
<data name="Canceled" xml:space="preserve">
|
||||
<value>Anulat</value>
|
||||
</data>
|
||||
<data name="CancelScan" xml:space="preserve">
|
||||
<value>Anulează Scanarea</value>
|
||||
</data>
|
||||
@@ -147,6 +150,9 @@
|
||||
<data name="ComparingFileHashes" xml:space="preserve">
|
||||
<value>Se compară hash-urile fișierelor...</value>
|
||||
</data>
|
||||
<data name="Completed" xml:space="preserve">
|
||||
<value>Finalizat</value>
|
||||
</data>
|
||||
<data name="Concert" xml:space="preserve">
|
||||
<value>Concert</value>
|
||||
</data>
|
||||
@@ -171,6 +177,9 @@
|
||||
<data name="Enabled" xml:space="preserve">
|
||||
<value>Activat</value>
|
||||
</data>
|
||||
<data name="Failed" xml:space="preserve">
|
||||
<value>Eșuat</value>
|
||||
</data>
|
||||
<data name="FilmFranchise" xml:space="preserve">
|
||||
<value>Franciză de Film</value>
|
||||
</data>
|
||||
|
||||
@@ -135,6 +135,9 @@
|
||||
<data name="BookSeries" xml:space="preserve">
|
||||
<value>Книжная Серия</value>
|
||||
</data>
|
||||
<data name="Canceled" xml:space="preserve">
|
||||
<value>Отменено</value>
|
||||
</data>
|
||||
<data name="CancelScan" xml:space="preserve">
|
||||
<value>Отменить Сканирование</value>
|
||||
</data>
|
||||
@@ -147,6 +150,9 @@
|
||||
<data name="ComparingFileHashes" xml:space="preserve">
|
||||
<value>Сравнение хешей файлов...</value>
|
||||
</data>
|
||||
<data name="Completed" xml:space="preserve">
|
||||
<value>Завершено</value>
|
||||
</data>
|
||||
<data name="Concert" xml:space="preserve">
|
||||
<value>Концерт</value>
|
||||
</data>
|
||||
@@ -171,6 +177,9 @@
|
||||
<data name="Enabled" xml:space="preserve">
|
||||
<value>Включено</value>
|
||||
</data>
|
||||
<data name="Failed" xml:space="preserve">
|
||||
<value>Ошибка</value>
|
||||
</data>
|
||||
<data name="FilmFranchise" xml:space="preserve">
|
||||
<value>Кинофраншиза</value>
|
||||
</data>
|
||||
|
||||
@@ -135,6 +135,9 @@
|
||||
<data name="BookSeries" xml:space="preserve">
|
||||
<value>丛书</value>
|
||||
</data>
|
||||
<data name="Canceled" xml:space="preserve">
|
||||
<value>已取消</value>
|
||||
</data>
|
||||
<data name="CancelScan" xml:space="preserve">
|
||||
<value>取消扫描</value>
|
||||
</data>
|
||||
@@ -147,6 +150,9 @@
|
||||
<data name="ComparingFileHashes" xml:space="preserve">
|
||||
<value>正在比较文件哈希值...</value>
|
||||
</data>
|
||||
<data name="Completed" xml:space="preserve">
|
||||
<value>已完成</value>
|
||||
</data>
|
||||
<data name="Concert" xml:space="preserve">
|
||||
<value>音乐会</value>
|
||||
</data>
|
||||
@@ -171,6 +177,9 @@
|
||||
<data name="Enabled" xml:space="preserve">
|
||||
<value>已启用</value>
|
||||
</data>
|
||||
<data name="Failed" xml:space="preserve">
|
||||
<value>失败</value>
|
||||
</data>
|
||||
<data name="FilmFranchise" xml:space="preserve">
|
||||
<value>电影系列品牌</value>
|
||||
</data>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
@using Lumina.Presentation.Web.Common.Models.Libraries
|
||||
@using Lumina.Presentation.Web.Common.Services
|
||||
@using Microsoft.AspNetCore.Mvc.Localization
|
||||
@using System.Security.Claims
|
||||
|
||||
@{
|
||||
// generate a unique id for the scripts section of this view, so it can be dynamically loaded/unloaded by the global AJAX navigator handler
|
||||
@@ -14,6 +15,90 @@
|
||||
@inject IUrlService _urlService
|
||||
@inject IViewLocalizer _localizer
|
||||
|
||||
<style>
|
||||
/* main container */
|
||||
.td-scan {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
padding: 4px 0;
|
||||
min-height: 50px;
|
||||
}
|
||||
|
||||
/* text label */
|
||||
.scan-job-status {
|
||||
flex: 1;
|
||||
padding: 0 10px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
/* progress bar container */
|
||||
.scan-progress {
|
||||
flex: 0 0 80px;
|
||||
height: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin: 10px;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
/* progress bars */
|
||||
.scan-progress-total,
|
||||
.scan-progress-job {
|
||||
height: 50%;
|
||||
background: #ddd;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.scan-progress-total > div,
|
||||
.scan-progress-job > div {
|
||||
height: 100%;
|
||||
background: #4CAF50;
|
||||
transition: width 0.3s ease;
|
||||
}
|
||||
|
||||
.icon-groups {
|
||||
flex: 0 0 auto; /* prevent shrinking */
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-left: auto; /* push to right */
|
||||
}
|
||||
|
||||
/* status icons subgroup */
|
||||
.status-icons {
|
||||
display: flex;
|
||||
gap: 5px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* action icons subgroup */
|
||||
.action-icons {
|
||||
display: flex;
|
||||
gap: 5px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* icon groups */
|
||||
/* status icons (right margin group) */
|
||||
img[src*="green.png"],
|
||||
img[src*="red.png"],
|
||||
img[src*="yellow.png"] {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
/* action icons (fixed size group) */
|
||||
img[src*="stop.svg"],
|
||||
img[src*="trigger.svg"],
|
||||
img[src*="delete.svg"],
|
||||
a > img[src*="edit.svg"] {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div style="display: grid; grid-template-rows: auto 1fr;"><!--container with two rows, one fixed, one filling remaining space-->
|
||||
<div style="min-height: 1rem;"></div><!--the first row is a dummy row for "margin", because setting a margin on the next row would offset the parent's position-->
|
||||
<div class="enlightenment-panel shadow-effect mx-auto panel w-75 mb-10" style="min-width: 320px;">
|
||||
@@ -27,10 +112,10 @@
|
||||
<thead class="text-light-two">
|
||||
<tr>
|
||||
<th class="w-30">@_localizer["Title"]</th>
|
||||
<th class="w-30">@_localizer["LibraryType"]</th>
|
||||
<th class="w-15">@_localizer["LibraryType"]</th>
|
||||
<th class="w-10">@_localizer["Enabled"]</th>
|
||||
<th class="w-10">@_localizer["Locked"]</th>
|
||||
<th class="w-20">@_localizer["Actions"]</th>
|
||||
<th class="w-35">@_localizer["Actions"]</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -49,6 +134,18 @@
|
||||
// create cleanup registry for this view
|
||||
const cleanupFunctions = [];
|
||||
let isInitialized = false;
|
||||
const jsLocalizedLibraryScanStatuses = {
|
||||
Completed: '@_localizer["Completed"]',
|
||||
Failed: '@_localizer["Failed"]',
|
||||
Canceled: '@_localizer["Canceled"]'
|
||||
};
|
||||
const jsLocalizedLibraryScanJobsStatuses = {
|
||||
DiscoveringFiles: '@_localizer["DiscoveringFiles"]',
|
||||
RetrievingPastScanData: '@_localizer["RetrievingPastScanData"]',
|
||||
ComparingFileHashes: '@_localizer["ComparingFileHashes"]',
|
||||
GoodReadsMetadataDownload: '@_localizer["GoodReadsMetadataDownload"]',
|
||||
SavingScanData: '@_localizer["SavingScanData"]'
|
||||
};
|
||||
const jsLocalizedLibraryTypes = {
|
||||
Book: '@_localizer["Book"]',
|
||||
EBook: '@_localizer["EBook"]',
|
||||
@@ -87,7 +184,17 @@
|
||||
const btnScanAllLibraries = document.getElementById('btn-scan-all-libraries');
|
||||
const btnCancelLibrariesScan = document.getElementById('btn-cancel-libraries-scan');
|
||||
|
||||
// on view load
|
||||
// SignalR
|
||||
const signalRConnection = new signalR.HubConnectionBuilder()
|
||||
.withUrl('http://localhost:5214/scanProgressHub')
|
||||
.withAutomaticReconnect({
|
||||
nextRetryDelayInMilliseconds: retryContext =>
|
||||
Math.min(retryContext.elapsedMilliseconds * 2, 10000)
|
||||
})
|
||||
.configureLogging(signalR.LogLevel.Warning)
|
||||
.build();
|
||||
|
||||
// get media libraries
|
||||
const loadLibrariesAsync = async function() {
|
||||
const response = await callApiGetAsync('@_urlService.GetAbsoluteUrl("GetLibraries", "LibraryManagement")');
|
||||
const table = document.getElementById('media-libraries-table');
|
||||
@@ -107,13 +214,29 @@
|
||||
<td>${jsLocalizedLibraryTypes[library.libraryType]}</td>
|
||||
<td class="text-center">${library.isEnabled === true ? `@_localizer["Yes"]` : `@_localizer["No"]`}</td>
|
||||
<td class="text-center">${library.isLocked === true ? `@_localizer["Yes"]` : `@_localizer["No"]`}</td>
|
||||
<td class="text-end">
|
||||
<img src="/images/ui/stop.svg" alt="@_localizer["CancelScan"]" title="@_localizer["CancelScan"]" class="hidden remove-form-table-row-icon" />
|
||||
<img src="/images/ui/trigger.svg" alt="@_localizer["Scan"]" title="@_localizer["Scan"]" class="remove-form-table-row-icon" />
|
||||
<a href="${editUrl}">
|
||||
<img src="/images/ui/edit.svg" alt="@_localizer["Edit"]" title="@_localizer["Edit"]" class="remove-form-table-row-icon" />
|
||||
</a>
|
||||
<img src="/images/ui/delete.svg" alt="@_localizer["Remove"]" title="@_localizer["Remove"]" class="remove-form-table-row-icon" />
|
||||
<td class="td-scan">
|
||||
<span class="scan-job-status hidden">Downloading metadata</span>
|
||||
<div class="scan-progress hidden">
|
||||
<div class="scan-progress-total"><div></div></div>
|
||||
<div class="scan-progress-job"><div></div></div>
|
||||
</div>
|
||||
|
||||
<div class="icon-groups">
|
||||
<div class="status-icons">
|
||||
<img src="/images/ui/green.png" alt="@_localizer["Completed"]" title="@_localizer["Completed"]" class="hidden status-icon" />
|
||||
<img src="/images/ui/red.png" alt="@_localizer["Failed"]" title="@_localizer["Failed"]" class="hidden status-icon" />
|
||||
<img src="/images/ui/yellow.png" alt="@_localizer["Canceled"]" title="@_localizer["Canceled"]" class="hidden status-icon" />
|
||||
</div>
|
||||
|
||||
<div class="action-icons">
|
||||
<img src="/images/ui/stop.svg" alt="@_localizer["CancelScan"]" title="@_localizer["CancelScan"]" class="hidden action-icon" />
|
||||
<img src="/images/ui/trigger.svg" alt="@_localizer["Scan"]" title="@_localizer["Scan"]" class="action-icon" />
|
||||
<a href="${editUrl}">
|
||||
<img src="/images/ui/edit.svg" alt="@_localizer["Edit"]" title="@_localizer["Edit"]" class="action-icon" />
|
||||
</a>
|
||||
<img src="/images/ui/delete.svg" alt="@_localizer["Remove"]" title="@_localizer["Remove"]" class="mr-5 action-icon" />
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
@@ -125,6 +248,40 @@
|
||||
}
|
||||
};
|
||||
|
||||
// get which libraries have active scans
|
||||
const getRunningLibraryScansAsync = async function() {
|
||||
const response = await callApiGetAsync('@_urlService.GetAbsoluteUrl("GetRunningLibraryScans", "LibraryManagement")');
|
||||
if (response && response.length > 0) {
|
||||
await Promise.all(response.map(async scan => {
|
||||
const row = document.querySelector(`tr[data-library-id="${scan.libraryId}"]`);
|
||||
if (row) {
|
||||
// restore UI state
|
||||
const scanProgress = row.querySelector('.scan-progress');
|
||||
const totalProgressDiv = row.querySelector('.scan-progress-total > div');
|
||||
const jobProgressDiv = row.querySelector('.scan-progress-job > div');
|
||||
const statusSpan = row.querySelector('.scan-job-status');
|
||||
const scanIcon = row.querySelector('img[src*="trigger.svg"]');
|
||||
const cancelScanIcon = row.querySelector('img[src*="stop.svg"]');
|
||||
|
||||
row.setAttribute('data-scan-id', scan.scanId);
|
||||
|
||||
statusSpan.textContent = jsLocalizedLibraryScanJobsStatuses[scan.currentJobProgress.currentOperation];
|
||||
statusSpan.classList.remove('hidden');
|
||||
|
||||
scanProgress.classList.remove('hidden');
|
||||
totalProgressDiv.style.width = `${scan.overallProgressPercentage}%`;
|
||||
jobProgressDiv.style.width = `${scan.currentJobProgress.progressPercentage}%`;
|
||||
|
||||
scanIcon.classList.add('hidden');
|
||||
cancelScanIcon.classList.remove('hidden');
|
||||
|
||||
// re-subscribe to SignalR
|
||||
await signalRConnection.invoke('SubscribeToScan', scan.scanId, '@User.FindFirst(ClaimTypes.NameIdentifier)?.Value');
|
||||
}
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
// on delete library icon click
|
||||
const handleDeleteLibraryClick = async function(e) {
|
||||
if (e.target.matches('img[src*="delete.svg"]')) {
|
||||
@@ -152,15 +309,27 @@
|
||||
|
||||
// toggle icons only for libraries that had their scan started
|
||||
const tbody = document.querySelector('tbody');
|
||||
data.forEach(scan => {
|
||||
data.forEach(async scan => {
|
||||
const row = tbody.querySelector(`tr[data-library-id="${scan.libraryId}"]`);
|
||||
if (row) {
|
||||
row.setAttribute('data-scan-id', scan.scanId);
|
||||
const scanIcon = row.querySelector('img[src*="trigger.svg"]');
|
||||
const cancelScanIcon = row.querySelector('img[src*="stop.svg"]');
|
||||
const completedIdon = row.querySelector('img[src*="green.png"]');
|
||||
const failedIdon = row.querySelector('img[src*="red.png"]');
|
||||
const canceledIdon = row.querySelector('img[src*="yellow.png"]');
|
||||
|
||||
// hide scan status icons
|
||||
completedIdon.classList.add('hidden');
|
||||
failedIdon.classList.add('hidden');
|
||||
canceledIdon.classList.add('hidden');
|
||||
// toggle visibility on scan action icons
|
||||
scanIcon.classList.add('hidden');
|
||||
cancelScanIcon.classList.remove('hidden');
|
||||
|
||||
const scanId = scan.scanId;
|
||||
const userId = '@User.FindFirst(ClaimTypes.NameIdentifier)?.Value';
|
||||
await signalRConnection.invoke('SubscribeToScan', scanId, userId);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -179,9 +348,21 @@
|
||||
row.setAttribute('data-scan-id', success.scanId);
|
||||
const scanIcon = e.target;
|
||||
const cancelScanIcon = row.querySelector('img[src*="stop.svg"]');
|
||||
const completedIdon = row.querySelector('img[src*="green.png"]');
|
||||
const failedIdon = row.querySelector('img[src*="red.png"]');
|
||||
const canceledIdon = row.querySelector('img[src*="yellow.png"]');
|
||||
|
||||
// hide scan status icons
|
||||
completedIdon.classList.add('hidden');
|
||||
failedIdon.classList.add('hidden');
|
||||
canceledIdon.classList.add('hidden');
|
||||
// toggle visibility on scan action icons
|
||||
scanIcon.classList.add('hidden');
|
||||
cancelScanIcon.classList.remove('hidden');
|
||||
|
||||
const scanId = success.scanId;
|
||||
const userId = '@User.FindFirst(ClaimTypes.NameIdentifier)?.Value';
|
||||
await signalRConnection.invoke('SubscribeToScan', scanId, userId);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -192,14 +373,25 @@
|
||||
btnCancelLibrariesScan.style.display = 'none';
|
||||
btnScanAllLibraries.style.display = 'block';
|
||||
|
||||
// toggle icons for all rows
|
||||
const tbody = document.querySelector('tbody');
|
||||
const allRows = tbody.querySelectorAll('tr');
|
||||
// toggle icons for all active scan rows
|
||||
const rows = document.querySelectorAll('tr[data-scan-id]');
|
||||
|
||||
allRows.forEach(row => {
|
||||
rows.forEach(row => {
|
||||
// remove the scan Id, its no longer being scanned
|
||||
row.removeAttribute('data-scan-id');
|
||||
|
||||
const statusSpan = row.querySelector('.scan-job-status');
|
||||
statusSpan.textContent = `${jsLocalizedLibraryScanStatuses['Canceled']}.`;
|
||||
const scanProgress = row.querySelector('.scan-progress');
|
||||
scanProgress.classList.add('hidden');
|
||||
|
||||
// show scan status icon
|
||||
const completedIdon = row.querySelector('img[src*="yellow.png"]');
|
||||
completedIdon.classList.remove('hidden');
|
||||
|
||||
// toggle scan action icons
|
||||
const scanIcon = row.querySelector('img[src*="trigger.svg"]');
|
||||
const cancelScanIcon = row.querySelector('img[src*="stop.svg"]');
|
||||
|
||||
scanIcon.classList.remove('hidden');
|
||||
cancelScanIcon.classList.add('hidden');
|
||||
});
|
||||
@@ -228,14 +420,140 @@
|
||||
).join('/');
|
||||
|
||||
await callApiPostAsync(finalUrl);
|
||||
|
||||
// remove the scan Id, its no longer being scanned
|
||||
row.removeAttribute('data-scan-id');
|
||||
|
||||
const statusSpan = row.querySelector('.scan-job-status');
|
||||
statusSpan.textContent = `${jsLocalizedLibraryScanStatuses['Canceled']}.`;
|
||||
const scanProgress = row.querySelector('.scan-progress');
|
||||
scanProgress.classList.add('hidden');
|
||||
|
||||
// show scan status icon
|
||||
const completedIdon = row.querySelector('img[src*="yellow.png"]');
|
||||
completedIdon.classList.remove('hidden');
|
||||
|
||||
// toggle scan action icons
|
||||
const scanIcon = row.querySelector('img[src*="trigger.svg"]');
|
||||
const cancelScanIcon = row.querySelector('img[src*="stop.svg"]');
|
||||
|
||||
scanIcon.classList.remove('hidden');
|
||||
cancelScanIcon.classList.add('hidden');
|
||||
|
||||
// toggle scan action buttons
|
||||
const hasActiveScans = document.querySelectorAll('tr[data-scan-id]').length > 0;
|
||||
btnCancelLibrariesScan.style.display = hasActiveScans ? 'block' : 'none';
|
||||
btnScanAllLibraries.style.display = hasActiveScans ? 'none' : 'block';
|
||||
}
|
||||
};
|
||||
|
||||
// handle all SignalR stuff
|
||||
function setupSignalRHandlers() {
|
||||
const onReconnecting = error => {
|
||||
console.log(error ? `SignalR reconnected with error: ${error}` : "SignalR reconnecting...");
|
||||
};
|
||||
const onReconnected = connectionId => {
|
||||
console.log('SignalR reconnected:', connectionId);
|
||||
};
|
||||
const onClose = error => {
|
||||
console.log(error ? `SignalR connection closed with error: ${error}` : "SignalR connection closed");
|
||||
};
|
||||
// progress update handler
|
||||
const progressHandler = (progress) => {
|
||||
const rows = document.querySelectorAll(`tr[data-scan-id="${progress.scanId}"]`);
|
||||
rows.forEach(row => {
|
||||
// update status text
|
||||
const statusSpan = row.querySelector('.scan-job-status');
|
||||
statusSpan.textContent = jsLocalizedLibraryScanJobsStatuses[progress.currentJobProgress.currentOperation];
|
||||
statusSpan.classList.remove('hidden');
|
||||
|
||||
// update progress bars
|
||||
const scanProgress = row.querySelector('.scan-progress');
|
||||
const totalProgressDiv = row.querySelector('.scan-progress-total > div');
|
||||
const jobProgressDiv = row.querySelector('.scan-progress-job > div');
|
||||
scanProgress.classList.remove('hidden');
|
||||
totalProgressDiv.style.width = `${progress.overallProgressPercentage}%`;
|
||||
jobProgressDiv.style.width = `${progress.currentJobProgress.progressPercentage}%`;
|
||||
|
||||
// toggle scan action icons
|
||||
const scanIcon = row.querySelector('img[src*="trigger.svg"]');
|
||||
const cancelScanIcon = row.querySelector('img[src*="stop.svg"]');
|
||||
scanIcon.classList.add('hidden');
|
||||
cancelScanIcon.classList.remove('hidden');
|
||||
});
|
||||
};
|
||||
|
||||
// scan completion handler
|
||||
const completionHandler = (progress) => {
|
||||
const rows = document.querySelectorAll(`tr[data-scan-id="${progress.scanId}"]`);
|
||||
rows.forEach(row => {
|
||||
// remove the scan Id, its no longer being scanned
|
||||
row.removeAttribute('data-scan-id');
|
||||
|
||||
const statusSpan = row.querySelector('.scan-job-status');
|
||||
statusSpan.textContent = `${jsLocalizedLibraryScanStatuses[progress.status]}.`;
|
||||
const scanProgress = row.querySelector('.scan-progress');
|
||||
scanProgress.classList.add('hidden');
|
||||
|
||||
// show scan status icon
|
||||
const completedIdon = row.querySelector('img[src*="green.png"]');
|
||||
completedIdon.classList.remove('hidden');
|
||||
|
||||
// toggle scan action icons
|
||||
const scanIcon = row.querySelector('img[src*="trigger.svg"]');
|
||||
const cancelScanIcon = row.querySelector('img[src*="stop.svg"]');
|
||||
scanIcon.classList.remove('hidden');
|
||||
cancelScanIcon.classList.add('hidden');
|
||||
});
|
||||
const hasActiveScans = document.querySelectorAll('tr[data-scan-id]').length > 0;
|
||||
btnCancelLibrariesScan.style.display = hasActiveScans ? 'block' : 'none';
|
||||
btnScanAllLibraries.style.display = hasActiveScans ? 'none' : 'block';
|
||||
};
|
||||
|
||||
// scan failure handler
|
||||
const failureHandler = (progress) => {
|
||||
const rows = document.querySelectorAll(`tr[data-scan-id="${progress.scanId}"]`);
|
||||
rows.forEach(row => {
|
||||
// remove the scan Id, its no longer being scanned
|
||||
row.removeAttribute('data-scan-id');
|
||||
|
||||
const statusSpan = row.querySelector('.scan-job-status');
|
||||
statusSpan.textContent = `${jsLocalizedLibraryScanStatuses[progress.status]}.`;
|
||||
const scanProgress = row.querySelector('.scan-progress');
|
||||
scanProgress.classList.add('hidden');
|
||||
|
||||
// show scan status icon
|
||||
const completedIdon = row.querySelector('img[src*="red.png"]');
|
||||
completedIdon.classList.remove('hidden');
|
||||
|
||||
// toggle scan action icons
|
||||
const scanIcon = row.querySelector('img[src*="trigger.svg"]');
|
||||
const cancelScanIcon = row.querySelector('img[src*="stop.svg"]');
|
||||
scanIcon.classList.remove('hidden');
|
||||
cancelScanIcon.classList.add('hidden');
|
||||
});
|
||||
const hasActiveScans = document.querySelectorAll('tr[data-scan-id]').length > 0;
|
||||
btnCancelLibrariesScan.style.display = hasActiveScans ? 'block' : 'none';
|
||||
btnScanAllLibraries.style.display = hasActiveScans ? 'none' : 'block';
|
||||
};
|
||||
|
||||
// subscribe to events
|
||||
signalRConnection.on("libraryScanProgressUpdateEvent", progressHandler);
|
||||
signalRConnection.on("libraryScanFinishedEvent", completionHandler);
|
||||
signalRConnection.on("libraryScanFailedEvent", failureHandler);
|
||||
signalRConnection.onclose(onClose);
|
||||
signalRConnection.onreconnecting(onReconnecting);
|
||||
signalRConnection.onreconnected(onReconnected);
|
||||
// add to cleanup
|
||||
cleanupFunctions.push(() => {
|
||||
signalRConnection.off("libraryScanProgressUpdateEvent", progressHandler);
|
||||
signalRConnection.off("libraryScanFinishedEvent", completionHandler);
|
||||
signalRConnection.off("libraryScanFailedEvent", failureHandler);
|
||||
signalRConnection.off("close", onClose);
|
||||
signalRConnection.off("reconnecting", onReconnecting);
|
||||
signalRConnection.off("reconnected", onReconnected);
|
||||
});
|
||||
}
|
||||
|
||||
// add listeners
|
||||
btnScanAllLibraries.addEventListener('click', handleScanAllLibrariesClick);
|
||||
btnCancelLibrariesScan.addEventListener('click', handleCancelLibrariesScanClick);
|
||||
@@ -245,7 +563,11 @@
|
||||
document.addEventListener('DOMContentLoaded', InitializeAsync);
|
||||
|
||||
// register cleanup for these listeners
|
||||
cleanupFunctions.push(() => {
|
||||
cleanupFunctions.push(() => {
|
||||
// proper connection stop
|
||||
if (signalRConnection.state === 'Connected')
|
||||
signalRConnection.stop().then(() => console.log('SignalR connection stopped'));
|
||||
|
||||
btnScanAllLibraries.removeEventListener('click', handleScanAllLibrariesClick);
|
||||
btnCancelLibrariesScan.removeEventListener('click', handleCancelLibrariesScanClick);
|
||||
document.removeEventListener('click', handleDeleteLibraryClick);
|
||||
@@ -265,7 +587,14 @@
|
||||
if (isInitialized)
|
||||
return;
|
||||
isInitialized = true;
|
||||
await loadLibrariesAsync();
|
||||
try {
|
||||
await loadLibrariesAsync();
|
||||
await signalRConnection.start();
|
||||
setupSignalRHandlers();
|
||||
await getRunningLibraryScansAsync();
|
||||
} catch (err) {
|
||||
console.error('SignalR connection failed:', err);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`Loaded @scriptId`);
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
};
|
||||
|
||||
</script>
|
||||
<script src="~/libs/microsoft-signalr/signalr.min.js" asp-append-version="true"></script>
|
||||
<script defer src="~/js/notifications.js" asp-append-version="true"></script>
|
||||
<script defer src="~/js/dialogs.js" asp-append-version="true"></script>
|
||||
<script defer src="~/js/site.js" asp-append-version="true"></script>
|
||||
|
||||
@@ -53,5 +53,12 @@
|
||||
"ApiVersion": 1,
|
||||
"BaseAddress": "http://localhost",
|
||||
"Port": 5214
|
||||
},
|
||||
"Kestrel": {
|
||||
"Endpoints": {
|
||||
"Http": {
|
||||
"Url": "http://localhost:5012"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 7.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 8.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
@@ -0,0 +1,2 @@
|
||||
var t, e; t = self, e = function () { return (() => { var t = { d: (e, s) => { for (var n in s) t.o(s, n) && !t.o(e, n) && Object.defineProperty(e, n, { enumerable: !0, get: s[n] }) } }; t.g = function () { if ("object" == typeof globalThis) return globalThis; try { return this || new Function("return this")() } catch (t) { if ("object" == typeof window) return window } }(), t.o = (t, e) => Object.prototype.hasOwnProperty.call(t, e), t.r = t => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t, "t", { value: !0 }) }; var e, s = {}; t.r(s), t.d(s, { AbortError: () => r, DefaultHttpClient: () => H, HttpClient: () => d, HttpError: () => n, HttpResponse: () => u, HttpTransportType: () => W, HubConnection: () => L, HubConnectionBuilder: () => Q, HubConnectionState: () => R, JsonHubProtocol: () => G, LogLevel: () => e, MessageType: () => A, NullLogger: () => f, Subject: () => U, TimeoutError: () => i, TransferFormat: () => O, VERSION: () => p }); class n extends Error { constructor(t, e) { const s = new.target.prototype; super(`${t}: Status code '${e}'`), this.statusCode = e, this.__proto__ = s } } class i extends Error { constructor(t = "A timeout occurred.") { const e = new.target.prototype; super(t), this.__proto__ = e } } class r extends Error { constructor(t = "An abort occurred.") { const e = new.target.prototype; super(t), this.__proto__ = e } } class o extends Error { constructor(t, e) { const s = new.target.prototype; super(t), this.transport = e, this.errorType = "UnsupportedTransportError", this.__proto__ = s } } class h extends Error { constructor(t, e) { const s = new.target.prototype; super(t), this.transport = e, this.errorType = "DisabledTransportError", this.__proto__ = s } } class c extends Error { constructor(t, e) { const s = new.target.prototype; super(t), this.transport = e, this.errorType = "FailedToStartTransportError", this.__proto__ = s } } class a extends Error { constructor(t) { const e = new.target.prototype; super(t), this.errorType = "FailedToNegotiateWithServerError", this.__proto__ = e } } class l extends Error { constructor(t, e) { const s = new.target.prototype; super(t), this.innerErrors = e, this.__proto__ = s } } class u { constructor(t, e, s) { this.statusCode = t, this.statusText = e, this.content = s } } class d { get(t, e) { return this.send({ ...e, method: "GET", url: t }) } post(t, e) { return this.send({ ...e, method: "POST", url: t }) } delete(t, e) { return this.send({ ...e, method: "DELETE", url: t }) } getCookieString(t) { return "" } } !function (t) { t[t.Trace = 0] = "Trace", t[t.Debug = 1] = "Debug", t[t.Information = 2] = "Information", t[t.Warning = 3] = "Warning", t[t.Error = 4] = "Error", t[t.Critical = 5] = "Critical", t[t.None = 6] = "None" }(e || (e = {})); class f { constructor() { } log(t, e) { } } f.instance = new f; const p = "6.0.1"; class w { static isRequired(t, e) { if (null == t) throw new Error(`The '${e}' argument is required.`) } static isNotEmpty(t, e) { if (!t || t.match(/^\s*$/)) throw new Error(`The '${e}' argument should not be empty.`) } static isIn(t, e, s) { if (!(t in e)) throw new Error(`Unknown ${s} value: ${t}.`) } } class g { static get isBrowser() { return "object" == typeof window } static get isWebWorker() { return "object" == typeof self && "importScripts" in self } static get isNode() { return !this.isBrowser && !this.isWebWorker } } function m(t, e) { let s = ""; return y(t) ? (s = `Binary data of length ${t.byteLength}`, e && (s += `. Content: '${function (t) { const e = new Uint8Array(t); let s = ""; return e.forEach((t => { s += `0x${t < 16 ? "0" : ""}${t.toString(16)} ` })), s.substr(0, s.length - 1) }(t)}'`)) : "string" == typeof t && (s = `String data of length ${t.length}`, e && (s += `. Content: '${t}'`)), s } function y(t) { return t && "undefined" != typeof ArrayBuffer && (t instanceof ArrayBuffer || t.constructor && "ArrayBuffer" === t.constructor.name) } async function b(t, s, n, i, r, o, h) { let c = {}; if (r) { const t = await r(); t && (c = { Authorization: `Bearer ${t}` }) } const [a, l] = $(); c[a] = l, t.log(e.Trace, `(${s} transport) sending data. ${m(o, h.logMessageContent)}.`); const u = y(o) ? "arraybuffer" : "text", d = await n.post(i, { content: o, headers: { ...c, ...h.headers }, responseType: u, timeout: h.timeout, withCredentials: h.withCredentials }); t.log(e.Trace, `(${s} transport) request complete. Response status: ${d.statusCode}.`) } class v { constructor(t, e) { this.i = t, this.h = e } dispose() { const t = this.i.observers.indexOf(this.h); t > -1 && this.i.observers.splice(t, 1), 0 === this.i.observers.length && this.i.cancelCallback && this.i.cancelCallback().catch((t => { })) } } class E { constructor(t) { this.l = t, this.out = console } log(t, s) { if (t >= this.l) { const n = `[${(new Date).toISOString()}] ${e[t]}: ${s}`; switch (t) { case e.Critical: case e.Error: this.out.error(n);
Line truncated
|
||||
//# sourceMappingURL=signalr.js.map
|
||||
@@ -0,0 +1 @@
|
||||
var t, e; t = self, e = function () { return (() => { var t = { d: (e, n) => { for (var o in n) t.o(n, o) && !t.o(e, o) && Object.defineProperty(e, o, { enumerable: !0, get: n[o] }) } }; t.g = function () { if ("object" == typeof globalThis) return globalThis; try { return this || new Function("return this")() } catch (t) { if ("object" == typeof window) return window } }(), t.o = (t, e) => Object.prototype.hasOwnProperty.call(t, e), t.r = t => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t, "t", { value: !0 }) }; var e, n = {}; t.r(n), t.d(n, { AbortError: () => s, DefaultHttpClient: () => q, HttpClient: () => d, HttpError: () => o, HttpResponse: () => u, HttpTransportType: () => O, HubConnection: () => j, HubConnectionBuilder: () => Z, HubConnectionState: () => W, JsonHubProtocol: () => G, LogLevel: () => e, MessageType: () => H, NullLogger: () => p, Subject: () => L, TimeoutError: () => r, TransferFormat: () => _, VERSION: () => g }); class o extends Error { constructor(t, e) { const n = new.target.prototype; super(`${t}: Status code '${e}'`), this.statusCode = e, this.__proto__ = n } } class r extends Error { constructor(t = "A timeout occurred.") { const e = new.target.prototype; super(t), this.__proto__ = e } } class s extends Error { constructor(t = "An abort occurred.") { const e = new.target.prototype; super(t), this.__proto__ = e } } class i extends Error { constructor(t, e) { const n = new.target.prototype; super(t), this.transport = e, this.errorType = "UnsupportedTransportError", this.__proto__ = n } } class c extends Error { constructor(t, e) { const n = new.target.prototype; super(t), this.transport = e, this.errorType = "DisabledTransportError", this.__proto__ = n } } class a extends Error { constructor(t, e) { const n = new.target.prototype; super(t), this.transport = e, this.errorType = "FailedToStartTransportError", this.__proto__ = n } } class h extends Error { constructor(t) { const e = new.target.prototype; super(t), this.errorType = "FailedToNegotiateWithServerError", this.__proto__ = e } } class l extends Error { constructor(t, e) { const n = new.target.prototype; super(t), this.innerErrors = e, this.__proto__ = n } } class u { constructor(t, e, n) { this.statusCode = t, this.statusText = e, this.content = n } } class d { get(t, e) { return this.send({ ...e, method: "GET", url: t }) } post(t, e) { return this.send({ ...e, method: "POST", url: t }) } delete(t, e) { return this.send({ ...e, method: "DELETE", url: t }) } getCookieString(t) { return "" } } !function (t) { t[t.Trace = 0] = "Trace", t[t.Debug = 1] = "Debug", t[t.Information = 2] = "Information", t[t.Warning = 3] = "Warning", t[t.Error = 4] = "Error", t[t.Critical = 5] = "Critical", t[t.None = 6] = "None" }(e || (e = {})); class p { constructor() { } log(t, e) { } } p.instance = new p; const g = "6.0.1"; class f { static isRequired(t, e) { if (null == t) throw new Error(`The '${e}' argument is required.`) } static isNotEmpty(t, e) { if (!t || t.match(/^\s*$/)) throw new Error(`The '${e}' argument should not be empty.`) } static isIn(t, e, n) { if (!(t in e)) throw new Error(`Unknown ${n} value: ${t}.`) } } class w { static get isBrowser() { return "object" == typeof window } static get isWebWorker() { return "object" == typeof self && "importScripts" in self } static get isNode() { return !this.isBrowser && !this.isWebWorker } } function m(t, e) { let n = ""; return b(t) ? (n = `Binary data of length ${t.byteLength}`, e && (n += `. Content: '${function (t) { const e = new Uint8Array(t); let n = ""; return e.forEach((t => { n += `0x${t < 16 ? "0" : ""}${t.toString(16)} ` })), n.substr(0, n.length - 1) }(t)}'`)) : "string" == typeof t && (n = `String data of length ${t.length}`, e && (n += `. Content: '${t}'`)), n } function b(t) { return t && "undefined" != typeof ArrayBuffer && (t instanceof ArrayBuffer || t.constructor && "ArrayBuffer" === t.constructor.name) } async function y(t, n, o, r, s, i, c) { let a = {}; if (s) { const t = await s(); t && (a = { Authorization: `Bearer ${t}` }) } const [h, l] = S(); a[h] = l, t.log(e.Trace, `(${n} transport) sending data. ${m(i, c.logMessageContent)}.`); const u = b(i) ? "arraybuffer" : "text", d = await o.post(r, { content: i, headers: { ...a, ...c.headers }, responseType: u, timeout: c.timeout, withCredentials: c.withCredentials }); t.log(e.Trace, `(${n} transport) request complete. Response status: ${d.statusCode}.`) } class v { constructor(t, e) { this.i = t, this.h = e } dispose() { const t = this.i.observers.indexOf(this.h); t > -1 && this.i.observers.splice(t, 1), 0 === this.i.observers.length && this.i.cancelCallback && this.i.cancelCallback().catch((t => { })) } } class C { constructor(t) { this.l = t, this.out = console } log(t, n) { if (t >= this.l) { const o = `[${(new Date).toISOString()}] ${e[t]}: ${n}`; switch (t) { case e.Critical: case e.Error: this.out.error(o);
Line truncated
|
||||
+1
-1
@@ -32,7 +32,7 @@ EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{ACD16983-F1BD-4A92-B282-95BA8C456F6A}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
..\docs\CONTRIBUTING.md = ..\docs\CONTRIBUTING.md
|
||||
INSTALL.md = INSTALL.md
|
||||
..\docs\INSTALL.md = ..\docs\INSTALL.md
|
||||
..\LICENSE.md = ..\LICENSE.md
|
||||
..\README.md = ..\README.md
|
||||
..\docs\SOURCES.md = ..\docs\SOURCES.md
|
||||
|
||||
Reference in new issue
Block a user