diff --git a/Lantean.QBTMud.Test/Lantean.QBTMud.Test.csproj b/Lantean.QBTMud.Test/Lantean.QBTMud.Test.csproj index b21e876..d3e95c3 100644 --- a/Lantean.QBTMud.Test/Lantean.QBTMud.Test.csproj +++ b/Lantean.QBTMud.Test/Lantean.QBTMud.Test.csproj @@ -10,11 +10,11 @@ - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Lantean.QBTMud/Components/Dialogs/SearchPluginsDialog.razor b/Lantean.QBTMud/Components/Dialogs/SearchPluginsDialog.razor new file mode 100644 index 0000000..4f734cb --- /dev/null +++ b/Lantean.QBTMud/Components/Dialogs/SearchPluginsDialog.razor @@ -0,0 +1,20 @@ + + + + + + Add + Remove + + @foreach (var plugin in Plugins) + { + var pluginRef = plugin; + @pluginRef.Name + } + + + + + + + \ No newline at end of file diff --git a/Lantean.QBTMud/Components/Dialogs/SearchPluginsDialog.razor.cs b/Lantean.QBTMud/Components/Dialogs/SearchPluginsDialog.razor.cs new file mode 100644 index 0000000..551ffc3 --- /dev/null +++ b/Lantean.QBTMud/Components/Dialogs/SearchPluginsDialog.razor.cs @@ -0,0 +1,72 @@ +using Lantean.QBitTorrentClient; +using Lantean.QBitTorrentClient.Models; +using Lantean.QBTMud.Helpers; +using Microsoft.AspNetCore.Components; +using MudBlazor; + +namespace Lantean.QBTMud.Components.Dialogs +{ + public partial class SearchPluginsDialog + { + [Inject] + protected IApiClient ApiClient { get; set; } = default!; + + [Inject] + protected IDialogService DialogService { get; set; } = default!; + + [CascadingParameter] + IMudDialogInstance MudDialog { get; set; } = default!; + + protected HashSet Plugins { get; set; } = []; + + protected IList TorrentCategories { get; private set; } = []; + + protected override async Task OnInitializedAsync() + { + Plugins = [.. (await ApiClient.GetSearchPlugins())]; + } + + protected string GetIcon(string tag) + { + return Icons.Material.Filled.PlusOne; + } + + protected async Task SetPlugin(QBitTorrentClient.Models.SearchPlugin plugin) + { + + + await InvokeAsync(StateHasChanged); + } + + protected async Task AddCategory() + { + var addedCategoy = await DialogService.InvokeAddCategoryDialog(ApiClient); + if (addedCategoy is null) + { + return; + } + + await ApiClient.SetTorrentCategory(addedCategoy, Hashes); + Plugins.Add(addedCategoy); + await GetTorrentCategories(); + } + + protected async Task RemoveCategory() + { + await ApiClient.RemoveTorrentCategory(Hashes); + await GetTorrentCategories(); + } + + protected Task CloseDialog() + { + MudDialog.Close(); + + return Task.CompletedTask; + } + + protected void Cancel() + { + MudDialog.Cancel(); + } + } +} \ No newline at end of file diff --git a/Lantean.QBTMud/Helpers/DialogHelper.cs b/Lantean.QBTMud/Helpers/DialogHelper.cs index 50f843e..14cbe39 100644 --- a/Lantean.QBTMud/Helpers/DialogHelper.cs +++ b/Lantean.QBTMud/Helpers/DialogHelper.cs @@ -435,5 +435,22 @@ namespace Lantean.QBTMud.Helpers await dialogService.ShowAsync(parent.Text, parameters, FormDialogOptions); } + + public static async Task ShowSearchPluginsDialog(this IDialogService dialogService) + { + var parameters = new DialogParameters + { + { nameof(SearchPluginsDialog.Hashes), "" }, + }; + + var result = await dialogService.ShowAsync("Search Plugins", parameters, FormDialogOptions); + var dialogResult = await result.Result; + if (dialogResult is null || dialogResult.Canceled || dialogResult.Data is null) + { + return null; + } + + return (QBitTorrentClient.Models.SearchPlugin)dialogResult.Data; + } } } \ No newline at end of file diff --git a/Lantean.QBTMud/Lantean.QBTMud.csproj b/Lantean.QBTMud/Lantean.QBTMud.csproj index 4ea246c..070108c 100644 --- a/Lantean.QBTMud/Lantean.QBTMud.csproj +++ b/Lantean.QBTMud/Lantean.QBTMud.csproj @@ -12,10 +12,10 @@ - - - - + + + + diff --git a/Lantean.QBTMud/Pages/Search.razor b/Lantean.QBTMud/Pages/Search.razor index 321c4f2..f371379 100644 --- a/Lantean.QBTMud/Pages/Search.razor +++ b/Lantean.QBTMud/Pages/Search.razor @@ -9,6 +9,8 @@ } Search + + diff --git a/Lantean.QBTMud/Pages/Search.razor.cs b/Lantean.QBTMud/Pages/Search.razor.cs index bdba7f6..d35729b 100644 --- a/Lantean.QBTMud/Pages/Search.razor.cs +++ b/Lantean.QBTMud/Pages/Search.razor.cs @@ -150,6 +150,11 @@ namespace Lantean.QBTMud.Pages } } + protected async Task ShowSearchPlugins() + { + await DialogService.ShowSearchPluginsDialog(); + } + protected IEnumerable> Columns => ColumnsDefinitions; public static List> ColumnsDefinitions { get; } =