mirror of
https://github.com/lantean-code/qbtmud.git
synced 2025-10-23 04:52:22 +00:00
Update project name and namespaces
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
namespace Lantean.QBTFluent.Comparers
|
||||
{
|
||||
}
|
3
Lantean.QBTMud.Test/ContentItemSizeComparer.cs
Normal file
3
Lantean.QBTMud.Test/ContentItemSizeComparer.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
namespace Lantean.QBTMud.Test
|
||||
{
|
||||
}
|
@@ -10,9 +10,10 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
|
||||
<PackageReference Include="FluentAssertions" Version="6.12.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
|
||||
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
|
||||
<PackageReference Include="xunit" Version="2.9.0" />
|
||||
<PackageReference Include="xunit" Version="2.9.2" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
@@ -22,7 +23,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Lantean.QBitTorrentClient\Lantean.QBitTorrentClient.csproj" />
|
||||
<ProjectReference Include="..\Lantean.QBTMudBlade\Lantean.QBTMudBlade.csproj" />
|
||||
<ProjectReference Include="..\Lantean.QBTMud\Lantean.QBTMud.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
6
Lantean.QBTMud.Test/Tests.cs
Normal file
6
Lantean.QBTMud.Test/Tests.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Lantean.QBTMud.Test
|
||||
{
|
||||
internal class Tests
|
||||
{
|
||||
}
|
||||
}
|
@@ -4,7 +4,7 @@ using System.Linq.Expressions;
|
||||
using System.Text.Json;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Lantean.QBTBlazor.Test
|
||||
namespace Lantean.QBTMud.Test
|
||||
{
|
||||
public class UnitTest1
|
||||
{
|
@@ -3,11 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.8.34511.84
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lantean.QBTBlazor.Test", "Lantean.QBTBlazor.Test\Lantean.QBTBlazor.Test.csproj", "{715E075C-1D86-4A7F-BC72-E1E24A294F17}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lantean.QBTMud.Test", "Lantean.QBTMud.Test\Lantean.QBTMud.Test.csproj", "{715E075C-1D86-4A7F-BC72-E1E24A294F17}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lantean.QBitTorrentClient", "Lantean.QBitTorrentClient\Lantean.QBitTorrentClient.csproj", "{F0DDAB07-0D6C-40C7-AFE6-08FF2C4CC7E7}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lantean.QBTMudBlade", "Lantean.QBTMudBlade\Lantean.QBTMudBlade.csproj", "{83BC76CC-D51B-42AF-A6EE-FA400C300098}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lantean.QBTMud", "Lantean.QBTMud\Lantean.QBTMud.csproj", "{83BC76CC-D51B-42AF-A6EE-FA400C300098}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1BF1A631-87D7-4039-A701-88C5E0234B63}"
|
||||
ProjectSection(SolutionItems) = preProject
|
@@ -1,11 +1,11 @@
|
||||
using Lantean.QBitTorrentClient.Models;
|
||||
using Lantean.QBitTorrentClient;
|
||||
using Lantean.QBitTorrentClient;
|
||||
using Lantean.QBitTorrentClient.Models;
|
||||
using Lantean.QBTMud.Helpers;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
using Lantean.QBTMudBlade.Helpers;
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components
|
||||
namespace Lantean.QBTMud.Components
|
||||
{
|
||||
public partial class ApplicationActions
|
||||
{
|
||||
@@ -38,7 +38,7 @@ namespace Lantean.QBTMudBlade.Components
|
||||
if (action.Name != "rss" || Preferences is not null && Preferences.RssProcessingEnabled)
|
||||
{
|
||||
yield return action;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,4 +91,4 @@ namespace Lantean.QBTMudBlade.Components
|
||||
await DialogService.ShowConfirmDialog("Quit?", "Are you sure you want to exit qBittorrent?", ApiClient.Shutdown);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,9 @@
|
||||
using Lantean.QBitTorrentClient.Models;
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
namespace Lantean.QBTMud.Components.Dialogs
|
||||
{
|
||||
public partial class AddPeerDialog
|
||||
{
|
@@ -1,9 +1,9 @@
|
||||
using Lantean.QBitTorrentClient;
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
namespace Lantean.QBTMud.Components.Dialogs
|
||||
{
|
||||
public partial class AddTagDialog
|
||||
{
|
||||
@@ -47,6 +47,10 @@ namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
|
||||
protected void Submit()
|
||||
{
|
||||
if (Tags.Count == 0 && Tag is not null)
|
||||
{
|
||||
Tags.Add(Tag);
|
||||
}
|
||||
MudDialog.Close(Tags);
|
||||
}
|
||||
|
@@ -1,9 +1,9 @@
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
namespace Lantean.QBTMud.Components.Dialogs
|
||||
{
|
||||
public partial class AddTorrentFileDialog
|
||||
{
|
@@ -1,13 +1,14 @@
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Lantean.QBTMudBlade.Services;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Lantean.QBTMud.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
namespace Lantean.QBTMud.Components.Dialogs
|
||||
{
|
||||
public partial class AddTorrentLinkDialog : IAsyncDisposable
|
||||
{
|
||||
private bool _disposedValue;
|
||||
|
||||
private readonly KeyboardEvent _ctrlEnterKey = new KeyboardEvent("Enter")
|
||||
{
|
||||
CtrlKey = true,
|
@@ -1,8 +1,8 @@
|
||||
using Lantean.QBitTorrentClient;
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
namespace Lantean.QBTMud.Components.Dialogs
|
||||
{
|
||||
public partial class AddTorrentOptions
|
||||
{
|
@@ -1,8 +1,8 @@
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
namespace Lantean.QBTMud.Components.Dialogs
|
||||
{
|
||||
public partial class AddTrackerDialog
|
||||
{
|
@@ -1,9 +1,9 @@
|
||||
using Lantean.QBitTorrentClient;
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
namespace Lantean.QBTMud.Components.Dialogs
|
||||
{
|
||||
public partial class CategoryPropertiesDialog
|
||||
{
|
@@ -1,8 +1,8 @@
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
namespace Lantean.QBTMud.Components.Dialogs
|
||||
{
|
||||
public partial class ColumnOptionsDialog<T>
|
||||
{
|
@@ -1,8 +1,8 @@
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
namespace Lantean.QBTMud.Components.Dialogs
|
||||
{
|
||||
public partial class ConfirmDialog
|
||||
{
|
@@ -1,8 +1,8 @@
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
namespace Lantean.QBTMud.Components.Dialogs
|
||||
{
|
||||
public partial class DeleteDialog
|
||||
{
|
@@ -1,7 +1,7 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
namespace Lantean.QBTMud.Components.Dialogs
|
||||
{
|
||||
public partial class ExceptionDialog
|
||||
{
|
@@ -1,10 +1,10 @@
|
||||
using Lantean.QBTMudBlade.Filter;
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Lantean.QBTMud.Filter;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
namespace Lantean.QBTMud.Components.Dialogs
|
||||
{
|
||||
public partial class FilterOptionsDialog<T>
|
||||
{
|
@@ -1,9 +1,9 @@
|
||||
using Lantean.QBitTorrentClient;
|
||||
using Lantean.QBTMudBlade.Helpers;
|
||||
using Lantean.QBTMud.Helpers;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
namespace Lantean.QBTMud.Components.Dialogs
|
||||
{
|
||||
public partial class ManageCategoriesDialog
|
||||
{
|
@@ -1,9 +1,9 @@
|
||||
using Lantean.QBitTorrentClient;
|
||||
using Lantean.QBTMudBlade.Helpers;
|
||||
using Lantean.QBTMud.Helpers;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
namespace Lantean.QBTMud.Components.Dialogs
|
||||
{
|
||||
public partial class ManageTagsDialog
|
||||
{
|
@@ -1,8 +1,8 @@
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
namespace Lantean.QBTMud.Components.Dialogs
|
||||
{
|
||||
public partial class MultipleFieldDialog
|
||||
{
|
@@ -1,9 +1,9 @@
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
namespace Lantean.QBTMud.Components.Dialogs
|
||||
{
|
||||
public partial class NumericFieldDialog<T> where T : struct, INumber<T>
|
||||
{
|
42
Lantean.QBTMud/Components/Dialogs/RenameFilesDialog.razor
Normal file
42
Lantean.QBTMud/Components/Dialogs/RenameFilesDialog.razor
Normal file
@@ -0,0 +1,42 @@
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
<MudGrid>
|
||||
<MudItem xs="12">
|
||||
<DynamicTable T="FileRow"
|
||||
ColumnDefinitions="Columns"
|
||||
Items="Files"
|
||||
MultiSelection="true"
|
||||
SelectedItems="SelectedItems"
|
||||
SelectedItemsChanged="SelectedItemsChanged"
|
||||
PreSorted="true"
|
||||
SortColumnChanged="SortColumnChanged"
|
||||
SortDirectionChanged="SortDirectionChanged"
|
||||
Class="file-list" />
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="Cancel">Close</MudButton>
|
||||
<MudButton Color="Color.Primary" OnClick="Submit">Rename</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@code {
|
||||
private static RenderFragment<RowContext<FileRow>> NameColumn
|
||||
{
|
||||
get
|
||||
{
|
||||
return context => __builder =>
|
||||
{
|
||||
<div style="@($"margin-left: {(context.Data.Level * 14) + (context.Data.Level >= 1 ? 16 : 0)}px")">
|
||||
@if (context.Data.IsFolder)
|
||||
{
|
||||
<MudIcon Icon="@Icons.Material.Filled.Folder" Class="pt-0" Style="margin-right: 4px; position: relative; top: 7px; margin-left: -15px" />
|
||||
}
|
||||
@context.Data.OriginalName
|
||||
</div>
|
||||
;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
468
Lantean.QBTMud/Components/Dialogs/RenameFilesDialog.razor.cs
Normal file
468
Lantean.QBTMud/Components/Dialogs/RenameFilesDialog.razor.cs
Normal file
@@ -0,0 +1,468 @@
|
||||
using Blazored.LocalStorage;
|
||||
using Lantean.QBitTorrentClient;
|
||||
using Lantean.QBTMud.Helpers;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Lantean.QBTMud.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Lantean.QBTMud.Components.Dialogs
|
||||
{
|
||||
public partial class RenameFilesDialog
|
||||
{
|
||||
private const string _preferencesStorageKey = "RenameFilesDialog.MultiRenamePreferences";
|
||||
|
||||
protected static readonly Dictionary<AppliesTo, string> AppliesToItems = Enum.GetValues<AppliesTo>().ToDictionary(v => v, v => v.GetDescriptionAttributeOrDefault());
|
||||
|
||||
private readonly Dictionary<string, RenderFragment<RowContext<FileRow>>> _columnRenderFragments = [];
|
||||
|
||||
private string? _sortColumn;
|
||||
private SortDirection _sortDirection;
|
||||
|
||||
[Inject]
|
||||
protected IApiClient ApiClient { get; set; } = default!;
|
||||
|
||||
[Inject]
|
||||
protected IDataManager DataManager { get; set; } = default!;
|
||||
|
||||
[Inject]
|
||||
protected ILocalStorageService LocalStorage { get; set; } = default!;
|
||||
|
||||
[CascadingParameter]
|
||||
public MudDialogInstance MudDialog { get; set; } = default!;
|
||||
|
||||
[Parameter]
|
||||
public string? Hash { get; set; }
|
||||
|
||||
protected HashSet<FileRow> SelectedItems { get; set; } = [];
|
||||
|
||||
protected IEnumerable<FileRow> FileList { get; private set; } = [];
|
||||
|
||||
protected IEnumerable<FileRow> Files => GetFiles();
|
||||
|
||||
protected HashSet<string> ExpandedNodes { get; set; } = [];
|
||||
|
||||
public RenameFilesDialog()
|
||||
{
|
||||
_columnRenderFragments.Add("Name", NameColumn);
|
||||
//_columnRenderFragments.Add("Replacement", ReplacementColumn);
|
||||
}
|
||||
|
||||
private ReadOnlyCollection<FileRow> GetFiles()
|
||||
{
|
||||
var maxLevel = FileList.Max(f => f.Level);
|
||||
// this is a flat file structure
|
||||
if (maxLevel == 0)
|
||||
{
|
||||
return FileList.OrderByDirection(_sortDirection, GetSortSelector()).ToList().AsReadOnly();
|
||||
}
|
||||
|
||||
var list = new List<FileRow>();
|
||||
|
||||
var rootItems = FileList.Where(c => c.Level == 0).OrderByDirection(_sortDirection, GetSortSelector()).ToList();
|
||||
foreach (var item in rootItems)
|
||||
{
|
||||
list.Add(item);
|
||||
|
||||
if (item.IsFolder)
|
||||
{
|
||||
var level = 0;
|
||||
var descendants = GetChildren(item, level);
|
||||
foreach (var descendant in descendants)
|
||||
{
|
||||
list.Add(descendant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list.AsReadOnly();
|
||||
}
|
||||
|
||||
private IEnumerable<FileRow> GetRenamedItems(IEnumerable<ContentItem> items)
|
||||
{
|
||||
var renamedFiles = FileNameMatcher.GetRenamedFiles(
|
||||
SelectedItems,
|
||||
Search,
|
||||
UseRegex,
|
||||
Replacement,
|
||||
MatchAllOccurrences,
|
||||
CaseSensitive,
|
||||
AppliesToValue,
|
||||
IncludeFiles,
|
||||
IncludeFolders,
|
||||
ReplaceAll,
|
||||
FileEnumerationStart);
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
var fileRow = CreateFileRow(item);
|
||||
if (renamedFiles.TryGetValue(fileRow.Name, out var renamedRow))
|
||||
{
|
||||
yield return renamedRow;
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return fileRow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static FileRow CreateFileRow(ContentItem item)
|
||||
{
|
||||
var fileRow = new FileRow
|
||||
{
|
||||
IsFolder = item.IsFolder,
|
||||
Level = item.Level,
|
||||
NewName = item.DisplayName,
|
||||
OriginalName = item.DisplayName,
|
||||
Name = item.Name,
|
||||
Path = item.Path,
|
||||
};
|
||||
|
||||
return fileRow;
|
||||
}
|
||||
|
||||
//private IEnumerable<(FileRow, string)> GetRenamedItemsOld(IEnumerable<FileRow> items)
|
||||
//{
|
||||
// foreach (var item in items)
|
||||
// {
|
||||
// if (!SelectedItems.Contains(item))
|
||||
// {
|
||||
// yield return (item, "");
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// if ((item.IsFolder && !IncludeFolders) || (!item.IsFolder && !IncludeFiles))
|
||||
// {
|
||||
// yield return (item, "");
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// if (string.IsNullOrEmpty(Search) || string.IsNullOrEmpty(Replacement))
|
||||
// {
|
||||
// yield return (item, "");
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// var newName = item.DisplayName;
|
||||
// switch (AppliesToValue)
|
||||
// {
|
||||
// case AppliesTo.FilenameExtension:
|
||||
// newName = ReplaceInString(item.DisplayName);
|
||||
// break;
|
||||
|
||||
// case AppliesTo.Filename:
|
||||
// var extension = Path.GetExtension(item.DisplayName);
|
||||
// var filename = Path.GetFileNameWithoutExtension(item.DisplayName);
|
||||
// filename = ReplaceInString(filename);
|
||||
// newName = filename + extension;
|
||||
// break;
|
||||
|
||||
// case AppliesTo.Extension:
|
||||
// extension = Path.GetExtension(item.DisplayName);
|
||||
// string newExtension = ReplaceInString(extension);
|
||||
// newName = Path.GetFileNameWithoutExtension(item.DisplayName) + newExtension;
|
||||
// break;
|
||||
// }
|
||||
|
||||
// yield return (item, newName);
|
||||
// }
|
||||
//}
|
||||
|
||||
//private string ReplaceInString(string input)
|
||||
//{
|
||||
// if (UseRegex)
|
||||
// {
|
||||
// var regex = new Regex(Search, CaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase);
|
||||
// return MatchAllOccurrences
|
||||
// ? regex.Replace(input, Replacement)
|
||||
// : regex.Replace(input, Replacement, 1);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var comparison = CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;
|
||||
|
||||
// if (MatchAllOccurrences)
|
||||
// {
|
||||
// return input.Replace(Search, Replacement, comparison);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var index = input.IndexOf(Search, comparison);
|
||||
// if (index == -1)
|
||||
// {
|
||||
// return input;
|
||||
// }
|
||||
// return input.Remove(index, Search.Length).Insert(index, Replacement);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
protected async Task DoRename()
|
||||
{
|
||||
if (Hash is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await RenameAsync(Hash, Files.Where(f => f.Renamed).ToList());
|
||||
}
|
||||
|
||||
private async Task RenameAsync(string hash, List<FileRow> matchedFiles)
|
||||
{
|
||||
if (matchedFiles == null || matchedFiles.Count == 0 || string.IsNullOrEmpty(hash))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = matchedFiles.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var file = matchedFiles[i];
|
||||
var (success, errorMessage) = await RenameItem(hash, file);
|
||||
file.Renamed = success;
|
||||
file.ErrorMessage = errorMessage;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<(bool, string?)> RenameItem(string hash, FileRow match)
|
||||
{
|
||||
if (match.NewName == match.OriginalName)
|
||||
{
|
||||
// Original file name is identical to Renamed
|
||||
return (false, null);
|
||||
}
|
||||
|
||||
var newName = match.NewName!;
|
||||
|
||||
var parentPath = Path.GetDirectoryName(match.Name);
|
||||
var oldPath = string.IsNullOrEmpty(parentPath)
|
||||
? match.OriginalName
|
||||
: Path.Combine(parentPath, match.OriginalName);
|
||||
var newPath = string.IsNullOrEmpty(parentPath)
|
||||
? newName
|
||||
: Path.Combine(parentPath, newName);
|
||||
|
||||
try
|
||||
{
|
||||
if (match.IsFolder)
|
||||
{
|
||||
await ApiClient.RenameFile(hash, oldPath, newPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
await ApiClient.RenameFile(hash, oldPath, newPath);
|
||||
}
|
||||
return (true, null);
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
return (false, ex.Message != "" ? ex.Message : $"Error with request: {ex.StatusCode}.");
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<FileRow> GetChildren(FileRow folder, int level)
|
||||
{
|
||||
level++;
|
||||
var descendantsKey = folder.Name.GetDescendantsKey(level);
|
||||
|
||||
foreach (var item in FileList.Where(f => f.Name.StartsWith(descendantsKey) && f.Level == level).OrderByDirection(_sortDirection, GetSortSelector()))
|
||||
{
|
||||
if (item.IsFolder)
|
||||
{
|
||||
var descendants = GetChildren(item, level);
|
||||
// if the filter returns some results then show folder item
|
||||
if (descendants.Any())
|
||||
{
|
||||
yield return item;
|
||||
}
|
||||
|
||||
// then show children
|
||||
foreach (var descendant in descendants)
|
||||
{
|
||||
yield return descendant;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Func<FileRow, object?> GetSortSelector()
|
||||
{
|
||||
var sortSelector = ColumnsDefinitions.Find(c => c.Id == _sortColumn)?.SortSelector;
|
||||
|
||||
return sortSelector ?? (i => i.Name);
|
||||
}
|
||||
|
||||
protected void SortColumnChanged(string sortColumn)
|
||||
{
|
||||
_sortColumn = sortColumn;
|
||||
}
|
||||
|
||||
protected void SortDirectionChanged(SortDirection sortDirection)
|
||||
{
|
||||
_sortDirection = sortDirection;
|
||||
}
|
||||
|
||||
protected void SelectedItemsChanged(HashSet<FileRow> selectedItems)
|
||||
{
|
||||
SelectedItems = selectedItems;
|
||||
}
|
||||
|
||||
protected string Search { get; set; } = "";
|
||||
|
||||
protected void SearchChanged(string value)
|
||||
{
|
||||
Search = value;
|
||||
}
|
||||
|
||||
protected bool UseRegex { get; set; }
|
||||
|
||||
protected void UseRegexChanged(bool value)
|
||||
{
|
||||
UseRegex = value;
|
||||
}
|
||||
|
||||
protected bool MatchAllOccurrences { get; set; }
|
||||
|
||||
protected void MatchAllOccurrencesChanged(bool value)
|
||||
{
|
||||
MatchAllOccurrences = value;
|
||||
}
|
||||
|
||||
protected bool CaseSensitive { get; set; }
|
||||
|
||||
protected void CaseSensitiveChanged(bool value)
|
||||
{
|
||||
CaseSensitive = value;
|
||||
}
|
||||
|
||||
protected string Replacement { get; set; } = "";
|
||||
|
||||
protected void ReplacementChanged(string value)
|
||||
{
|
||||
Replacement = value;
|
||||
}
|
||||
|
||||
protected AppliesTo AppliesToValue { get; set; } = AppliesTo.FilenameExtension;
|
||||
|
||||
protected void AppliesToChanged(AppliesTo value)
|
||||
{
|
||||
AppliesToValue = value;
|
||||
}
|
||||
|
||||
protected bool IncludeFiles { get; set; } = true;
|
||||
|
||||
protected void IncludeFilesChanged(bool value)
|
||||
{
|
||||
IncludeFiles = value;
|
||||
}
|
||||
|
||||
protected bool IncludeFolders { get; set; }
|
||||
|
||||
protected void IncludeFoldersChanged(bool value)
|
||||
{
|
||||
IncludeFolders = value;
|
||||
}
|
||||
|
||||
protected int FileEnumerationStart { get; set; }
|
||||
|
||||
protected void FileEnumerationStartChanged(int value)
|
||||
{
|
||||
FileEnumerationStart = value;
|
||||
}
|
||||
|
||||
protected bool ReplaceAll { get; set; }
|
||||
|
||||
protected void ReplaceAllChanged(bool value)
|
||||
{
|
||||
ReplaceAll = value;
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var preferences = await LocalStorage.GetItemAsync<MultiRenamePreferences>(_preferencesStorageKey) ?? new();
|
||||
|
||||
if (preferences.RememberPreferences)
|
||||
{
|
||||
Search = preferences.Search;
|
||||
UseRegex = preferences.UseRegex;
|
||||
MatchAllOccurrences = preferences.MatchAllOccurrences;
|
||||
CaseSensitive = preferences.CaseSensitive;
|
||||
Replacement = preferences.Replace;
|
||||
AppliesToValue = preferences.AppliesTo;
|
||||
IncludeFiles = preferences.IncludeFiles;
|
||||
IncludeFolders = preferences.IncludeFolders;
|
||||
FileEnumerationStart = preferences.FileEnumerationStart;
|
||||
ReplaceAll = preferences.ReplaceAll;
|
||||
}
|
||||
|
||||
if (Hash is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var contents = await ApiClient.GetTorrentContents(Hash);
|
||||
FileList = GetRenamedItems(DataManager.CreateContentsList(contents).Values);
|
||||
}
|
||||
|
||||
protected void Cancel()
|
||||
{
|
||||
MudDialog.Cancel();
|
||||
}
|
||||
|
||||
protected void Submit()
|
||||
{
|
||||
MudDialog.Close();
|
||||
}
|
||||
|
||||
protected IEnumerable<ColumnDefinition<FileRow>> Columns => GetColumnDefinitions();
|
||||
|
||||
private IEnumerable<ColumnDefinition<FileRow>> GetColumnDefinitions()
|
||||
{
|
||||
foreach (var columnDefinition in ColumnsDefinitions)
|
||||
{
|
||||
if (_columnRenderFragments.TryGetValue(columnDefinition.Header, out var fragment))
|
||||
{
|
||||
columnDefinition.RowTemplate = fragment;
|
||||
}
|
||||
|
||||
yield return columnDefinition;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<ColumnDefinition<FileRow>> ColumnsDefinitions { get; } =
|
||||
[
|
||||
ColumnDefinitionHelper.CreateColumnDefinition("Name", c => c.Name, NameColumn, width: 400, initialDirection: SortDirection.Ascending, classFunc: c => c.IsFolder ? "px-0 pt-0 pb-2" : "pa-2"),
|
||||
ColumnDefinitionHelper.CreateColumnDefinition<FileRow>("Replacement", c => c.NewName),
|
||||
];
|
||||
|
||||
private sealed class MultiRenamePreferences
|
||||
{
|
||||
public bool RememberPreferences { get; set; } = false;
|
||||
|
||||
public string Search { get; set; } = "";
|
||||
|
||||
public bool UseRegex { get; set; } = false;
|
||||
|
||||
public bool MatchAllOccurrences { get; set; } = false;
|
||||
|
||||
public bool CaseSensitive { get; set; } = false;
|
||||
|
||||
public string Replace { get; set; } = "";
|
||||
|
||||
public AppliesTo AppliesTo { get; set; } = AppliesTo.FilenameExtension;
|
||||
|
||||
public bool IncludeFiles { get; set; } = true;
|
||||
|
||||
public bool IncludeFolders { get; set; } = false;
|
||||
|
||||
public int FileEnumerationStart { get; set; } = 0;
|
||||
|
||||
public bool ReplaceAll { get; set; } = false;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,9 @@
|
||||
using Lantean.QBitTorrentClient;
|
||||
using Lantean.QBTMudBlade.Helpers;
|
||||
using Lantean.QBTMud.Helpers;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
namespace Lantean.QBTMud.Components.Dialogs
|
||||
{
|
||||
public partial class RssRulesDialog
|
||||
{
|
@@ -1,9 +1,9 @@
|
||||
using Lantean.QBitTorrentClient;
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
namespace Lantean.QBTMud.Components.Dialogs
|
||||
{
|
||||
public partial class ShareRatioDialog
|
||||
{
|
||||
@@ -67,7 +67,7 @@ namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (Value is null || (Value.RatioLimit == Limits.GlobalLimit && Value.SeedingTimeLimit == Limits.GlobalLimit && Value.InactiveSeedingTimeLimit == Limits.GlobalLimit))
|
||||
if (Value is null || Value.RatioLimit == Limits.GlobalLimit && Value.SeedingTimeLimit == Limits.GlobalLimit && Value.InactiveSeedingTimeLimit == Limits.GlobalLimit)
|
||||
{
|
||||
ShareRatioType = Limits.GlobalLimit;
|
||||
}
|
@@ -1,9 +1,9 @@
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
namespace Lantean.QBTMud.Components.Dialogs
|
||||
{
|
||||
public partial class SliderFieldDialog<T> where T : struct, INumber<T>
|
||||
{
|
@@ -1,8 +1,8 @@
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
namespace Lantean.QBTMud.Components.Dialogs
|
||||
{
|
||||
public partial class StringFieldDialog
|
||||
{
|
@@ -1,8 +1,8 @@
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
namespace Lantean.QBTMud.Components.Dialogs
|
||||
{
|
||||
public partial class SubMenuDialog
|
||||
{
|
@@ -1,8 +1,8 @@
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Lantean.QBTMudBlade.Services;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Lantean.QBTMud.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
namespace Lantean.QBTMud.Components.Dialogs
|
||||
{
|
||||
public abstract class SubmittableDialog : ComponentBase, IAsyncDisposable
|
||||
{
|
||||
@@ -43,4 +43,4 @@ namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,8 +1,8 @@
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
namespace Lantean.QBTMud.Components.Dialogs
|
||||
{
|
||||
public partial class TorrentOptionsDialog
|
||||
{
|
@@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Components.Rendering;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Runtime.ExceptionServices;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components
|
||||
namespace Lantean.QBTMud.Components
|
||||
{
|
||||
public class EnhancedErrorBoundary : ErrorBoundaryBase
|
||||
{
|
@@ -1,9 +1,9 @@
|
||||
using Lantean.QBTMudBlade.Components.Dialogs;
|
||||
using Lantean.QBTMudBlade.Helpers;
|
||||
using Lantean.QBTMud.Components.Dialogs;
|
||||
using Lantean.QBTMud.Helpers;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components
|
||||
namespace Lantean.QBTMud.Components
|
||||
{
|
||||
public partial class ErrorDisplay
|
||||
{
|
@@ -1,17 +1,17 @@
|
||||
using Blazored.LocalStorage;
|
||||
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 Lantean.QBTMud.Components.Dialogs;
|
||||
using Lantean.QBTMud.Components.UI;
|
||||
using Lantean.QBTMud.Filter;
|
||||
using Lantean.QBTMud.Helpers;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Lantean.QBTMud.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Net;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components
|
||||
namespace Lantean.QBTMud.Components
|
||||
{
|
||||
public partial class FilesTab : IAsyncDisposable
|
||||
{
|
||||
@@ -313,7 +313,7 @@ namespace Lantean.QBTMudBlade.Components
|
||||
}
|
||||
else
|
||||
{
|
||||
await DialogService.InvokeRenameFilesDialog(ApiClient, Hash);
|
||||
await DialogService.InvokeRenameFilesDialog(Hash);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -544,44 +544,12 @@ namespace Lantean.QBTMudBlade.Components
|
||||
|
||||
public static List<ColumnDefinition<ContentItem>> ColumnsDefinitions { get; } =
|
||||
[
|
||||
CreateColumnDefinition("Name", c => c.Name, width: 400, initialDirection: SortDirection.Ascending, classFunc: c => c.IsFolder ? "pa-0" : "pa-2"),
|
||||
CreateColumnDefinition("Total Size", c => c.Size, c => DisplayHelpers.Size(c.Size)),
|
||||
CreateColumnDefinition("Progress", c => c.Progress, ProgressBarColumn, tdClass: "table-progress pl-2 pr-2"),
|
||||
CreateColumnDefinition("Priority", c => c.Priority, tdClass: "table-select pa-0"),
|
||||
CreateColumnDefinition("Remaining", c => c.Remaining, c => DisplayHelpers.Size(c.Remaining)),
|
||||
CreateColumnDefinition("Availability", c => c.Availability, c => c.Availability.ToString("0.00")),
|
||||
ColumnDefinitionHelper.CreateColumnDefinition<ContentItem>("Name", c => c.Name, width: 400, initialDirection: SortDirection.Ascending, classFunc: c => c.IsFolder ? "pa-0" : "pa-2"),
|
||||
ColumnDefinitionHelper.CreateColumnDefinition<ContentItem>("Total Size", c => c.Size, c => DisplayHelpers.Size(c.Size)),
|
||||
ColumnDefinitionHelper.CreateColumnDefinition("Progress", c => c.Progress, ProgressBarColumn, tdClass: "table-progress pl-2 pr-2"),
|
||||
ColumnDefinitionHelper.CreateColumnDefinition<ContentItem>("Priority", c => c.Priority, tdClass: "table-select pa-0"),
|
||||
ColumnDefinitionHelper.CreateColumnDefinition<ContentItem>("Remaining", c => c.Remaining, c => DisplayHelpers.Size(c.Remaining)),
|
||||
ColumnDefinitionHelper.CreateColumnDefinition<ContentItem>("Availability", c => c.Availability, c => c.Availability.ToString("0.00")),
|
||||
];
|
||||
|
||||
private static ColumnDefinition<ContentItem> CreateColumnDefinition(string name, Func<ContentItem, object?> selector, RenderFragment<RowContext<ContentItem>> rowTemplate, int? width = null, string? tdClass = null, Func<ContentItem, string?>? classFunc = null, bool enabled = true, SortDirection initialDirection = SortDirection.None)
|
||||
{
|
||||
var cd = new ColumnDefinition<ContentItem>(name, selector, rowTemplate);
|
||||
cd.Class = "no-wrap";
|
||||
if (tdClass is not null)
|
||||
{
|
||||
cd.Class += " " + tdClass;
|
||||
}
|
||||
cd.ClassFunc = classFunc;
|
||||
cd.Width = width;
|
||||
cd.Enabled = enabled;
|
||||
cd.InitialDirection = initialDirection;
|
||||
|
||||
return cd;
|
||||
}
|
||||
|
||||
private static ColumnDefinition<ContentItem> CreateColumnDefinition(string name, Func<ContentItem, object?> selector, Func<ContentItem, string>? formatter = null, int? width = null, string? tdClass = null, Func<ContentItem, string?>? classFunc = null, bool enabled = true, SortDirection initialDirection = SortDirection.None)
|
||||
{
|
||||
var cd = new ColumnDefinition<ContentItem>(name, selector, formatter);
|
||||
cd.Class = "no-wrap";
|
||||
if (tdClass is not null)
|
||||
{
|
||||
cd.Class += " " + tdClass;
|
||||
}
|
||||
cd.ClassFunc = classFunc;
|
||||
cd.Width = width;
|
||||
cd.Enabled = enabled;
|
||||
cd.InitialDirection = initialDirection;
|
||||
|
||||
return cd;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,13 +1,14 @@
|
||||
using Blazored.LocalStorage;
|
||||
using Lantean.QBitTorrentClient;
|
||||
using Lantean.QBTMudBlade.Components.UI;
|
||||
using Lantean.QBTMudBlade.Helpers;
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Lantean.QBTMud.Components.UI;
|
||||
using Lantean.QBTMud.EventHandlers;
|
||||
using Lantean.QBTMud.Helpers;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components
|
||||
namespace Lantean.QBTMud.Components
|
||||
{
|
||||
public partial class FiltersNav
|
||||
{
|
||||
@@ -35,13 +36,13 @@ namespace Lantean.QBTMudBlade.Components
|
||||
protected string Tracker { get; set; } = FilterHelper.TRACKER_ALL;
|
||||
|
||||
[Inject]
|
||||
public ILocalStorageService LocalStorage { get; set; } = default!;
|
||||
protected ILocalStorageService LocalStorage { get; set; } = default!;
|
||||
|
||||
[Inject]
|
||||
public IDialogService DialogService { get; set; } = default!;
|
||||
protected IDialogService DialogService { get; set; } = default!;
|
||||
|
||||
[Inject]
|
||||
public IApiClient ApiClient { get; set; } = default!;
|
||||
protected IApiClient ApiClient { get; set; } = default!;
|
||||
|
||||
[CascadingParameter]
|
||||
public MainData? MainData { get; set; }
|
@@ -1,10 +1,10 @@
|
||||
using Lantean.QBitTorrentClient;
|
||||
using Lantean.QBitTorrentClient.Models;
|
||||
using Lantean.QBTMudBlade.Services;
|
||||
using Lantean.QBTMud.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Net;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components
|
||||
namespace Lantean.QBTMud.Components
|
||||
{
|
||||
public partial class GeneralTab : IAsyncDisposable
|
||||
{
|
@@ -1,10 +1,10 @@
|
||||
using Lantean.QBitTorrentClient;
|
||||
using Lantean.QBitTorrentClient.Models;
|
||||
using Lantean.QBTMudBlade.Helpers;
|
||||
using Lantean.QBTMud.Helpers;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components
|
||||
namespace Lantean.QBTMud.Components
|
||||
{
|
||||
public partial class Menu
|
||||
{
|
@@ -2,7 +2,7 @@
|
||||
using Lantean.QBitTorrentClient.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Options
|
||||
namespace Lantean.QBTMud.Components.Options
|
||||
{
|
||||
public partial class AdvancedOptions : Options
|
||||
{
|
@@ -1,6 +1,6 @@
|
||||
using Lantean.QBitTorrentClient.Models;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Options
|
||||
namespace Lantean.QBTMud.Components.Options
|
||||
{
|
||||
public partial class BehaviourOptions : Options
|
||||
{
|
@@ -1,4 +1,4 @@
|
||||
namespace Lantean.QBTMudBlade.Components.Options
|
||||
namespace Lantean.QBTMud.Components.Options
|
||||
{
|
||||
public partial class BitTorrentOptions : Options
|
||||
{
|
@@ -1,4 +1,4 @@
|
||||
namespace Lantean.QBTMudBlade.Components.Options
|
||||
namespace Lantean.QBTMud.Components.Options
|
||||
{
|
||||
public partial class ConnectionOptions : Options
|
||||
{
|
@@ -1,6 +1,6 @@
|
||||
using Lantean.QBitTorrentClient.Models;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Options
|
||||
namespace Lantean.QBTMud.Components.Options
|
||||
{
|
||||
public partial class DownloadsOptions : Options
|
||||
{
|
@@ -1,7 +1,7 @@
|
||||
using Lantean.QBitTorrentClient.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Options
|
||||
namespace Lantean.QBTMud.Components.Options
|
||||
{
|
||||
public abstract class Options : ComponentBase
|
||||
{
|
||||
@@ -23,7 +23,7 @@ namespace Lantean.QBTMudBlade.Components.Options
|
||||
[EditorRequired]
|
||||
public EventCallback<UpdatePreferences> PreferencesChanged { get; set; }
|
||||
|
||||
protected Func<int, string?> PortNonNegativeValidation = (int port) =>
|
||||
protected Func<int, string?> PortNonNegativeValidation = (port) =>
|
||||
{
|
||||
if (port < MinNonNegativePortValue || port > MaxPortValue)
|
||||
{
|
||||
@@ -33,7 +33,7 @@ namespace Lantean.QBTMudBlade.Components.Options
|
||||
return null;
|
||||
};
|
||||
|
||||
protected Func<int, string?> PortValidation = (int port) =>
|
||||
protected Func<int, string?> PortValidation = (port) =>
|
||||
{
|
||||
if (port < MinPortValue || port > MaxPortValue)
|
||||
{
|
@@ -1,8 +1,8 @@
|
||||
using Lantean.QBTMudBlade.Helpers;
|
||||
using Lantean.QBTMud.Helpers;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Options
|
||||
namespace Lantean.QBTMud.Components.Options
|
||||
{
|
||||
public partial class RSSOptions : Options
|
||||
{
|
@@ -1,4 +1,4 @@
|
||||
namespace Lantean.QBTMudBlade.Components.Options
|
||||
namespace Lantean.QBTMud.Components.Options
|
||||
{
|
||||
public partial class SpeedOptions : Options
|
||||
{
|
||||
@@ -71,8 +71,8 @@
|
||||
LimitTcpOverhead = Preferences.LimitTcpOverhead;
|
||||
LimitLanPeers = Preferences.LimitLanPeers;
|
||||
SchedulerEnabled = Preferences.SchedulerEnabled;
|
||||
ScheduleFrom = TimeSpan.FromMinutes((Preferences.ScheduleFromHour * 60) + Preferences.ScheduleFromMin);
|
||||
ScheduleTo = TimeSpan.FromMinutes((Preferences.ScheduleToHour * 60) + Preferences.ScheduleToMin);
|
||||
ScheduleFrom = TimeSpan.FromMinutes(Preferences.ScheduleFromHour * 60 + Preferences.ScheduleFromMin);
|
||||
ScheduleTo = TimeSpan.FromMinutes(Preferences.ScheduleToHour * 60 + Preferences.ScheduleToMin);
|
||||
SchedulerDays = Preferences.SchedulerDays;
|
||||
|
||||
return true;
|
@@ -1,8 +1,8 @@
|
||||
using Lantean.QBTMudBlade.Interop;
|
||||
using Lantean.QBTMud.Interop;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Options
|
||||
namespace Lantean.QBTMud.Components.Options
|
||||
{
|
||||
public partial class WebUIOptions : Options
|
||||
{
|
@@ -1,14 +1,14 @@
|
||||
using Lantean.QBitTorrentClient;
|
||||
using Lantean.QBTMudBlade.Components.UI;
|
||||
using Lantean.QBTMudBlade.Helpers;
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Lantean.QBTMudBlade.Services;
|
||||
using Lantean.QBTMud.Components.UI;
|
||||
using Lantean.QBTMud.Helpers;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Lantean.QBTMud.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
using System.Data;
|
||||
using System.Net;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components
|
||||
namespace Lantean.QBTMud.Components
|
||||
{
|
||||
public partial class PeersTab : IAsyncDisposable
|
||||
{
|
@@ -1,11 +1,11 @@
|
||||
using Lantean.QBitTorrentClient.Models;
|
||||
using Lantean.QBTMudBlade.Interop;
|
||||
using Lantean.QBTMud.Interop;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using MudBlazor;
|
||||
using MudBlazor.Services;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components
|
||||
namespace Lantean.QBTMud.Components
|
||||
{
|
||||
public partial class PieceProgress : IBrowserViewportObserver, IAsyncDisposable
|
||||
{
|
@@ -1,18 +1,21 @@
|
||||
using Lantean.QBitTorrentClient;
|
||||
using Lantean.QBTMudBlade.Components.Dialogs;
|
||||
using Lantean.QBTMudBlade.Helpers;
|
||||
using Lantean.QBTMudBlade.Interop;
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Lantean.QBTMudBlade.Services;
|
||||
using Lantean.QBTMud.Components.Dialogs;
|
||||
using Lantean.QBTMud.Helpers;
|
||||
using Lantean.QBTMud.Interop;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Lantean.QBTMud.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components
|
||||
namespace Lantean.QBTMud.Components
|
||||
{
|
||||
public partial class TorrentActions : IAsyncDisposable
|
||||
{
|
||||
private const int _defaultVersion = 5;
|
||||
|
||||
private bool _disposedValue;
|
||||
private int? _version;
|
||||
|
||||
private List<UIAction>? _actions;
|
||||
|
||||
@@ -37,6 +40,9 @@ namespace Lantean.QBTMudBlade.Components
|
||||
[Inject]
|
||||
protected IKeyboardService KeyboardService { get; set; } = default!;
|
||||
|
||||
[CascadingParameter(Name = "Version")]
|
||||
public string? Version { get; set; }
|
||||
|
||||
[Parameter]
|
||||
[EditorRequired]
|
||||
public IEnumerable<string> Hashes { get; set; } = default!;
|
||||
@@ -68,6 +74,31 @@ namespace Lantean.QBTMudBlade.Components
|
||||
|
||||
protected bool OverlayVisible { get; set; }
|
||||
|
||||
protected int MajorVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_version is not null)
|
||||
{
|
||||
return _version.Value;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(Version))
|
||||
{
|
||||
return _defaultVersion;
|
||||
}
|
||||
|
||||
if (!System.Version.TryParse(Version.Replace("v", ""), out var version))
|
||||
{
|
||||
return _defaultVersion;
|
||||
}
|
||||
|
||||
_version = version.Major;
|
||||
|
||||
return _version.Value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
_actions =
|
||||
@@ -124,7 +155,7 @@ namespace Lantean.QBTMudBlade.Components
|
||||
var actionCount = visibleActions.Count();
|
||||
var separatorCount = visibleActions.Count(c => c.SeparatorBefore);
|
||||
|
||||
return (actionCount * 36) + (separatorCount * 1);
|
||||
return actionCount * 36 + separatorCount * 1;
|
||||
}
|
||||
|
||||
protected async Task OverlayVisibleChanged(bool value)
|
||||
@@ -193,7 +224,7 @@ namespace Lantean.QBTMudBlade.Components
|
||||
|
||||
protected async Task RenameFiles()
|
||||
{
|
||||
await DialogService.InvokeRenameFilesDialog(ApiClient, Hashes.First());
|
||||
await DialogService.InvokeRenameFilesDialog(Hashes.First());
|
||||
}
|
||||
|
||||
protected async Task SetCategory(string category)
|
||||
@@ -403,13 +434,27 @@ namespace Lantean.QBTMudBlade.Components
|
||||
allAreSuperSeeding = false;
|
||||
}
|
||||
|
||||
if (torrent.State != "pausedUP" && torrent.State != "pausedDL")
|
||||
if (MajorVersion < 5)
|
||||
{
|
||||
allArePaused = false;
|
||||
if (torrent.State != "pausedUP" && torrent.State != "pausedDL")
|
||||
{
|
||||
allArePaused = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
thereArePaused = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
thereArePaused = true;
|
||||
if (torrent.State != "stoppedUP" && torrent.State != "stoppedDL")
|
||||
{
|
||||
allArePaused = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
thereArePaused = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!torrent.ForceStart)
|
||||
@@ -510,6 +555,27 @@ namespace Lantean.QBTMudBlade.Components
|
||||
actionStates["start"] = ActionState.Hidden;
|
||||
}
|
||||
|
||||
if (MajorVersion >= 5)
|
||||
{
|
||||
if (actionStates.ContainsKey("start"))
|
||||
{
|
||||
actionStates["start"].TextOverride = "Start";
|
||||
}
|
||||
else
|
||||
{
|
||||
actionStates["start"] = new ActionState { TextOverride = "Start" };
|
||||
}
|
||||
|
||||
if (actionStates.ContainsKey("pause"))
|
||||
{
|
||||
actionStates["pause"].TextOverride = "Stop";
|
||||
}
|
||||
else
|
||||
{
|
||||
actionStates["pause"] = new ActionState { TextOverride = "Stop" };
|
||||
}
|
||||
}
|
||||
|
||||
if (!allAreAutoTmm && thereAreAutoTmm)
|
||||
{
|
||||
actionStates["autoTorrentManagement"] = ActionState.Hidden;
|
||||
@@ -552,6 +618,10 @@ namespace Lantean.QBTMudBlade.Components
|
||||
{
|
||||
act.IsChecked = actionState.IsChecked.Value;
|
||||
}
|
||||
if (actionState.TextOverride is not null)
|
||||
{
|
||||
act.Text = actionState.TextOverride;
|
||||
}
|
||||
|
||||
yield return act;
|
||||
}
|
||||
@@ -567,6 +637,8 @@ namespace Lantean.QBTMudBlade.Components
|
||||
|
||||
public bool? IsChecked { get; set; }
|
||||
|
||||
public string? TextOverride { get; set; }
|
||||
|
||||
public static readonly ActionState Hidden = new() { Show = false };
|
||||
|
||||
public static readonly ActionState HasSeperator = new() { HasSeparator = true };
|
||||
@@ -588,7 +660,6 @@ namespace Lantean.QBTMudBlade.Components
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
@@ -1,7 +1,7 @@
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components
|
||||
namespace Lantean.QBTMud.Components
|
||||
{
|
||||
public partial class TorrentInfo
|
||||
{
|
@@ -1,9 +1,9 @@
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Lantean.QBTMudBlade.Pages;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Lantean.QBTMud.Pages;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components
|
||||
namespace Lantean.QBTMud.Components
|
||||
{
|
||||
public partial class TorrentsListNav
|
||||
{
|
@@ -1,16 +1,16 @@
|
||||
using Lantean.QBitTorrentClient;
|
||||
using Lantean.QBitTorrentClient.Models;
|
||||
using Lantean.QBTMudBlade.Components.UI;
|
||||
using Lantean.QBTMudBlade.Helpers;
|
||||
using Lantean.QBTMudBlade.Interop;
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Lantean.QBTMudBlade.Services;
|
||||
using Lantean.QBTMud.Components.UI;
|
||||
using Lantean.QBTMud.Helpers;
|
||||
using Lantean.QBTMud.Interop;
|
||||
using Lantean.QBTMud.Models;
|
||||
using Lantean.QBTMud.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using MudBlazor;
|
||||
using System.Net;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components
|
||||
namespace Lantean.QBTMud.Components
|
||||
{
|
||||
public partial class TrackersTab : IAsyncDisposable
|
||||
{
|
||||
@@ -168,7 +168,7 @@ namespace Lantean.QBTMudBlade.Components
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
await ApiClient.AddTrackersToTorrent(Hash, trackers);
|
||||
}
|
||||
|
@@ -1,11 +1,12 @@
|
||||
using Lantean.QBTMudBlade.Interop;
|
||||
using Lantean.QBTMud.EventHandlers;
|
||||
using Lantean.QBTMud.Interop;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.JSInterop;
|
||||
using MudBlazor;
|
||||
using MudBlazor.Utilities;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.UI
|
||||
namespace Lantean.QBTMud.Components.UI
|
||||
{
|
||||
// This is a very hacky approach but works for now.
|
||||
// This needs to inherit from MudMenu because MudMenuItem needs a MudMenu passed to it to control the close of the menu when an item is clicked.
|
@@ -1,9 +1,10 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Lantean.QBTMud.EventHandlers;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using MudBlazor;
|
||||
using MudBlazor.Utilities;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.UI
|
||||
namespace Lantean.QBTMud.Components.UI
|
||||
{
|
||||
public partial class CustomNavLink
|
||||
{
|
||||
@@ -49,7 +50,6 @@ namespace Lantean.QBTMudBlade.Components.UI
|
||||
[Parameter]
|
||||
public RenderFragment? ContextMenu { get; set; }
|
||||
|
||||
|
||||
protected string Classname =>
|
||||
new CssBuilder("mud-nav-item")
|
||||
.AddClass($"mud-ripple", !DisableRipple && !Disabled)
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user