From f89ba4960a9a1e3b7e20cbb474f4b6531f1efa7b Mon Sep 17 00:00:00 2001 From: Binary Alley Date: Sat, 25 Jan 2025 12:27:50 +0200 Subject: [PATCH] Adds media library advanced options --- .../MediaLibrary/Management/LibraryEntity.cs | 20 + .../MediaLibrary/ILibraryRepository.cs | 17 + .../AddMediaLibraryRequestMapping.cs | 6 +- .../Management/LibraryEntityMapping.cs | 10 +- .../MediaLibrary/Management/LibraryMapping.cs | 4 + .../Management/UpdateLibraryRequestMapping.cs | 6 +- .../Commands/AddLibrary/AddLibraryCommand.cs | 10 +- .../AddLibrary/AddLibraryCommandHandler.cs | 17 +- .../ScanLibrariesCommandHandler.cs | 4 +- .../UpdateLibrary/UpdateLibraryCommand.cs | 10 +- .../UpdateLibraryCommandHandler.cs | 6 +- .../GetEnabledLibrariesQuery.cs | 12 + .../GetEnabledLibrariesQueryHandler.cs | 73 ++ .../GetLibraries/GetLibrariesQueryHandler.cs | 6 +- .../WrittenContent/BookLibraryTypeScanner.cs | 7 +- .../Management/AddLibraryRequest.cs | 10 +- .../Management/UpdateLibraryRequest.cs | 10 +- .../Management/LibraryResponse.cs | 4 + .../Configuration/LibraryConfiguration.cs | 14 + ...ddsMediaLibraryAdvancedOptions.Designer.cs | 734 ++++++++++++++++++ ...4174632_AddsMediaLibraryAdvancedOptions.cs | 65 ++ .../LuminaDbContextModelSnapshot.cs | 20 + .../Libraries/LibraryRepository.cs | 27 + .../LibraryAggregate/Library.cs | 67 +- .../Library/Management/ApiRoutes.Libraries.cs | 1 + .../AddLibrary/AddLibraryEndpointSummary.cs | 20 +- .../GetEnabledLibrariesEndpoint.cs | 52 ++ .../GetEnabledLibrariesEndpointSummary.cs | 87 +++ .../GetLibraries/GetLibrariesEndpoint.cs | 3 +- .../GetLibrariesEndpointSummary.cs | 8 + .../GetLibrary/GetLibraryEndpointSummary.cs | 8 + .../UpdateLibraryEndpointSummary.cs | 22 +- .../Common/Models/Libraries/LibraryModel.cs | 20 + .../Management/LibraryManagementController.cs | 11 + .../Views/Library/Management/Index.de-DE.resx | 3 + .../Views/Library/Management/Index.en-US.resx | 3 + .../Views/Library/Management/Index.es-ES.resx | 3 + .../Views/Library/Management/Index.fr-FR.resx | 3 + .../Views/Library/Management/Index.it-IT.resx | 3 + .../Views/Library/Management/Index.ja-JP.resx | 3 + .../Views/Library/Management/Index.resx | 3 + .../Views/Library/Management/Index.ro-RO.resx | 3 + .../Views/Library/Management/Index.ru-RU.resx | 3 + .../Views/Library/Management/Index.zh-CN.resx | 3 + .../Views/Library/Management/Item.Designer.cs | 81 ++ .../Views/Library/Management/Item.de-DE.resx | 27 + .../Views/Library/Management/Item.en-US.resx | 27 + .../Views/Library/Management/Item.es-ES.resx | 27 + .../Views/Library/Management/Item.fr-FR.resx | 27 + .../Views/Library/Management/Item.it-IT.resx | 27 + .../Views/Library/Management/Item.ja-JP.resx | 27 + .../Views/Library/Management/Item.resx | 27 + .../Views/Library/Management/Item.ro-RO.resx | 27 + .../Views/Library/Management/Item.ru-RU.resx | 27 + .../Views/Library/Management/Item.zh-CN.resx | 27 + .../Views/Home/Index.cshtml | 2 +- .../Views/Library/Management/Item.cshtml | 60 +- .../AddMediaLibraryRequestMappingTests.cs | 32 +- .../Management/LibraryMappingTests.cs | 38 +- .../Fixtures/DomainLibraryFixture.cs | 24 +- 60 files changed, 1877 insertions(+), 51 deletions(-) create mode 100644 src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetEnabledLibraries/GetEnabledLibrariesQuery.cs create mode 100644 src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetEnabledLibraries/GetEnabledLibrariesQueryHandler.cs create mode 100644 src/Lumina.DataAccess/Common/Migrations/20250124174632_AddsMediaLibraryAdvancedOptions.Designer.cs create mode 100644 src/Lumina.DataAccess/Common/Migrations/20250124174632_AddsMediaLibraryAdvancedOptions.cs create mode 100644 src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/GetEnabledLibraries/GetEnabledLibrariesEndpoint.cs create mode 100644 src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/GetEnabledLibraries/GetEnabledLibrariesEndpointSummary.cs diff --git a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryEntity.cs index 9522bcbf..fc3a189f 100644 --- a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryEntity.cs +++ b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryEntity.cs @@ -45,6 +45,26 @@ public class LibraryEntity : IStorageEntity, IAuditableEntity /// public required ICollection ContentLocations { get; init; } = []; + /// + /// Gets whether this media library is enabled or not. A disabled media library is never shown or changed. + /// + public bool IsEnabled { get; init; } + + /// + /// Gets whether this media library is locked or not. A locked media library is displayed, but is never changed or updated. + /// + public bool IsLocked { get; init; } + + /// + /// Gets whether this media library should update the metadata of its elements from the web, or not. + /// + public bool DownloadMedatadaFromWeb { get; init; } + + /// + /// Gets whether this media library should copy the downloaded metadata into the media library content locations, or not. + /// + public bool SaveMetadataInMediaDirectories { get; init; } + /// /// Gets the user that owns the media library. /// diff --git a/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryRepository.cs b/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryRepository.cs index 0d6528b6..0f5687d6 100644 --- a/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryRepository.cs +++ b/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryRepository.cs @@ -1,8 +1,12 @@ #region ========================================================================= USING ===================================================================================== +using ErrorOr; using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management; using Lumina.Application.Common.DataAccess.Repositories.Common.Actions; using Lumina.Application.Common.DataAccess.Repositories.Common.Base; using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; #endregion namespace Lumina.Application.Common.DataAccess.Repositories.MediaLibrary; @@ -17,4 +21,17 @@ public interface ILibraryRepository : IRepository, IUpdateRepositoryAction, IDeleteByIdRepositoryAction { + /// + /// Gets all media libraries that are marked as enabled and unlocked, from the storage medium. + /// + /// Cancellation token that can be used to stop the execution. + /// An containing either a collection of , or an error. + Task>> GetAllEnabledAndUnlockedAsync(CancellationToken cancellationToken); + + /// + /// Gets all media libraries that are marked as enabled from the storage medium. + /// + /// Cancellation token that can be used to stop the execution. + /// An containing either a collection of , or an error. + Task>> GetAllEnabledAsync(CancellationToken cancellationToken); } diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs index 6ce350b2..deda7756 100644 --- a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs +++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs @@ -24,7 +24,11 @@ public static class AddMediaLibraryRequestMapping request.Title, request.LibraryType, request.ContentLocations, - request.CoverImage + request.CoverImage, + request.IsEnabled, + request.IsLocked, + request.DownloadMedatadaFromWeb, + request.SaveMetadataInMediaDirectories ); } } diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryEntityMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryEntityMapping.cs index 7766d988..05f49fd9 100644 --- a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryEntityMapping.cs +++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryEntityMapping.cs @@ -29,6 +29,10 @@ public static class LibraryEntityMapping repositoryEntity.LibraryType, repositoryEntity.ContentLocations.Select(location => location.Path).ToList(), repositoryEntity.CoverImage, + repositoryEntity.IsEnabled, + repositoryEntity.IsLocked, + repositoryEntity.DownloadMedatadaFromWeb, + repositoryEntity.SaveMetadataInMediaDirectories, repositoryEntity.CreatedOnUtc, repositoryEntity.UpdatedOnUtc ); @@ -47,7 +51,11 @@ public static class LibraryEntityMapping repositoryEntity.Title, repositoryEntity.LibraryType, repositoryEntity.ContentLocations.Select(contentLocation => contentLocation.Path), - repositoryEntity.CoverImage + repositoryEntity.CoverImage, + repositoryEntity.IsEnabled, + repositoryEntity.IsLocked, + repositoryEntity.DownloadMedatadaFromWeb, + repositoryEntity.SaveMetadataInMediaDirectories ); } diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryMapping.cs index 03f8016b..427dc42b 100644 --- a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryMapping.cs +++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryMapping.cs @@ -27,6 +27,10 @@ public static class LibraryMapping UserId = domainEntity.UserId.Value, ContentLocations = domainEntity.ContentLocations.Select(path => new LibraryContentLocationEntity() { Path = path.Path }).ToList(), CoverImage = domainEntity.CoverImage, + IsEnabled = domainEntity.IsEnabled, + IsLocked = domainEntity.IsLocked, + DownloadMedatadaFromWeb = domainEntity.DownloadMedatadaFromWeb, + SaveMetadataInMediaDirectories = domainEntity.SaveMetadataInMediaDirectories, CreatedOnUtc = domainEntity.CreatedOnUtc, CreatedBy = Guid.Empty, UpdatedOnUtc = domainEntity.UpdatedOnUtc.HasValue ? domainEntity.UpdatedOnUtc : null, diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/UpdateLibraryRequestMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/UpdateLibraryRequestMapping.cs index 92aa3f64..6275c61c 100644 --- a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/UpdateLibraryRequestMapping.cs +++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/UpdateLibraryRequestMapping.cs @@ -24,7 +24,11 @@ public static class UpdateLibraryRequestMapping request.Title, request.LibraryType, request.ContentLocations, - request.CoverImage + request.CoverImage, + request.IsEnabled, + request.IsLocked, + request.DownloadMedatadaFromWeb, + request.SaveMetadataInMediaDirectories ); } } diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommand.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommand.cs index ad8838f9..466ed364 100644 --- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommand.cs +++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommand.cs @@ -15,10 +15,18 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary; /// The type of the media library. /// The file system paths of the directories where the media library elements are located. /// The path of the image file used as the cover for the library. +/// Whether this media library is enabled or not. A disabled media library is never shown or changed. +/// Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated. +/// Whether this media library should update the metadata of its elements from the web, or not. +/// Whether this media library should copy the downloaded metadata into the media library content locations, or not. [DebuggerDisplay("Title: {Title}")] public record AddLibraryCommand( string? Title, string? LibraryType, string[]? ContentLocations, - string? CoverImage + string? CoverImage, + bool IsEnabled, + bool IsLocked, + bool DownloadMedatadaFromWeb, + bool SaveMetadataInMediaDirectories ) : IRequest>; diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandHandler.cs index 823008d8..032f5ca2 100644 --- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandHandler.cs +++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandHandler.cs @@ -68,6 +68,12 @@ public class AddLibraryCommandHandler : IRequestHandler public async ValueTask> Handle(AddLibraryCommand request, CancellationToken cancellationToken) { + + // if the user that made the request is not an Admin or they don't have the permission to manage media libraries, they do not have the right to create it + if (!await _authorizationService.IsInRoleAsync(_currentUserService.UserId!.Value, "Admin", cancellationToken).ConfigureAwait(false) && + !await _authorizationService.HasPermissionAsync(_currentUserService.UserId!.Value, AuthorizationPermission.CanCreateLibraries, cancellationToken).ConfigureAwait(false)) + return ApplicationErrors.Authorization.NotAuthorized; + // make sure the file is an actual supported image if (request.CoverImage is not null) { @@ -88,14 +94,13 @@ public class AddLibraryCommandHandler : IRequestHandler(request.LibraryType!), request.ContentLocations!, - request.CoverImage + request.CoverImage, + request.IsEnabled, + request.IsLocked, + request.DownloadMedatadaFromWeb, + request.SaveMetadataInMediaDirectories ); - // if the user that made the request is not an Admin or they don't have the permission to manage media libraries, they do not have the right to create it - if (!await _authorizationService.IsInRoleAsync(_currentUserService.UserId!.Value, "Admin", cancellationToken).ConfigureAwait(false) && - !await _authorizationService.HasPermissionAsync(_currentUserService.UserId!.Value, AuthorizationPermission.CanCreateLibraries, cancellationToken).ConfigureAwait(false)) - return ApplicationErrors.Authorization.NotAuthorized; - if (createLibraryResult.IsError) return createLibraryResult.Errors; diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/ScanLibraries/ScanLibrariesCommandHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/ScanLibraries/ScanLibrariesCommandHandler.cs index 7d519d65..621b6300 100644 --- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/ScanLibraries/ScanLibrariesCommandHandler.cs +++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/ScanLibraries/ScanLibrariesCommandHandler.cs @@ -58,9 +58,9 @@ public class ScanLibrariesCommandHandler : IRequestHandler(); - ErrorOr> getLibrariesResult = await libraryRepository.GetAllAsync(cancellationToken).ConfigureAwait(false); + ErrorOr> getLibrariesResult = await libraryRepository.GetAllEnabledAndUnlockedAsync(cancellationToken).ConfigureAwait(false); if (getLibrariesResult.IsError) return getLibrariesResult.Errors; diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommand.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommand.cs index e3b37d1d..a4a4ce69 100644 --- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommand.cs +++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommand.cs @@ -17,6 +17,10 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Commands.UpdateLibrary /// The type of the media library. /// The file system paths of the directories where the media library elements are located. /// The path of the image file used as the cover for the library. +/// Whether this media library is enabled or not. A disabled media library is never shown or changed. +/// Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated. +/// Whether this media library should update the metadata of its elements from the web, or not. +/// Whether this media library should copy the downloaded metadata into the media library content locations, or not. [DebuggerDisplay("Title: {Title}")] public record UpdateLibraryCommand( Guid Id, @@ -24,5 +28,9 @@ public record UpdateLibraryCommand( string? Title, string? LibraryType, string[]? ContentLocations, - string? CoverImage + string? CoverImage, + bool IsEnabled, + bool IsLocked, + bool DownloadMedatadaFromWeb, + bool SaveMetadataInMediaDirectories ) : IRequest>; diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandHandler.cs index 41cae421..6f04b336 100644 --- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandHandler.cs +++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandHandler.cs @@ -103,7 +103,11 @@ public class UpdateLibraryCommandHandler : IRequestHandler(request.LibraryType!), request.ContentLocations!, - request.CoverImage + request.CoverImage, + request.IsEnabled, + request.IsLocked, + request.DownloadMedatadaFromWeb, + request.SaveMetadataInMediaDirectories ); if (createLibraryResult.IsError) return createLibraryResult.Errors; diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetEnabledLibraries/GetEnabledLibrariesQuery.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetEnabledLibraries/GetEnabledLibrariesQuery.cs new file mode 100644 index 00000000..097948d6 --- /dev/null +++ b/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetEnabledLibraries/GetEnabledLibrariesQuery.cs @@ -0,0 +1,12 @@ +#region ========================================================================= USING ===================================================================================== +using ErrorOr; +using Lumina.Contracts.Responses.MediaLibrary.Management; +using Mediator; +#endregion + +namespace Lumina.Application.Core.MediaLibrary.Management.Queries.GetEnabledLibraries; + +/// +/// Query for getting the list of enabled media libraries. +/// +public record GetEnabledLibrariesQuery : IRequest>; diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetEnabledLibraries/GetEnabledLibrariesQueryHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetEnabledLibraries/GetEnabledLibrariesQueryHandler.cs new file mode 100644 index 00000000..6252b1d2 --- /dev/null +++ b/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetEnabledLibraries/GetEnabledLibrariesQueryHandler.cs @@ -0,0 +1,73 @@ +#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 Mediator; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +#endregion + +namespace Lumina.Application.Core.MediaLibrary.Management.Queries.GetEnabledLibraries; + +/// +/// Handler for the query to get the enabled media libraries. +/// +public class GetEnabledLibrariesQueryHandler : IRequestHandler> +{ + private readonly IUnitOfWork _unitOfWork; + private readonly ICurrentUserService _currentUserService; + private readonly IAuthorizationService _authorizationService; + + /// + /// Initializes a new instance of the class. + /// + /// Injected service for authorization related functionality. + /// Injected service to retrieve the current user information. + /// Injected unit of work for interacting with the data access layer repositories. + public GetEnabledLibrariesQueryHandler( + IAuthorizationService authorizationService, + ICurrentUserService currentUserService, + IUnitOfWork unitOfWork) + { + _authorizationService = authorizationService; + _currentUserService = currentUserService; + _unitOfWork = unitOfWork; + } + + /// + /// Handles the query to get the enabled media libraries. + /// + /// The request to be handled. + /// Cancellation token that can be used to stop the execution. + /// + /// An containing either a successfuly created , or an error message. + /// + public async ValueTask> Handle(GetEnabledLibrariesQuery request, CancellationToken cancellationToken) + { + // get the enabled libraries from the repository + ILibraryRepository libraryRepository = _unitOfWork.GetRepository(); + ErrorOr> getEnabledLibrariesResult = await libraryRepository.GetAllEnabledAsync(cancellationToken).ConfigureAwait(false); + if (getEnabledLibrariesResult.IsError) + return getEnabledLibrariesResult.Errors; + + // admins can see all libraries + if (await _authorizationService.IsInRoleAsync(_currentUserService.UserId!.Value, "Admin", cancellationToken).ConfigureAwait(false)) + return ErrorOrFactory.From(getEnabledLibrariesResult.Value.Select(library => library.ToResponse()).ToArray()); + else + { + // for regular users, only take the libraries that belong to them + LibraryResponse[] userEnabledLibraries = getEnabledLibrariesResult.Value + .Where(library => library.UserId == _currentUserService.UserId) + .Select(library => library.ToResponse()).ToArray(); + + return ErrorOrFactory.From(userEnabledLibraries); + } + } +} diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraries/GetLibrariesQueryHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraries/GetLibrariesQueryHandler.cs index b59303db..e9d1ec78 100644 --- a/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraries/GetLibrariesQueryHandler.cs +++ b/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraries/GetLibrariesQueryHandler.cs @@ -17,7 +17,7 @@ using System.Threading.Tasks; namespace Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibraries; /// -/// Handler for the query to authenticate an account. +/// Handler for the query to get the media libraries. /// public class GetLibrariesQueryHandler : IRequestHandler> { @@ -42,7 +42,7 @@ public class GetLibrariesQueryHandler : IRequestHandler - /// Handles the query to authenticate an account. + /// Handles the query to get the media libraries. /// /// The request to be handled. /// Cancellation token that can be used to stop the execution. @@ -51,7 +51,7 @@ public class GetLibrariesQueryHandler : IRequestHandler public async ValueTask> Handle(GetLibrariesQuery request, CancellationToken cancellationToken) { - // get the library with the specified id from the repository + // get the libraries from the repository ILibraryRepository libraryRepository = _unitOfWork.GetRepository(); ErrorOr> getLibrariesResult = await libraryRepository.GetAllAsync(cancellationToken).ConfigureAwait(false); if (getLibrariesResult.IsError) diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Services/Scanning/Scanners/WrittenContent/BookLibraryTypeScanner.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Services/Scanning/Scanners/WrittenContent/BookLibraryTypeScanner.cs index 3b0d2b73..bf7c3a20 100644 --- a/src/Lumina.Application/Core/MediaLibrary/Management/Services/Scanning/Scanners/WrittenContent/BookLibraryTypeScanner.cs +++ b/src/Lumina.Application/Core/MediaLibrary/Management/Services/Scanning/Scanners/WrittenContent/BookLibraryTypeScanner.cs @@ -42,9 +42,12 @@ internal class BookLibraryTypeScanner : IBookLibraryTypeScanner hashComparerJob.AddParent(fileSystemDiscoveryJob); hashComparerJob.AddParent(repositoryMetadataDiscoveryJob); - hashComparerJob.AddChild(goodReadsMetadataScrapJob); - goodReadsMetadataScrapJob.AddParent(hashComparerJob); + if (library.DownloadMedatadaFromWeb) + { + hashComparerJob.AddChild(goodReadsMetadataScrapJob); + goodReadsMetadataScrapJob.AddParent(hashComparerJob); + } // return the top level jobs that will be triggered when the scan will be started yield return fileSystemDiscoveryJob; diff --git a/src/Lumina.Contracts/Requests/MediaLibrary/Management/AddLibraryRequest.cs b/src/Lumina.Contracts/Requests/MediaLibrary/Management/AddLibraryRequest.cs index 0111445f..9b0021db 100644 --- a/src/Lumina.Contracts/Requests/MediaLibrary/Management/AddLibraryRequest.cs +++ b/src/Lumina.Contracts/Requests/MediaLibrary/Management/AddLibraryRequest.cs @@ -11,10 +11,18 @@ namespace Lumina.Contracts.Requests.MediaLibrary.Management; /// The type of the media library. Required. /// The file system paths of the directories where the media library elements are located. Required. /// The path of the image file used as the cover for the library. Optional. +/// Whether this media library is enabled or not. A disabled media library is never shown or changed. Optional. +/// Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated. Optional. +/// Whether this media library should update the metadata of its elements from the web, or not. Optional. +/// Whether this media library should copy the downloaded metadata into the media library content locations, or not. Optional. [DebuggerDisplay("Title: {Title}")] public record AddLibraryRequest( string? Title, string? LibraryType, string[]? ContentLocations, - string? CoverImage + string? CoverImage, + bool IsEnabled, + bool IsLocked, + bool DownloadMedatadaFromWeb, + bool SaveMetadataInMediaDirectories ); diff --git a/src/Lumina.Contracts/Requests/MediaLibrary/Management/UpdateLibraryRequest.cs b/src/Lumina.Contracts/Requests/MediaLibrary/Management/UpdateLibraryRequest.cs index e4b864ac..35b91a28 100644 --- a/src/Lumina.Contracts/Requests/MediaLibrary/Management/UpdateLibraryRequest.cs +++ b/src/Lumina.Contracts/Requests/MediaLibrary/Management/UpdateLibraryRequest.cs @@ -16,6 +16,10 @@ namespace Lumina.Contracts.Requests.MediaLibrary.Management; /// The type of the media library. Required. /// The file system paths of the directories where the media library elements are located. Required. /// The path of the image file used as the cover for the library. Optional. +/// Whether this media library is enabled or not. A disabled media library is never shown or changed. Optional. +/// Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated. Optional. +/// Whether this media library should update the metadata of its elements from the web, or not. Optional. +/// Whether this media library should copy the downloaded metadata into the media library content locations, or not. [DebuggerDisplay("Title: {Title}")] public record class UpdateLibraryRequest( Guid Id, @@ -23,5 +27,9 @@ public record class UpdateLibraryRequest( string? Title, string? LibraryType, string[]? ContentLocations, - string? CoverImage + string? CoverImage, + bool IsEnabled, + bool IsLocked, + bool DownloadMedatadaFromWeb, + bool SaveMetadataInMediaDirectories ); diff --git a/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryResponse.cs b/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryResponse.cs index a4ab81ff..ef6a42c4 100644 --- a/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryResponse.cs +++ b/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryResponse.cs @@ -26,6 +26,10 @@ public record LibraryResponse( LibraryType LibraryType, List ContentLocations, string? CoverImage, + bool IsEnabled, + bool IsLocked, + bool DownloadMedatadaFromWeb, + bool SaveMetadataInMediaDirectories, DateTime CreatedOnUtc, DateTime? UpdatedOnUtc ); diff --git a/src/Lumina.DataAccess/Common/Configuration/LibraryConfiguration.cs b/src/Lumina.DataAccess/Common/Configuration/LibraryConfiguration.cs index 20de8a2d..8f5a8cd4 100644 --- a/src/Lumina.DataAccess/Common/Configuration/LibraryConfiguration.cs +++ b/src/Lumina.DataAccess/Common/Configuration/LibraryConfiguration.cs @@ -39,6 +39,20 @@ public class LibraryConfiguration : IEntityTypeConfiguration .HasDefaultValue(null) .HasColumnOrder(3); + builder.Property(library => library.IsEnabled) + .HasDefaultValue(true) + .HasColumnOrder(4); + + builder.Property(library => library.IsLocked) + .HasColumnOrder(5); + + builder.Property(library => library.DownloadMedatadaFromWeb) + .HasDefaultValue(true) + .HasColumnOrder(6); + + builder.Property(library => library.SaveMetadataInMediaDirectories) + .HasColumnOrder(7); + // one user with many libraries builder.HasOne(library => library.User) .WithMany(user => user.Libraries) diff --git a/src/Lumina.DataAccess/Common/Migrations/20250124174632_AddsMediaLibraryAdvancedOptions.Designer.cs b/src/Lumina.DataAccess/Common/Migrations/20250124174632_AddsMediaLibraryAdvancedOptions.Designer.cs new file mode 100644 index 00000000..0e085756 --- /dev/null +++ b/src/Lumina.DataAccess/Common/Migrations/20250124174632_AddsMediaLibraryAdvancedOptions.Designer.cs @@ -0,0 +1,734 @@ +// +using System; +using Lumina.DataAccess.Core.UoW; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Lumina.DataAccess.Common.Migrations +{ + [DbContext(typeof(LuminaDbContext))] + [Migration("20250124174632_AddsMediaLibraryAdvancedOptions")] + partial class AddsMediaLibraryAdvancedOptions + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "9.0.0"); + + modelBuilder.Entity("BookGenres", b => + { + b.Property("BookId") + .HasColumnType("TEXT"); + + b.Property("GenreId") + .HasColumnType("TEXT"); + + b.HasKey("BookId", "GenreId"); + + b.HasIndex("GenreId"); + + b.ToTable("BookGenres", (string)null); + }); + + modelBuilder.Entity("BookTags", b => + { + b.Property("BookId") + .HasColumnType("TEXT"); + + b.Property("TagId") + .HasColumnType("TEXT"); + + b.HasKey("BookId", "TagId"); + + b.HasIndex("TagId"); + + b.ToTable("BookTags", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("PermissionName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.HasKey("Id"); + + b.ToTable("Permissions", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("RoleName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.HasKey("Id"); + + b.ToTable("Roles", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RolePermissionEntity", b => + { + b.Property("RoleId") + .HasColumnType("TEXT"); + + b.Property("PermissionId") + .HasColumnType("TEXT"); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.HasKey("RoleId", "PermissionId"); + + b.HasIndex("PermissionId"); + + b.HasIndex("RoleId", "PermissionId") + .IsUnique(); + + b.ToTable("RolePermissions", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserPermissionEntity", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("PermissionId") + .HasColumnType("TEXT"); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.HasKey("UserId", "PermissionId"); + + b.HasIndex("PermissionId"); + + b.HasIndex("UserId", "PermissionId") + .IsUnique(); + + b.ToTable("UserPermissions", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("RoleId") + .HasColumnType("TEXT"); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.HasKey("UserId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId", "RoleId") + .IsUnique(); + + b.ToTable("UserRoles", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Common.GenreEntity", b => + { + b.Property("Name") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.ToTable("Genres", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Common.TagEntity", b => + { + b.Property("Name") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Name"); + + b.ToTable("Tags", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CoverImage") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("CreatedBy") + .HasColumnType("TEXT"); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT"); + + b.Property("DownloadMedatadaFromWeb") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true) + .HasColumnOrder(6); + + b.Property("IsEnabled") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true) + .HasColumnOrder(4); + + b.Property("IsLocked") + .HasColumnType("INTEGER") + .HasColumnOrder(5); + + b.Property("LibraryType") + .IsRequired() + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("SaveMetadataInMediaDirectories") + .HasColumnType("INTEGER") + .HasColumnOrder(7); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("UpdatedBy") + .HasColumnType("TEXT"); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Libraries", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("ASIN") + .HasMaxLength(10) + .HasColumnType("TEXT") + .HasColumnOrder(21); + + b.Property("AppleBooksId") + .HasColumnType("TEXT") + .HasColumnOrder(29); + + b.Property("BarnesAndNobleId") + .HasMaxLength(10) + .HasColumnType("TEXT") + .HasColumnOrder(28); + + b.Property("CreatedBy") + .HasColumnType("TEXT"); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(30); + + b.Property("Description") + .HasMaxLength(2000) + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("Edition") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(19); + + b.Property("Format") + .HasColumnType("TEXT") + .HasColumnOrder(18); + + b.Property("GoodreadsId") + .HasColumnType("TEXT") + .HasColumnOrder(22); + + b.Property("GoogleBooksId") + .HasMaxLength(12) + .HasColumnType("TEXT") + .HasColumnOrder(27); + + b.Property("LCCN") + .HasColumnType("TEXT") + .HasColumnOrder(23); + + b.Property("LanguageCode") + .HasColumnType("TEXT") + .HasColumnOrder(10); + + b.Property("LanguageName") + .HasColumnType("TEXT") + .HasColumnOrder(11); + + b.Property("LanguageNativeName") + .HasColumnType("TEXT") + .HasColumnOrder(12); + + b.Property("LibraryThingId") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(26); + + b.Property("OCLCNumber") + .HasColumnType("TEXT") + .HasColumnOrder(24); + + b.Property("OpenLibraryId") + .HasMaxLength(50) + .HasColumnType("TEXT") + .HasColumnOrder(25); + + b.Property("OriginalLanguageCode") + .HasColumnType("TEXT") + .HasColumnOrder(13); + + b.Property("OriginalLanguageName") + .HasColumnType("TEXT") + .HasColumnOrder(14); + + b.Property("OriginalLanguageNativeName") + .HasColumnType("TEXT") + .HasColumnOrder(15); + + b.Property("OriginalReleaseDate") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("OriginalReleaseYear") + .HasColumnType("INTEGER") + .HasColumnOrder(5); + + b.Property("OriginalTitle") + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("PageCount") + .HasColumnType("INTEGER") + .HasColumnOrder(17); + + b.Property("Publisher") + .HasMaxLength(100) + .HasColumnType("TEXT") + .HasColumnOrder(16); + + b.Property("ReReleaseDate") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("ReReleaseYear") + .HasColumnType("INTEGER") + .HasColumnOrder(7); + + b.Property("ReleaseCountry") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("ReleaseVersion") + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("UpdatedBy") + .HasColumnType("TEXT"); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(31); + + b.Property("VolumeNumber") + .HasColumnType("INTEGER") + .HasColumnOrder(20); + + b.HasKey("Id"); + + b.ToTable("Books", (string)null); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", b => + { + b.Property("Id") + .HasColumnType("TEXT") + .HasColumnOrder(0); + + b.Property("CreatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(7); + + b.Property("CreatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(6); + + b.Property("Password") + .IsRequired() + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("TempPassword") + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("TempPasswordCreated") + .HasColumnType("TEXT") + .HasColumnOrder(5); + + b.Property("TotpSecret") + .HasColumnType("TEXT") + .HasColumnOrder(4); + + b.Property("UpdatedBy") + .HasColumnType("TEXT") + .HasColumnOrder(9); + + b.Property("UpdatedOnUtc") + .HasColumnType("TEXT") + .HasColumnOrder(8); + + b.Property("Username") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.HasKey("Id"); + + b.HasIndex("Username") + .IsUnique(); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("BookGenres", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", null) + .WithMany() + .HasForeignKey("BookId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.GenreEntity", null) + .WithMany() + .HasForeignKey("GenreId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("BookTags", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", null) + .WithMany() + .HasForeignKey("BookId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Common.TagEntity", null) + .WithMany() + .HasForeignKey("TagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RolePermissionEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", "Permission") + .WithMany("RolePermissions") + .HasForeignKey("PermissionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", "Role") + .WithMany("RolePermissions") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Permission"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserPermissionEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", "Permission") + .WithMany("UserPermissions") + .HasForeignKey("PermissionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User") + .WithMany("UserPermissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Permission"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User") + .WithOne("UserRole") + .HasForeignKey("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", "UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", b => + { + b.HasOne("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", "User") + .WithMany("Libraries") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryContentLocationEntity", "ContentLocations", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("LibraryId") + .HasColumnType("TEXT"); + + b1.Property("Path") + .IsRequired() + .HasMaxLength(260) + .HasColumnType("TEXT") + .HasColumnName("Path"); + + b1.HasKey("Id"); + + b1.HasIndex("LibraryId"); + + b1.ToTable("LibraryContentLocations", (string)null); + + b1.WithOwner() + .HasForeignKey("LibraryId"); + }); + + b.Navigation("ContentLocations"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", b => + { + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookRatingEntity", "Ratings", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("BookId") + .HasColumnType("TEXT"); + + b1.Property("MaxValue") + .HasColumnType("decimal(3,2)"); + + b1.Property("Source") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b1.Property("Value") + .HasColumnType("decimal(3,2)"); + + b1.Property("VoteCount") + .HasColumnType("INTEGER"); + + b1.HasKey("Id"); + + b1.HasIndex("BookId"); + + b1.ToTable("BookRatings", (string)null); + + b1.WithOwner() + .HasForeignKey("BookId"); + }); + + b.OwnsMany("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.IsbnEntity", "ISBNs", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b1.Property("BookId") + .HasColumnType("TEXT"); + + b1.Property("Format") + .IsRequired() + .HasMaxLength(6) + .HasColumnType("TEXT"); + + b1.Property("Value") + .IsRequired() + .HasMaxLength(13) + .HasColumnType("TEXT") + .HasColumnName("ISBN"); + + b1.HasKey("Id"); + + b1.HasIndex("BookId"); + + b1.ToTable("BookISBNs", (string)null); + + b1.WithOwner() + .HasForeignKey("BookId"); + }); + + b.Navigation("ISBNs"); + + b.Navigation("Ratings"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", b => + { + b.Navigation("RolePermissions"); + + b.Navigation("UserPermissions"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", b => + { + b.Navigation("RolePermissions"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.UsersManagement.UserEntity", b => + { + b.Navigation("Libraries"); + + b.Navigation("UserPermissions"); + + b.Navigation("UserRole"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Lumina.DataAccess/Common/Migrations/20250124174632_AddsMediaLibraryAdvancedOptions.cs b/src/Lumina.DataAccess/Common/Migrations/20250124174632_AddsMediaLibraryAdvancedOptions.cs new file mode 100644 index 00000000..6e7ea1d0 --- /dev/null +++ b/src/Lumina.DataAccess/Common/Migrations/20250124174632_AddsMediaLibraryAdvancedOptions.cs @@ -0,0 +1,65 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Lumina.DataAccess.Common.Migrations; + +/// +public partial class AddsMediaLibraryAdvancedOptions : Migration +{ + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "DownloadMedatadaFromWeb", + table: "Libraries", + type: "INTEGER", + nullable: false, + defaultValue: true) + .Annotation("Relational:ColumnOrder", 6); + + migrationBuilder.AddColumn( + name: "IsEnabled", + table: "Libraries", + type: "INTEGER", + nullable: false, + defaultValue: true) + .Annotation("Relational:ColumnOrder", 4); + + migrationBuilder.AddColumn( + name: "IsLocked", + table: "Libraries", + type: "INTEGER", + nullable: false, + defaultValue: false) + .Annotation("Relational:ColumnOrder", 5); + + migrationBuilder.AddColumn( + name: "SaveMetadataInMediaDirectories", + table: "Libraries", + type: "INTEGER", + nullable: false, + defaultValue: false) + .Annotation("Relational:ColumnOrder", 7); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "DownloadMedatadaFromWeb", + table: "Libraries"); + + migrationBuilder.DropColumn( + name: "IsEnabled", + table: "Libraries"); + + migrationBuilder.DropColumn( + name: "IsLocked", + table: "Libraries"); + + migrationBuilder.DropColumn( + name: "SaveMetadataInMediaDirectories", + table: "Libraries"); + } +} diff --git a/src/Lumina.DataAccess/Common/Migrations/LuminaDbContextModelSnapshot.cs b/src/Lumina.DataAccess/Common/Migrations/LuminaDbContextModelSnapshot.cs index d6abaff4..de7dff2d 100644 --- a/src/Lumina.DataAccess/Common/Migrations/LuminaDbContextModelSnapshot.cs +++ b/src/Lumina.DataAccess/Common/Migrations/LuminaDbContextModelSnapshot.cs @@ -256,11 +256,31 @@ namespace Lumina.DataAccess.Common.Migrations b.Property("CreatedOnUtc") .HasColumnType("TEXT"); + b.Property("DownloadMedatadaFromWeb") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true) + .HasColumnOrder(6); + + b.Property("IsEnabled") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true) + .HasColumnOrder(4); + + b.Property("IsLocked") + .HasColumnType("INTEGER") + .HasColumnOrder(5); + b.Property("LibraryType") .IsRequired() .HasColumnType("TEXT") .HasColumnOrder(2); + b.Property("SaveMetadataInMediaDirectories") + .HasColumnType("INTEGER") + .HasColumnOrder(7); + b.Property("Title") .IsRequired() .HasMaxLength(255) diff --git a/src/Lumina.DataAccess/Core/Repositories/Libraries/LibraryRepository.cs b/src/Lumina.DataAccess/Core/Repositories/Libraries/LibraryRepository.cs index 278291e2..c4120d24 100644 --- a/src/Lumina.DataAccess/Core/Repositories/Libraries/LibraryRepository.cs +++ b/src/Lumina.DataAccess/Core/Repositories/Libraries/LibraryRepository.cs @@ -7,6 +7,7 @@ using Lumina.Domain.Common.Errors; using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; +using System.Linq; using System.Threading; using System.Threading.Tasks; #endregion @@ -58,6 +59,32 @@ internal sealed class LibraryRepository : ILibraryRepository .FirstOrDefaultAsync(library => library.Id == id, cancellationToken).ConfigureAwait(false); } + /// + /// Gets all media libraries that are marked as enabled, from the storage medium. + /// + /// Cancellation token that can be used to stop the execution. + /// An containing either a collection of , or an error. + public async Task>> GetAllEnabledAsync(CancellationToken cancellationToken) + { + return await _luminaDbContext.Libraries + .Include(library => library.ContentLocations) + .Where(library => library.IsEnabled) + .ToListAsync(cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets all media libraries that are marked as enabled and unlocked, from the storage medium. + /// + /// Cancellation token that can be used to stop the execution. + /// An containing either a collection of , or an error. + public async Task>> GetAllEnabledAndUnlockedAsync(CancellationToken cancellationToken) + { + return await _luminaDbContext.Libraries + .Include(library => library.ContentLocations) + .Where(library => library.IsEnabled && !library.IsLocked) + .ToListAsync(cancellationToken).ConfigureAwait(false); + } + /// /// Gets all media libraries. /// diff --git a/src/Lumina.Domain/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/Library.cs b/src/Lumina.Domain/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/Library.cs index 401381bc..c4765c11 100644 --- a/src/Lumina.Domain/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/Library.cs +++ b/src/Lumina.Domain/Core/BoundedContexts/LibraryManagementBoundedContext/LibraryAggregate/Library.cs @@ -47,6 +47,26 @@ public class Library : AggregateRoot /// public string? CoverImageSourcePath { get; private set; } + /// + /// Gets whether this media library is enabled or not. A disabled media library is never shown or changed. + /// + public bool IsEnabled { get; private set; } = true; + + /// + /// Gets whether this media library is locked or not. A locked media library is displayed, but is never changed or updated. + /// + public bool IsLocked { get; private set; } + + /// + /// Gets whether this media library should update the metadata of its elements from the web, or not. + /// + public bool DownloadMedatadaFromWeb { get; private set; } = true; + + /// + /// Gets whether this media library should copy the downloaded metadata into the media library content locations, or not. + /// + public bool SaveMetadataInMediaDirectories { get; private set; } + /// /// Gets the list of file system paths that make up the media library. /// @@ -61,20 +81,31 @@ public class Library : AggregateRoot /// The type of the media library (e.g., Book, TvShow). /// The list of file system paths that make up the media library. /// The path of the image file used as the cover for the library. + /// Whether this media library is enabled or not. A disabled media library is never shown or changed. + /// Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated. + /// Whether this media library should update the metadata of its elements from the web, or not. + /// Whether this media library should copy the downloaded metadata into the media library content locations, or not. private Library( LibraryId id, UserId userId, string title, LibraryType libraryType, List contentLocations, - string? coverImage) : base(id) + string? coverImage, + bool isEnabled, + bool isLocked, + bool downloadMedatadaFromWeb, + bool saveMetadataInMediaDirectories) : base(id) { UserId = userId; Title = title; LibraryType = libraryType; _contentLocations = contentLocations; CoverImage = coverImage; - + IsEnabled = isEnabled; + IsLocked = isLocked; + DownloadMedatadaFromWeb = downloadMedatadaFromWeb; + SaveMetadataInMediaDirectories = saveMetadataInMediaDirectories; _domainEvents.Add(new LibrarySavedDomainEvent(Guid.NewGuid(), this, DateTime.UtcNow)); } @@ -86,6 +117,10 @@ public class Library : AggregateRoot /// The type of the media library (e.g., Book, TvShow). /// The list of file system paths that make up the media library. /// The path of the image file chosen by the user to be used as the cover for the library. + /// Whether this media library is enabled or not. A disabled media library is never shown or changed. + /// Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated. + /// Whether this media library should update the metadata of its elements from the web, or not. + /// Whether this media library should copy the downloaded metadata into the media library content locations, or not. /// /// An containing either a successfuly created , or an error message. /// @@ -94,7 +129,11 @@ public class Library : AggregateRoot string title, LibraryType libraryType, IEnumerable contentLocations, - string? coverImageSourcePath) + string? coverImageSourcePath, + bool isEnabled, + bool isLocked, + bool downloadMedatadaFromWeb, + bool saveMetadataInMediaDirectories) { List tempContentLocations = []; // go through all the file system paths that make up the media library and create domain objects from them @@ -111,7 +150,11 @@ public class Library : AggregateRoot title, libraryType, tempContentLocations, - coverImageSourcePath + coverImageSourcePath, + isEnabled, + isLocked, + downloadMedatadaFromWeb, + saveMetadataInMediaDirectories ); } @@ -124,6 +167,10 @@ public class Library : AggregateRoot /// The type of the media library (e.g., Book, TvShow). /// The list of file system paths that make up the media library. /// The path of the image file chosen by the user to be used as the cover for the library. + /// Whether this media library is enabled or not. A disabled media library is never shown or changed. + /// Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated. + /// Whether this media library should update the metadata of its elements from the web, or not. + /// Whether this media library should copy the downloaded metadata into the media library content locations, or not. /// /// An containing either a successfuly created , or an error message. /// @@ -133,7 +180,11 @@ public class Library : AggregateRoot string title, LibraryType libraryType, IEnumerable contentLocations, - string? coverImageSourcePath) + string? coverImageSourcePath, + bool isEnabled, + bool isLocked, + bool downloadMedatadaFromWeb, + bool saveMetadataInMediaDirectories) { List tempContentLocations = []; // go through all the file system paths that make up the media library and create domain objects from them @@ -150,7 +201,11 @@ public class Library : AggregateRoot title, libraryType, tempContentLocations, - coverImageSourcePath + coverImageSourcePath, + isEnabled, + isLocked, + downloadMedatadaFromWeb, + saveMetadataInMediaDirectories ); } diff --git a/src/Lumina.Presentation.Api/Common/Routes/Library/Management/ApiRoutes.Libraries.cs b/src/Lumina.Presentation.Api/Common/Routes/Library/Management/ApiRoutes.Libraries.cs index da9222f5..256a8c0e 100644 --- a/src/Lumina.Presentation.Api/Common/Routes/Library/Management/ApiRoutes.Libraries.cs +++ b/src/Lumina.Presentation.Api/Common/Routes/Library/Management/ApiRoutes.Libraries.cs @@ -12,6 +12,7 @@ public static partial class ApiRoutes { public const string GET_LIBRARY_BY_ID = "/libraries/{id}"; public const string GET_LIBRARIES = "/libraries"; + public const string GET_ENABLED_LIBRARIES = "/libraries/enabled"; public const string ADD_LIBRARY = "/libraries"; public const string UPDATE_LIBRARY = "/libraries/{id}"; public const string DELETE_LIBRARY = "/libraries/{id}"; diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpointSummary.cs index 2f8ecf72..426d33ad 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpointSummary.cs @@ -31,13 +31,21 @@ public class AddLibraryEndpointSummary : Summary r.Title, "The title of the media library. Required."); RequestParam(r => r.LibraryType, "The type of the media library. Required."); RequestParam(r => r.ContentLocations, "The file system paths of the directories where the media library elements are located. Required."); RequestParam(r => r.CoverImage, "The path of the image file used as the cover for the library. Optional."); + RequestParam(r => r.IsEnabled, "Whether this media library is enabled or not. A disabled media library is never shown or changed. Optional."); + RequestParam(r => r.IsLocked, "Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated. Optional."); + RequestParam(r => r.DownloadMedatadaFromWeb, "Whether this media library should update the metadata of its elements from the web, or not. Optional."); + RequestParam(r => r.SaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not. Optional."); ResponseParam(r => r.Id, "The unique identifier of the entity."); ResponseParam(r => r.UserId, "The Id of the user owning the media library."); @@ -45,10 +53,13 @@ public class AddLibraryEndpointSummary : Summary(r => r.LibraryType, "The type of the media library."); ResponseParam(r => r.ContentLocations, "The file system paths of the directories where the media library elements are located."); ResponseParam(r => r.CoverImage, "The path of the image file used as the cover for the library."); + ResponseParam(r => r.IsEnabled, "Whether this media library is enabled or not. A disabled media library is never shown or changed."); + ResponseParam(r => r.IsLocked, "Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated."); + ResponseParam(r => r.DownloadMedatadaFromWeb, "Whether this media library should update the metadata of its elements from the web, or not."); + ResponseParam(r => r.SaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not."); ResponseParam(r => r.CreatedOnUtc, "The date and time when the entity was created."); ResponseParam(r => r.UpdatedOnUtc, "The date and time when the entity was last updated."); - Response(201, "The media library was successfuly created.", example: new LibraryResponse( Id: Guid.NewGuid(), @@ -57,11 +68,14 @@ public class AddLibraryEndpointSummary : Summary +/// API endpoint for the /libraries/enabled route. +/// +public class GetEnabledLibrariesEndpoint : BaseEndpoint +{ + private readonly ISender _sender; + + /// + /// Initializes a new instance of the class. + /// + /// Injected service for mediating commands and queries. + public GetEnabledLibrariesEndpoint(ISender sender) + { + _sender = sender; + } + + /// + /// Configures the API endpoint. + /// + public override void Configure() + { + Verbs(Http.GET); + Routes(ApiRoutes.Libraries.GET_ENABLED_LIBRARIES); + Version(1); + DontCatchExceptions(); + } + + /// + /// Gets the list of enabled media libraries. + /// + /// Cancellation token that can be used to stop the execution. + public override async Task ExecuteAsync(EmptyRequest _, CancellationToken cancellationToken) + { + ErrorOr result = await _sender.Send(new GetEnabledLibrariesQuery(), cancellationToken).ConfigureAwait(false); + return result.Match(success => TypedResults.Ok(success), Problem); + } +} diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/GetEnabledLibraries/GetEnabledLibrariesEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/GetEnabledLibraries/GetEnabledLibrariesEndpointSummary.cs new file mode 100644 index 00000000..485f6871 --- /dev/null +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/GetEnabledLibraries/GetEnabledLibrariesEndpointSummary.cs @@ -0,0 +1,87 @@ +#region ========================================================================= USING ===================================================================================== +using FastEndpoints; +using Lumina.Contracts.Responses.MediaLibrary.Management; +using Lumina.Domain.Common.Enums.MediaLibrary; +using System; +using System.Diagnostics.CodeAnalysis; +#endregion + +namespace Lumina.Presentation.Api.Core.Endpoints.Library.Management.GetEnabledLibraries; + +/// +/// Class used for providing a textual description for the API endpoint, for OpenAPI. +/// +[ExcludeFromCodeCoverage] +public class GetEnabledLibrariesEndpointSummary : Summary +{ + /// + /// Initializes a new instance of the class. + /// + public GetEnabledLibrariesEndpointSummary() + { + Summary = "Retrieves the list of enabled media libraries."; + Description = "Retrieves the entire list of media libraries that are marked as enabled, if the user making the request is an Admin, or just the library owned by them, for regular users."; + + Response(200, "The media libraries are returned.", + example: new LibraryResponse[] { + new ( + Id: Guid.NewGuid(), + UserId: Guid.NewGuid(), + Title: "TV Shows", + LibraryType: LibraryType.TvShow, + ContentLocations: ["/media/tv shows/drama/", "/media/tv shows/SCI-FI/"], + CoverImage: "/media/myTvShowPoster.jpg", + IsEnabled: true, + IsLocked: false, + DownloadMedatadaFromWeb: true, + SaveMetadataInMediaDirectories: false, + CreatedOnUtc: DateTime.UtcNow, + UpdatedOnUtc: default + ), + new ( + Id: Guid.NewGuid(), + UserId: Guid.NewGuid(), + Title: "Movies", + LibraryType: LibraryType.TvShow, + ContentLocations: ["/media/movies/"], + CoverImage: "/media/myMoviePoster.jpg", + IsEnabled: true, + IsLocked: true, + DownloadMedatadaFromWeb: true, + SaveMetadataInMediaDirectories: true, + CreatedOnUtc: DateTime.UtcNow, + UpdatedOnUtc: default + ) + }); + + Response(401, "Authentication required.", "application/problem+json", + example: new[] + { + new + { + type = "https://tools.ietf.org/html/rfc7235#section-3.1", + status = 401, + title = "Unauthorized", + detail = "You are not authorized", + instance = "/api/v1/libraries/enabled" + }, + new + { + type = "https://tools.ietf.org/html/rfc7235#section-3.1", + status = 401, + title = "Unauthorized", + detail = "Invalid token: The token expired at '01/01/2024 01:00:00'", + instance = "/api/v1/libraries/enabled" + }, + new + { + type = "https://tools.ietf.org/html/rfc7235#section-3.1", + status = 401, + title = "Unauthorized", + detail = "The token is invalid", + instance = "/api/v1/libraries/enabled" + } + } + ); + } +} diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/GetLibraries/GetLibrariesEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/GetLibraries/GetLibrariesEndpoint.cs index 83012128..5a21d3b3 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/GetLibraries/GetLibrariesEndpoint.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/GetLibraries/GetLibrariesEndpoint.cs @@ -41,9 +41,8 @@ public class GetLibrariesEndpoint : BaseEndpoint } /// - /// Gets the list of libraries. + /// Gets the list of media libraries. /// - /// The request containing the id of the library to be retrieved. /// Cancellation token that can be used to stop the execution. public override async Task ExecuteAsync(EmptyRequest _, CancellationToken cancellationToken) { diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/GetLibraries/GetLibrariesEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/GetLibraries/GetLibrariesEndpointSummary.cs index 10dc2144..f5ffc6e9 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/GetLibraries/GetLibrariesEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/Management/GetLibraries/GetLibrariesEndpointSummary.cs @@ -31,6 +31,10 @@ public class GetLibrariesEndpointSummary : Summary(r => r.LibraryType, "The type of the media library."); ResponseParam(r => r.ContentLocations, "The file system paths of the directories where the media library elements are located."); ResponseParam(r => r.CoverImage, "The path of the image file used as the cover for the library."); + ResponseParam(r => r.IsEnabled, "Whether this media library is enabled or not. A disabled media library is never shown or changed."); + ResponseParam(r => r.IsLocked, "Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated."); + ResponseParam(r => r.DownloadMedatadaFromWeb, "Whether this media library should update the metadata of its elements from the web, or not."); + ResponseParam(r => r.SaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not."); ResponseParam(r => r.CreatedOnUtc, "The date and time when the entity was created."); ResponseParam(r => r.UpdatedOnUtc, "The date and time when the entity was last updated."); @@ -46,6 +50,10 @@ public class GetLibraryEndpointSummary : Summary r.Id, "The Id of the media library. Required."); @@ -42,6 +46,10 @@ public class UpdateLibraryEndpointSummary : Summary r.LibraryType, "The type of the media library. Required."); RequestParam(r => r.ContentLocations, ">The file system paths of the directories where the media library elements are located. Required."); RequestParam(r => r.CoverImage, "The path of the image file used as the cover for the library. Optional."); + RequestParam(r => r.IsEnabled, "Whether this media library is enabled or not. A disabled media library is never shown or changed. Optional."); + RequestParam(r => r.IsLocked, "Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated. Optional."); + RequestParam(r => r.DownloadMedatadaFromWeb, "Whether this media library should update the metadata of its elements from the web, or not. Optional."); + RequestParam(r => r.SaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not. Optional."); ResponseParam(r => r.Id, "The unique identifier of the entity."); ResponseParam(r => r.UserId, "The Id of the user owning the media library."); @@ -49,10 +57,13 @@ public class UpdateLibraryEndpointSummary : Summary(r => r.LibraryType, "The type of the media library."); ResponseParam(r => r.ContentLocations, "The file system paths of the directories where the media library elements are located."); ResponseParam(r => r.CoverImage, "The path of the image file used as the cover for the library."); + ResponseParam(r => r.IsEnabled, "Whether this media library is enabled or not. A disabled media library is never shown or changed."); + ResponseParam(r => r.IsLocked, "Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated."); + ResponseParam(r => r.DownloadMedatadaFromWeb, "Whether this media library should update the metadata of its elements from the web, or not."); + ResponseParam(r => r.SaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not."); ResponseParam(r => r.CreatedOnUtc, "The date and time when the entity was created."); ResponseParam(r => r.UpdatedOnUtc, "The date and time when the entity was last updated."); - Response(200, "The media library was successfuly updated.", example: new LibraryResponse( Id: Guid.NewGuid(), @@ -60,12 +71,15 @@ public class UpdateLibraryEndpointSummary : Summary public List ContentLocations { get; set; } = []; + + /// + /// Gets or sets whether this media library is enabled or not. A disabled media library is never shown or changed. + /// + public bool IsEnabled { get; set; } = true; + + /// + /// Gets or sets whether this media library is locked or not. A locked media library is displayed, but is never changed or updated. + /// + public bool IsLocked { get; set; } = false; + + /// + /// Gets or sets whether this media library should update the metadata of its elements from the web, or not. + /// + public bool DownloadMedatadaFromWeb { get; set; } = true; + + /// + /// Gets or sets whether this media library should copy the downloaded metadata into the media library content locations, or not. + /// + public bool SaveMetadataInMediaDirectories { get; set; } = false; } diff --git a/src/Lumina.Presentation.Web/Controllers/Library/Management/LibraryManagementController.cs b/src/Lumina.Presentation.Web/Controllers/Library/Management/LibraryManagementController.cs index 027a54a6..1e2f723a 100644 --- a/src/Lumina.Presentation.Web/Controllers/Library/Management/LibraryManagementController.cs +++ b/src/Lumina.Presentation.Web/Controllers/Library/Management/LibraryManagementController.cs @@ -73,6 +73,17 @@ public class LibraryManagementController : Controller return Json(new { success = true, data = response }); } + /// + /// Gets the list of enabled media libraries. + /// + /// Cancellation token that can be used to stop the execution. + [HttpGet("api-get-enabled-libraries")] + public async Task GetEnabledLibraries(CancellationToken cancellationToken = default) + { + LibraryModel[] response = await _apiHttpClient.GetAsync($"libraries/enabled/", cancellationToken).ConfigureAwait(false); + return Json(new { success = true, data = response }); + } + /// /// Adds a new media library, or updates an existing one. /// diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.de-DE.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.de-DE.resx index f64df03a..c0d82467 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.de-DE.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.de-DE.resx @@ -132,4 +132,7 @@ Keine Bibliotheken + + Entfernen + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.en-US.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.en-US.resx index e28890f7..21523706 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.en-US.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.en-US.resx @@ -132,4 +132,7 @@ No libraries + + Remove + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.es-ES.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.es-ES.resx index d73a41d8..0de053f6 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.es-ES.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.es-ES.resx @@ -132,4 +132,7 @@ Sin bibliotecas + + Eliminar + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.fr-FR.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.fr-FR.resx index ec01ece5..0817e439 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.fr-FR.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.fr-FR.resx @@ -132,4 +132,7 @@ Aucune bibliothèque + + Supprimer + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.it-IT.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.it-IT.resx index 6c3554c7..47edc4f5 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.it-IT.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.it-IT.resx @@ -132,4 +132,7 @@ Nessuna libreria + + Rimuovere + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.ja-JP.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.ja-JP.resx index 549b22b9..3984906d 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.ja-JP.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.ja-JP.resx @@ -132,4 +132,7 @@ ライブラリがありません + + 削除 + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.resx index e28890f7..21523706 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.resx @@ -132,4 +132,7 @@ No libraries + + Remove + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.ro-RO.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.ro-RO.resx index 8105a7bf..68fd180f 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.ro-RO.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.ro-RO.resx @@ -132,4 +132,7 @@ Nicio bibliotecă + + Șterge + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.ru-RU.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.ru-RU.resx index 7cac2e87..86d65aff 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.ru-RU.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.ru-RU.resx @@ -132,4 +132,7 @@ Нет библиотек + + Удалить + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.zh-CN.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.zh-CN.resx index b6f2e4ed..7c600260 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.zh-CN.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Index.zh-CN.resx @@ -132,4 +132,7 @@ 无库 + + 删除 + \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.Designer.cs b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.Designer.cs index b9d621a7..891a627c 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.Designer.cs +++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.Designer.cs @@ -96,6 +96,15 @@ namespace Lumina.Presentation.Web.Resources.Views.Library.Management { } } + /// + /// Looks up a localized string similar to Advanced Settings. + /// + public static string AdvancedSettings { + get { + return ResourceManager.GetString("AdvancedSettings", resourceCulture); + } + } + /// /// Looks up a localized string similar to Anime. /// @@ -213,6 +222,24 @@ namespace Lumina.Presentation.Web.Resources.Views.Library.Management { } } + /// + /// Looks up a localized string similar to Whether this media library should get the metadata of it elements by downloading it from the Internet, or not.. + /// + public static string DescriptionDownloadMetadataFromWeb { + get { + return ResourceManager.GetString("DescriptionDownloadMetadataFromWeb", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Whether this media library is disabled or not. A disabled library is not displayed to the users, scanned, updated, etc.. + /// + public static string DescriptionEnabled { + get { + return ResourceManager.GetString("DescriptionEnabled", resourceCulture); + } + } + /// /// Looks up a localized string similar to Select the type of media content this library will contain. /// @@ -222,6 +249,24 @@ namespace Lumina.Presentation.Web.Resources.Views.Library.Management { } } + /// + /// Looks up a localized string similar to Whether this media library is locked or not. A locked library is displayed to the users, but it is never scanned, updated, modified, etc.. + /// + public static string DescriptionLocked { + get { + return ResourceManager.GetString("DescriptionLocked", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Whether to save a copy of the downloaded metadata in the media library content locations directories, or not. This only has an effect if downloading metadata from the web is active.. + /// + public static string DescriptionSaveMetadataInMediaDirectories { + get { + return ResourceManager.GetString("DescriptionSaveMetadataInMediaDirectories", resourceCulture); + } + } + /// /// Looks up a localized string similar to A name to identify this library. /// @@ -249,6 +294,15 @@ namespace Lumina.Presentation.Web.Resources.Views.Library.Management { } } + /// + /// Looks up a localized string similar to Download Metadata From The Web. + /// + public static string DownloadMetadataFromWeb { + get { + return ResourceManager.GetString("DownloadMetadataFromWeb", resourceCulture); + } + } + /// /// Looks up a localized string similar to E Book. /// @@ -267,6 +321,15 @@ namespace Lumina.Presentation.Web.Resources.Views.Library.Management { } } + /// + /// Looks up a localized string similar to Enabled. + /// + public static string Enabled { + get { + return ResourceManager.GetString("Enabled", resourceCulture); + } + } + /// /// Looks up a localized string similar to Film Franchise. /// @@ -339,6 +402,15 @@ namespace Lumina.Presentation.Web.Resources.Views.Library.Management { } } + /// + /// Looks up a localized string similar to Locked. + /// + public static string Locked { + get { + return ResourceManager.GetString("Locked", resourceCulture); + } + } + /// /// Looks up a localized string similar to Magazine. /// @@ -456,6 +528,15 @@ namespace Lumina.Presentation.Web.Resources.Views.Library.Management { } } + /// + /// Looks up a localized string similar to Save Metadata In Media Directories. + /// + public static string SaveMetadataInMediaDirectories { + get { + return ResourceManager.GetString("SaveMetadataInMediaDirectories", resourceCulture); + } + } + /// /// Looks up a localized string similar to Screenplay. /// diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.de-DE.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.de-DE.resx index 94373104..e630247e 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.de-DE.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.de-DE.resx @@ -129,6 +129,9 @@ Neue Bibliothek Hinzufügen + + Erweiterte Einstellungen + Anime @@ -168,9 +171,21 @@ Wählen Sie die Ordner mit den Mediendateien dieser Bibliothek aus + + Ob diese Medienbibliothek die Metadaten ihrer Elemente aus dem Internet herunterladen soll oder nicht. + + + Ob diese Medienbibliothek deaktiviert ist oder nicht. Eine deaktivierte Bibliothek wird den Benutzern nicht angezeigt, nicht gescannt, nicht aktualisiert, usw. + Wählen Sie die Art der Medieninhalte aus, die diese Bibliothek enthalten soll + + Ob diese Medienbibliothek gesperrt ist oder nicht. Eine gesperrte Bibliothek wird den Benutzern angezeigt, wird aber nie gescannt, aktualisiert, verändert, usw. + + + Ob eine Kopie der heruntergeladenen Metadaten in den Verzeichnissen der Medienbibliothek gespeichert werden soll oder nicht. Dies hat nur eine Auswirkung, wenn das Herunterladen von Metadaten aus dem Web aktiv ist. + Eine Bezeichnung für diese Bibliothek @@ -180,12 +195,18 @@ Dokumentarfilm + + Metadaten Aus Dem Web Herunterladen + E-Buch Bibliothek Bearbeiten + + Aktiviert + Filmfranchise @@ -210,6 +231,9 @@ Live-Auftritt + + Gesperrt + Zeitschrift @@ -249,6 +273,9 @@ Speichern + + Metadaten In Medienverzeichnissen Speichern + Drehbuch diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.en-US.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.en-US.resx index 8c7d70e1..ea47cf88 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.en-US.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.en-US.resx @@ -129,6 +129,9 @@ Add New Library + + Advanced Settings + Anime @@ -168,9 +171,21 @@ Select the folders containing the media files of this library + + Whether this media library should get the metadata of it elements by downloading it from the Internet, or not. + + + Whether this media library is disabled or not. A disabled library is not displayed to the users, scanned, updated, etc. + Select the type of media content this library will contain + + Whether this media library is locked or not. A locked library is displayed to the users, but it is never scanned, updated, modified, etc. + + + Whether to save a copy of the downloaded metadata in the media library content locations directories, or not. This only has an effect if downloading metadata from the web is active. + A name to identify this library @@ -180,12 +195,18 @@ Documentary + + Download Metadata From The Web + E Book Edit Library + + Enabled + Film Franchise @@ -210,6 +231,9 @@ Live Performance + + Locked + Magazine @@ -249,6 +273,9 @@ Save + + Save Metadata In Media Directories + Screenplay diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.es-ES.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.es-ES.resx index c35d9502..5d3732d1 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.es-ES.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.es-ES.resx @@ -129,6 +129,9 @@ Agregar Nueva Biblioteca + + Configuración Avanzada + Anime @@ -168,9 +171,21 @@ Selecciona las carpetas que contienen los archivos multimedia de esta biblioteca + + Si esta biblioteca multimedia debe obtener los metadatos de sus elementos descargándolos de Internet o no. + + + Si esta biblioteca multimedia está desactivada o no. Una biblioteca desactivada no se muestra a los usuarios, no se escanea, no se actualiza, etc. + Selecciona el tipo de contenido multimedia que contendrá esta biblioteca + + Si esta biblioteca multimedia está bloqueada o no. Una biblioteca bloqueada se muestra a los usuarios, pero nunca se escanea, actualiza, modifica, etc. + + + Si guardar o no una copia de los metadatos descargados en los directorios de contenido de la biblioteca multimedia. Esto solo tiene efecto si la descarga de metadatos desde la web está activa. + Un nombre para identificar esta biblioteca @@ -180,12 +195,18 @@ Documental + + Descargar Metadatos Desde La Web + Libro Electrónico Editar Biblioteca + + Activado + Franquicia Cinematográfica @@ -210,6 +231,9 @@ Actuación en Vivo + + Bloqueado + Revista @@ -249,6 +273,9 @@ Guardar + + Guardar Metadatos En Los Directorios Multimedia + Guión diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.fr-FR.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.fr-FR.resx index bac6a7f9..702920cb 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.fr-FR.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.fr-FR.resx @@ -129,6 +129,9 @@ Ajouter Une Nouvelle Bibliothèque + + Paramètres Avancés + Animé @@ -168,9 +171,21 @@ Sélectionnez les dossiers contenant les fichiers multimédias de cette bibliothèque + + Si cette médiathèque doit obtenir les métadonnées de ses éléments en les téléchargeant depuis Internet ou non. + + + Si cette médiathèque est désactivée ou non. Une bibliothèque désactivée n'est pas affichée aux utilisateurs, ni analysée, ni mise à jour, etc. + Choisissez le type de contenu multimédia que contiendra cette bibliothèque + + Si cette médiathèque est verrouillée ou non. Une bibliothèque verrouillée est affichée aux utilisateurs, mais n'est jamais analysée, mise à jour, modifiée, etc. + + + Si une copie des métadonnées téléchargées doit être sauvegardée dans les répertoires de contenu de la médiathèque ou non. Ceci n'a d'effet que si le téléchargement des métadonnées depuis le web est actif. + Un nom pour identifier cette bibliothèque @@ -180,12 +195,18 @@ Documentaire + + Télécharger Les Métadonnées Depuis Le Web + Livre Numérique Modifier La Bibliothèque + + Activé + Franchise Cinématographique @@ -210,6 +231,9 @@ Concert Live + + Verrouillé + Magazine @@ -249,6 +273,9 @@ Enregistrer + + Sauvegarder Les Métadonnées Dans Les Répertoires Média + Scénario diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.it-IT.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.it-IT.resx index 90772f16..d0b07797 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.it-IT.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.it-IT.resx @@ -129,6 +129,9 @@ Aggiungi Nuova Libreria + + Impostazioni Avanzate + Anime @@ -168,9 +171,21 @@ Seleziona le cartelle che contengono i file multimediali di questa biblioteca + + Se questa libreria multimediale deve ottenere i metadati dei suoi elementi scaricandoli da Internet o meno. + + + Se questa libreria multimediale è disabilitata o meno. Una libreria disabilitata non viene mostrata agli utenti, scansionata, aggiornata, ecc. + Seleziona il tipo di contenuti multimediali che questa biblioteca conterrà + + Se questa libreria multimediale è bloccata o meno. Una libreria bloccata viene mostrata agli utenti, ma non viene mai scansionata, aggiornata, modificata, ecc. + + + Se salvare o meno una copia dei metadati scaricati nelle directory dei contenuti della libreria multimediale. Questo ha effetto solo se il download dei metadati dal web è attivo. + Un nome per identificare questa biblioteca @@ -180,12 +195,18 @@ Documentario + + Scarica I Metadati Dal Web + E-Book Modifica La Libreria + + Attivato + Franchise Cinematografico @@ -210,6 +231,9 @@ Esibizione dal Vivo + + Bloccato + Rivista @@ -249,6 +273,9 @@ Salva + + Salvare I Metadati Nelle Directory Multimediali + Sceneggiatura diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.ja-JP.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.ja-JP.resx index ce7ed5ce..791fd9d6 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.ja-JP.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.ja-JP.resx @@ -129,6 +129,9 @@ 新しい ライブラリ 追加 + + 詳細設定 + アニメ @@ -168,9 +171,21 @@ このライブラリのメディアファイルを含むフォルダを選択してください + + このメディアライブラリの要素のメタデータをインターネットからダウンロードして取得するかどうか。 + + + このメディアライブラリが無効になっているかどうか。無効化されたライブラリはユーザーに表示されず、スキャンされず、更新もされません。 + この図書館に含める媒体コンテンツの種類を選択してください + + このメディアライブラリがロックされているかどうか。ロックされたライブラリはユーザーに表示されますが、スキャン、更新、変更などは一切されません。 + + + ダウンロードしたメタデータのコピーをメディアライブラリのコンテンツディレクトリに保存するかどうか。これはウェブからのメタデータのダウンロードが有効な場合のみ効果があります。 + この図書館を識別するための名称 @@ -180,12 +195,18 @@ ドキュメンタリー + + ウェブからメタデータをダウンロード + 電子書籍 ライブラリ 編集 + + 有効 + 映画フランチャイズ @@ -210,6 +231,9 @@ ライブパフォーマンス + + ロック済 + 雑誌 @@ -249,6 +273,9 @@ 保存 + + メディアディレクトリにメタデータを保存 + 脚本 diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.resx index 8c7d70e1..ea47cf88 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.resx @@ -129,6 +129,9 @@ Add New Library + + Advanced Settings + Anime @@ -168,9 +171,21 @@ Select the folders containing the media files of this library + + Whether this media library should get the metadata of it elements by downloading it from the Internet, or not. + + + Whether this media library is disabled or not. A disabled library is not displayed to the users, scanned, updated, etc. + Select the type of media content this library will contain + + Whether this media library is locked or not. A locked library is displayed to the users, but it is never scanned, updated, modified, etc. + + + Whether to save a copy of the downloaded metadata in the media library content locations directories, or not. This only has an effect if downloading metadata from the web is active. + A name to identify this library @@ -180,12 +195,18 @@ Documentary + + Download Metadata From The Web + E Book Edit Library + + Enabled + Film Franchise @@ -210,6 +231,9 @@ Live Performance + + Locked + Magazine @@ -249,6 +273,9 @@ Save + + Save Metadata In Media Directories + Screenplay diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.ro-RO.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.ro-RO.resx index 488819dc..251ebb68 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.ro-RO.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.ro-RO.resx @@ -129,6 +129,9 @@ Adaugă Bibliotecă Nouă + + Setări Avansate + Anime @@ -168,9 +171,21 @@ Selectează dosarele care conțin fișierele media ale acestei biblioteci + + Dacă această bibliotecă media ar trebui să obțină metadatele elementelor sale prin descărcare de pe Internet sau nu. + + + Dacă această bibliotecă media este dezactivată sau nu. O bibliotecă dezactivată nu este afișată utilizatorilor, scanată, actualizată, etc. + Selectează tipul de conținut media pe care îl va conține această bibliotecă + + Dacă această bibliotecă media este blocată sau nu. O bibliotecă blocată este afișată utilizatorilor, dar nu este niciodată scanată, actualizată, modificată, etc. + + + Dacă se salvează sau nu o copie a metadatelor descărcate în directoarele cu conținut ale bibliotecii media. Acest lucru are efect doar dacă descărcarea metadatelor de pe web este activă. + Un nume pentru identificarea acestei biblioteci @@ -180,12 +195,18 @@ Documentar + + Descarcă Metadate De Pe Web + Carte Electronică Editează Bibliotecă + + Activat + Franciză de Film @@ -210,6 +231,9 @@ Spectacol Live + + Blocat + Revistă @@ -249,6 +273,9 @@ Salvează + + Salvează Metadatele În Directoarele Media + Scenariu diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.ru-RU.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.ru-RU.resx index e6764bab..88bbd37f 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.ru-RU.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.ru-RU.resx @@ -129,6 +129,9 @@ Добавить Новую Библиотеку + + Расширенные Настройки + Аниме @@ -168,9 +171,21 @@ Выберите папки, содержащие медиафайлы этой библиотеки + + Должна ли эта медиатека получать метаданные своих элементов путем загрузки из Интернета или нет. + + + Отключена эта медиатека или нет. Отключенная библиотека не отображается пользователям, не сканируется, не обновляется и т.д. + Выберите тип медиаконтента, который будет содержать эта библиотека + + Заблокирована эта медиатека или нет. Заблокированная библиотека отображается пользователям, но никогда не сканируется, не обновляется, не изменяется и т.д. + + + Сохранять копию загруженных метаданных в каталогах содержимого медиатеки или нет. Это действует только если активна загрузка метаданных из интернета. + Название для этой библиотеки @@ -180,12 +195,18 @@ Документальный Фильм + + Загрузить Метаданные Из Интернета + Электронная Книга Редактировать Библиотеку + + Включено + Кинофраншиза @@ -210,6 +231,9 @@ Живое Выступление + + Заблокировано + Журнал @@ -249,6 +273,9 @@ Сохранить + + Сохранить Метаданные В Каталогах Медиафайлов + Сценарий diff --git a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.zh-CN.resx b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.zh-CN.resx index 86a9b73b..3bbb6979 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.zh-CN.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Library/Management/Item.zh-CN.resx @@ -129,6 +129,9 @@ 添加 新库 + + 高级设置 + 动画 @@ -168,9 +171,21 @@ 选择包含该图书馆媒体文件的文件夹 + + 此媒体库是否应该从互联网下载其元素的元数据。 + + + 此媒体库是否已禁用。禁用的库不会显示给用户,不会被扫描、更新等。 + 选择这个图书馆将包含的媒体内容类型 + + 此媒体库是否已锁定。锁定的库会显示给用户,但永远不会被扫描、更新、修改等。 + + + 是否在媒体库内容位置目录中保存已下载元数据的副本。这仅在从网络下载元数据处于活动状态时才有效。 + 给这个图书馆起个名字 @@ -180,12 +195,18 @@ 纪录片 + + 从网络下载元数据 + 电子书 编辑 库 + + 已启用 + 电影系列品牌 @@ -210,6 +231,9 @@ 现场表演 + + 已锁定 + 杂志 @@ -249,6 +273,9 @@ 保存 + + 在媒体目录中保存元数据 + 剧本 diff --git a/src/Lumina.Presentation.Web/Views/Home/Index.cshtml b/src/Lumina.Presentation.Web/Views/Home/Index.cshtml index 36477ab7..8587d682 100644 --- a/src/Lumina.Presentation.Web/Views/Home/Index.cshtml +++ b/src/Lumina.Presentation.Web/Views/Home/Index.cshtml @@ -34,7 +34,7 @@ const documentLoaded = async function () { // get the media libraries // TODO: add setting check whether the user desires this feature or not - const data = await callApiGetAsync('@_urlService.GetAbsoluteUrl("GetLibraries", "LibraryManagement")'); + const data = await callApiGetAsync('@_urlService.GetAbsoluteUrl("GetEnabledLibraries", "LibraryManagement")'); if (data && data.length > 0) { noLibrariesMessage.classList.replace('block', 'hidden'); librariesContainer.classList.replace('justify-center', 'justify-start'); diff --git a/src/Lumina.Presentation.Web/Views/Library/Management/Item.cshtml b/src/Lumina.Presentation.Web/Views/Library/Management/Item.cshtml index d94b0990..6df068ca 100644 --- a/src/Lumina.Presentation.Web/Views/Library/Management/Item.cshtml +++ b/src/Lumina.Presentation.Web/Views/Library/Management/Item.cshtml @@ -142,6 +142,56 @@ @_localizer["DescriptionDirectories"] + +

@_localizer["AdvancedSettings"]

+
+
+ : +
+
+ +
+ @_localizer["DescriptionEnabled"] +
+
+
+ : +
+
+ +
+ @_localizer["DescriptionLocked"] +
+
+
+ : +
+
+ +
+ @_localizer["DescriptionDownloadMetadataFromWeb"] +
+
+
+ +
+
+ +
+ @_localizer["DescriptionSaveMetadataInMediaDirectories"] +
@@ -168,6 +218,10 @@ const imgAddCover = document.getElementById('add-media-cover'); const mediaCoverFormTable = document.getElementById('add-media-cover-form-table'); const mediaDirectoriesFormTable = document.getElementById('add-media-directory-form-table'); + const chkIsEnabled = form.querySelector('[name="IsEnabled"]'); + const chkIsLocked = form.querySelector('[name="IsLocked"]'); + const chkDownloadMedatadaFromWeb = form.querySelector('[name="DownloadMedatadaFromWeb"]'); + const chkSaveMetadataInMediaDirectories = form.querySelector('[name="SaveMetadataInMediaDirectories"]'); // create new or update existing media library async function handleAddMediaLibraryAsync() { @@ -182,7 +236,11 @@ // get the first (and only) span in the mediaCoverFormTable, if it exists const coverSpan = mediaCoverFormTable.querySelector('.form-table-row span'); return coverSpan ? coverSpan.textContent : null; // return null if no cover image is selected - })() + })(), + IsEnabled: chkIsEnabled.checked, + IsLocked: chkIsLocked.checked, + DownloadMedatadaFromWeb: chkDownloadMedatadaFromWeb.checked, + SaveMetadataInMediaDirectories: chkSaveMetadataInMediaDirectories.checked }; const data = await callApiPostAsync('@_urlService.GetAbsoluteUrl("SaveLibrary", "LibraryManagement")', formData); if (data) { diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMappingTests.cs index e30b20fb..7e632c0e 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMappingTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMappingTests.cs @@ -23,7 +23,11 @@ public class AddMediaLibraryRequestMappingTests "My Library", "Book", ["C:/Books", "D:/Media/Books"], - "D:/poster.jpg" + "D:/poster.jpg", + true, + false, + true, + false ); // Act @@ -35,6 +39,10 @@ public class AddMediaLibraryRequestMappingTests result.LibraryType.Should().Be(request.LibraryType); result.ContentLocations.Should().BeEquivalentTo(request.ContentLocations); result.CoverImage.Should().BeEquivalentTo(request.CoverImage); + result.IsEnabled.Should().Be(request.IsEnabled); + result.IsLocked.Should().Be(request.IsLocked); + result.DownloadMedatadaFromWeb.Should().Be(request.DownloadMedatadaFromWeb); + result.SaveMetadataInMediaDirectories.Should().Be(request.SaveMetadataInMediaDirectories); } [Theory] @@ -49,7 +57,11 @@ public class AddMediaLibraryRequestMappingTests "My Library", libraryType.ToString(), ["C:/Media"], - "D:/poster.jpg" + "D:/poster.jpg", + true, + false, + true, + false ); // Act @@ -61,6 +73,10 @@ public class AddMediaLibraryRequestMappingTests result.LibraryType.Should().Be(libraryType.ToString()); result.ContentLocations.Should().BeEquivalentTo(request.ContentLocations); result.CoverImage.Should().BeEquivalentTo(request.CoverImage); + result.IsEnabled.Should().Be(request.IsEnabled); + result.IsLocked.Should().Be(request.IsLocked); + result.DownloadMedatadaFromWeb.Should().Be(request.DownloadMedatadaFromWeb); + result.SaveMetadataInMediaDirectories.Should().Be(request.SaveMetadataInMediaDirectories); } [Fact] @@ -79,7 +95,11 @@ public class AddMediaLibraryRequestMappingTests "My Library", "Book", contentLocations, - "D:/poster.jpg" + "D:/poster.jpg", + true, + false, + true, + false ); // Act @@ -104,7 +124,11 @@ public class AddMediaLibraryRequestMappingTests "My Library", "Book", contentLocations, - null + null, + true, + false, + true, + false ); // Act diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/LibraryMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/LibraryMappingTests.cs index d024f92f..cac92d2d 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/LibraryMappingTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/Management/LibraryMappingTests.cs @@ -30,7 +30,11 @@ public class LibraryMappingTests "Test Library", LibraryType.Book, ["C:/Books", "D:/Media/Books"], - "D:/myPoster.jpg" + "D:/myPoster.jpg", + true, + false, + true, + false ); Library library = libraryResult.Value; @@ -48,6 +52,10 @@ public class LibraryMappingTests result.CoverImage.Should().BeEquivalentTo(library.CoverImage); result.CreatedOnUtc.Should().Be(library.CreatedOnUtc); result.UpdatedOnUtc.Should().Be(library.UpdatedOnUtc.HasValue ? library.UpdatedOnUtc : null); + result.IsEnabled.Should().BeTrue(); + result.IsLocked.Should().BeFalse(); + result.DownloadMedatadaFromWeb.Should().BeTrue(); + result.SaveMetadataInMediaDirectories.Should().BeFalse(); } [Fact] @@ -59,7 +67,11 @@ public class LibraryMappingTests "Empty Library", LibraryType.Book, [], - "D:/myPoster.jpg" + "D:/myPoster.jpg", + true, + false, + true, + false ); Library library = libraryResult.Value; @@ -85,7 +97,11 @@ public class LibraryMappingTests "Test Library", libraryType, ["C:/Media"], - "D:/myPoster.jpg" + "D:/myPoster.jpg", + true, + false, + true, + false ); Library library = libraryResult.Value; @@ -96,6 +112,10 @@ public class LibraryMappingTests result.Should().NotBeNull(); result.LibraryType.Should().Be(libraryType); result.CoverImage.Should().BeEquivalentTo(library.CoverImage); + result.IsEnabled.Should().BeTrue(); + result.IsLocked.Should().BeFalse(); + result.DownloadMedatadaFromWeb.Should().BeTrue(); + result.SaveMetadataInMediaDirectories.Should().BeFalse(); } [Fact] @@ -115,7 +135,11 @@ public class LibraryMappingTests "Test Library", LibraryType.Book, contentLocations, - "D:/myPoster.jpg" + "D:/myPoster.jpg", + true, + false, + true, + false ); Library library = libraryResult.Value; @@ -144,7 +168,11 @@ public class LibraryMappingTests "Test Library", LibraryType.Book, contentLocations, - null + null, + true, + false, + true, + false ); Library library = libraryResult.Value; diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Fixtures/DomainLibraryFixture.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Fixtures/DomainLibraryFixture.cs index 1a019125..72ea9c0a 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Fixtures/DomainLibraryFixture.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/Management/Fixtures/DomainLibraryFixture.cs @@ -48,7 +48,11 @@ public class DomainLibraryFixture _faker.Random.String2(_faker.Random.Number(1, 50)), _faker.PickRandom(), validPaths.Take(_random.Next(1, validPaths.Count)), - _faker.System.FilePath() + _faker.System.FilePath(), + _faker.Random.Bool(), + _faker.Random.Bool(), + _faker.Random.Bool(), + _faker.Random.Bool() ); return library.Value; @@ -60,7 +64,11 @@ public class DomainLibraryFixture string? title = null, LibraryType? libraryType = null, IEnumerable? contentLocations = null, - string? coverImage = null) + string? coverImage = null, + bool isEnabled = true, + bool isLocked = false, + bool downloadMedatadaFromWeb = true, + bool saveMetadataInMediaDirectories = false) { ErrorOr library = id is null ? Library.Create( @@ -68,7 +76,11 @@ public class DomainLibraryFixture title ?? _faker.Random.String2(_faker.Random.Number(1, 50)), libraryType ?? LibraryType.Book, contentLocations ?? ["C:/Media"], - coverImage + coverImage, + isEnabled, + isLocked, + downloadMedatadaFromWeb, + saveMetadataInMediaDirectories ) : Library.Create( LibraryId.Create(id.Value), @@ -76,7 +88,11 @@ public class DomainLibraryFixture title ?? _faker.Random.String2(_faker.Random.Number(1, 50)), libraryType ?? LibraryType.Book, contentLocations ?? ["C:/Media"], - coverImage + coverImage, + isEnabled, + isLocked, + downloadMedatadaFromWeb, + saveMetadataInMediaDirectories ); return library.Value;