mirror of
https://github.com/lantean-code/qbtmud.git
synced 2025-10-23 04:52:22 +00:00
Start plugin fix
This commit is contained in:
@@ -10,11 +10,11 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AwesomeAssertions" Version="9.0.0" />
|
<PackageReference Include="AwesomeAssertions" Version="9.2.1" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
|
||||||
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
|
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
|
||||||
<PackageReference Include="xunit" Version="2.9.3" />
|
<PackageReference Include="xunit" Version="2.9.3" />
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.0">
|
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
20
Lantean.QBTMud/Components/Dialogs/SearchPluginsDialog.razor
Normal file
20
Lantean.QBTMud/Components/Dialogs/SearchPluginsDialog.razor
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<MudDialog>
|
||||||
|
<DialogContent>
|
||||||
|
<MudGrid>
|
||||||
|
<MudItem xs="12">
|
||||||
|
<MudList T="string">
|
||||||
|
<MudListItem Icon="@Icons.Material.Filled.Add" IconColor="Color.Info" OnClick="AddCategory">Add</MudListItem>
|
||||||
|
<MudListItem Icon="@Icons.Material.Filled.Remove" IconColor="Color.Error" OnClick="RemoveCategory">Remove</MudListItem>
|
||||||
|
<MudDivider />
|
||||||
|
@foreach (var plugin in Plugins)
|
||||||
|
{
|
||||||
|
var pluginRef = plugin;
|
||||||
|
<MudListItem Icon="@GetIcon(pluginRef.FullName)" IconColor="Color.Default" OnClick="@(e => SetPlugin(pluginRef))">@pluginRef.Name</MudListItem>
|
||||||
|
}
|
||||||
|
</MudList>
|
||||||
|
</MudItem>
|
||||||
|
</MudGrid>
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions>
|
||||||
|
</DialogActions>
|
||||||
|
</MudDialog>
|
@@ -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<SearchPlugin> Plugins { get; set; } = [];
|
||||||
|
|
||||||
|
protected IList<string> 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -435,5 +435,22 @@ namespace Lantean.QBTMud.Helpers
|
|||||||
|
|
||||||
await dialogService.ShowAsync<SubMenuDialog>(parent.Text, parameters, FormDialogOptions);
|
await dialogService.ShowAsync<SubMenuDialog>(parent.Text, parameters, FormDialogOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async Task<QBitTorrentClient.Models.SearchPlugin?> ShowSearchPluginsDialog(this IDialogService dialogService)
|
||||||
|
{
|
||||||
|
var parameters = new DialogParameters
|
||||||
|
{
|
||||||
|
{ nameof(SearchPluginsDialog.Hashes), "" },
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = await dialogService.ShowAsync<SearchPluginsDialog>("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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -12,10 +12,10 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
|
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
|
||||||
<PackageReference Include="ByteSize" Version="2.1.2" />
|
<PackageReference Include="ByteSize" Version="2.1.2" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.5" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.10" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.5" PrivateAssets="all" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.10" PrivateAssets="all" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.5" />
|
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.10" />
|
||||||
<PackageReference Include="MudBlazor" Version="8.7.0" />
|
<PackageReference Include="MudBlazor" Version="8.13.0" />
|
||||||
<PackageReference Include="MudBlazor.ThemeManager" Version="3.0.0" />
|
<PackageReference Include="MudBlazor.ThemeManager" Version="3.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@@ -9,6 +9,8 @@
|
|||||||
}
|
}
|
||||||
<MudDivider Vertical="true" />
|
<MudDivider Vertical="true" />
|
||||||
<MudText Class="pl-5 no-wrap">Search</MudText>
|
<MudText Class="pl-5 no-wrap">Search</MudText>
|
||||||
|
<MudDivider Vertical="true" />
|
||||||
|
<MudIconButton Icon="@Icons.Material.Outlined.Settings" OnClick="ShowSearchPlugins" title="Search plugins" />
|
||||||
</MudToolBar>
|
</MudToolBar>
|
||||||
|
|
||||||
<MudCard Elevation="1" Class="ml-4 mr-4 mb-4">
|
<MudCard Elevation="1" Class="ml-4 mr-4 mb-4">
|
||||||
|
@@ -150,6 +150,11 @@ namespace Lantean.QBTMud.Pages
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected async Task ShowSearchPlugins()
|
||||||
|
{
|
||||||
|
await DialogService.ShowSearchPluginsDialog();
|
||||||
|
}
|
||||||
|
|
||||||
protected IEnumerable<ColumnDefinition<QBitTorrentClient.Models.SearchResult>> Columns => ColumnsDefinitions;
|
protected IEnumerable<ColumnDefinition<QBitTorrentClient.Models.SearchResult>> Columns => ColumnsDefinitions;
|
||||||
|
|
||||||
public static List<ColumnDefinition<QBitTorrentClient.Models.SearchResult>> ColumnsDefinitions { get; } =
|
public static List<ColumnDefinition<QBitTorrentClient.Models.SearchResult>> ColumnsDefinitions { get; } =
|
||||||
|
Reference in New Issue
Block a user