From 4926efbe8d9184a2a8834048be5fef7fc99ba44e Mon Sep 17 00:00:00 2001 From: Binary Alley Date: Wed, 12 Aug 2026 11:07:28 -0700 Subject: [PATCH] Adds the plugins and metadata provider management UI --- .../Common/Enums/Plugins/PluginLoadStatus.cs | 17 ++ .../Common/Enums/Plugins/PluginSettingType.cs | 27 +++ .../Plugins/LibraryMetadataProviderModel.cs | 33 +++ .../Common/Models/Plugins/PluginModel.cs | 55 +++++ .../Plugins/PluginSettingDescriptorModel.cs | 37 ++++ .../Models/Plugins/PluginSettingsModel.cs | 27 +++ .../ReorderLibraryMetadataProvidersModel.cs | 22 ++ .../SetLibraryMetadataProviderEnabledModel.cs | 27 +++ .../Plugins/UpdatePluginSettingsModel.cs | 22 ++ .../Management/LibraryManagementController.cs | 37 ++++ .../Controllers/Plugins/PluginsController.cs | 91 ++++++++ .../Lumina.Presentation.Web.csproj | 36 ++++ .../Views/Library/Management/Item.de-DE.resx | 23 +- .../Views/Library/Management/Item.en-US.resx | 23 +- .../Views/Library/Management/Item.es-ES.resx | 23 +- .../Views/Library/Management/Item.fr-FR.resx | 23 +- .../Views/Library/Management/Item.it-IT.resx | 23 +- .../Views/Library/Management/Item.ja-JP.resx | 23 +- .../Views/Library/Management/Item.resx | 23 +- .../Views/Library/Management/Item.ro-RO.resx | 23 +- .../Views/Library/Management/Item.ru-RU.resx | 23 +- .../Views/Library/Management/Item.zh-CN.resx | 23 +- .../Resources/Views/Plugins/Index.Designer.cs | 180 ++++++++++++++++ .../Resources/Views/Plugins/Index.de-DE.resx | 159 ++++++++++++++ .../Resources/Views/Plugins/Index.en-US.resx | 159 ++++++++++++++ .../Resources/Views/Plugins/Index.es-ES.resx | 159 ++++++++++++++ .../Resources/Views/Plugins/Index.fr-FR.resx | 159 ++++++++++++++ .../Resources/Views/Plugins/Index.it-IT.resx | 159 ++++++++++++++ .../Resources/Views/Plugins/Index.ja-JP.resx | 159 ++++++++++++++ .../Resources/Views/Plugins/Index.resx | 159 ++++++++++++++ .../Resources/Views/Plugins/Index.ro-RO.resx | 159 ++++++++++++++ .../Resources/Views/Plugins/Index.ru-RU.resx | 159 ++++++++++++++ .../Resources/Views/Plugins/Index.zh-CN.resx | 159 ++++++++++++++ .../Views/Shared/_NavMenu.de-DE.resx | 5 +- .../Views/Shared/_NavMenu.en-US.resx | 5 +- .../Views/Shared/_NavMenu.es-ES.resx | 5 +- .../Views/Shared/_NavMenu.fr-FR.resx | 5 +- .../Views/Shared/_NavMenu.it-IT.resx | 5 +- .../Views/Shared/_NavMenu.ja-JP.resx | 5 +- .../Resources/Views/Shared/_NavMenu.resx | 5 +- .../Views/Shared/_NavMenu.ro-RO.resx | 5 +- .../Views/Shared/_NavMenu.ru-RU.resx | 5 +- .../Views/Shared/_NavMenu.zh-CN.resx | 5 +- .../Views/Library/Management/Item.cshtml | 101 +++++++++ .../Views/Plugins/Index.cshtml | 200 ++++++++++++++++++ .../Views/Shared/_NavMenu.cshtml | 2 + 46 files changed, 2764 insertions(+), 20 deletions(-) create mode 100644 src/Lumina.Presentation.Web/Common/Enums/Plugins/PluginLoadStatus.cs create mode 100644 src/Lumina.Presentation.Web/Common/Enums/Plugins/PluginSettingType.cs create mode 100644 src/Lumina.Presentation.Web/Common/Models/Plugins/LibraryMetadataProviderModel.cs create mode 100644 src/Lumina.Presentation.Web/Common/Models/Plugins/PluginModel.cs create mode 100644 src/Lumina.Presentation.Web/Common/Models/Plugins/PluginSettingDescriptorModel.cs create mode 100644 src/Lumina.Presentation.Web/Common/Models/Plugins/PluginSettingsModel.cs create mode 100644 src/Lumina.Presentation.Web/Common/Models/Plugins/ReorderLibraryMetadataProvidersModel.cs create mode 100644 src/Lumina.Presentation.Web/Common/Models/Plugins/SetLibraryMetadataProviderEnabledModel.cs create mode 100644 src/Lumina.Presentation.Web/Common/Models/Plugins/UpdatePluginSettingsModel.cs create mode 100644 src/Lumina.Presentation.Web/Controllers/Plugins/PluginsController.cs create mode 100644 src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.Designer.cs create mode 100644 src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.de-DE.resx create mode 100644 src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.en-US.resx create mode 100644 src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.es-ES.resx create mode 100644 src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.fr-FR.resx create mode 100644 src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.it-IT.resx create mode 100644 src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.ja-JP.resx create mode 100644 src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.resx create mode 100644 src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.ro-RO.resx create mode 100644 src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.ru-RU.resx create mode 100644 src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.zh-CN.resx create mode 100644 src/Lumina.Presentation.Web/Views/Plugins/Index.cshtml diff --git a/src/Lumina.Presentation.Web/Common/Enums/Plugins/PluginLoadStatus.cs b/src/Lumina.Presentation.Web/Common/Enums/Plugins/PluginLoadStatus.cs new file mode 100644 index 00000000..99de4006 --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Enums/Plugins/PluginLoadStatus.cs @@ -0,0 +1,17 @@ +namespace Lumina.Presentation.Web.Common.Enums.Plugins; + +/// +/// Enumeration for the load status of a plugin. +/// +public enum PluginLoadStatus +{ + /// + /// The plugin was loaded successfully. + /// + Loaded, + + /// + /// The plugin failed to load. + /// + FailedToLoad +} diff --git a/src/Lumina.Presentation.Web/Common/Enums/Plugins/PluginSettingType.cs b/src/Lumina.Presentation.Web/Common/Enums/Plugins/PluginSettingType.cs new file mode 100644 index 00000000..1a317e1b --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Enums/Plugins/PluginSettingType.cs @@ -0,0 +1,27 @@ +namespace Lumina.Presentation.Web.Common.Enums.Plugins; + +/// +/// Enumeration for the types of a plugin setting. +/// +public enum PluginSettingType +{ + /// + /// A free-form single line text value. + /// + Text, + + /// + /// A numeric value. + /// + Number, + + /// + /// A boolean (true/false) value. + /// + Boolean, + + /// + /// A value selected from a list of allowed values. + /// + Select +} diff --git a/src/Lumina.Presentation.Web/Common/Models/Plugins/LibraryMetadataProviderModel.cs b/src/Lumina.Presentation.Web/Common/Models/Plugins/LibraryMetadataProviderModel.cs new file mode 100644 index 00000000..04f5e442 --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Models/Plugins/LibraryMetadataProviderModel.cs @@ -0,0 +1,33 @@ +#region ========================================================================= USING ===================================================================================== +using System; +using System.Diagnostics; +#endregion + +namespace Lumina.Presentation.Web.Common.Models.Plugins; + +/// +/// Represents a metadata provider configured for a media library. +/// +[DebuggerDisplay("Name: {Name}")] +public class LibraryMetadataProviderModel +{ + /// + /// Gets or sets the unique identifier of the plugin providing the metadata. + /// + public Guid PluginId { get; set; } + + /// + /// Gets or sets the display name of the metadata provider. + /// + public string Name { get; set; } = string.Empty; + + /// + /// Gets or sets whether the metadata provider is enabled for the media library. + /// + public bool IsEnabled { get; set; } + + /// + /// Gets or sets the rank of the metadata provider, determining the order in which providers are tried. + /// + public int Rank { get; set; } +} diff --git a/src/Lumina.Presentation.Web/Common/Models/Plugins/PluginModel.cs b/src/Lumina.Presentation.Web/Common/Models/Plugins/PluginModel.cs new file mode 100644 index 00000000..3b1bbbfa --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Models/Plugins/PluginModel.cs @@ -0,0 +1,55 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Presentation.Web.Common.Enums.Plugins; +using System; +using System.Collections.Generic; +using System.Diagnostics; +#endregion + +namespace Lumina.Presentation.Web.Common.Models.Plugins; + +/// +/// Represents a detected plugin. +/// +[DebuggerDisplay("Name: {Name}")] +public class PluginModel +{ + /// + /// Gets or sets the unique identifier of the plugin. + /// + public Guid Id { get; set; } + + /// + /// Gets or sets the display name of the plugin. + /// + public string Name { get; set; } = string.Empty; + + /// + /// Gets or sets the author of the plugin. + /// + public string Author { get; set; } = string.Empty; + + /// + /// Gets or sets the version of the plugin. + /// + public string Version { get; set; } = string.Empty; + + /// + /// Gets or sets the description of the plugin. + /// + public string Description { get; set; } = string.Empty; + + /// + /// Gets or sets the load status of the plugin. + /// + public PluginLoadStatus LoadStatus { get; set; } + + /// + /// Gets or sets the error message when the plugin failed to load. + /// + public string? LoadError { get; set; } + + /// + /// Gets or sets the settings of the plugin. + /// + public Dictionary? Settings { get; set; } +} diff --git a/src/Lumina.Presentation.Web/Common/Models/Plugins/PluginSettingDescriptorModel.cs b/src/Lumina.Presentation.Web/Common/Models/Plugins/PluginSettingDescriptorModel.cs new file mode 100644 index 00000000..3bc6a917 --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Models/Plugins/PluginSettingDescriptorModel.cs @@ -0,0 +1,37 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Presentation.Web.Common.Enums.Plugins; +using System.Collections.Generic; +#endregion + +namespace Lumina.Presentation.Web.Common.Models.Plugins; + +/// +/// Describes a single setting of a plugin. +/// +public class PluginSettingDescriptorModel +{ + /// + /// Gets or sets the unique key of the setting. + /// + public string Key { get; set; } = string.Empty; + + /// + /// Gets or sets the display label of the setting. + /// + public string Label { get; set; } = string.Empty; + + /// + /// Gets or sets the type of the setting. + /// + public PluginSettingType Type { get; set; } + + /// + /// Gets or sets the default value of the setting. + /// + public string? DefaultValue { get; set; } + + /// + /// Gets or sets the list of allowed values, when the setting is a selection. + /// + public IReadOnlyList? AllowedValues { get; set; } +} diff --git a/src/Lumina.Presentation.Web/Common/Models/Plugins/PluginSettingsModel.cs b/src/Lumina.Presentation.Web/Common/Models/Plugins/PluginSettingsModel.cs new file mode 100644 index 00000000..ac6ea9ad --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Models/Plugins/PluginSettingsModel.cs @@ -0,0 +1,27 @@ +#region ========================================================================= USING ===================================================================================== +using System; +using System.Collections.Generic; +#endregion + +namespace Lumina.Presentation.Web.Common.Models.Plugins; + +/// +/// Represents the settings of a plugin and their schema. +/// +public class PluginSettingsModel +{ + /// + /// Gets or sets the unique identifier of the plugin. + /// + public Guid PluginId { get; set; } + + /// + /// Gets or sets the schema of the plugin settings. + /// + public List Schema { get; set; } = []; + + /// + /// Gets or sets the current values of the plugin settings. + /// + public Dictionary? Settings { get; set; } +} diff --git a/src/Lumina.Presentation.Web/Common/Models/Plugins/ReorderLibraryMetadataProvidersModel.cs b/src/Lumina.Presentation.Web/Common/Models/Plugins/ReorderLibraryMetadataProvidersModel.cs new file mode 100644 index 00000000..f4331250 --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Models/Plugins/ReorderLibraryMetadataProvidersModel.cs @@ -0,0 +1,22 @@ +#region ========================================================================= USING ===================================================================================== +using System; +using System.Collections.Generic; +#endregion + +namespace Lumina.Presentation.Web.Common.Models.Plugins; + +/// +/// Represents a request to reorder the metadata providers of a media library. +/// +public class ReorderLibraryMetadataProvidersModel +{ + /// + /// Gets or sets the Id of the media library whose metadata providers are reordered. + /// + public Guid LibraryId { get; set; } + + /// + /// Gets or sets the plugin Ids in the new order, from highest to lowest rank. + /// + public List PluginIds { get; set; } = []; +} diff --git a/src/Lumina.Presentation.Web/Common/Models/Plugins/SetLibraryMetadataProviderEnabledModel.cs b/src/Lumina.Presentation.Web/Common/Models/Plugins/SetLibraryMetadataProviderEnabledModel.cs new file mode 100644 index 00000000..7d7a4eae --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Models/Plugins/SetLibraryMetadataProviderEnabledModel.cs @@ -0,0 +1,27 @@ +#region ========================================================================= USING ===================================================================================== +using System; +using System.Collections.Generic; +#endregion + +namespace Lumina.Presentation.Web.Common.Models.Plugins; + +/// +/// Represents a request to enable or disable a metadata provider for a media library. +/// +public class SetLibraryMetadataProviderEnabledModel +{ + /// + /// Gets or sets the Id of the media library whose metadata provider is enabled or disabled. + /// + public Guid LibraryId { get; set; } + + /// + /// Gets or sets the unique identifier of the plugin providing the metadata. + /// + public Guid PluginId { get; set; } + + /// + /// Gets or sets whether the metadata provider should be enabled for the media library. + /// + public bool IsEnabled { get; set; } +} diff --git a/src/Lumina.Presentation.Web/Common/Models/Plugins/UpdatePluginSettingsModel.cs b/src/Lumina.Presentation.Web/Common/Models/Plugins/UpdatePluginSettingsModel.cs new file mode 100644 index 00000000..246211a4 --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Models/Plugins/UpdatePluginSettingsModel.cs @@ -0,0 +1,22 @@ +#region ========================================================================= USING ===================================================================================== +using System; +using System.Collections.Generic; +#endregion + +namespace Lumina.Presentation.Web.Common.Models.Plugins; + +/// +/// Represents a request to update the settings of a plugin. +/// +public class UpdatePluginSettingsModel +{ + /// + /// Gets or sets the unique identifier of the plugin. + /// + public Guid PluginId { get; set; } + + /// + /// Gets or sets the settings of the plugin. + /// + public Dictionary? Settings { get; set; } +} diff --git a/src/Lumina.Presentation.Web/Controllers/Library/Management/LibraryManagementController.cs b/src/Lumina.Presentation.Web/Controllers/Library/Management/LibraryManagementController.cs index e884d370..57d511b9 100644 --- a/src/Lumina.Presentation.Web/Controllers/Library/Management/LibraryManagementController.cs +++ b/src/Lumina.Presentation.Web/Controllers/Library/Management/LibraryManagementController.cs @@ -4,6 +4,7 @@ using Lumina.Presentation.Web.Common.Attributes; using Lumina.Presentation.Web.Common.Enums.Authorization; using Lumina.Presentation.Web.Common.Models.Common; using Lumina.Presentation.Web.Common.Models.Libraries; +using Lumina.Presentation.Web.Common.Models.Plugins; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System; @@ -172,4 +173,40 @@ public class LibraryManagementController : Controller await _apiHttpClient.PostAsync($"libraries/{libraryId}/scans/{scanId}/cancel", new EmptyModel(), cancellationToken).ConfigureAwait(false); return Json(new { success = true }); } + + /// + /// Gets the metadata providers configured for the media library identified by . + /// + /// The id of the media library whose metadata providers are retrieved. + /// Cancellation token that can be used to stop the execution. + [HttpGet("api-get-metadata-providers/{libraryId}")] + public async Task GetMetadataProviders(Guid libraryId, CancellationToken cancellationToken = default) + { + LibraryMetadataProviderModel[] response = await _apiHttpClient.GetAsync($"libraries/{libraryId}/metadata-providers", cancellationToken).ConfigureAwait(false); + return Json(new { success = true, data = response }); + } + + /// + /// Enables or disables the metadata provider for the media library described by . + /// + /// The model containing the Ids of the media library and of the metadata provider. + /// Cancellation token that can be used to stop the execution. + [HttpPut("api-set-metadata-provider-enabled")] + public async Task SetMetadataProviderEnabled([FromBody] SetLibraryMetadataProviderEnabledModel model, CancellationToken cancellationToken = default) + { + await _apiHttpClient.PutAsync($"libraries/{model.LibraryId}/metadata-providers/{model.PluginId}/enabled", model, cancellationToken).ConfigureAwait(false); + return Json(new { success = true }); + } + + /// + /// Reorders the metadata providers of the media library described by . + /// + /// The model containing the Id of the media library and the plugin Ids in the new order. + /// Cancellation token that can be used to stop the execution. + [HttpPut("api-reorder-metadata-providers")] + public async Task ReorderMetadataProviders([FromBody] ReorderLibraryMetadataProvidersModel model, CancellationToken cancellationToken = default) + { + await _apiHttpClient.PutAsync($"libraries/{model.LibraryId}/metadata-providers/reorder", model, cancellationToken).ConfigureAwait(false); + return Json(new { success = true }); + } } diff --git a/src/Lumina.Presentation.Web/Controllers/Plugins/PluginsController.cs b/src/Lumina.Presentation.Web/Controllers/Plugins/PluginsController.cs new file mode 100644 index 00000000..6c103c82 --- /dev/null +++ b/src/Lumina.Presentation.Web/Controllers/Plugins/PluginsController.cs @@ -0,0 +1,91 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Presentation.Web.Common.Api; +using Lumina.Presentation.Web.Common.Attributes; +using Lumina.Presentation.Web.Common.Enums.Plugins; +using Lumina.Presentation.Web.Common.Models.Common; +using Lumina.Presentation.Web.Common.Models.Plugins; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +#endregion + +namespace Lumina.Presentation.Web.Controllers.Plugins; + +/// +/// Controller for the plugin management related operations. +/// +[Authorize] +[RequireRole("Admin")] +[Route("{culture}/plugins")] +public class PluginsController : Controller +{ + private readonly IApiHttpClient _apiHttpClient; + + /// + /// Initializes a new instance of the class. + /// + /// Injected service for interactions with the API. + public PluginsController(IApiHttpClient apiHttpClient) + { + _apiHttpClient = apiHttpClient; + } + + /// + /// Displays the view for managing the plugins and their settings. + /// + /// Cancellation token that can be used to stop the execution. + [HttpGet("")] + public async Task Index(CancellationToken cancellationToken) + { + PluginModel[] plugins = await _apiHttpClient.GetAsync("plugins", cancellationToken).ConfigureAwait(false); + + // load the settings of the loaded plugins, so that the settings forms can be rendered on the server + Dictionary settingsByPluginId = []; + foreach (PluginModel plugin in plugins) + { + if (plugin.LoadStatus == PluginLoadStatus.Loaded) + settingsByPluginId[plugin.Id] = await _apiHttpClient.GetAsync($"plugins/{plugin.Id}/settings", cancellationToken).ConfigureAwait(false); + } + + ViewData["pluginSettings"] = settingsByPluginId; + return View(plugins); + } + + /// + /// Gets the list of the detected plugins. + /// + /// Cancellation token that can be used to stop the execution. + [HttpGet("api-get-plugins")] + public async Task GetPlugins(CancellationToken cancellationToken = default) + { + PluginModel[] response = await _apiHttpClient.GetAsync("plugins/", cancellationToken).ConfigureAwait(false); + return Json(new { success = true, data = response }); + } + + /// + /// Gets the settings and their schema of the plugin identified by . + /// + /// The unique identifier of the plugin. + /// Cancellation token that can be used to stop the execution. + [HttpGet("api-get-plugin-settings/{pluginId}")] + public async Task GetPluginSettings(Guid pluginId, CancellationToken cancellationToken = default) + { + PluginSettingsModel response = await _apiHttpClient.GetAsync($"plugins/{pluginId}/settings", cancellationToken).ConfigureAwait(false); + return Json(new { success = true, data = response }); + } + + /// + /// Updates the settings of the plugin identified by . + /// + /// The model containing the Id of the plugin and its settings. + /// Cancellation token that can be used to stop the execution. + [HttpPut("api-update-plugin-settings")] + public async Task UpdatePluginSettings([FromBody] UpdatePluginSettingsModel model, CancellationToken cancellationToken) + { + await _apiHttpClient.PutAsync($"plugins/{model.PluginId}/settings", model, cancellationToken).ConfigureAwait(false); + return Json(new { success = true }); + } +} diff --git a/src/Lumina.Presentation.Web/Lumina.Presentation.Web.csproj b/src/Lumina.Presentation.Web/Lumina.Presentation.Web.csproj index a30266d0..de287112 100644 --- a/src/Lumina.Presentation.Web/Lumina.Presentation.Web.csproj +++ b/src/Lumina.Presentation.Web/Lumina.Presentation.Web.csproj @@ -58,6 +58,11 @@ True Item.resx + + True + True + Index.resx + @@ -324,6 +329,37 @@ PublicResXFileCodeGenerator + + PublicResXFileCodeGenerator + + + PublicResXFileCodeGenerator + + + PublicResXFileCodeGenerator + + + PublicResXFileCodeGenerator + + + PublicResXFileCodeGenerator + + + PublicResXFileCodeGenerator + + + PublicResXFileCodeGenerator + Index.Designer.cs + + + PublicResXFileCodeGenerator + + + PublicResXFileCodeGenerator + + + PublicResXFileCodeGenerator + 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 37fe1da0..78b24eb2 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 @@ -1,4 +1,4 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Plugins + + + Name + + + Autor + + + Version + + + Beschreibung + + + Ladestatus + + + Geladen + + + Fehler beim Laden + + + Ladefehler + + + Einstellungen + + + Es wurden keine Plugins erkannt. + + + Speichern + + + Einstellungen gespeichert + + diff --git a/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.en-US.resx b/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.en-US.resx new file mode 100644 index 00000000..6971d3db --- /dev/null +++ b/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.en-US.resx @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Plugins + + + Name + + + Author + + + Version + + + Description + + + Load status + + + Loaded + + + Failed to load + + + Load error + + + Settings + + + No plugins have been detected. + + + Save + + + Settings saved + + diff --git a/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.es-ES.resx b/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.es-ES.resx new file mode 100644 index 00000000..f093ae69 --- /dev/null +++ b/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.es-ES.resx @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Plugins + + + Nombre + + + Autor + + + Versión + + + Descripción + + + Estado de carga + + + Cargado + + + Error al cargar + + + Error de carga + + + Configuración + + + No se han detectado plugins. + + + Guardar + + + Configuración guardada + + diff --git a/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.fr-FR.resx b/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.fr-FR.resx new file mode 100644 index 00000000..8eca2513 --- /dev/null +++ b/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.fr-FR.resx @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Plugins + + + Nom + + + Auteur + + + Version + + + Description + + + État de chargement + + + Chargé + + + Échec du chargement + + + Erreur de chargement + + + Paramètres + + + Aucun plugin n'a été détecté. + + + Enregistrer + + + Paramètres enregistrés + + diff --git a/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.it-IT.resx b/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.it-IT.resx new file mode 100644 index 00000000..47b7de18 --- /dev/null +++ b/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.it-IT.resx @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Plugin + + + Nome + + + Autore + + + Versione + + + Descrizione + + + Stato di caricamento + + + Caricato + + + Errore di caricamento + + + Errore di caricamento + + + Impostazioni + + + Nessun plugin rilevato. + + + Salva + + + Impostazioni salvate + + diff --git a/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.ja-JP.resx b/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.ja-JP.resx new file mode 100644 index 00000000..768a0b13 --- /dev/null +++ b/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.ja-JP.resx @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + プラグイン + + + 名前 + + + 作者 + + + バージョン + + + 説明 + + + 読み込み状態 + + + 読み込み済み + + + 読み込みに失敗 + + + 読み込みエラー + + + 設定 + + + プラグインが検出されませんでした。 + + + 保存 + + + 設定を保存しました + + diff --git a/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.resx b/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.resx new file mode 100644 index 00000000..6971d3db --- /dev/null +++ b/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.resx @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Plugins + + + Name + + + Author + + + Version + + + Description + + + Load status + + + Loaded + + + Failed to load + + + Load error + + + Settings + + + No plugins have been detected. + + + Save + + + Settings saved + + diff --git a/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.ro-RO.resx b/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.ro-RO.resx new file mode 100644 index 00000000..5e9b67a1 --- /dev/null +++ b/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.ro-RO.resx @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Pluginuri + + + Nume + + + Autor + + + Versiune + + + Descriere + + + Stare de încărcare + + + Încărcat + + + Încărcare eșuată + + + Eroare de încărcare + + + Setări + + + Nu au fost detectate pluginuri. + + + Salvare + + + Setări salvate + + diff --git a/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.ru-RU.resx b/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.ru-RU.resx new file mode 100644 index 00000000..4dee8ba8 --- /dev/null +++ b/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.ru-RU.resx @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Плагины + + + Имя + + + Автор + + + Версия + + + Описание + + + Статус загрузки + + + Загружен + + + Не удалось загрузить + + + Ошибка загрузки + + + Настройки + + + Плагины не обнаружены. + + + Сохранить + + + Настройки сохранены + + diff --git a/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.zh-CN.resx b/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.zh-CN.resx new file mode 100644 index 00000000..38f058f0 --- /dev/null +++ b/src/Lumina.Presentation.Web/Resources/Views/Plugins/Index.zh-CN.resx @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 插件 + + + 名称 + + + 作者 + + + 版本 + + + 说明 + + + 加载状态 + + + 已加载 + + + 加载失败 + + + 加载错误 + + + 设置 + + + 未检测到插件。 + + + 保存 + + + 设置已保存 + + diff --git a/src/Lumina.Presentation.Web/Resources/Views/Shared/_NavMenu.de-DE.resx b/src/Lumina.Presentation.Web/Resources/Views/Shared/_NavMenu.de-DE.resx index e48e3fe3..2ec1dc87 100644 --- a/src/Lumina.Presentation.Web/Resources/Views/Shared/_NavMenu.de-DE.resx +++ b/src/Lumina.Presentation.Web/Resources/Views/Shared/_NavMenu.de-DE.resx @@ -1,4 +1,4 @@ - + + + + @_localizer["DescriptionMetadataProviders"] + + }
@@ -343,6 +362,75 @@ e.target.parentElement.remove(); }; + const id = '@id'; + const metadataProvidersTable = document.getElementById('metadata-providers-table'); + const metadataProvidersTbody = metadataProvidersTable ? metadataProvidersTable.querySelector('tbody') : null; + + // loads the metadata providers configured for the library, when editing an existing library + async function loadMetadataProvidersAsync() { + if (!id || !metadataProvidersTbody) return; + const url = '@_urlService.GetAbsoluteUrl("GetMetadataProviders", "LibraryManagement", new { libraryId = default(Guid) })' + .replace('/@(default(Guid))', `/${id}`); // libraryId needs to be replaced here, because GetAbsoluteUrl is server side, libraryId is client side + const response = await callApiGetAsync(url); + if (response && response.length > 0) { + metadataProvidersTbody.innerHTML = response.map((provider, index) => renderMetadataProviderRow(provider, index, response.length)).join(''); + } + } + + // renders a metadata provider row of the library + function renderMetadataProviderRow(provider, index, count) { + return ` + + ${provider.name} + + + + + + + + `; + } + + // on metadata provider move button click, reorders the providers and persists the new order + async function handleMetadataProviderReorderAsync(e) { + const button = e.target.closest('.metadata-provider-move-up, .metadata-provider-move-down'); + if (!button || !metadataProvidersTbody) return; + const row = button.closest('tr'); + if (button.classList.contains('metadata-provider-move-up')) { + const previousRow = row.previousElementSibling; + if (previousRow) metadataProvidersTbody.insertBefore(row, previousRow); + } else { + const nextRow = row.nextElementSibling; + if (nextRow) metadataProvidersTbody.insertBefore(nextRow, row); + } + await saveMetadataProviderOrderAsync(); + } + + // persists the current order of the metadata providers of the library + async function saveMetadataProviderOrderAsync() { + if (!id || !metadataProvidersTbody) return; + const pluginIds = Array.from(metadataProvidersTbody.querySelectorAll('tr[data-provider-plugin-id]')) + .map(row => row.getAttribute('data-provider-plugin-id')); + const result = await callApiPutAsync('@_urlService.GetAbsoluteUrl("ReorderMetadataProviders", "LibraryManagement")', { libraryId: id, pluginIds: pluginIds }); + if (result.success) { + notificationService.show('@_localizer["OrderSaved"]', NotificationType.SUCCESS); + } + } + + // on metadata provider enabled checkbox change, persists the new state + async function handleMetadataProviderEnabledChangeAsync(e) { + if (e.target.matches('.metadata-provider-enabled')) { + const row = e.target.closest('tr'); + const pluginId = row.getAttribute('data-provider-plugin-id'); + const isEnabled = e.target.checked; + const result = await callApiPutAsync('@_urlService.GetAbsoluteUrl("SetMetadataProviderEnabled", "LibraryManagement")', { libraryId: id, pluginId: pluginId, isEnabled: isEnabled }); + if (!result.success) { + e.target.checked = !isEnabled; + } + } + }; + // add listeners form.addEventListener('keypress', handleEnterKey); form.addEventListener('submit', handleSubmit); @@ -352,6 +440,10 @@ imgAddCover.addEventListener('click', handleImgAddCoverClick); mediaCoverFormTable.addEventListener('click', handleRowRemoval); mediaDirectoriesFormTable.addEventListener('click', handleRowRemoval); + if (metadataProvidersTbody) { + metadataProvidersTbody.addEventListener('click', handleMetadataProviderReorderAsync); + metadataProvidersTbody.addEventListener('change', handleMetadataProviderEnabledChangeAsync); + } // register cleanup for these listeners cleanupFunctions.push(() => { @@ -363,8 +455,17 @@ imgAddCover.removeEventListener('click', handleImgAddCoverClick); mediaCoverFormTable.removeEventListener('click', handleRowRemoval); mediaDirectoriesFormTable.removeEventListener('click', handleRowRemoval); + if (metadataProvidersTbody) { + metadataProvidersTbody.removeEventListener('click', handleMetadataProviderReorderAsync); + metadataProvidersTbody.removeEventListener('change', handleMetadataProviderEnabledChangeAsync); + } }); + // load the metadata providers when editing an existing library + if (id) { + loadMetadataProvidersAsync(); + } + // store all cleanups for this view on window object using the scriptId window.viewCleanups = window.viewCleanups || {}; window.viewCleanups['@scriptId'] = () => { diff --git a/src/Lumina.Presentation.Web/Views/Plugins/Index.cshtml b/src/Lumina.Presentation.Web/Views/Plugins/Index.cshtml new file mode 100644 index 00000000..cf0140c2 --- /dev/null +++ b/src/Lumina.Presentation.Web/Views/Plugins/Index.cshtml @@ -0,0 +1,200 @@ +@* +/plugins +*@ + +@using Lumina.Presentation.Web.Common.Enums.Plugins +@using Lumina.Presentation.Web.Common.Models.Plugins +@using Lumina.Presentation.Web.Common.Services +@using Microsoft.AspNetCore.Mvc.Localization + +@model PluginModel[] + +@{ + var settingsByPluginId = ViewData["pluginSettings"] as Dictionary ?? new Dictionary(); + // 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(); +} + +@inject IUrlService _urlService +@inject IViewLocalizer _localizer + +
+
+
+
+
+

+ @_localizer["Plugins"] +

+
+ @if (Model.Length > 0) + { + + + + + + + + + + + + + @foreach (PluginModel plugin in Model) + { + + + + + + + + + @if (plugin.LoadStatus == PluginLoadStatus.FailedToLoad && !string.IsNullOrWhiteSpace(plugin.LoadError)) + { + + + + } + @if (plugin.LoadStatus == PluginLoadStatus.Loaded && settingsByPluginId.ContainsKey(plugin.Id)) + { + PluginSettingsModel pluginSettings = settingsByPluginId[plugin.Id]; + + + + } + } + +
@_localizer["Name"]@_localizer["Author"]@_localizer["Version"]@_localizer["Description"]@_localizer["LoadStatus"]@_localizer["Settings"]
@plugin.Name@plugin.Author@plugin.Version@plugin.Description + @if (plugin.LoadStatus == PluginLoadStatus.Loaded) + { + @_localizer["Loaded"] + } + else + { + @_localizer["FailedToLoad"] + } + + @if (plugin.LoadStatus == PluginLoadStatus.Loaded && settingsByPluginId.ContainsKey(plugin.Id)) + { + + } +
+ @_localizer["LoadError"]: @plugin.LoadError +
+ } + else + { +

@_localizer["NoPlugins"]

+ } +
+
+@section Scripts { + +} diff --git a/src/Lumina.Presentation.Web/Views/Shared/_NavMenu.cshtml b/src/Lumina.Presentation.Web/Views/Shared/_NavMenu.cshtml index 6a781b6d..c03f5074 100644 --- a/src/Lumina.Presentation.Web/Views/Shared/_NavMenu.cshtml +++ b/src/Lumina.Presentation.Web/Views/Shared/_NavMenu.cshtml @@ -51,6 +51,7 @@ }