From 01ae4d637a42ceba856124b5e7dffb1008695d20 Mon Sep 17 00:00:00 2001 From: ahjephson Date: Sat, 17 Aug 2024 11:49:34 +0100 Subject: [PATCH] Reorganise files in root and update menu/nav --- .../Components/ApplicationActions.razor | 28 +++++++ .../Components/ApplicationActions.razor.cs | 78 +++++++++++++++++++ .../Dialogs/ManageCategoriesDialog.razor.cs | 1 + .../Dialogs/ManageTagsDialog.razor.cs | 1 + .../Components/Dialogs/SubMenuDialog.razor | 6 -- .../Components/Dialogs/SubMenuDialog.razor.cs | 4 +- .../Components/ErrorDisplay.razor.cs | 1 + .../Components/FilesTab.razor.cs | 1 + .../Components/FiltersNav.razor.cs | 1 + Lantean.QBTMudBlade/Components/Menu.razor | 15 +--- Lantean.QBTMudBlade/Components/Menu.razor.cs | 1 + .../Components/Options/RSSOptions.razor.cs | 3 +- .../Components/PeersTab.razor.cs | 1 + .../Components/TorrentActions.razor | 6 +- .../Components/TorrentActions.razor.cs | 67 +++------------- .../Components/TrackersTab.razor.cs | 1 + .../Components/UI/DynamicTable.razor.cs | 1 + .../{ => Filter}/ExpressionModifier.cs | 2 +- .../{ => Helpers}/DialogHelper.cs | 7 +- .../{ => Helpers}/DisplayHelpers.cs | 2 +- .../{ => Helpers}/FilterHelper.cs | 4 +- .../Layout/LoggedInLayout.razor.cs | 1 + .../Layout/MainLayout.razor.cs | 2 +- Lantean.QBTMudBlade/Layout/OtherLayout.razor | 13 +--- .../Layout/OtherLayout.razor.cs | 8 -- .../{ => Models}/FilterState.cs | 4 +- Lantean.QBTMudBlade/Models/KeyboardEvent.cs | 3 +- Lantean.QBTMudBlade/Models/UIAction.cs | 64 +++++++++++++++ Lantean.QBTMudBlade/Pages/Blocks.razor.cs | 1 + .../Pages/CategoryManagement.razor.cs | 1 + Lantean.QBTMudBlade/Pages/Log.razor.cs | 1 + Lantean.QBTMudBlade/Pages/Login.razor.cs | 2 +- Lantean.QBTMudBlade/Pages/Options.razor.cs | 1 + Lantean.QBTMudBlade/Pages/Search.razor.cs | 1 + .../Pages/TagManagement.razor.cs | 1 + .../Pages/TorrentList.razor.cs | 1 + .../{ => Services}/CookieHandler.cs | 2 +- Lantean.QBTMudBlade/Services/DataManager.cs | 3 +- Lantean.QBTMudBlade/_Imports.razor | 7 +- 39 files changed, 222 insertions(+), 125 deletions(-) create mode 100644 Lantean.QBTMudBlade/Components/ApplicationActions.razor create mode 100644 Lantean.QBTMudBlade/Components/ApplicationActions.razor.cs rename Lantean.QBTMudBlade/{ => Filter}/ExpressionModifier.cs (99%) rename Lantean.QBTMudBlade/{ => Helpers}/DialogHelper.cs (98%) rename Lantean.QBTMudBlade/{ => Helpers}/DisplayHelpers.cs (99%) rename Lantean.QBTMudBlade/{ => Helpers}/FilterHelper.cs (98%) rename Lantean.QBTMudBlade/{ => Models}/FilterState.cs (90%) create mode 100644 Lantean.QBTMudBlade/Models/UIAction.cs rename Lantean.QBTMudBlade/{ => Services}/CookieHandler.cs (91%) diff --git a/Lantean.QBTMudBlade/Components/ApplicationActions.razor b/Lantean.QBTMudBlade/Components/ApplicationActions.razor new file mode 100644 index 0000000..30ece9b --- /dev/null +++ b/Lantean.QBTMudBlade/Components/ApplicationActions.razor @@ -0,0 +1,28 @@ +@if (IsMenu) +{ + @foreach (var action in Actions) + { + if (action.SeparatorBefore) + { + + } + @action.Text + } + Reset Web UI + + Logout + Exit qBittorrent +} +else +{ + Torrents + + @foreach (var action in Actions) + { + if (action.SeparatorBefore) + { + + } + @action.Text + } +} \ No newline at end of file diff --git a/Lantean.QBTMudBlade/Components/ApplicationActions.razor.cs b/Lantean.QBTMudBlade/Components/ApplicationActions.razor.cs new file mode 100644 index 0000000..3f2ab2b --- /dev/null +++ b/Lantean.QBTMudBlade/Components/ApplicationActions.razor.cs @@ -0,0 +1,78 @@ +using Lantean.QBitTorrentClient.Models; +using Lantean.QBitTorrentClient; +using Microsoft.AspNetCore.Components; +using MudBlazor; +using Lantean.QBTMudBlade.Helpers; +using Lantean.QBTMudBlade.Models; +using System; +using Lantean.QBTMudBlade.Pages; +using static MudBlazor.CategoryTypes; + +namespace Lantean.QBTMudBlade.Components +{ + public partial class ApplicationActions + { + private List? _actions; + + [Inject] + protected NavigationManager NavigationManager { get; set; } = default!; + + [Inject] + protected IDialogService DialogService { get; set; } = default!; + + [Inject] + protected IApiClient ApiClient { get; set; } = default!; + + [Parameter] + public bool IsMenu { get; set; } + + protected IEnumerable Actions => _actions ?? []; + + protected override void OnInitialized() + { + _actions = + [ + new("Statistics", "Statistics", Icons.Material.Filled.PieChart, Color.Default, "/statistics"), + new("Search", "Search", Icons.Material.Filled.Search, Color.Default, "/search"), + new("RSS", "RSS", Icons.Material.Filled.RssFeed, Color.Default, "/rss"), + new("Execution Log", "Execution Log", Icons.Material.Filled.List, Color.Default, "/log"), + new("Blocked IPs", "Blocked IPs", Icons.Material.Filled.DisabledByDefault, Color.Default, "/blocks"), + new("Tag Management", "Tag Management", Icons.Material.Filled.Label, Color.Default, "/tags", separatorBefore: true), + new("Category Management", "Category Management", Icons.Material.Filled.List, Color.Default, "/categories"), + new("Settings", "Settings", Icons.Material.Filled.Settings, Color.Default, "/settings", separatorBefore: true), + ]; + } + + protected void NavigateBack() + { + NavigationManager.NavigateTo("/"); + } + + 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); + } + } +} diff --git a/Lantean.QBTMudBlade/Components/Dialogs/ManageCategoriesDialog.razor.cs b/Lantean.QBTMudBlade/Components/Dialogs/ManageCategoriesDialog.razor.cs index d0421c7..9ad30eb 100644 --- a/Lantean.QBTMudBlade/Components/Dialogs/ManageCategoriesDialog.razor.cs +++ b/Lantean.QBTMudBlade/Components/Dialogs/ManageCategoriesDialog.razor.cs @@ -1,4 +1,5 @@ using Lantean.QBitTorrentClient; +using Lantean.QBTMudBlade.Helpers; using Microsoft.AspNetCore.Components; using MudBlazor; diff --git a/Lantean.QBTMudBlade/Components/Dialogs/ManageTagsDialog.razor.cs b/Lantean.QBTMudBlade/Components/Dialogs/ManageTagsDialog.razor.cs index 72d0bd8..f275f86 100644 --- a/Lantean.QBTMudBlade/Components/Dialogs/ManageTagsDialog.razor.cs +++ b/Lantean.QBTMudBlade/Components/Dialogs/ManageTagsDialog.razor.cs @@ -1,4 +1,5 @@ using Lantean.QBitTorrentClient; +using Lantean.QBTMudBlade.Helpers; using Microsoft.AspNetCore.Components; using MudBlazor; diff --git a/Lantean.QBTMudBlade/Components/Dialogs/SubMenuDialog.razor b/Lantean.QBTMudBlade/Components/Dialogs/SubMenuDialog.razor index f15d083..1834bf4 100644 --- a/Lantean.QBTMudBlade/Components/Dialogs/SubMenuDialog.razor +++ b/Lantean.QBTMudBlade/Components/Dialogs/SubMenuDialog.razor @@ -8,10 +8,4 @@ - - @if (MultiAction) - { - Close - } - \ No newline at end of file diff --git a/Lantean.QBTMudBlade/Components/Dialogs/SubMenuDialog.razor.cs b/Lantean.QBTMudBlade/Components/Dialogs/SubMenuDialog.razor.cs index 0e43d2f..f9ba156 100644 --- a/Lantean.QBTMudBlade/Components/Dialogs/SubMenuDialog.razor.cs +++ b/Lantean.QBTMudBlade/Components/Dialogs/SubMenuDialog.razor.cs @@ -10,7 +10,7 @@ namespace Lantean.QBTMudBlade.Components.Dialogs public MudDialogInstance MudDialog { get; set; } = default!; [Parameter] - public TorrentAction? ParentAction { get; set; } + public UIAction? ParentAction { get; set; } [Parameter] public Dictionary Torrents { get; set; } = default!; @@ -18,8 +18,6 @@ namespace Lantean.QBTMudBlade.Components.Dialogs [Parameter] public QBitTorrentClient.Models.Preferences? Preferences { get; set; } - protected bool MultiAction => ParentAction?.MultiAction ?? false; - [Parameter] public IEnumerable Hashes { get; set; } = []; diff --git a/Lantean.QBTMudBlade/Components/ErrorDisplay.razor.cs b/Lantean.QBTMudBlade/Components/ErrorDisplay.razor.cs index 3c189b5..80a159c 100644 --- a/Lantean.QBTMudBlade/Components/ErrorDisplay.razor.cs +++ b/Lantean.QBTMudBlade/Components/ErrorDisplay.razor.cs @@ -1,4 +1,5 @@ using Lantean.QBTMudBlade.Components.Dialogs; +using Lantean.QBTMudBlade.Helpers; using Microsoft.AspNetCore.Components; using MudBlazor; diff --git a/Lantean.QBTMudBlade/Components/FilesTab.razor.cs b/Lantean.QBTMudBlade/Components/FilesTab.razor.cs index b5be11b..626e2ac 100644 --- a/Lantean.QBTMudBlade/Components/FilesTab.razor.cs +++ b/Lantean.QBTMudBlade/Components/FilesTab.razor.cs @@ -3,6 +3,7 @@ using Lantean.QBitTorrentClient; using Lantean.QBTMudBlade.Components.Dialogs; using Lantean.QBTMudBlade.Components.UI; using Lantean.QBTMudBlade.Filter; +using Lantean.QBTMudBlade.Helpers; using Lantean.QBTMudBlade.Models; using Lantean.QBTMudBlade.Services; using Microsoft.AspNetCore.Components; diff --git a/Lantean.QBTMudBlade/Components/FiltersNav.razor.cs b/Lantean.QBTMudBlade/Components/FiltersNav.razor.cs index 772a517..0275948 100644 --- a/Lantean.QBTMudBlade/Components/FiltersNav.razor.cs +++ b/Lantean.QBTMudBlade/Components/FiltersNav.razor.cs @@ -1,6 +1,7 @@ using Blazored.LocalStorage; using Lantean.QBitTorrentClient; using Lantean.QBTMudBlade.Components.UI; +using Lantean.QBTMudBlade.Helpers; using Lantean.QBTMudBlade.Models; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; diff --git a/Lantean.QBTMudBlade/Components/Menu.razor b/Lantean.QBTMudBlade/Components/Menu.razor index 4546cbb..f0a7343 100644 --- a/Lantean.QBTMudBlade/Components/Menu.razor +++ b/Lantean.QBTMudBlade/Components/Menu.razor @@ -1,16 +1,3 @@  - Statistics - Search - RSS - Execution Log - Blocked IPs - - Tag Management - Category Management - - Settings - Reset Web UI - - Logout - Exit qBittorrent + \ No newline at end of file diff --git a/Lantean.QBTMudBlade/Components/Menu.razor.cs b/Lantean.QBTMudBlade/Components/Menu.razor.cs index 94b86d8..697d3f0 100644 --- a/Lantean.QBTMudBlade/Components/Menu.razor.cs +++ b/Lantean.QBTMudBlade/Components/Menu.razor.cs @@ -1,5 +1,6 @@ using Lantean.QBitTorrentClient; using Lantean.QBitTorrentClient.Models; +using Lantean.QBTMudBlade.Helpers; using Microsoft.AspNetCore.Components; using MudBlazor; diff --git a/Lantean.QBTMudBlade/Components/Options/RSSOptions.razor.cs b/Lantean.QBTMudBlade/Components/Options/RSSOptions.razor.cs index d930934..5176227 100644 --- a/Lantean.QBTMudBlade/Components/Options/RSSOptions.razor.cs +++ b/Lantean.QBTMudBlade/Components/Options/RSSOptions.razor.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Components; +using Lantean.QBTMudBlade.Helpers; +using Microsoft.AspNetCore.Components; using MudBlazor; namespace Lantean.QBTMudBlade.Components.Options diff --git a/Lantean.QBTMudBlade/Components/PeersTab.razor.cs b/Lantean.QBTMudBlade/Components/PeersTab.razor.cs index b7051dc..248c39d 100644 --- a/Lantean.QBTMudBlade/Components/PeersTab.razor.cs +++ b/Lantean.QBTMudBlade/Components/PeersTab.razor.cs @@ -1,5 +1,6 @@ using Lantean.QBitTorrentClient; using Lantean.QBTMudBlade.Components.UI; +using Lantean.QBTMudBlade.Helpers; using Lantean.QBTMudBlade.Models; using Lantean.QBTMudBlade.Services; using Microsoft.AspNetCore.Components; diff --git a/Lantean.QBTMudBlade/Components/TorrentActions.razor b/Lantean.QBTMudBlade/Components/TorrentActions.razor index d5375f6..16bb134 100644 --- a/Lantean.QBTMudBlade/Components/TorrentActions.razor +++ b/Lantean.QBTMudBlade/Components/TorrentActions.razor @@ -155,7 +155,7 @@ else if (RenderType == RenderType.MenuItems) } } - private RenderFragment ChildItem(TorrentAction action) + private RenderFragment ChildItem(UIAction action) { return __builder => { @@ -168,7 +168,7 @@ else if (RenderType == RenderType.MenuItems) }; } - private RenderFragment Menu(IEnumerable actions) + private RenderFragment Menu(IEnumerable actions) { return __builder => { @@ -178,7 +178,7 @@ else if (RenderType == RenderType.MenuItems) }; } - private RenderFragment MenuContents(IEnumerable actions) + private RenderFragment MenuContents(IEnumerable actions) { return __builder => { diff --git a/Lantean.QBTMudBlade/Components/TorrentActions.razor.cs b/Lantean.QBTMudBlade/Components/TorrentActions.razor.cs index c214464..27c44ab 100644 --- a/Lantean.QBTMudBlade/Components/TorrentActions.razor.cs +++ b/Lantean.QBTMudBlade/Components/TorrentActions.razor.cs @@ -1,5 +1,6 @@ using Lantean.QBitTorrentClient; using Lantean.QBTMudBlade.Components.Dialogs; +using Lantean.QBTMudBlade.Helpers; using Lantean.QBTMudBlade.Interop; using Lantean.QBTMudBlade.Models; using Lantean.QBTMudBlade.Services; @@ -13,7 +14,7 @@ namespace Lantean.QBTMudBlade.Components { private bool _disposedValue; - private List? _actions; + private List? _actions; [Inject] public IApiClient ApiClient { get; set; } = default!; @@ -59,7 +60,7 @@ namespace Lantean.QBTMudBlade.Components public MudDialogInstance? MudDialog { get; set; } [Parameter] - public TorrentAction? ParentAction { get; set; } + public UIAction? ParentAction { get; set; } public MudMenu? ActionsMenu { get; set; } @@ -89,14 +90,14 @@ namespace Lantean.QBTMudBlade.Components new("firstLastPiecePrio", "Download first and last pieces first", Icons.Material.Filled.Check, Color.Info, CreateCallback(DownloadFirstLast)), new("forceRecheck", "Force recheck", Icons.Material.Filled.Loop, Color.Info, CreateCallback(ForceRecheck), separatorBefore: true), new("forceReannounce", "Force reannounce", Icons.Material.Filled.BroadcastOnHome, Color.Info, CreateCallback(ForceReannounce)), - new("queue", "Queue", Icons.Material.Filled.Queue, Color.Transparent, new List + new("queue", "Queue", Icons.Material.Filled.Queue, Color.Transparent, new List { new("queueTop", "Move to top", Icons.Material.Filled.VerticalAlignTop, Color.Inherit, CreateCallback(MoveToTop)), new("queueUp", "Move up", Icons.Material.Filled.ArrowUpward, Color.Inherit, CreateCallback(MoveUp)), new("queueDown", "Move down", Icons.Material.Filled.ArrowDownward, Color.Inherit, CreateCallback(MoveDown)), new("queueBottom", "Move to bottom", Icons.Material.Filled.VerticalAlignBottom, Color.Inherit, CreateCallback(MoveToBottom)), }, separatorBefore: true), - new("copy", "Copy", Icons.Material.Filled.FolderCopy, Color.Info, new List + new("copy", "Copy", Icons.Material.Filled.FolderCopy, Color.Info, new List { new("copyName", "Name", Icons.Material.Filled.TextFields, Color.Info, CreateCallback(() => Copy(t => t.Name))), new("copyHashv1", "Info hash v1", Icons.Material.Filled.Tag, Color.Info, CreateCallback(() => Copy(t => t.InfoHashV1))), @@ -335,7 +336,7 @@ namespace Lantean.QBTMudBlade.Components await ApiClient.SetFirstLastPiecePriority(null, Hashes.ToArray()); } - protected async Task SubMenuTouch(TorrentAction action) + protected async Task SubMenuTouch(UIAction action) { await DialogService.ShowSubMenu(Hashes, action, Torrents, Preferences); } @@ -351,9 +352,9 @@ namespace Lantean.QBTMudBlade.Components } } - private IEnumerable Actions => GetActions(); + private IEnumerable Actions => GetActions(); - private IEnumerable GetActions() + private IEnumerable GetActions() { var allAreSequentialDownload = true; var thereAreSequentialDownload = false; @@ -523,7 +524,7 @@ namespace Lantean.QBTMudBlade.Components return Filter(actionStates); } - private IEnumerable Filter(Dictionary actionStates) + private IEnumerable Filter(Dictionary actionStates) { if (_actions is null) { @@ -641,54 +642,4 @@ namespace Lantean.QBTMudBlade.Components MenuItems, } - - public record TorrentAction - { - private readonly Color _color; - - public TorrentAction(string name, string text, string? icon, Color color, EventCallback callback, bool separatorBefore = false) - { - Name = name; - Text = text; - Icon = icon; - _color = color; - Callback = callback; - SeparatorBefore = separatorBefore; - Children = []; - } - - public TorrentAction(string name, string text, string? icon, Color color, IEnumerable children, bool multiAction = false, bool useTextButton = false, bool separatorBefore = false) - { - Name = name; - Text = text; - Icon = icon; - _color = color; - Callback = default; - Children = children; - UseTextButton = useTextButton; - SeparatorBefore = separatorBefore; - } - - public string Name { get; } - - public string Text { get; } - - public string? Icon { get; } - - - - public Color Color => IsChecked is null || IsChecked.Value ? _color : Color.Transparent; - - public EventCallback Callback { get; } - - public bool SeparatorBefore { get; set; } - - public IEnumerable Children { get; } - - public bool UseTextButton { get; } - - public bool MultiAction { get; } - - public bool? IsChecked { get; internal set; } - } } \ No newline at end of file diff --git a/Lantean.QBTMudBlade/Components/TrackersTab.razor.cs b/Lantean.QBTMudBlade/Components/TrackersTab.razor.cs index 9ea63f2..5d6d823 100644 --- a/Lantean.QBTMudBlade/Components/TrackersTab.razor.cs +++ b/Lantean.QBTMudBlade/Components/TrackersTab.razor.cs @@ -1,6 +1,7 @@ using Lantean.QBitTorrentClient; using Lantean.QBitTorrentClient.Models; using Lantean.QBTMudBlade.Components.UI; +using Lantean.QBTMudBlade.Helpers; using Lantean.QBTMudBlade.Interop; using Lantean.QBTMudBlade.Services; using Microsoft.AspNetCore.Components; diff --git a/Lantean.QBTMudBlade/Components/UI/DynamicTable.razor.cs b/Lantean.QBTMudBlade/Components/UI/DynamicTable.razor.cs index 905755f..1d08e05 100644 --- a/Lantean.QBTMudBlade/Components/UI/DynamicTable.razor.cs +++ b/Lantean.QBTMudBlade/Components/UI/DynamicTable.razor.cs @@ -1,4 +1,5 @@ using Blazored.LocalStorage; +using Lantean.QBTMudBlade.Helpers; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; using MudBlazor; diff --git a/Lantean.QBTMudBlade/ExpressionModifier.cs b/Lantean.QBTMudBlade/Filter/ExpressionModifier.cs similarity index 99% rename from Lantean.QBTMudBlade/ExpressionModifier.cs rename to Lantean.QBTMudBlade/Filter/ExpressionModifier.cs index 909d0a7..4576490 100644 --- a/Lantean.QBTMudBlade/ExpressionModifier.cs +++ b/Lantean.QBTMudBlade/Filter/ExpressionModifier.cs @@ -1,7 +1,7 @@ using System.Diagnostics.CodeAnalysis; using System.Linq.Expressions; -namespace Lantean.QBTMudBlade +namespace Lantean.QBTMudBlade.Filter { internal static class ExpressionModifier { diff --git a/Lantean.QBTMudBlade/DialogHelper.cs b/Lantean.QBTMudBlade/Helpers/DialogHelper.cs similarity index 98% rename from Lantean.QBTMudBlade/DialogHelper.cs rename to Lantean.QBTMudBlade/Helpers/DialogHelper.cs index e39fcdd..d080bb8 100644 --- a/Lantean.QBTMudBlade/DialogHelper.cs +++ b/Lantean.QBTMudBlade/Helpers/DialogHelper.cs @@ -1,11 +1,10 @@ using Lantean.QBitTorrentClient; -using Lantean.QBTMudBlade.Components; using Lantean.QBTMudBlade.Components.Dialogs; using Lantean.QBTMudBlade.Filter; using Lantean.QBTMudBlade.Models; using MudBlazor; -namespace Lantean.QBTMudBlade +namespace Lantean.QBTMudBlade.Helpers { public static class DialogHelper { @@ -238,7 +237,7 @@ namespace Lantean.QBTMudBlade public static async Task ShowConfirmDialog(this IDialogService dialogService, string title, string content, Action onSuccess) { - await ShowConfirmDialog(dialogService, title, content, () => + await dialogService.ShowConfirmDialog(title, content, () => { onSuccess(); @@ -389,7 +388,7 @@ namespace Lantean.QBTMudBlade await Task.Delay(0); } - public static async Task ShowSubMenu(this IDialogService dialogService, IEnumerable hashes, TorrentAction parent, Dictionary torrents, QBitTorrentClient.Models.Preferences? preferences) + public static async Task ShowSubMenu(this IDialogService dialogService, IEnumerable hashes, UIAction parent, Dictionary torrents, QBitTorrentClient.Models.Preferences? preferences) { var parameters = new DialogParameters { diff --git a/Lantean.QBTMudBlade/DisplayHelpers.cs b/Lantean.QBTMudBlade/Helpers/DisplayHelpers.cs similarity index 99% rename from Lantean.QBTMudBlade/DisplayHelpers.cs rename to Lantean.QBTMudBlade/Helpers/DisplayHelpers.cs index 12f5022..98d261e 100644 --- a/Lantean.QBTMudBlade/DisplayHelpers.cs +++ b/Lantean.QBTMudBlade/Helpers/DisplayHelpers.cs @@ -4,7 +4,7 @@ using MudBlazor; using System.Diagnostics.CodeAnalysis; using System.Text; -namespace Lantean.QBTMudBlade +namespace Lantean.QBTMudBlade.Helpers { public static class DisplayHelpers { diff --git a/Lantean.QBTMudBlade/FilterHelper.cs b/Lantean.QBTMudBlade/Helpers/FilterHelper.cs similarity index 98% rename from Lantean.QBTMudBlade/FilterHelper.cs rename to Lantean.QBTMudBlade/Helpers/FilterHelper.cs index 079da3f..2f159df 100644 --- a/Lantean.QBTMudBlade/FilterHelper.cs +++ b/Lantean.QBTMudBlade/Helpers/FilterHelper.cs @@ -1,6 +1,6 @@ using Lantean.QBTMudBlade.Models; -namespace Lantean.QBTMudBlade +namespace Lantean.QBTMudBlade.Helpers { public static class FilterHelper { @@ -192,7 +192,7 @@ namespace Lantean.QBTMudBlade break; case Status.Completed: - if ((state != "uploading") && (!state.Contains("UP"))) + if (state != "uploading" && !state.Contains("UP")) { return false; } diff --git a/Lantean.QBTMudBlade/Layout/LoggedInLayout.razor.cs b/Lantean.QBTMudBlade/Layout/LoggedInLayout.razor.cs index 7efcc5a..91246e4 100644 --- a/Lantean.QBTMudBlade/Layout/LoggedInLayout.razor.cs +++ b/Lantean.QBTMudBlade/Layout/LoggedInLayout.razor.cs @@ -1,4 +1,5 @@ using Lantean.QBitTorrentClient; +using Lantean.QBTMudBlade.Helpers; using Lantean.QBTMudBlade.Models; using Lantean.QBTMudBlade.Services; using Microsoft.AspNetCore.Components; diff --git a/Lantean.QBTMudBlade/Layout/MainLayout.razor.cs b/Lantean.QBTMudBlade/Layout/MainLayout.razor.cs index 84e28a8..0cc1853 100644 --- a/Lantean.QBTMudBlade/Layout/MainLayout.razor.cs +++ b/Lantean.QBTMudBlade/Layout/MainLayout.razor.cs @@ -81,7 +81,7 @@ namespace Lantean.QBTMudBlade.Layout var isDarkMode = await LocalStorage.GetItemAsync(_isDarkModeStorageKey); if (isDarkMode is null) { - IsDarkMode = await MudThemeProvider.GetSystemPreference(); + IsDarkMode = true; } else { diff --git a/Lantean.QBTMudBlade/Layout/OtherLayout.razor b/Lantean.QBTMudBlade/Layout/OtherLayout.razor index f1734ac..74122d9 100644 --- a/Lantean.QBTMudBlade/Layout/OtherLayout.razor +++ b/Lantean.QBTMudBlade/Layout/OtherLayout.razor @@ -3,18 +3,7 @@ - Torrents - - Statistics - Search - RSS - Execution Log - Blocked IPs - - Tag Management - Category Management - - Settings + diff --git a/Lantean.QBTMudBlade/Layout/OtherLayout.razor.cs b/Lantean.QBTMudBlade/Layout/OtherLayout.razor.cs index 790724c..249ef40 100644 --- a/Lantean.QBTMudBlade/Layout/OtherLayout.razor.cs +++ b/Lantean.QBTMudBlade/Layout/OtherLayout.razor.cs @@ -4,15 +4,7 @@ namespace Lantean.QBTMudBlade.Layout { public partial class OtherLayout { - [Inject] - protected NavigationManager NavigationManager { get; set; } = default!; - [CascadingParameter(Name = "DrawerOpen")] public bool DrawerOpen { get; set; } - - protected void NavigateBack() - { - NavigationManager.NavigateTo("/"); - } } } \ No newline at end of file diff --git a/Lantean.QBTMudBlade/FilterState.cs b/Lantean.QBTMudBlade/Models/FilterState.cs similarity index 90% rename from Lantean.QBTMudBlade/FilterState.cs rename to Lantean.QBTMudBlade/Models/FilterState.cs index 79f2760..fc2c8c1 100644 --- a/Lantean.QBTMudBlade/FilterState.cs +++ b/Lantean.QBTMudBlade/Models/FilterState.cs @@ -1,6 +1,4 @@ -using Lantean.QBTMudBlade.Models; - -namespace Lantean.QBTMudBlade +namespace Lantean.QBTMudBlade.Models { public struct FilterState { diff --git a/Lantean.QBTMudBlade/Models/KeyboardEvent.cs b/Lantean.QBTMudBlade/Models/KeyboardEvent.cs index e759466..57ba123 100644 --- a/Lantean.QBTMudBlade/Models/KeyboardEvent.cs +++ b/Lantean.QBTMudBlade/Models/KeyboardEvent.cs @@ -78,8 +78,7 @@ namespace Lantean.QBTMudBlade.Models { var modifiers = (CtrlKey ? "Ctrl" : "") + (ShiftKey ? "Shift" : "") + (AltKey ? "Alt" : "") + (MetaKey ? "Meta" : ""); - return modifiers + (modifiers.Length == 0 ? "" : "+") + Key + (Repeat ? "-repeated" : ""); - //return Key + (CtrlKey ? '1' : '0') + (ShiftKey ? '1' : '0') + (AltKey ? '1' : '0') + (MetaKey ? '1' : '0') + (Repeat ? '1' : '0'); + return modifiers + (modifiers.Length == 0 ? "" : "+") + (Key == "+" ? "'+'" : "+") + (Repeat ? "-repeated" : ""); } public override int GetHashCode() diff --git a/Lantean.QBTMudBlade/Models/UIAction.cs b/Lantean.QBTMudBlade/Models/UIAction.cs new file mode 100644 index 0000000..0e75b44 --- /dev/null +++ b/Lantean.QBTMudBlade/Models/UIAction.cs @@ -0,0 +1,64 @@ +using Microsoft.AspNetCore.Components; +using MudBlazor; + +namespace Lantean.QBTMudBlade.Models +{ + public record UIAction + { + private readonly Color _color; + + public UIAction(string name, string text, string? icon, Color color, string href, bool separatorBefore = false) + { + Name = name; + Text = text; + Icon = icon; + _color = color; + Href = href; + SeparatorBefore = separatorBefore; + Children = []; + } + + public UIAction(string name, string text, string? icon, Color color, EventCallback callback, bool separatorBefore = false) + { + Name = name; + Text = text; + Icon = icon; + _color = color; + Callback = callback; + SeparatorBefore = separatorBefore; + Children = []; + } + + public UIAction(string name, string text, string? icon, Color color, IEnumerable children, bool useTextButton = false, bool separatorBefore = false) + { + Name = name; + Text = text; + Icon = icon; + _color = color; + Callback = default; + Children = children; + UseTextButton = useTextButton; + SeparatorBefore = separatorBefore; + } + + public string Name { get; } + + public string Text { get; } + + public string? Icon { get; } + + public Color Color => IsChecked is null || IsChecked.Value ? _color : Color.Transparent; + + public EventCallback Callback { get; } + + public string? Href { get; } + + public bool SeparatorBefore { get; set; } + + public IEnumerable Children { get; } + + public bool UseTextButton { get; } + + public bool? IsChecked { get; internal set; } + } +} \ No newline at end of file diff --git a/Lantean.QBTMudBlade/Pages/Blocks.razor.cs b/Lantean.QBTMudBlade/Pages/Blocks.razor.cs index 4fb9bce..9bbe3a8 100644 --- a/Lantean.QBTMudBlade/Pages/Blocks.razor.cs +++ b/Lantean.QBTMudBlade/Pages/Blocks.razor.cs @@ -2,6 +2,7 @@ using Lantean.QBitTorrentClient; using Lantean.QBitTorrentClient.Models; using Lantean.QBTMudBlade.Components.UI; +using Lantean.QBTMudBlade.Helpers; using Lantean.QBTMudBlade.Models; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Forms; diff --git a/Lantean.QBTMudBlade/Pages/CategoryManagement.razor.cs b/Lantean.QBTMudBlade/Pages/CategoryManagement.razor.cs index b6365de..34d57b7 100644 --- a/Lantean.QBTMudBlade/Pages/CategoryManagement.razor.cs +++ b/Lantean.QBTMudBlade/Pages/CategoryManagement.razor.cs @@ -1,6 +1,7 @@ using Blazored.LocalStorage; using Lantean.QBitTorrentClient; using Lantean.QBTMudBlade.Components.UI; +using Lantean.QBTMudBlade.Helpers; using Lantean.QBTMudBlade.Models; using Microsoft.AspNetCore.Components; using MudBlazor; diff --git a/Lantean.QBTMudBlade/Pages/Log.razor.cs b/Lantean.QBTMudBlade/Pages/Log.razor.cs index 7c5cfc5..524529f 100644 --- a/Lantean.QBTMudBlade/Pages/Log.razor.cs +++ b/Lantean.QBTMudBlade/Pages/Log.razor.cs @@ -2,6 +2,7 @@ using Lantean.QBitTorrentClient; using Lantean.QBitTorrentClient.Models; using Lantean.QBTMudBlade.Components.UI; +using Lantean.QBTMudBlade.Helpers; using Lantean.QBTMudBlade.Models; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Forms; diff --git a/Lantean.QBTMudBlade/Pages/Login.razor.cs b/Lantean.QBTMudBlade/Pages/Login.razor.cs index efeeeb5..93bed47 100644 --- a/Lantean.QBTMudBlade/Pages/Login.razor.cs +++ b/Lantean.QBTMudBlade/Pages/Login.razor.cs @@ -48,7 +48,7 @@ namespace Lantean.QBTMudBlade.Pages #if DEBUG protected override Task OnInitializedAsync() { - return DoLogin("admin", "YZQC4Jhcw"); + return DoLogin("admin", "V9VpmhCvv"); } #endif } diff --git a/Lantean.QBTMudBlade/Pages/Options.razor.cs b/Lantean.QBTMudBlade/Pages/Options.razor.cs index 16184cc..f9bc6b2 100644 --- a/Lantean.QBTMudBlade/Pages/Options.razor.cs +++ b/Lantean.QBTMudBlade/Pages/Options.razor.cs @@ -1,6 +1,7 @@ using Lantean.QBitTorrentClient; using Lantean.QBitTorrentClient.Models; using Lantean.QBTMudBlade.Components.Options; +using Lantean.QBTMudBlade.Helpers; using Lantean.QBTMudBlade.Services; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Routing; diff --git a/Lantean.QBTMudBlade/Pages/Search.razor.cs b/Lantean.QBTMudBlade/Pages/Search.razor.cs index 4d7e3a2..bdf7281 100644 --- a/Lantean.QBTMudBlade/Pages/Search.razor.cs +++ b/Lantean.QBTMudBlade/Pages/Search.razor.cs @@ -1,5 +1,6 @@ using Lantean.QBitTorrentClient; using Lantean.QBTMudBlade.Components.UI; +using Lantean.QBTMudBlade.Helpers; using Lantean.QBTMudBlade.Models; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Forms; diff --git a/Lantean.QBTMudBlade/Pages/TagManagement.razor.cs b/Lantean.QBTMudBlade/Pages/TagManagement.razor.cs index ea89dea..6a68f09 100644 --- a/Lantean.QBTMudBlade/Pages/TagManagement.razor.cs +++ b/Lantean.QBTMudBlade/Pages/TagManagement.razor.cs @@ -1,6 +1,7 @@ using Blazored.LocalStorage; using Lantean.QBitTorrentClient; using Lantean.QBTMudBlade.Components.UI; +using Lantean.QBTMudBlade.Helpers; using Lantean.QBTMudBlade.Models; using Microsoft.AspNetCore.Components; using MudBlazor; diff --git a/Lantean.QBTMudBlade/Pages/TorrentList.razor.cs b/Lantean.QBTMudBlade/Pages/TorrentList.razor.cs index 6075c5a..4e98f49 100644 --- a/Lantean.QBTMudBlade/Pages/TorrentList.razor.cs +++ b/Lantean.QBTMudBlade/Pages/TorrentList.razor.cs @@ -1,5 +1,6 @@ using Lantean.QBitTorrentClient; using Lantean.QBTMudBlade.Components.UI; +using Lantean.QBTMudBlade.Helpers; using Lantean.QBTMudBlade.Models; using Lantean.QBTMudBlade.Services; using Microsoft.AspNetCore.Components; diff --git a/Lantean.QBTMudBlade/CookieHandler.cs b/Lantean.QBTMudBlade/Services/CookieHandler.cs similarity index 91% rename from Lantean.QBTMudBlade/CookieHandler.cs rename to Lantean.QBTMudBlade/Services/CookieHandler.cs index 00c6f04..c4fa84f 100644 --- a/Lantean.QBTMudBlade/CookieHandler.cs +++ b/Lantean.QBTMudBlade/Services/CookieHandler.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Components.WebAssembly.Http; -namespace Lantean.QBTMudBlade +namespace Lantean.QBTMudBlade.Services { public class CookieHandler : DelegatingHandler { diff --git a/Lantean.QBTMudBlade/Services/DataManager.cs b/Lantean.QBTMudBlade/Services/DataManager.cs index df01673..473f15b 100644 --- a/Lantean.QBTMudBlade/Services/DataManager.cs +++ b/Lantean.QBTMudBlade/Services/DataManager.cs @@ -1,4 +1,5 @@ -using Lantean.QBTMudBlade.Models; +using Lantean.QBTMudBlade.Helpers; +using Lantean.QBTMudBlade.Models; namespace Lantean.QBTMudBlade.Services { diff --git a/Lantean.QBTMudBlade/_Imports.razor b/Lantean.QBTMudBlade/_Imports.razor index 22d0615..0a83396 100644 --- a/Lantean.QBTMudBlade/_Imports.razor +++ b/Lantean.QBTMudBlade/_Imports.razor @@ -8,9 +8,10 @@ @using Microsoft.JSInterop @using MudBlazor @using Lantean.QBTMudBlade -@using Lantean.QBTMudBlade.Layout -@using Lantean.QBTMudBlade.Models @using Lantean.QBTMudBlade.Components @using Lantean.QBTMudBlade.Components.Dialogs @using Lantean.QBTMudBlade.Components.Options -@using Lantean.QBTMudBlade.Components.UI \ No newline at end of file +@using Lantean.QBTMudBlade.Components.UI +@using Lantean.QBTMudBlade.Helpers +@using Lantean.QBTMudBlade.Layout +@using Lantean.QBTMudBlade.Models \ No newline at end of file