Adds deletion and restore for music library items.

This commit is contained in:
BinaryAlley committed 2026-11-15 18:53:10 +02:00
1 parent 98515dc5e8
commit f9ad8b2fc5
224 files changed
+22384 -1360

No files matched your search

@@ -0,0 +1,27 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
/// <summary>
/// Data transfer object for a music album that the user deleted and can restore.
/// </summary>
/// <param name="Id">The Id of the deleted album.</param>
/// <param name="LibraryId">The Id of the media library the deleted album belongs to.</param>
/// <param name="ArtistId">The Id of the artist the deleted album belongs to.</param>
/// <param name="ArtistName">The name of the artist the deleted album belongs to.</param>
/// <param name="Title">The title of the deleted album.</param>
/// <param name="DeletedOnUtc">The date and time when the album was deleted.</param>
/// <param name="CoverPath">The relative path of the stored cover image of the deleted album, when it has one.</param>
[DebuggerDisplay("Title: {Title}")]
public sealed record DeletedMusicAlbumDto(
Guid Id,
Guid LibraryId,
Guid ArtistId,
string ArtistName,
string Title,
DateTime DeletedOnUtc,
string? CoverPath
);
@@ -0,0 +1,23 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
/// <summary>
/// Data transfer object for a music artist that the user deleted and can restore.
/// </summary>
/// <param name="Id">The Id of the deleted artist.</param>
/// <param name="LibraryId">The Id of the media library the deleted artist belongs to.</param>
/// <param name="Name">The name of the deleted artist.</param>
/// <param name="DeletedOnUtc">The date and time when the artist was deleted.</param>
/// <param name="CoverPath">The relative path of the stored cover image of the deleted artist, when it has one.</param>
[DebuggerDisplay("Name: {Name}")]
public sealed record DeletedMusicArtistDto(
Guid Id,
Guid LibraryId,
string Name,
DateTime DeletedOnUtc,
string? CoverPath
);
@@ -0,0 +1,20 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.DTO.Libraries;
using System.Collections.Generic;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
/// <summary>
/// Data transfer object carrying the data needed by the deleted items page of a music library.
/// </summary>
/// <param name="Library">The media library whose deleted music items are shown.</param>
/// <param name="DeletedArtists">The deleted artists of the media library, ordered by the time they were deleted, most recent first.</param>
/// <param name="DeletedAlbums">The deleted albums of the media library, ordered by the time they were deleted, most recent first.</param>
/// <param name="DeletedTracks">The deleted tracks of the media library, ordered by the time they were deleted, most recent first.</param>
public sealed record DeletedMusicItemsPageDto(
LibraryDto Library,
IReadOnlyList<DeletedMusicArtistDto> DeletedArtists,
IReadOnlyList<DeletedMusicAlbumDto> DeletedAlbums,
IReadOnlyList<DeletedMusicTrackDto> DeletedTracks
);
@@ -0,0 +1,31 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
/// <summary>
/// Data transfer object for a music track that the user deleted and can restore.
/// </summary>
/// <param name="Id">The Id of the deleted track.</param>
/// <param name="LibraryId">The Id of the media library the deleted track belongs to.</param>
/// <param name="ArtistId">The Id of the artist the deleted track belongs to.</param>
/// <param name="ArtistName">The name of the artist the deleted track belongs to.</param>
/// <param name="AlbumId">The Id of the album the deleted track belongs to.</param>
/// <param name="AlbumTitle">The title of the album the deleted track belongs to.</param>
/// <param name="Title">The title of the deleted track.</param>
/// <param name="Path">The file system path of the deleted track.</param>
/// <param name="DeletedOnUtc">The date and time when the track was deleted.</param>
[DebuggerDisplay("Title: {Title}")]
public sealed record DeletedMusicTrackDto(
Guid Id,
Guid LibraryId,
Guid ArtistId,
string ArtistName,
Guid AlbumId,
string AlbumTitle,
string Title,
string Path,
DateTime DeletedOnUtc
);
@@ -15,16 +15,22 @@ public static partial class ApiRoutes
public const string UPDATE_ARTIST = "libraries/{libraryId}/artists/{artistId}";
public const string UPDATE_ARTIST_COVER = "libraries/{libraryId}/artists/{artistId}/cover";
public const string DELETE_ARTIST = "libraries/{libraryId}/artists/{artistId}";
public const string GET_DELETED_ARTISTS = "libraries/{libraryId}/artists/deleted-items";
public const string RESTORE_ARTIST = "libraries/{libraryId}/artists/{artistId}/restore";
public const string GET_ARTIST_ALBUMS_LITE = "libraries/{libraryId}/artists/{artistId}/albums/lite";
public const string GET_ALBUM = "libraries/{libraryId}/artists/{artistId}/albums/{albumId}";
public const string UPDATE_ALBUM = "libraries/{libraryId}/artists/{artistId}/albums/{albumId}";
public const string UPDATE_ALBUM_COVER = "libraries/{libraryId}/artists/{artistId}/albums/{albumId}/cover";
public const string DELETE_ALBUM = "libraries/{libraryId}/artists/{artistId}/albums/{albumId}";
public const string GET_DELETED_ALBUMS = "libraries/{libraryId}/albums/deleted-items";
public const string RESTORE_ALBUM = "libraries/{libraryId}/artists/{artistId}/albums/{albumId}/restore";
public const string GET_ALBUM_TRACKS_LITE = "libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/lite";
public const string SHUFFLE_TRACKS = "libraries/{libraryId}/tracks/shuffle";
public const string GET_TRACK = "libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/{trackId}";
public const string UPDATE_TRACK = "libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/{trackId}";
public const string DELETE_TRACK = "libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/{trackId}";
public const string GET_DELETED_TRACKS = "libraries/{libraryId}/tracks/deleted-items";
public const string RESTORE_TRACK = "libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/{trackId}/restore";
public const string STREAM_TRACK = "libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/{trackId}/stream";
public const string STREAM_TRACK_SEGMENT = "libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/{trackId}/stream/deliveries/{deliveryId}/segments/{segmentIndex}";
public const string GET_PLAYBACK_MANIFEST = "libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/{trackId}/playback-manifest";
@@ -11,24 +11,28 @@ public static partial class WebRoutes
public static class Music
{
public const string ARTISTS_INDEX = "{culture}/library/audio-library/music-library/artists";
public const string DELETED_MUSIC_ITEMS = "{culture}/library/audio-library/music-library/deleted-items";
public const string GET_ARTISTS = "{culture}/library/audio-library/music-library/artists/api-get-artists";
public const string ARTIST = "{culture}/library/audio-library/music-library/artists/{artistId}";
public const string GET_ARTIST = "{culture}/library/audio-library/music-library/artists/{artistId}/api-get-artist";
public const string SAVE_ARTIST = "{culture}/library/audio-library/music-library/artists/{artistId}/api-save-artist";
public const string UPDATE_ARTIST_COVER = "{culture}/library/audio-library/music-library/artists/{artistId}/api-update-cover";
public const string DELETE_ARTIST = "{culture}/library/audio-library/music-library/artists/{artistId}/api-delete-artist";
public const string RESTORE_ARTIST = "{culture}/library/audio-library/music-library/artists/{artistId}/api-restore-artist";
public const string GET_ARTIST_ALBUMS = "{culture}/library/audio-library/music-library/artists/{artistId}/albums/api-get-albums";
public const string ALBUM = "{culture}/library/audio-library/music-library/artists/{artistId}/albums/{albumId}";
public const string GET_ALBUM = "{culture}/library/audio-library/music-library/artists/{artistId}/albums/{albumId}/api-get-album";
public const string SAVE_ALBUM = "{culture}/library/audio-library/music-library/artists/{artistId}/albums/{albumId}/api-save-album";
public const string UPDATE_ALBUM_COVER = "{culture}/library/audio-library/music-library/artists/{artistId}/albums/{albumId}/api-update-cover";
public const string DELETE_ALBUM = "{culture}/library/audio-library/music-library/artists/{artistId}/albums/{albumId}/api-delete-album";
public const string RESTORE_ALBUM = "{culture}/library/audio-library/music-library/artists/{artistId}/albums/{albumId}/api-restore-album";
public const string GET_ALBUM_TRACKS = "{culture}/library/audio-library/music-library/artists/{artistId}/albums/{albumId}/tracks/api-get-tracks";
public const string SHUFFLE_TRACKS = "{culture}/library/audio-library/music-library/tracks/api-shuffle-tracks";
public const string TRACK = "{culture}/library/audio-library/music-library/artists/{artistId}/albums/{albumId}/tracks/{trackId}";
public const string GET_TRACK = "{culture}/library/audio-library/music-library/artists/{artistId}/albums/{albumId}/tracks/{trackId}/api-get-track";
public const string SAVE_TRACK = "{culture}/library/audio-library/music-library/artists/{artistId}/albums/{albumId}/tracks/{trackId}/api-save-track";
public const string DELETE_TRACK = "{culture}/library/audio-library/music-library/artists/{artistId}/albums/{albumId}/tracks/{trackId}/api-delete-track";
public const string RESTORE_TRACK = "{culture}/library/audio-library/music-library/artists/{artistId}/albums/{albumId}/tracks/{trackId}/api-restore-track";
public const string STREAM_TRACK = "{culture}/library/audio-library/music-library/artists/{artistId}/albums/{albumId}/tracks/{trackId}/api-stream-track";
public const string STREAM_TRACK_SEGMENT = "{culture}/library/audio-library/music-library/artists/{artistId}/albums/{albumId}/tracks/{trackId}/api-stream-track-segment/{deliveryId}/{segmentIndex}";
public const string GET_PLAYBACK_MANIFEST = "{culture}/library/audio-library/music-library/artists/{artistId}/albums/{albumId}/tracks/{trackId}/api-get-playback-manifest";
@@ -17,7 +17,7 @@ public class DeleteMusicAlbumEndpointSummary : Summary<DeleteMusicAlbumEndpoint>
public DeleteMusicAlbumEndpointSummary()
{
Summary = "Deletes a music album.";
Description = "Deletes the music album identified by the route, together with its tracks.";
Description = "Soft deletes the music album identified by the route, so its metadata, artwork and track paths are kept and the album can be restored.";
Response(200, "The music album was deleted.");
}
@@ -0,0 +1,66 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Presentation.Web.Common.Api;
using Lumina.Presentation.Web.Common.Routes;
using Lumina.Presentation.Web.Core.Endpoints.Common;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using System;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Web.Core.Endpoints.Library.AudioLibrary.MusicLibrary.Albums.RestoreMusicAlbum;
/// <summary>
/// API endpoint for the <c>/{culture}/library/audio-library/music-library/artists/{artistId}/albums/{albumId}/api-restore-album</c> route.
/// </summary>
public class RestoreMusicAlbumEndpoint : BaseEndpoint<EmptyRequest, IResult>
{
private readonly IApiHttpClient _apiHttpClient;
/// <summary>
/// Initializes a new instance of the <see cref="RestoreMusicAlbumEndpoint"/> class.
/// </summary>
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
public RestoreMusicAlbumEndpoint(IApiHttpClient apiHttpClient)
{
_apiHttpClient = apiHttpClient;
}
/// <summary>
/// Configures the endpoint.
/// </summary>
public override void Configure()
{
base.Configure();
Verbs(Http.POST);
Routes(WebRoutes.Music.RESTORE_ALBUM);
DontAutoTag();
Options(options => options.WithTags("Music"));
EnableAntiforgery();
}
/// <summary>
/// Restores the deleted music album identified by the route.
/// </summary>
/// <param name="request">The request object.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
public override async Task<IResult> ExecuteAsync(EmptyRequest request, CancellationToken cancellationToken)
{
// The album is identified by the {artistId} and {albumId} route values and the owning library by the {libraryId} query string;
// all ids are normalized to Guids before they are substituted into the upstream URL, so that a crafted value can never escape its URL segment.
string routeArtistId = HttpContext.Request.RouteValues["artistId"]?.ToString() ?? string.Empty;
string artistId = Guid.TryParse(routeArtistId, out Guid parsedArtistId) ? parsedArtistId.ToString() : Guid.Empty.ToString();
string routeAlbumId = HttpContext.Request.RouteValues["albumId"]?.ToString() ?? string.Empty;
string albumId = Guid.TryParse(routeAlbumId, out Guid parsedAlbumId) ? parsedAlbumId.ToString() : Guid.Empty.ToString();
string queryLibraryId = HttpContext.Request.Query["libraryId"].ToString();
string libraryId = Guid.TryParse(queryLibraryId, out Guid parsedLibraryId) ? parsedLibraryId.ToString() : Guid.Empty.ToString();
await _apiHttpClient.PostAsync<Web.Common.Requests.Common.EmptyRequest, Web.Common.Requests.Common.EmptyRequest>(
ApiRoutes.Music.RESTORE_ALBUM.Replace("{libraryId}", libraryId).Replace("{artistId}", artistId).Replace("{albumId}", albumId),
new Web.Common.Requests.Common.EmptyRequest(),
cancellationToken).ConfigureAwait(false);
return JsonSuccess(new { isRestored = true });
}
}
@@ -0,0 +1,24 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Web.Core.Endpoints.Library.AudioLibrary.MusicLibrary.Albums.RestoreMusicAlbum;
/// <summary>
/// Class used for providing a textual description for the <see cref="RestoreMusicAlbumEndpoint"/> endpoint, for OpenAPI.
/// </summary>
[ExcludeFromCodeCoverage]
public class RestoreMusicAlbumEndpointSummary : Summary<RestoreMusicAlbumEndpoint>
{
/// <summary>
/// Initializes a new instance of the <see cref="RestoreMusicAlbumEndpointSummary"/> class.
/// </summary>
public RestoreMusicAlbumEndpointSummary()
{
Summary = "Restores a deleted music album.";
Description = "Restores the deleted music album identified by the route, together with the metadata and artwork kept for it.";
Response(200, "The music album was restored.");
}
}
@@ -17,7 +17,7 @@ public class DeleteMusicArtistEndpointSummary : Summary<DeleteMusicArtistEndpoin
public DeleteMusicArtistEndpointSummary()
{
Summary = "Deletes a music artist.";
Description = "Deletes the music artist identified by the route, together with its albums and tracks.";
Description = "Soft deletes the music artist identified by the route, so its metadata, artwork and track paths are kept and the artist can be restored.";
Response(200, "The music artist was deleted.");
}
@@ -96,6 +96,7 @@ public class MusicArtistsIndexViewEndpoint : BaseEndpoint<GetMusicArtistsViewReq
["settingsUrl"] = _urlService.GetAbsoluteUrl(WebRoutes.Settings.GET_USER_SETTINGS) ?? string.Empty,
["artistUrl"] = _urlService.GetAbsoluteUrl(WebRoutes.Music.ARTIST, new { artistId = default(Guid) }) ?? string.Empty,
["deleteUrl"] = _urlService.GetAbsoluteUrl(WebRoutes.Music.DELETE_ARTIST, new { artistId = default(Guid) }) ?? string.Empty,
["deletedItemsUrl"] = _urlService.GetAbsoluteUrl(WebRoutes.Music.DELETED_MUSIC_ITEMS) ?? string.Empty,
["strings"] = ThemePageDataFactory.CreateLocalizedStrings(_localizer)
}
};
@@ -0,0 +1,64 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Presentation.Web.Common.Api;
using Lumina.Presentation.Web.Common.Routes;
using Lumina.Presentation.Web.Core.Endpoints.Common;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using System;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Web.Core.Endpoints.Library.AudioLibrary.MusicLibrary.Artists.RestoreMusicArtist;
/// <summary>
/// API endpoint for the <c>/{culture}/library/audio-library/music-library/artists/{artistId}/api-restore-artist</c> route.
/// </summary>
public class RestoreMusicArtistEndpoint : BaseEndpoint<EmptyRequest, IResult>
{
private readonly IApiHttpClient _apiHttpClient;
/// <summary>
/// Initializes a new instance of the <see cref="RestoreMusicArtistEndpoint"/> class.
/// </summary>
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
public RestoreMusicArtistEndpoint(IApiHttpClient apiHttpClient)
{
_apiHttpClient = apiHttpClient;
}
/// <summary>
/// Configures the endpoint.
/// </summary>
public override void Configure()
{
base.Configure();
Verbs(Http.POST);
Routes(WebRoutes.Music.RESTORE_ARTIST);
DontAutoTag();
Options(options => options.WithTags("Music"));
EnableAntiforgery();
}
/// <summary>
/// Restores the deleted music artist identified by the route.
/// </summary>
/// <param name="request">The request object.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
public override async Task<IResult> ExecuteAsync(EmptyRequest request, CancellationToken cancellationToken)
{
// The artist is identified by the {artistId} route value and the owning library by the {libraryId} query string; both ids are
// normalized to Guids before they are substituted into the upstream URL, so that a crafted value can never escape its URL segment.
string routeArtistId = HttpContext.Request.RouteValues["artistId"]?.ToString() ?? string.Empty;
string artistId = Guid.TryParse(routeArtistId, out Guid parsedArtistId) ? parsedArtistId.ToString() : Guid.Empty.ToString();
string queryLibraryId = HttpContext.Request.Query["libraryId"].ToString();
string libraryId = Guid.TryParse(queryLibraryId, out Guid parsedLibraryId) ? parsedLibraryId.ToString() : Guid.Empty.ToString();
await _apiHttpClient.PostAsync<Web.Common.Requests.Common.EmptyRequest, Web.Common.Requests.Common.EmptyRequest>(
ApiRoutes.Music.RESTORE_ARTIST.Replace("{libraryId}", libraryId).Replace("{artistId}", artistId),
new Web.Common.Requests.Common.EmptyRequest(),
cancellationToken).ConfigureAwait(false);
return JsonSuccess(new { isRestored = true });
}
}
@@ -0,0 +1,24 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Web.Core.Endpoints.Library.AudioLibrary.MusicLibrary.Artists.RestoreMusicArtist;
/// <summary>
/// Class used for providing a textual description for the <see cref="RestoreMusicArtistEndpoint"/> endpoint, for OpenAPI.
/// </summary>
[ExcludeFromCodeCoverage]
public class RestoreMusicArtistEndpointSummary : Summary<RestoreMusicArtistEndpoint>
{
/// <summary>
/// Initializes a new instance of the <see cref="RestoreMusicArtistEndpointSummary"/> class.
/// </summary>
public RestoreMusicArtistEndpointSummary()
{
Summary = "Restores a deleted music artist.";
Description = "Restores the deleted music artist identified by the route, together with the metadata and artwork kept for it.";
Response(200, "The music artist was restored.");
}
}
@@ -0,0 +1,143 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Presentation.Web.Common.Api;
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
using Lumina.Presentation.Web.Common.DTO.Libraries;
using Lumina.Presentation.Web.Common.DTO.Themes;
using Lumina.Presentation.Web.Common.Primitives;
using Lumina.Presentation.Web.Common.Requests.Library.AudioLibrary.MusicLibrary.Artists;
using Lumina.Presentation.Web.Common.Routes;
using Lumina.Presentation.Web.Common.Services;
using Lumina.Presentation.Web.Core.Endpoints.Common;
using Lumina.Presentation.Web.Core.Themes;
using Microsoft.AspNetCore.Antiforgery;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Localization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Web.Core.Endpoints.Library.AudioLibrary.MusicLibrary.DeletedMusicItems;
/// <summary>
/// API endpoint for the <c>/{culture}/library/audio-library/music-library/deleted-items</c> route.
/// </summary>
public class DeletedMusicItemsViewEndpoint : BaseEndpoint<GetMusicArtistsViewRequest, IResult>
{
// The resource base name deliberately excludes the "Core.Resources" segment: the localization factory re-roots it with the configured ResourcesPath.
private const string VIEW_RESOURCE_BASE_NAME = "Lumina.Presentation.Web.Views.Library.AudioLibrary.MusicLibrary.DeletedItems";
private const string VIEW_RESOURCE_LOCATION = "Lumina.Presentation.Web";
// The page key mirrors the path of the Razor view under Core/Views, so that theme templates can override it at the page, section or default scope.
private const string VIEW_PAGE_KEY = "library/audio-library/music-library/deleted-items";
private static readonly JsonSerializerOptions s_camelCaseJsonOptions = new()
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
Converters = { new JsonStringEnumConverter() }
};
private readonly IApiHttpClient _apiHttpClient;
private readonly IUrlService _urlService;
private readonly ThemePageRenderer _themePageRenderer;
private readonly IAntiforgery _antiforgery;
private readonly IStringLocalizer _localizer;
/// <summary>
/// Initializes a new instance of the <see cref="DeletedMusicItemsViewEndpoint"/> class.
/// </summary>
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
/// <param name="urlService">Injected service for generating URLs from action and controller names, with localization.</param>
/// <param name="themePageRenderer">Injected service for rendering themed pages.</param>
/// <param name="antiforgery">Injected service for anti-forgery token handling.</param>
/// <param name="stringLocalizerFactory">Injected factory used to create the localizer of the view resources.</param>
public DeletedMusicItemsViewEndpoint(IApiHttpClient apiHttpClient, IUrlService urlService, ThemePageRenderer themePageRenderer, IAntiforgery antiforgery, IStringLocalizerFactory stringLocalizerFactory)
{
_apiHttpClient = apiHttpClient;
_urlService = urlService;
_themePageRenderer = themePageRenderer;
_antiforgery = antiforgery;
_localizer = stringLocalizerFactory.Create(VIEW_RESOURCE_BASE_NAME, VIEW_RESOURCE_LOCATION);
}
/// <summary>
/// Configures the endpoint.
/// </summary>
public override void Configure()
{
base.Configure();
Verbs(Http.GET);
Routes(WebRoutes.Music.DELETED_MUSIC_ITEMS);
DontAutoTag();
Options(options => options.WithTags("Music"));
}
/// <summary>
/// Displays the deleted music items of a media library, rendered by the active theme with a fallback to the Razor view.
/// </summary>
/// <param name="request">The request containing the Id of the media library whose deleted music items are shown.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
public override async Task<IResult> ExecuteAsync(GetMusicArtistsViewRequest request, CancellationToken cancellationToken)
{
if (request.LibraryId is null)
return Results.Redirect(_urlService.GetAbsoluteUrl(WebRoutes.Home.INDEX_CULTURED)!);
LibraryDto library = await _apiHttpClient.GetAsync<LibraryDto>(
ApiRoutes.Libraries.GET_LIBRARY_BY_ID.Replace("{id}", request.LibraryId.Value.ToString()), cancellationToken).ConfigureAwait(false);
DeletedMusicArtistDto[] deletedArtists = await _apiHttpClient.GetAsync<DeletedMusicArtistDto[]>(
ApiRoutes.Music.GET_DELETED_ARTISTS.Replace("{libraryId}", request.LibraryId.Value.ToString()), cancellationToken).ConfigureAwait(false);
DeletedMusicAlbumDto[] deletedAlbums = await _apiHttpClient.GetAsync<DeletedMusicAlbumDto[]>(
ApiRoutes.Music.GET_DELETED_ALBUMS.Replace("{libraryId}", request.LibraryId.Value.ToString()), cancellationToken).ConfigureAwait(false);
DeletedMusicTrackDto[] deletedTracks = await _apiHttpClient.GetAsync<DeletedMusicTrackDto[]>(
ApiRoutes.Music.GET_DELETED_TRACKS.Replace("{libraryId}", request.LibraryId.Value.ToString()), cancellationToken).ConfigureAwait(false);
// The page restores music items, which submit through the form anti-forgery token, so a fresh token must be issued for it.
AntiforgeryTokenSet antiforgeryTokens = _antiforgery.GetAndStoreTokens(HttpContext);
string title = _localizer["Title"].Value;
string backUrl = (_urlService.GetAbsoluteUrl(WebRoutes.Music.ARTISTS_INDEX) ?? string.Empty) + "?libraryId=" + request.LibraryId.Value;
Dictionary<string, object?> strings = ThemePageDataFactory.CreateLocalizedStrings(_localizer);
// The themed page script reads the localized strings through camel case keys, and they are serialized as JSON so that quotes and
// apostrophes in translations never terminate the JavaScript string literals of the template.
string stringsJson = JsonSerializer.Serialize(strings.ToDictionary(
entry => JsonNamingPolicy.CamelCase.ConvertName(entry.Key),
entry => entry.Value));
ThemePageDto pageModel = new()
{
PageKey = VIEW_PAGE_KEY,
Title = title,
Description = string.Empty,
PageData = new Dictionary<string, object?>
{
["libraryId"] = request.LibraryId.Value.ToString(),
["libraryTitle"] = library.Title ?? string.Empty,
["deletedArtistsJson"] = JsonSerializer.Serialize(deletedArtists, s_camelCaseJsonOptions),
["deletedAlbumsJson"] = JsonSerializer.Serialize(deletedAlbums, s_camelCaseJsonOptions),
["deletedTracksJson"] = JsonSerializer.Serialize(deletedTracks, s_camelCaseJsonOptions),
["artistRestoreUrl"] = _urlService.GetAbsoluteUrl(WebRoutes.Music.RESTORE_ARTIST, new { artistId = default(Guid) }) ?? string.Empty,
["albumRestoreUrl"] = _urlService.GetAbsoluteUrl(WebRoutes.Music.RESTORE_ALBUM, new { artistId = default(Guid), albumId = default(Guid) }) ?? string.Empty,
["trackRestoreUrl"] = _urlService.GetAbsoluteUrl(WebRoutes.Music.RESTORE_TRACK, new { artistId = default(Guid), albumId = default(Guid), trackId = default(Guid) }) ?? string.Empty,
["backUrl"] = backUrl,
["antiforgeryToken"] = antiforgeryTokens.RequestToken,
["strings"] = strings,
["stringsJson"] = stringsJson
}
};
Result<ThemePageRenderResultDto> sectionResult = await _themePageRenderer.RenderAsync(pageModel, requestedThemeId: null, cancellationToken).ConfigureAwait(false);
if (sectionResult.IsFailure)
return View("/Core/Views/Library/AudioLibrary/MusicLibrary/DeletedItems.cshtml",
new DeletedMusicItemsPageDto(library, deletedArtists, deletedAlbums, deletedTracks),
new Dictionary<string, object?> { ["Title"] = title });
return View(
"/Core/Views/Shared/_ThemedView.cshtml",
new ThemeViewDto(sectionResult.Value.Content, sectionResult.Value.Script),
new Dictionary<string, object?> { ["Title"] = title });
}
}
@@ -0,0 +1,25 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Presentation.Web.Common.Requests.Library.AudioLibrary.MusicLibrary.Artists;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Web.Core.Endpoints.Library.AudioLibrary.MusicLibrary.DeletedMusicItems;
/// <summary>
/// Class used for providing a textual description for the <see cref="DeletedMusicItemsViewEndpoint"/> endpoint, for OpenAPI.
/// </summary>
[ExcludeFromCodeCoverage]
public class DeletedMusicItemsViewEndpointSummary : Summary<DeletedMusicItemsViewEndpoint, GetMusicArtistsViewRequest>
{
/// <summary>
/// Initializes a new instance of the <see cref="DeletedMusicItemsViewEndpointSummary"/> class.
/// </summary>
public DeletedMusicItemsViewEndpointSummary()
{
Summary = "Renders the deleted items page of a music library.";
Description = "Renders the page that lists the artists, albums and tracks the user deleted from a music library and lets the user restore them.";
Response(200, "The deleted items page is rendered.");
}
}
@@ -17,7 +17,7 @@ public class DeleteMusicTrackEndpointSummary : Summary<DeleteMusicTrackEndpoint>
public DeleteMusicTrackEndpointSummary()
{
Summary = "Deletes a music track.";
Description = "Deletes the music track identified by the route, together with its metadata.";
Description = "Soft deletes the music track identified by the route, so its metadata, artwork and file path are kept and the track can be restored.";
Response(200, "The music track was deleted.");
}
@@ -0,0 +1,68 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Presentation.Web.Common.Api;
using Lumina.Presentation.Web.Common.Routes;
using Lumina.Presentation.Web.Core.Endpoints.Common;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using System;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Web.Core.Endpoints.Library.AudioLibrary.MusicLibrary.Tracks.RestoreMusicTrack;
/// <summary>
/// API endpoint for the <c>/{culture}/library/audio-library/music-library/artists/{artistId}/albums/{albumId}/tracks/{trackId}/api-restore-track</c> route.
/// </summary>
public class RestoreMusicTrackEndpoint : BaseEndpoint<EmptyRequest, IResult>
{
private readonly IApiHttpClient _apiHttpClient;
/// <summary>
/// Initializes a new instance of the <see cref="RestoreMusicTrackEndpoint"/> class.
/// </summary>
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
public RestoreMusicTrackEndpoint(IApiHttpClient apiHttpClient)
{
_apiHttpClient = apiHttpClient;
}
/// <summary>
/// Configures the endpoint.
/// </summary>
public override void Configure()
{
base.Configure();
Verbs(Http.POST);
Routes(WebRoutes.Music.RESTORE_TRACK);
DontAutoTag();
Options(options => options.WithTags("Music"));
EnableAntiforgery();
}
/// <summary>
/// Restores the deleted music track identified by the route.
/// </summary>
/// <param name="request">The request object.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
public override async Task<IResult> ExecuteAsync(EmptyRequest request, CancellationToken cancellationToken)
{
// The track is identified by the {artistId}, {albumId} and {trackId} route values and the owning library by the {libraryId} query string;
// all ids are normalized to Guids before they are substituted into the upstream URL, so that a crafted value can never escape its URL segment.
string routeArtistId = HttpContext.Request.RouteValues["artistId"]?.ToString() ?? string.Empty;
string artistId = Guid.TryParse(routeArtistId, out Guid parsedArtistId) ? parsedArtistId.ToString() : Guid.Empty.ToString();
string routeAlbumId = HttpContext.Request.RouteValues["albumId"]?.ToString() ?? string.Empty;
string albumId = Guid.TryParse(routeAlbumId, out Guid parsedAlbumId) ? parsedAlbumId.ToString() : Guid.Empty.ToString();
string routeTrackId = HttpContext.Request.RouteValues["trackId"]?.ToString() ?? string.Empty;
string trackId = Guid.TryParse(routeTrackId, out Guid parsedTrackId) ? parsedTrackId.ToString() : Guid.Empty.ToString();
string queryLibraryId = HttpContext.Request.Query["libraryId"].ToString();
string libraryId = Guid.TryParse(queryLibraryId, out Guid parsedLibraryId) ? parsedLibraryId.ToString() : Guid.Empty.ToString();
await _apiHttpClient.PostAsync<Web.Common.Requests.Common.EmptyRequest, Web.Common.Requests.Common.EmptyRequest>(
ApiRoutes.Music.RESTORE_TRACK.Replace("{libraryId}", libraryId).Replace("{artistId}", artistId).Replace("{albumId}", albumId).Replace("{trackId}", trackId),
new Web.Common.Requests.Common.EmptyRequest(),
cancellationToken).ConfigureAwait(false);
return JsonSuccess(new { isRestored = true });
}
}
@@ -0,0 +1,24 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Web.Core.Endpoints.Library.AudioLibrary.MusicLibrary.Tracks.RestoreMusicTrack;
/// <summary>
/// Class used for providing a textual description for the <see cref="RestoreMusicTrackEndpoint"/> endpoint, for OpenAPI.
/// </summary>
[ExcludeFromCodeCoverage]
public class RestoreMusicTrackEndpointSummary : Summary<RestoreMusicTrackEndpoint>
{
/// <summary>
/// Initializes a new instance of the <see cref="RestoreMusicTrackEndpointSummary"/> class.
/// </summary>
public RestoreMusicTrackEndpointSummary()
{
Summary = "Restores a deleted music track.";
Description = "Restores the deleted music track identified by the route, together with the metadata and artwork kept for it.";
Response(200, "The music track was restored.");
}
}
@@ -69,4 +69,7 @@
<data name="AddToPlaylist" xml:space="preserve">
<value>إضافة إلى قائمة التشغيل</value>
</data>
<data name="DeletedItems" xml:space="preserve">
<value>العناصر المحذوفة</value>
</data>
</root>
@@ -69,4 +69,7 @@
<data name="AddToPlaylist" xml:space="preserve">
<value>Zur Wiedergabeliste hinzufügen</value>
</data>
<data name="DeletedItems" xml:space="preserve">
<value>Gelöschte Elemente</value>
</data>
</root>
@@ -69,4 +69,7 @@
<data name="AddToPlaylist" xml:space="preserve">
<value>Add to playlist</value>
</data>
<data name="DeletedItems" xml:space="preserve">
<value>Deleted items</value>
</data>
</root>
@@ -69,4 +69,7 @@
<data name="AddToPlaylist" xml:space="preserve">
<value>Añadir a la lista de reproducción</value>
</data>
<data name="DeletedItems" xml:space="preserve">
<value>Elementos eliminados</value>
</data>
</root>
@@ -69,4 +69,7 @@
<data name="AddToPlaylist" xml:space="preserve">
<value>Ajouter à la liste de lecture</value>
</data>
<data name="DeletedItems" xml:space="preserve">
<value>Éléments supprimés</value>
</data>
</root>
@@ -69,4 +69,7 @@
<data name="AddToPlaylist" xml:space="preserve">
<value>Aggiungi alla playlist</value>
</data>
<data name="DeletedItems" xml:space="preserve">
<value>Elementi eliminati</value>
</data>
</root>
@@ -69,4 +69,7 @@
<data name="AddToPlaylist" xml:space="preserve">
<value>プレイリストに追加</value>
</data>
<data name="DeletedItems" xml:space="preserve">
<value>削除済みアイテム</value>
</data>
</root>
@@ -69,4 +69,7 @@
<data name="AddToPlaylist" xml:space="preserve">
<value>Add to playlist</value>
</data>
<data name="DeletedItems" xml:space="preserve">
<value>Deleted items</value>
</data>
</root>
@@ -69,4 +69,7 @@
<data name="AddToPlaylist" xml:space="preserve">
<value>Adaugă în listă de redare</value>
</data>
<data name="DeletedItems" xml:space="preserve">
<value>Elemente șterse</value>
</data>
</root>
@@ -69,4 +69,7 @@
<data name="AddToPlaylist" xml:space="preserve">
<value>Додати до списку відтворення</value>
</data>
<data name="DeletedItems" xml:space="preserve">
<value>Видалені елементи</value>
</data>
</root>
@@ -69,4 +69,7 @@
<data name="AddToPlaylist" xml:space="preserve">
<value>添加到播放列表</value>
</data>
<data name="DeletedItems" xml:space="preserve">
<value>已删除项目</value>
</data>
</root>
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Title" xml:space="preserve">
<value>العناصر المحذوفة</value>
</data>
<data name="BackToLibrary" xml:space="preserve">
<value>العودة إلى المكتبة</value>
</data>
<data name="NoDeletedItems" xml:space="preserve">
<value>لا توجد عناصر محذوفة في هذه المكتبة.</value>
</data>
<data name="Artists" xml:space="preserve">
<value>الفنانون</value>
</data>
<data name="Albums" xml:space="preserve">
<value>الألبومات</value>
</data>
<data name="Tracks" xml:space="preserve">
<value>المقاطع</value>
</data>
<data name="Name" xml:space="preserve">
<value>الاسم</value>
</data>
<data name="Artist" xml:space="preserve">
<value>الفنان</value>
</data>
<data name="Album" xml:space="preserve">
<value>ألبوم</value>
</data>
<data name="TrackTitle" xml:space="preserve">
<value>العنوان</value>
</data>
<data name="DeletedOn" xml:space="preserve">
<value>تاريخ الحذف</value>
</data>
<data name="Restore" xml:space="preserve">
<value>استعادة</value>
</data>
<data name="Restored" xml:space="preserve">
<value>تمت استعادة العنصر.</value>
</data>
<data name="RestoreFailed" xml:space="preserve">
<value>تعذرت استعادة العنصر.</value>
</data>
</root>
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Title" xml:space="preserve">
<value>Gelöschte Elemente</value>
</data>
<data name="BackToLibrary" xml:space="preserve">
<value>Zurück zur Bibliothek</value>
</data>
<data name="NoDeletedItems" xml:space="preserve">
<value>In dieser Bibliothek gibt es keine gelöschten Elemente.</value>
</data>
<data name="Artists" xml:space="preserve">
<value>Künstler</value>
</data>
<data name="Albums" xml:space="preserve">
<value>Alben</value>
</data>
<data name="Tracks" xml:space="preserve">
<value>Titel</value>
</data>
<data name="Name" xml:space="preserve">
<value>Name</value>
</data>
<data name="Artist" xml:space="preserve">
<value>Künstler</value>
</data>
<data name="Album" xml:space="preserve">
<value>Album</value>
</data>
<data name="TrackTitle" xml:space="preserve">
<value>Titel</value>
</data>
<data name="DeletedOn" xml:space="preserve">
<value>Gelöscht am</value>
</data>
<data name="Restore" xml:space="preserve">
<value>Wiederherstellen</value>
</data>
<data name="Restored" xml:space="preserve">
<value>Das Element wurde wiederhergestellt.</value>
</data>
<data name="RestoreFailed" xml:space="preserve">
<value>Das Element konnte nicht wiederhergestellt werden.</value>
</data>
</root>
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Title" xml:space="preserve">
<value>Deleted items</value>
</data>
<data name="BackToLibrary" xml:space="preserve">
<value>Back to library</value>
</data>
<data name="NoDeletedItems" xml:space="preserve">
<value>There are no deleted items in this library.</value>
</data>
<data name="Artists" xml:space="preserve">
<value>Artists</value>
</data>
<data name="Albums" xml:space="preserve">
<value>Albums</value>
</data>
<data name="Tracks" xml:space="preserve">
<value>Tracks</value>
</data>
<data name="Name" xml:space="preserve">
<value>Name</value>
</data>
<data name="Artist" xml:space="preserve">
<value>Artist</value>
</data>
<data name="Album" xml:space="preserve">
<value>Album</value>
</data>
<data name="TrackTitle" xml:space="preserve">
<value>Title</value>
</data>
<data name="DeletedOn" xml:space="preserve">
<value>Deleted on</value>
</data>
<data name="Restore" xml:space="preserve">
<value>Restore</value>
</data>
<data name="Restored" xml:space="preserve">
<value>The item was restored.</value>
</data>
<data name="RestoreFailed" xml:space="preserve">
<value>The item could not be restored.</value>
</data>
</root>
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Title" xml:space="preserve">
<value>Elementos eliminados</value>
</data>
<data name="BackToLibrary" xml:space="preserve">
<value>Volver a la biblioteca</value>
</data>
<data name="NoDeletedItems" xml:space="preserve">
<value>No hay elementos eliminados en esta biblioteca.</value>
</data>
<data name="Artists" xml:space="preserve">
<value>Artistas</value>
</data>
<data name="Albums" xml:space="preserve">
<value>Álbumes</value>
</data>
<data name="Tracks" xml:space="preserve">
<value>Pistas</value>
</data>
<data name="Name" xml:space="preserve">
<value>Nombre</value>
</data>
<data name="Artist" xml:space="preserve">
<value>Artista</value>
</data>
<data name="Album" xml:space="preserve">
<value>Álbum</value>
</data>
<data name="TrackTitle" xml:space="preserve">
<value>Título</value>
</data>
<data name="DeletedOn" xml:space="preserve">
<value>Eliminado el</value>
</data>
<data name="Restore" xml:space="preserve">
<value>Restaurar</value>
</data>
<data name="Restored" xml:space="preserve">
<value>El elemento se ha restaurado.</value>
</data>
<data name="RestoreFailed" xml:space="preserve">
<value>El elemento no se ha podido restaurar.</value>
</data>
</root>
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Title" xml:space="preserve">
<value>Éléments supprimés</value>
</data>
<data name="BackToLibrary" xml:space="preserve">
<value>Retour à la bibliothèque</value>
</data>
<data name="NoDeletedItems" xml:space="preserve">
<value>Cette bibliothèque ne contient aucun élément supprimé.</value>
</data>
<data name="Artists" xml:space="preserve">
<value>Artistes</value>
</data>
<data name="Albums" xml:space="preserve">
<value>Albums</value>
</data>
<data name="Tracks" xml:space="preserve">
<value>Pistes</value>
</data>
<data name="Name" xml:space="preserve">
<value>Nom</value>
</data>
<data name="Artist" xml:space="preserve">
<value>Artiste</value>
</data>
<data name="Album" xml:space="preserve">
<value>Album</value>
</data>
<data name="TrackTitle" xml:space="preserve">
<value>Titre</value>
</data>
<data name="DeletedOn" xml:space="preserve">
<value>Supprimé le</value>
</data>
<data name="Restore" xml:space="preserve">
<value>Restaurer</value>
</data>
<data name="Restored" xml:space="preserve">
<value>L&apos;élément a été restauré.</value>
</data>
<data name="RestoreFailed" xml:space="preserve">
<value>L&apos;élément n&apos;a pas pu être restauré.</value>
</data>
</root>
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Title" xml:space="preserve">
<value>Elementi eliminati</value>
</data>
<data name="BackToLibrary" xml:space="preserve">
<value>Torna alla biblioteca</value>
</data>
<data name="NoDeletedItems" xml:space="preserve">
<value>Non ci sono elementi eliminati in questa biblioteca.</value>
</data>
<data name="Artists" xml:space="preserve">
<value>Artisti</value>
</data>
<data name="Albums" xml:space="preserve">
<value>Album</value>
</data>
<data name="Tracks" xml:space="preserve">
<value>Tracce</value>
</data>
<data name="Name" xml:space="preserve">
<value>Nome</value>
</data>
<data name="Artist" xml:space="preserve">
<value>Artista</value>
</data>
<data name="Album" xml:space="preserve">
<value>Album</value>
</data>
<data name="TrackTitle" xml:space="preserve">
<value>Titolo</value>
</data>
<data name="DeletedOn" xml:space="preserve">
<value>Eliminato il</value>
</data>
<data name="Restore" xml:space="preserve">
<value>Ripristina</value>
</data>
<data name="Restored" xml:space="preserve">
<value>L&apos;elemento è stato ripristinato.</value>
</data>
<data name="RestoreFailed" xml:space="preserve">
<value>Non è stato possibile ripristinare l&apos;elemento.</value>
</data>
</root>
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Title" xml:space="preserve">
<value>削除済みアイテム</value>
</data>
<data name="BackToLibrary" xml:space="preserve">
<value>ライブラリに戻る</value>
</data>
<data name="NoDeletedItems" xml:space="preserve">
<value>このライブラリに削除済みアイテムはありません。</value>
</data>
<data name="Artists" xml:space="preserve">
<value>アーティスト</value>
</data>
<data name="Albums" xml:space="preserve">
<value>アルバム</value>
</data>
<data name="Tracks" xml:space="preserve">
<value>トラック</value>
</data>
<data name="Name" xml:space="preserve">
<value>名前</value>
</data>
<data name="Artist" xml:space="preserve">
<value>アーティスト</value>
</data>
<data name="Album" xml:space="preserve">
<value>アルバム</value>
</data>
<data name="TrackTitle" xml:space="preserve">
<value>タイトル</value>
</data>
<data name="DeletedOn" xml:space="preserve">
<value>削除日</value>
</data>
<data name="Restore" xml:space="preserve">
<value>復元</value>
</data>
<data name="Restored" xml:space="preserve">
<value>項目を復元しました。</value>
</data>
<data name="RestoreFailed" xml:space="preserve">
<value>項目を復元できませんでした。</value>
</data>
</root>
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Title" xml:space="preserve">
<value>Deleted items</value>
</data>
<data name="BackToLibrary" xml:space="preserve">
<value>Back to library</value>
</data>
<data name="NoDeletedItems" xml:space="preserve">
<value>There are no deleted items in this library.</value>
</data>
<data name="Artists" xml:space="preserve">
<value>Artists</value>
</data>
<data name="Albums" xml:space="preserve">
<value>Albums</value>
</data>
<data name="Tracks" xml:space="preserve">
<value>Tracks</value>
</data>
<data name="Name" xml:space="preserve">
<value>Name</value>
</data>
<data name="Artist" xml:space="preserve">
<value>Artist</value>
</data>
<data name="Album" xml:space="preserve">
<value>Album</value>
</data>
<data name="TrackTitle" xml:space="preserve">
<value>Title</value>
</data>
<data name="DeletedOn" xml:space="preserve">
<value>Deleted on</value>
</data>
<data name="Restore" xml:space="preserve">
<value>Restore</value>
</data>
<data name="Restored" xml:space="preserve">
<value>The item was restored.</value>
</data>
<data name="RestoreFailed" xml:space="preserve">
<value>The item could not be restored.</value>
</data>
</root>
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Title" xml:space="preserve">
<value>Elemente șterse</value>
</data>
<data name="BackToLibrary" xml:space="preserve">
<value>Înapoi la bibliotecă</value>
</data>
<data name="NoDeletedItems" xml:space="preserve">
<value>Nu există elemente șterse în această bibliotecă.</value>
</data>
<data name="Artists" xml:space="preserve">
<value>Artiști</value>
</data>
<data name="Albums" xml:space="preserve">
<value>Albume</value>
</data>
<data name="Tracks" xml:space="preserve">
<value>Piese</value>
</data>
<data name="Name" xml:space="preserve">
<value>Nume</value>
</data>
<data name="Artist" xml:space="preserve">
<value>Artist</value>
</data>
<data name="Album" xml:space="preserve">
<value>Album</value>
</data>
<data name="TrackTitle" xml:space="preserve">
<value>Titlu</value>
</data>
<data name="DeletedOn" xml:space="preserve">
<value>Șters la</value>
</data>
<data name="Restore" xml:space="preserve">
<value>Restaurează</value>
</data>
<data name="Restored" xml:space="preserve">
<value>Elementul a fost restaurat.</value>
</data>
<data name="RestoreFailed" xml:space="preserve">
<value>Elementul nu a putut fi restaurat.</value>
</data>
</root>
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Title" xml:space="preserve">
<value>Видалені елементи</value>
</data>
<data name="BackToLibrary" xml:space="preserve">
<value>Повернутися до бібліотеки</value>
</data>
<data name="NoDeletedItems" xml:space="preserve">
<value>У цій бібліотеці немає видалених елементів.</value>
</data>
<data name="Artists" xml:space="preserve">
<value>Виконавці</value>
</data>
<data name="Albums" xml:space="preserve">
<value>Альбоми</value>
</data>
<data name="Tracks" xml:space="preserve">
<value>Треки</value>
</data>
<data name="Name" xml:space="preserve">
<value>Ім&apos;я</value>
</data>
<data name="Artist" xml:space="preserve">
<value>Виконавець</value>
</data>
<data name="Album" xml:space="preserve">
<value>Альбом</value>
</data>
<data name="TrackTitle" xml:space="preserve">
<value>Назва</value>
</data>
<data name="DeletedOn" xml:space="preserve">
<value>Видалено</value>
</data>
<data name="Restore" xml:space="preserve">
<value>Відновити</value>
</data>
<data name="Restored" xml:space="preserve">
<value>Елемент відновлено.</value>
</data>
<data name="RestoreFailed" xml:space="preserve">
<value>Не вдалося відновити елемент.</value>
</data>
</root>
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Title" xml:space="preserve">
<value>已删除项目</value>
</data>
<data name="BackToLibrary" xml:space="preserve">
<value>返回图书馆</value>
</data>
<data name="NoDeletedItems" xml:space="preserve">
<value>此库中没有已删除项目。</value>
</data>
<data name="Artists" xml:space="preserve">
<value>艺术家</value>
</data>
<data name="Albums" xml:space="preserve">
<value>专辑</value>
</data>
<data name="Tracks" xml:space="preserve">
<value>曲目</value>
</data>
<data name="Name" xml:space="preserve">
<value>名称</value>
</data>
<data name="Artist" xml:space="preserve">
<value>艺术家</value>
</data>
<data name="Album" xml:space="preserve">
<value>专辑</value>
</data>
<data name="TrackTitle" xml:space="preserve">
<value>标题</value>
</data>
<data name="DeletedOn" xml:space="preserve">
<value>删除时间</value>
</data>
<data name="Restore" xml:space="preserve">
<value>恢复</value>
</data>
<data name="Restored" xml:space="preserve">
<value>项目已恢复。</value>
</data>
<data name="RestoreFailed" xml:space="preserve">
<value>无法恢复项目。</value>
</data>
</root>
@@ -46,6 +46,8 @@
<button id="sort-toggle" type="button" class="confirm-button">@_localizer["SortAscending"]</button>
<!-- Item count. -->
<span id="count-label" class="text-light-two"></span>
<!-- Deleted items. -->
<button id="deleted-items-button" type="button" class="abort-button">@_localizer["DeletedItems"]</button>
</div>
<div style="display: flex; align-items: flex-start;">
<!-- Artists grid. -->
@@ -89,6 +91,8 @@
const prevPageButton = document.getElementById('prev-page');
const nextPageButton = document.getElementById('next-page');
const pageIndicator = document.getElementById('page-indicator');
const deletedItemsButton = document.getElementById('deleted-items-button');
const deletedItemsUrl = '@_urlService.GetAbsoluteUrl(WebRoutes.Music.DELETED_MUSIC_ITEMS)';
// The special alpha keys for numbers and symbols, followed by the letters.
const alphaKeys = ['#', '*', ...Array.from({ length: 26 }, (_, index) => String.fromCharCode(65 + index))];
@@ -492,6 +496,10 @@
loadItemsAsync();
}
async function handleDeletedItemsClick() {
await updateContentAsync(`${deletedItemsUrl}?libraryId=${encodeURIComponent(libraryId)}`, true);
}
async function loadSettingsAsync() {
const data = await callApiGetAsync('@_urlService.GetAbsoluteUrl(WebRoutes.Settings.GET_USER_SETTINGS)');
if (data) {
@@ -515,6 +523,7 @@
bindEventHandler(sortToggle, 'click', handleSortToggle);
bindEventHandler(prevPageButton, 'click', handlePrevPageClick);
bindEventHandler(nextPageButton, 'click', handleNextPageClick);
bindEventHandler(deletedItemsButton, 'click', handleDeletedItemsClick);
document.addEventListener('keydown', handleAlphaKeydown);
document.addEventListener('click', handleCardMenuDismiss);
document.addEventListener('keydown', handleCardMenuDismiss);
@@ -526,6 +535,7 @@
unbindEventHandler(sortToggle, 'click', handleSortToggle);
unbindEventHandler(prevPageButton, 'click', handlePrevPageClick);
unbindEventHandler(nextPageButton, 'click', handleNextPageClick);
unbindEventHandler(deletedItemsButton, 'click', handleDeletedItemsClick);
document.removeEventListener('keydown', handleAlphaKeydown);
document.removeEventListener('click', handleCardMenuDismiss);
document.removeEventListener('keydown', handleCardMenuDismiss);
@@ -0,0 +1,220 @@
@*
FALLBACK DELETED ITEMS VIEW - READ BEFORE EDITING
This view is the application fallback of the deleted items page of a music library, rendered only when the
active theme does not provide its own template for the page. It keeps the DOM contract and the client script
the theme template mirrors, so that restoring a deleted artist, album or track keeps working even without the theme.
/library/audio-library/music-library/deleted-items?libraryId=...
*@
@using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary
@using Lumina.Presentation.Web.Common.Services
@using Microsoft.AspNetCore.Mvc.Localization
@{
// Generate a unique id for the scripts section of this view, so it can be dynamically loaded/unloaded by the global AJAX navigator handler.
var scriptId = ScriptIdentifierHelper.GenerateScriptId();
var libraryId = Model.Library.Id?.ToString() ?? string.Empty;
}
@inject IViewLocalizer _localizer
@inject IUrlService _urlService
@model DeletedMusicItemsPageDto
@Html.AntiForgeryToken()
<div style="display: grid; grid-template-rows: auto 1fr;">
<div style="min-height: 1rem;"></div>
<div class="enlightenment-panel shadow-effect mx-auto panel w-60 mb-10 deleted-music-items-panel" style="min-width: 320px;">
<div class="shine-effect"></div>
<div class="form-row deleted-music-items-top-bar">
<button id="btn-back-to-library" type="button" class="abort-button">@_localizer["BackToLibrary"]</button>
</div>
<div class="form-row deleted-music-items-title-row">
<h1 class="text-light-two w-100 text-center pt-0 pb-0 engraved-title">@_localizer["Title"]</h1>
</div>
<p id="no-deleted-music-items" class="text-light-two text-center @(Model.DeletedArtists.Count == 0 && Model.DeletedAlbums.Count == 0 && Model.DeletedTracks.Count == 0 ? string.Empty : "hidden")">@_localizer["NoDeletedItems"]</p>
<section class="deleted-music-items-section @(Model.DeletedArtists.Count == 0 ? "hidden" : string.Empty)" data-section="artists">
<h2 class="text-light-two text-center">@_localizer["Artists"]</h2>
<table id="deleted-artists-table" class="w-100 form-table deleted-music-items-table">
<thead>
<tr>
<th>@_localizer["Name"]</th>
<th>@_localizer["DeletedOn"]</th>
<th class="w-100px"></th>
</tr>
</thead>
<tbody>
@foreach (DeletedMusicArtistDto artist in Model.DeletedArtists)
{
<tr class="deleted-music-item-row deleted-artist-row" data-row-type="artists" data-artist-id="@artist.Id">
<td>@artist.Name</td>
<td>@artist.DeletedOnUtc.ToString("g")</td>
<td>
<button type="button" class="confirm-button w-100px btn-restore-artist" data-artist-id="@artist.Id">@_localizer["Restore"]</button>
</td>
</tr>
}
</tbody>
</table>
</section>
<section class="deleted-music-items-section @(Model.DeletedAlbums.Count == 0 ? "hidden" : string.Empty)" data-section="albums">
<h2 class="text-light-two text-center">@_localizer["Albums"]</h2>
<table id="deleted-albums-table" class="w-100 form-table deleted-music-items-table">
<thead>
<tr>
<th>@_localizer["Artist"]</th>
<th>@_localizer["Album"]</th>
<th>@_localizer["DeletedOn"]</th>
<th class="w-100px"></th>
</tr>
</thead>
<tbody>
@foreach (DeletedMusicAlbumDto album in Model.DeletedAlbums)
{
<tr class="deleted-music-item-row deleted-album-row" data-row-type="albums" data-artist-id="@album.ArtistId" data-album-id="@album.Id">
<td>@album.ArtistName</td>
<td>@album.Title</td>
<td>@album.DeletedOnUtc.ToString("g")</td>
<td>
<button type="button" class="confirm-button w-100px btn-restore-album" data-artist-id="@album.ArtistId" data-album-id="@album.Id">@_localizer["Restore"]</button>
</td>
</tr>
}
</tbody>
</table>
</section>
<section class="deleted-music-items-section @(Model.DeletedTracks.Count == 0 ? "hidden" : string.Empty)" data-section="tracks">
<h2 class="text-light-two text-center">@_localizer["Tracks"]</h2>
<table id="deleted-tracks-table" class="w-100 form-table deleted-music-items-table">
<thead>
<tr>
<th>@_localizer["Artist"]</th>
<th>@_localizer["Album"]</th>
<th>@_localizer["TrackTitle"]</th>
<th>@_localizer["DeletedOn"]</th>
<th class="w-100px"></th>
</tr>
</thead>
<tbody>
@foreach (DeletedMusicTrackDto track in Model.DeletedTracks)
{
<tr class="deleted-music-item-row deleted-track-row" data-row-type="tracks" data-artist-id="@track.ArtistId" data-album-id="@track.AlbumId" data-track-id="@track.Id">
<td>@track.ArtistName</td>
<td>@track.AlbumTitle</td>
<td>@track.Title</td>
<td>@track.DeletedOnUtc.ToString("g")</td>
<td>
<button type="button" class="confirm-button w-100px btn-restore-track" data-artist-id="@track.ArtistId" data-album-id="@track.AlbumId" data-track-id="@track.Id">@_localizer["Restore"]</button>
</td>
</tr>
}
</tbody>
</table>
</section>
</div>
</div>
@section Scripts {
<!-- The "text/plain" type is a design choice, not a mistake: it keeps the browser from executing this view script during HTML parsing, before site.js defines the API helpers it calls. site.js (which loads deferred) executes these scripts once it is loaded, both on the initial page load and during AJAX navigation. -->
<script type="text/plain" data-form="@scriptId">
// Create cleanup registry for this view.
const cleanupFunctions = [];
let isInitialized = false;
const libraryId = '@libraryId';
const libraryIndexUrl = '@_urlService.GetAbsoluteUrl(WebRoutes.Music.ARTISTS_INDEX)';
const restoreArtistUrlTemplate = '@_urlService.GetAbsoluteUrl(WebRoutes.Music.RESTORE_ARTIST, new { artistId = default(Guid) })';
const restoreAlbumUrlTemplate = '@_urlService.GetAbsoluteUrl(WebRoutes.Music.RESTORE_ALBUM, new { artistId = default(Guid), albumId = default(Guid) })';
const restoreTrackUrlTemplate = '@_urlService.GetAbsoluteUrl(WebRoutes.Music.RESTORE_TRACK, new { artistId = default(Guid), albumId = default(Guid), trackId = default(Guid) })';
// The element references are captured once, so that the cleanup can unbind their listeners even after the AJAX navigator has swapped the content out of the document.
const btnBackToLibrary = document.getElementById('btn-back-to-library');
const noDeletedMusicItems = document.getElementById('no-deleted-music-items');
const jsLocalizedStrings = {
restored: @Json.Serialize(_localizer["Restored"].Value),
restoreFailed: @Json.Serialize(_localizer["RestoreFailed"].Value)
};
// Replaces the first default Guid segment of a restore URL with the provided value.
function applySegment(url, value) {
return url.replace('/@(default(Guid))', `/${value}`);
}
function buildRestoreUrl(row) {
if (row.dataset.rowType === 'artists')
return applySegment(restoreArtistUrlTemplate, row.dataset.artistId) + `?libraryId=${encodeURIComponent(libraryId)}`;
if (row.dataset.rowType === 'albums') {
const albumUrl = applySegment(applySegment(restoreAlbumUrlTemplate, row.dataset.artistId), row.dataset.albumId);
return albumUrl + `?libraryId=${encodeURIComponent(libraryId)}`;
}
const trackUrl = applySegment(applySegment(applySegment(restoreTrackUrlTemplate, row.dataset.artistId), row.dataset.albumId), row.dataset.trackId);
return trackUrl + `?libraryId=${encodeURIComponent(libraryId)}`;
}
// Restores the clicked deleted music item, then removes its row from the page.
async function handleRestoreAsync(event) {
const button = event.target.closest('.btn-restore-artist, .btn-restore-album, .btn-restore-track');
if (!button || button.disabled)
return;
const row = button.closest('.deleted-music-item-row');
if (!row)
return;
button.disabled = true;
try {
const result = await callApiPostAsync(buildRestoreUrl(row), {});
if (result?.isRestored !== true) {
notificationService.show(jsLocalizedStrings.restoreFailed, NotificationType.ERROR);
return;
}
notificationService.show(jsLocalizedStrings.restored, NotificationType.SUCCESS);
const section = row.closest('.deleted-music-items-section');
row.remove();
if (section && section.querySelectorAll('.deleted-music-item-row').length === 0)
section.classList.add('hidden');
if (document.querySelectorAll('.deleted-music-item-row').length === 0)
noDeletedMusicItems?.classList.remove('hidden');
} finally {
if (button.isConnected)
button.disabled = false;
}
}
// Navigates back to the library page of the deleted music items.
async function handleBackToLibraryAsync() {
await updateContentAsync(`${libraryIndexUrl}?libraryId=${encodeURIComponent(libraryId)}`, true);
}
// Add listeners.
btnBackToLibrary.addEventListener('click', handleBackToLibraryAsync);
document.addEventListener('click', handleRestoreAsync);
document.addEventListener('DOMContentLoaded', InitializeAsync);
// Register cleanup for these listeners.
cleanupFunctions.push(() => {
btnBackToLibrary.removeEventListener('click', handleBackToLibraryAsync);
document.removeEventListener('click', handleRestoreAsync);
document.removeEventListener('DOMContentLoaded', InitializeAsync);
});
function InitializeAsync() {
if (isInitialized)
return;
isInitialized = true;
}
// Store all cleanups for this view on window object using the scriptId.
window.viewCleanups = window.viewCleanups || {};
window.viewCleanups['@scriptId'] = () => {
cleanupFunctions.forEach(cleanup => cleanup());
console.log(`Unloaded @scriptId`);
};
console.log(`Loaded @scriptId`);
</script>
}