mirror of
https://github.com/lantean-code/qbtmud.git
synced 2025-10-22 20:42:24 +00:00
61 lines
1.6 KiB
C#
61 lines
1.6 KiB
C#
using Lantean.QBitTorrentClient;
|
|
using Lantean.QBitTorrentClient.Models;
|
|
using Lantean.QBTMudBlade.Helpers;
|
|
using Microsoft.AspNetCore.Components;
|
|
using MudBlazor;
|
|
|
|
namespace Lantean.QBTMudBlade.Components
|
|
{
|
|
public partial class Menu
|
|
{
|
|
private bool _isVisible = false;
|
|
|
|
private Preferences? _preferences;
|
|
|
|
[Inject]
|
|
protected NavigationManager NavigationManager { get; set; } = default!;
|
|
|
|
[Inject]
|
|
protected IDialogService DialogService { get; set; } = default!;
|
|
|
|
[Inject]
|
|
protected IApiClient ApiClient { get; set; } = default!;
|
|
|
|
protected Preferences? Preferences => _preferences;
|
|
|
|
public void ShowMenu(Preferences? preferences = null)
|
|
{
|
|
_isVisible = true;
|
|
_preferences = preferences;
|
|
|
|
StateHasChanged();
|
|
}
|
|
|
|
protected async Task ResetWebUI()
|
|
{
|
|
var preferences = new UpdatePreferences
|
|
{
|
|
AlternativeWebuiEnabled = false,
|
|
};
|
|
|
|
await ApiClient.SetApplicationPreferences(preferences);
|
|
|
|
NavigationManager.NavigateTo("/", true);
|
|
}
|
|
|
|
protected async Task Logout()
|
|
{
|
|
await DialogService.ShowConfirmDialog("Logout?", "Are you sure you want to logout?", async () =>
|
|
{
|
|
await ApiClient.Logout();
|
|
|
|
NavigationManager.NavigateTo("/login", true);
|
|
});
|
|
}
|
|
|
|
protected async Task Exit()
|
|
{
|
|
await DialogService.ShowConfirmDialog("Quit?", "Are you sure you want to exit qBittorrent?", ApiClient.Shutdown);
|
|
}
|
|
}
|
|
} |