mirror of
https://github.com/lantean-code/qbtmud.git
synced 2025-10-23 04:52:22 +00:00
Update torrent actions
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<DialogContent>
|
||||
<MudGrid>
|
||||
<MudItem xs="12">
|
||||
<MudTextField Label="Urls" Lines="10" @bind-Value="Urls" Variant="Variant.Filled" />
|
||||
<MudTextField Label="Urls" Lines="10" @bind-Value="Urls" Variant="Variant.Outlined" />
|
||||
</MudItem>
|
||||
<AddTorrentOptions @ref="TorrentOptions" ShowCookieOption />
|
||||
</MudGrid>
|
||||
|
@@ -1,23 +1,23 @@
|
||||
<MudItem xs="12">
|
||||
<MudSelect Label="Torrent Management Mode" @bind-Value="TorrentManagementMode" Variant="Variant.Filled">
|
||||
<MudSelect Label="Torrent Management Mode" @bind-Value="TorrentManagementMode" Variant="Variant.Outlined">
|
||||
<MudSelectItem Value="false">Manual</MudSelectItem>
|
||||
<MudSelectItem Value="true">Automatic</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudTextField Label="Save files to location" @bind-Value="SavePath" Variant="Variant.Filled"></MudTextField>
|
||||
<MudTextField Label="Save files to location" @bind-Value="SavePath" Variant="Variant.Outlined"></MudTextField>
|
||||
</MudItem>
|
||||
@if (ShowCookieOption)
|
||||
{
|
||||
<MudItem xs="12">
|
||||
<MudTextField Label="Cookie" @bind-Value="Cookie" Variant="Variant.Filled"></MudTextField>
|
||||
<MudTextField Label="Cookie" @bind-Value="Cookie" Variant="Variant.Outlined"></MudTextField>
|
||||
</MudItem>
|
||||
}
|
||||
<MudItem xs="12">
|
||||
<MudTextField Label="Rename" @bind-Value="RenameTorrent" Variant="Variant.Filled"></MudTextField>
|
||||
<MudTextField Label="Rename" @bind-Value="RenameTorrent" Variant="Variant.Outlined"></MudTextField>
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudSelect Label="Category" @bind-Value="Category" Variant="Variant.Filled">
|
||||
<MudSelect Label="Category" @bind-Value="Category" Variant="Variant.Outlined">
|
||||
@foreach (var category in Categories)
|
||||
{
|
||||
<MudSelectItem Value="category">@category</MudSelectItem>
|
||||
@@ -25,38 +25,38 @@
|
||||
</MudSelect>
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudCheckBox Label="Start torrent" @bind-Value="StartTorrent" LabelPosition="LabelPosition.End" />
|
||||
<MudFieldSwitch Label="Start torrent" @bind-Value="StartTorrent" />
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudCheckBox Label="Add to top of queue" @bind-Value="AddToTopOfQueue" LabelPosition="LabelPosition.End" />
|
||||
<MudFieldSwitch Label="Add to top of queue" @bind-Value="AddToTopOfQueue" />
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudSelect Label="Stop condition" @bind-Value="StopCondition" Variant="Variant.Filled">
|
||||
<MudSelect Label="Stop condition" @bind-Value="StopCondition" Variant="Variant.Outlined">
|
||||
<MudSelectItem Value="@("None")">None</MudSelectItem>
|
||||
<MudSelectItem Value="@("MetadataReceived")">Metadata received</MudSelectItem>
|
||||
<MudSelectItem Value="@("FilesChecked")">Files checked</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudCheckBox Label="Add to top of queue" @bind-Value="AddToTopOfQueue" LabelPosition="LabelPosition.End" />
|
||||
<MudFieldSwitch Label="Add to top of queue" @bind-Value="AddToTopOfQueue" />
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudCheckBox Label="Skip hash check" @bind-Value="SkipHashCheck" LabelPosition="LabelPosition.End" />
|
||||
<MudFieldSwitch Label="Skip hash check" @bind-Value="SkipHashCheck" />
|
||||
</MudItem>
|
||||
<MudSelect Label="Content layout" @bind-Value="ContentLayout" Variant="Variant.Filled">
|
||||
<MudSelect Label="Content layout" @bind-Value="ContentLayout" Variant="Variant.Outlined">
|
||||
<MudSelectItem Value="@("Original")">Original</MudSelectItem>
|
||||
<MudSelectItem Value="@("Subfolder")">Create subfolder</MudSelectItem>
|
||||
<MudSelectItem Value="@("NoSubfolder")">Don't create subfolder'</MudSelectItem>
|
||||
</MudSelect>
|
||||
<MudItem xs="12">
|
||||
<MudCheckBox Label="Download in sequentual order" @bind-Value="DownloadInSequentialOrder" LabelPosition="LabelPosition.End" />
|
||||
<MudFieldSwitch Label="Download in sequentual order" @bind-Value="DownloadInSequentialOrder" />
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudCheckBox Label="Download first and last pieces first" @bind-Value="DownloadFirstAndLastPiecesFirst" LabelPosition="LabelPosition.End" />
|
||||
<MudFieldSwitch Label="Download first and last pieces first" @bind-Value="DownloadFirstAndLastPiecesFirst" />
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudNumericField Label="Limit download rate" @bind-Value="DownloadLimit" Variant="Variant.Filled" Min="0" />
|
||||
<MudNumericField Label="Limit download rate" @bind-Value="DownloadLimit" Variant="Variant.Outlined" Min="0" />
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudNumericField Label="Limit upload rate" @bind-Value="UploadLimit" Variant="Variant.Filled" Min="0" />
|
||||
<MudNumericField Label="Limit upload rate" @bind-Value="UploadLimit" Variant="Variant.Outlined" Min="0" />
|
||||
</MudItem>
|
@@ -0,0 +1,12 @@
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
<MudGrid>
|
||||
<MudItem xs="12">
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="Cancel">Close</MudButton>
|
||||
<MudButton Color="Color.Primary" OnClick="Submit">Rename</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
@@ -0,0 +1,23 @@
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
{
|
||||
public partial class RenameFilesDialog
|
||||
{
|
||||
[CascadingParameter]
|
||||
public MudDialogInstance MudDialog { get; set; } = default!;
|
||||
|
||||
protected void Cancel(MouseEventArgs args)
|
||||
{
|
||||
MudDialog.Cancel();
|
||||
}
|
||||
|
||||
protected void Submit(MouseEventArgs args)
|
||||
{
|
||||
MudDialog.Close();
|
||||
}
|
||||
}
|
||||
}
|
12
Lantean.QBTMudBlade/Components/Dialogs/RssRulesDialog.razor
Normal file
12
Lantean.QBTMudBlade/Components/Dialogs/RssRulesDialog.razor
Normal file
@@ -0,0 +1,12 @@
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
<MudGrid>
|
||||
<MudItem xs="12">
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="Cancel">Close</MudButton>
|
||||
<MudButton Color="Color.Primary" OnClick="Submit">Save</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
@@ -0,0 +1,22 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
{
|
||||
public partial class RssRulesDialog
|
||||
{
|
||||
[CascadingParameter]
|
||||
public MudDialogInstance MudDialog { get; set; } = default!;
|
||||
|
||||
protected void Cancel(MouseEventArgs args)
|
||||
{
|
||||
MudDialog.Cancel();
|
||||
}
|
||||
|
||||
protected void Submit(MouseEventArgs args)
|
||||
{
|
||||
MudDialog.Close();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +0,0 @@
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
<MudText>Statistics</MudText>
|
||||
</DialogContent>
|
||||
</MudDialog>
|
@@ -1,11 +0,0 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Dialogs
|
||||
{
|
||||
public partial class StatisticsDialog
|
||||
{
|
||||
[CascadingParameter]
|
||||
public MudDialogInstance MudDialog { get; set; } = default!;
|
||||
}
|
||||
}
|
@@ -13,12 +13,12 @@
|
||||
<MudDivider Vertical="true" />
|
||||
<MudIconButton Icon="@Icons.Material.Outlined.ViewColumn" Color="Color.Inherit" OnClick="ColumnOptions" Title="Choose Columns" />
|
||||
<MudDivider Vertical="true" />
|
||||
<MudMenu Icon="@Icons.Material.Outlined.FileDownloadOff" Label="Do Not Download" AnchorOrigin="Origin.BottomLeft" TransformOrigin="Origin.TopLeft">
|
||||
<MudMenu Icon="@Icons.Material.Outlined.FileDownloadOff" Label="Do Not Download" AnchorOrigin="Origin.BottomLeft" TransformOrigin="Origin.TopLeft" title="Do Not Download">
|
||||
<MudMenuItem OnClick="DoNotDownloadLessThan100PercentAvailability" OnTouch="DoNotDownloadLessThan100PercentAvailability">Less Than 100% Availability</MudMenuItem>
|
||||
<MudMenuItem OnClick="DoNotDownloadLessThan80PercentAvailability" OnTouch="DoNotDownloadLessThan80PercentAvailability">Less than 80% Availability</MudMenuItem>
|
||||
<MudMenuItem OnClick="DoNotDownloadCurrentlyFilteredFiles" OnTouch="NormalPriorityCurrentlyFilteredFiles">Currently Filtered Files</MudMenuItem>
|
||||
</MudMenu>
|
||||
<MudMenu Icon="@Icons.Material.Outlined.FileDownload" Label="Normal Priority" AnchorOrigin="Origin.BottomLeft" TransformOrigin="Origin.TopLeft">
|
||||
<MudMenu Icon="@Icons.Material.Outlined.FileDownload" Label="Normal Priority" AnchorOrigin="Origin.BottomLeft" TransformOrigin="Origin.TopLeft" title="Download">
|
||||
<MudMenuItem OnClick="NormalPriorityLessThan100PercentAvailability" OnTouch="NormalPriorityLessThan100PercentAvailability">Less Than 100% Availability</MudMenuItem>
|
||||
<MudMenuItem OnClick="NormalPriorityLessThan80PercentAvailability" OnTouch="NormalPriorityLessThan80PercentAvailability">Less than 80% Availability</MudMenuItem>
|
||||
<MudMenuItem OnClick="NormalPriorityCurrentlyFilteredFiles" OnTouch="NormalPriorityCurrentlyFilteredFiles">Currently Filtered Files</MudMenuItem>
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using Lantean.QBitTorrentClient;
|
||||
using Blazored.LocalStorage;
|
||||
using Lantean.QBitTorrentClient;
|
||||
using Lantean.QBTMudBlade.Components.Dialogs;
|
||||
using Lantean.QBTMudBlade.Filter;
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
@@ -8,12 +9,15 @@ using Microsoft.AspNetCore.Components.Web;
|
||||
using MudBlazor;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Net;
|
||||
using static MudBlazor.CategoryTypes;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components
|
||||
{
|
||||
public partial class FilesTab : IAsyncDisposable
|
||||
{
|
||||
private readonly bool _refreshEnabled = true;
|
||||
|
||||
private const string _columnStorageKey = "FilesTab.Columns";
|
||||
|
||||
private readonly CancellationTokenSource _timerCancellationToken = new();
|
||||
private bool _disposedValue;
|
||||
|
||||
@@ -39,6 +43,9 @@ namespace Lantean.QBTMudBlade.Components
|
||||
[Inject]
|
||||
protected IDataManager DataManager { get; set; } = default!;
|
||||
|
||||
[Inject]
|
||||
protected ILocalStorageService LocalStorage { get; set; } = default!;
|
||||
|
||||
protected HashSet<string> ExpandedNodes { get; set; } = [];
|
||||
|
||||
protected Dictionary<string, ContentItem>? FileList { get; set; }
|
||||
@@ -71,6 +78,22 @@ namespace Lantean.QBTMudBlade.Components
|
||||
SelectedColumns = _columns.Where(c => c.Enabled).Select(c => c.Id).ToHashSet();
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (!await LocalStorage.ContainKeyAsync(_columnStorageKey))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var selectedColumns = await LocalStorage.GetItemAsync<HashSet<string>>(_columnStorageKey);
|
||||
if (selectedColumns is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SelectedColumns = selectedColumns;
|
||||
}
|
||||
|
||||
protected IEnumerable<ColumnDefinition<ContentItem>> GetColumns()
|
||||
{
|
||||
return _columns.Where(c => SelectedColumns.Contains(c.Id));
|
||||
@@ -92,6 +115,8 @@ namespace Lantean.QBTMudBlade.Components
|
||||
}
|
||||
|
||||
SelectedColumns = (HashSet<string>)result.Data;
|
||||
|
||||
await LocalStorage.SetItemAsync(_columnStorageKey, SelectedColumns);
|
||||
}
|
||||
|
||||
protected async Task ShowFilterDialog()
|
||||
@@ -163,7 +188,7 @@ namespace Lantean.QBTMudBlade.Components
|
||||
_timerCancellationToken.Cancel();
|
||||
_timerCancellationToken.Dispose();
|
||||
|
||||
await Task.Delay(0);
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
_disposedValue = true;
|
||||
@@ -193,6 +218,11 @@ namespace Lantean.QBTMudBlade.Components
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (!_refreshEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!firstRender)
|
||||
{
|
||||
return;
|
||||
@@ -304,11 +334,11 @@ namespace Lantean.QBTMudBlade.Components
|
||||
protected string RowStyle(ContentItem item, int index)
|
||||
{
|
||||
var style = "user-select: none; cursor: pointer;";
|
||||
if (_selectedIndex == item.Index)
|
||||
if (_selectedIndex != item.Index)
|
||||
{
|
||||
style += " background: #D3D3D3";
|
||||
return style;
|
||||
}
|
||||
return style;
|
||||
return $"{style} background: #D3D3D3";
|
||||
}
|
||||
|
||||
protected async Task SelectedItemsChanged(HashSet<ContentItem> selectedItems)
|
||||
|
@@ -1,4 +1,6 @@
|
||||
<MudContainer MaxWidth="MaxWidth.ExtraExtraLarge">
|
||||
<MudText Typo="Typo.subtitle2" Class="pt-6">Progress</MudText>
|
||||
<PieceProgress Pieces="Pieces" Hash="@Hash" />
|
||||
<MudText Typo="Typo.subtitle2" Class="pt-6">Transfer</MudText>
|
||||
<MudGrid>
|
||||
<MudItem xs="4">
|
||||
@@ -53,7 +55,7 @@
|
||||
|
||||
</MudGrid>
|
||||
|
||||
<MudText Typo="Typo.subtitle1" Class="pt-6">Information</MudText>
|
||||
<MudText Typo="Typo.subtitle2" Class="pt-6">Information</MudText>
|
||||
<MudGrid>
|
||||
<MudItem xs="4">
|
||||
<MudField Label="Total Size">@DisplayHelpers.Size(Properties?.TotalSize)</MudField>
|
||||
|
@@ -8,6 +8,8 @@ namespace Lantean.QBTMudBlade.Components
|
||||
{
|
||||
public partial class GeneralTab : IAsyncDisposable
|
||||
{
|
||||
private readonly bool _refreshEnabled = true;
|
||||
|
||||
private readonly CancellationTokenSource _timerCancellationToken = new();
|
||||
private bool _disposedValue;
|
||||
|
||||
@@ -50,6 +52,11 @@ namespace Lantean.QBTMudBlade.Components
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (!_refreshEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (firstRender)
|
||||
{
|
||||
using (var timer = new PeriodicTimer(TimeSpan.FromMilliseconds(RefreshInterval)))
|
||||
@@ -84,7 +91,8 @@ namespace Lantean.QBTMudBlade.Components
|
||||
{
|
||||
_timerCancellationToken.Cancel();
|
||||
_timerCancellationToken.Dispose();
|
||||
await Task.Delay(0);
|
||||
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
_disposedValue = true;
|
||||
|
@@ -15,7 +15,7 @@
|
||||
</MudSelect>
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudNumericField T="int" Label="Physical memory (RAM) usage limit (applied if libtorrent >= 2.0)" Value="MemoryWorkingSetLimit" ValueChanged="MemoryWorkingSetLimitChanged" Min="0" HelperText="This option is less effective on Linux" ShrinkLabel Variant="Variant.Outlined" /> <MudText Typo="Typo.caption">MiB</MudText>
|
||||
<MudNumericField T="int" Label="Physical memory (RAM) usage limit (applied if libtorrent >= 2.0)" Value="MemoryWorkingSetLimit" ValueChanged="MemoryWorkingSetLimitChanged" Min="0" HelperText="This option is less effective on Linux" ShrinkLabel Variant="Variant.Outlined" Adornment="Adornment.End" AdornmentText="MiB" />
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudSelect T="string" Label="Network interface" Value="CurrentNetworkInterface" ValueChanged="CurrentNetworkInterfaceChanged" ShrinkLabel Variant="Variant.Outlined">
|
||||
|
@@ -607,7 +607,5 @@ namespace Lantean.QBTMudBlade.Components.Options
|
||||
UpdatePreferences.I2pOutboundLength = value;
|
||||
await PreferencesChanged.InvokeAsync(UpdatePreferences);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@@ -81,7 +81,7 @@
|
||||
<MudNumericField T="int" Label="Slots" Value="I2pPort" ValueChanged="I2pPortChanged" Min="0" Max="65535" Disabled="@(!I2pEnabled)" ShrinkLabel Variant="Variant.Outlined" />
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudFieldSwitch Label="Mixed mode" Value="I2pMixedMode" ValueChanged="I2pMixedModeChanged" Disabled="@(!I2pEnabled)" title="If "mixed mode" is enabled, I2P torrents are allowed to also get peers from other sources than the tracker, and connect to regular IPs, not providing any anonymization. This may be useful if the user is not interested in the anonymization of I2P, but still wants to be able to connect to I2P peers." />
|
||||
<MudFieldSwitch Label="Mixed mode" Value="I2pMixedMode" ValueChanged="I2pMixedModeChanged" Disabled="@(!I2pEnabled)" HelperText="If "mixed mode" is enabled, I2P torrents are allowed to also get peers from other sources than the tracker, and connect to regular IPs, not providing any anonymization. This may be useful if the user is not interested in the anonymization of I2P, but still wants to be able to connect to I2P peers." />
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
</MudCardContent>
|
||||
|
@@ -86,7 +86,7 @@
|
||||
</MudSelect>
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudFieldSwitch Label="Use Subcategories" Value="UseSubcategories" ValueChanged="UseSubcategoriesChanged" LabelPosition="LabelPosition.End" />
|
||||
<MudFieldSwitch Label="Use Subcategories" Value="UseSubcategories" ValueChanged="UseSubcategoriesChanged" />
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudTextField T="string" Label="Default Save Path" Value="SavePath" ValueChanged="SavePathChanged" ShrinkLabel Variant="Variant.Outlined" />
|
||||
@@ -94,7 +94,7 @@
|
||||
<MudItem xs="12">
|
||||
<MudGrid>
|
||||
<MudItem xs="12" sm="6" md="3">
|
||||
<MudFieldSwitch Label="Keep incomplete torrents in" Value="TempPathEnabled" ValueChanged="TempPathEnabledChanged" LabelPosition="LabelPosition.End" />
|
||||
<MudFieldSwitch Label="Keep incomplete torrents in" Value="TempPathEnabled" ValueChanged="TempPathEnabledChanged" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" md="9">
|
||||
<MudTextField T="string" Label="Path" Value="TempPath" ValueChanged="TempPathChanged" Disabled="@(!TempPathEnabled)" ShrinkLabel Variant="Variant.Outlined" />
|
||||
@@ -104,7 +104,7 @@
|
||||
<MudItem xs="12">
|
||||
<MudGrid>
|
||||
<MudItem xs="12" sm="6" md="3">
|
||||
<MudFieldSwitch Label="Copy .torrent files to" Value="ExportDirEnabled" ValueChanged="ExportDirEnabledChanged" LabelPosition="LabelPosition.End" />
|
||||
<MudFieldSwitch Label="Copy .torrent files to" Value="ExportDirEnabled" ValueChanged="ExportDirEnabledChanged" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" md="9">
|
||||
<MudTextField T="string" Label="Path" Value="ExportDir" ValueChanged="ExportDirChanged" Disabled="@(!TempPathEnabled)" ShrinkLabel Variant="Variant.Outlined" />
|
||||
@@ -114,7 +114,7 @@
|
||||
<MudItem xs="12">
|
||||
<MudGrid>
|
||||
<MudItem xs="12" sm="6" md="3">
|
||||
<MudFieldSwitch Label="Copy .torrent files for finished downloads to" Value="ExportDirFinEnabled" ValueChanged="ExportDirFinEnabledChanged" LabelPosition="LabelPosition.End" />
|
||||
<MudFieldSwitch Label="Copy .torrent files for finished downloads to" Value="ExportDirFinEnabled" ValueChanged="ExportDirFinEnabledChanged" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" md="9">
|
||||
<MudTextField T="string" Label="Path" Value="ExportDirFin" ValueChanged="ExportDirFinChanged" Disabled="@(!TempPathEnabled)" ShrinkLabel Variant="Variant.Outlined" />
|
||||
@@ -222,7 +222,7 @@
|
||||
<MudCardContent>
|
||||
<MudGrid>
|
||||
<MudItem xs="12">
|
||||
<MudFieldSwitch Label="Excluded file names" Value="ExcludedFileNamesEnabled" ValueChanged="ExcludedFileNamesEnabledChanged" LabelPosition="LabelPosition.End" />
|
||||
<MudFieldSwitch Label="Excluded file names" Value="ExcludedFileNamesEnabled" ValueChanged="ExcludedFileNamesEnabledChanged" />
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudTextField T="string" Label="Excluded files names" Value="ExcludedFileNames" ValueChanged="ExcludedFileNamesChanged" Lines="5" Disabled="@(!ExcludedFileNamesEnabled)" ShrinkLabel Variant="Variant.Outlined" />
|
||||
|
@@ -9,10 +9,10 @@
|
||||
<MudCardContent Class="pt-0">
|
||||
<MudGrid>
|
||||
<MudItem xs="12">
|
||||
<MudCheckBox T="bool" Label="Enable fetching RSS feeds" Value="RssProcessingEnabled" ValueChanged="RssProcessingEnabledChanged" LabelPosition="LabelPosition.End" />
|
||||
<MudFieldSwitch Label="Enable fetching RSS feeds" Value="RssProcessingEnabled" ValueChanged="RssProcessingEnabledChanged" />
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudNumericField T="int" Label="Feeds refresh interval" Value="RssRefreshInterval" ValueChanged="RssRefreshIntervalChanged" Min="0" ShrinkLabel Variant="Variant.Outlined" /> <MudText Typo="Typo.caption">min</MudText>
|
||||
<MudNumericField T="int" Label="Feeds refresh interval" Value="RssRefreshInterval" ValueChanged="RssRefreshIntervalChanged" Min="0" ShrinkLabel Variant="Variant.Outlined" Adornment="Adornment.End" AdornmentText="min" />
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudNumericField T="int" Label="Maximum number of articles per feed" Value="RssMaxArticlesPerFeed" ValueChanged="RssMaxArticlesPerFeedChanged" Min="0" ShrinkLabel Variant="Variant.Outlined" />
|
||||
@@ -30,7 +30,7 @@
|
||||
<MudCardContent Class="pt-0">
|
||||
<MudGrid>
|
||||
<MudItem xs="12">
|
||||
<MudCheckBox T="bool" Label="Enable auto downloading of RSS torrents" Value="RssAutoDownloadingEnabled" ValueChanged="RssAutoDownloadingEnabledChanged" LabelPosition="LabelPosition.End" />
|
||||
<MudFieldSwitch Label="Enable auto downloading of RSS torrents" Value="RssAutoDownloadingEnabled" ValueChanged="RssAutoDownloadingEnabledChanged" />
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudButton OnClick="OpenRssRulesDialog" Variant="Variant.Filled">Edit auto downloading rules</MudButton>
|
||||
@@ -48,7 +48,7 @@
|
||||
<MudCardContent Class="pt-0">
|
||||
<MudGrid>
|
||||
<MudItem xs="12">
|
||||
<MudCheckBox T="bool" Label="Download REPACK/PROPER episodes" Value="RssDownloadRepackProperEpisodes" ValueChanged="RssDownloadRepackProperEpisodesChanged" LabelPosition="LabelPosition.End" />
|
||||
<MudFieldSwitch Label="Download REPACK/PROPER episodes" Value="RssDownloadRepackProperEpisodes" ValueChanged="RssDownloadRepackProperEpisodesChanged" />
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudTextField T="string" Label="Filters" Value="RssSmartEpisodeFilters" ValueChanged="RssSmartEpisodeFiltersChanged" Lines="5" ShrinkLabel Variant="Variant.Outlined" />
|
||||
|
@@ -1,7 +1,13 @@
|
||||
namespace Lantean.QBTMudBlade.Components.Options
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Options
|
||||
{
|
||||
public partial class RSSOptions : Options
|
||||
{
|
||||
[Inject]
|
||||
public IDialogService DialogService { get; set; } = default!;
|
||||
|
||||
protected bool RssProcessingEnabled { get; private set; }
|
||||
protected int RssRefreshInterval { get; private set; }
|
||||
protected long RssFetchDelay { get; private set; }
|
||||
@@ -79,7 +85,7 @@
|
||||
|
||||
protected async Task OpenRssRulesDialog()
|
||||
{
|
||||
await Task.Delay(0);
|
||||
await DialogService.InvokeRssRulesDialog();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +1,14 @@
|
||||
namespace Lantean.QBTMudBlade.Components.Options
|
||||
using Lantean.QBTMudBlade.Interop;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components.Options
|
||||
{
|
||||
public partial class WebUIOptions : Options
|
||||
{
|
||||
[Inject]
|
||||
public IJSRuntime JSRuntime { get; set; } = default!;
|
||||
|
||||
protected string? Locale { get; private set; }
|
||||
protected bool PerformanceWarning { get; private set; }
|
||||
protected string? WebUiDomainList { get; private set; }
|
||||
@@ -385,7 +392,20 @@
|
||||
|
||||
protected async Task RegisterDyndnsService()
|
||||
{
|
||||
await Task.Delay(0);
|
||||
if (!DyndnsEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#pragma warning disable S1075 // URIs should not be hardcoded
|
||||
var url = DyndnsService switch
|
||||
{
|
||||
0 => "https://www.dyndns.com/account/services/hosts/add.html",
|
||||
1 => "http://www.no-ip.com/services/managed_dns/free_dynamic_dns.html",
|
||||
_ => throw new InvalidOperationException($"DyndnsService value of {DyndnsService} is not supported."),
|
||||
};
|
||||
#pragma warning restore S1075 // URIs should not be hardcoded
|
||||
await JSRuntime.Open(url, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -102,7 +102,7 @@ namespace Lantean.QBTMudBlade.Components
|
||||
_timerCancellationToken.Cancel();
|
||||
_timerCancellationToken.Dispose();
|
||||
|
||||
await Task.Delay(0);
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
_disposedValue = true;
|
||||
|
1
Lantean.QBTMudBlade/Components/PieceProgress.razor
Normal file
1
Lantean.QBTMudBlade/Components/PieceProgress.razor
Normal file
@@ -0,0 +1 @@
|
||||
<div id="progress"></div>
|
77
Lantean.QBTMudBlade/Components/PieceProgress.razor.cs
Normal file
77
Lantean.QBTMudBlade/Components/PieceProgress.razor.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using Lantean.QBitTorrentClient.Models;
|
||||
using Lantean.QBTMudBlade.Interop;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using MudBlazor.Services;
|
||||
using MudBlazor;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components
|
||||
{
|
||||
public partial class PieceProgress : IBrowserViewportObserver, IAsyncDisposable
|
||||
{
|
||||
private bool _disposedValue;
|
||||
|
||||
[Inject]
|
||||
public IJSRuntime JSRuntime { get; set; } = default!;
|
||||
|
||||
[Inject]
|
||||
private IBrowserViewportService BrowserViewportService { get; set; } = default!;
|
||||
|
||||
[Parameter]
|
||||
[EditorRequired]
|
||||
public string Hash { get; set; } = default!;
|
||||
|
||||
[Parameter]
|
||||
[EditorRequired]
|
||||
public IReadOnlyList<PieceState> Pieces { get; set; } = [];
|
||||
|
||||
public Guid Id => Guid.NewGuid();
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
await JSRuntime.RenderPiecesBar("progress", Hash, Pieces.Select(s => (int)s).ToArray());
|
||||
}
|
||||
|
||||
ResizeOptions IBrowserViewportObserver.ResizeOptions { get; } = new()
|
||||
{
|
||||
ReportRate = 50,
|
||||
NotifyOnBreakpointOnly = false
|
||||
};
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
await BrowserViewportService.SubscribeAsync(this, fireImmediately: true);
|
||||
}
|
||||
|
||||
await base.OnAfterRenderAsync(firstRender);
|
||||
}
|
||||
|
||||
public async Task NotifyBrowserViewportChangeAsync(BrowserViewportEventArgs browserViewportEventArgs)
|
||||
{
|
||||
await JSRuntime.RenderPiecesBar("progress", Hash, Pieces.Select(s => (int)s).ToArray());
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
protected virtual async Task DisposeAsync(bool disposing)
|
||||
{
|
||||
if (!_disposedValue)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
await BrowserViewportService.UnsubscribeAsync(this);
|
||||
}
|
||||
|
||||
_disposedValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
||||
await DisposeAsync(disposing: true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,13 +1,71 @@
|
||||
@if (Type == ParentType.StandaloneToolbar)
|
||||
@if (Type == ParentType.Toolbar)
|
||||
{
|
||||
<MudToolBar Dense="true" DisableGutters="true">
|
||||
<MudToolBar Dense="true" DisableGutters="true" WrapContent="true">
|
||||
@ToolbarContent
|
||||
</MudToolBar>
|
||||
}
|
||||
else if (Type == ParentType.Toolbar)
|
||||
else if (Type == ParentType.ToolbarContents)
|
||||
{
|
||||
@ToolbarContent
|
||||
}
|
||||
else if (Type == ParentType.MixedToolbar)
|
||||
{
|
||||
<MudToolBar Dense="true" DisableGutters="true" WrapContent="true">
|
||||
@MixedToolbarContent
|
||||
</MudToolBar>
|
||||
}
|
||||
else if (Type == ParentType.MixedToolbarContents)
|
||||
{
|
||||
@MixedToolbarContent
|
||||
}
|
||||
else if (Type == ParentType.InitialIconsOnly)
|
||||
{
|
||||
@foreach (var option in GetOptions().Take(5))
|
||||
{
|
||||
@if (option is Divider)
|
||||
{
|
||||
<MudDivider Vertical="true" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudIconButton Title="@option.Name" Icon="@option.Icon" Color="option.Color" OnClick="option.Callback" />
|
||||
}
|
||||
}
|
||||
|
||||
<MudMenu Dense="true" AnchorOrigin="Origin.BottomLeft" TransformOrigin="Origin.TopLeft" Label="Actions" EndIcon="@Icons.Material.Filled.ArrowDropDown" @ref="ActionsMenu">
|
||||
@foreach (var option in GetOptions().Skip(5))
|
||||
{
|
||||
@if (option is Divider)
|
||||
{
|
||||
<MudDivider />
|
||||
}
|
||||
else if (!option.Children.Any())
|
||||
{
|
||||
<MudMenuItem Icon="@option.Icon" IconColor="option.Color" OnClick="option.Callback" OnTouch="option.Callback">
|
||||
@option.Name
|
||||
</MudMenuItem>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudMenuItem Icon="@option.Icon" IconColor="option.Color">
|
||||
<MudMenu Dense="true" AnchorOrigin="Origin.TopRight" TransformOrigin="Origin.TopLeft" ActivationEvent="MouseEvent.MouseOver" Icon="@Icons.Material.Filled.ArrowDropDown" DisableElevation="true" DisableRipple="true" Class="sub-menu">
|
||||
<ActivatorContent>
|
||||
@option.Name
|
||||
</ActivatorContent>
|
||||
|
||||
<ChildContent>
|
||||
@foreach (var childItem in option.Children)
|
||||
{
|
||||
@ChildItem(childItem)
|
||||
}
|
||||
</ChildContent>
|
||||
</MudMenu>
|
||||
</MudMenuItem>
|
||||
}
|
||||
|
||||
}
|
||||
</MudMenu>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudMenu AnchorOrigin="Origin.BottomLeft" TransformOrigin="Origin.TopLeft">
|
||||
@@ -24,9 +82,9 @@ else
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudMenu Dense="true" AnchorOrigin="Origin.BottomLeft" TransformOrigin="Origin.TopLeft">
|
||||
<MudMenu Dense="true" AnchorOrigin="Origin.BottomLeft" TransformOrigin="Origin.TopLeft" ActivationEvent="MouseEvent.LeftClick" Icon="@Icons.Material.Filled.ArrowDropDown" DisableElevation="true" DisableRipple="true" Class="sub-menu">
|
||||
<ActivatorContent>
|
||||
<MudMenuItem>@option.Name</MudMenuItem>
|
||||
@option.Name
|
||||
</ActivatorContent>
|
||||
|
||||
<ChildContent>
|
||||
@@ -64,7 +122,39 @@ else
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudMenu Icon="@option.Icon" IconColor="@option.Color" Class="icon-menu" Label="@option.Name" title="@option.Name" AnchorOrigin="Origin.BottomLeft" TransformOrigin="Origin.TopLeft">
|
||||
<MudMenu Icon="@option.Icon" IconColor="@option.Color" Label="@option.Name" title="@option.Name" AnchorOrigin="Origin.BottomLeft" TransformOrigin="Origin.TopLeft">
|
||||
@foreach (var childItem in option.Children)
|
||||
{
|
||||
@ChildItem(childItem)
|
||||
}
|
||||
</MudMenu>
|
||||
}
|
||||
}
|
||||
</NonRendering>
|
||||
;
|
||||
|
||||
private RenderFragment MixedToolbarContent =>
|
||||
@<NonRendering>
|
||||
@foreach (var option in GetOptions())
|
||||
{
|
||||
@if (option is Divider)
|
||||
{
|
||||
<MudDivider Vertical="true" />
|
||||
}
|
||||
else if (!option.Children.Any())
|
||||
{
|
||||
if (option.Icon is null)
|
||||
{
|
||||
<MudButton Color="option.Color" OnClick="option.Callback">@option.Name</MudButton>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudIconButton Title="@option.Name" Icon="@option.Icon" Color="option.Color" OnClick="option.Callback" />
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudMenu Label="@option.Name" title="@option.Name" AnchorOrigin="Origin.BottomLeft" TransformOrigin="Origin.TopLeft" EndIcon="@Icons.Material.Filled.ArrowDropDown">
|
||||
@foreach (var childItem in option.Children)
|
||||
{
|
||||
@ChildItem(childItem)
|
||||
|
@@ -44,6 +44,11 @@ namespace Lantean.QBTMudBlade.Components
|
||||
[CascadingParameter]
|
||||
public MainData MainData { get; set; } = default!;
|
||||
|
||||
[CascadingParameter]
|
||||
public QBitTorrentClient.Models.Preferences? Preferences { get; set; }
|
||||
|
||||
protected MudMenu? ActionsMenu { get; set; }
|
||||
|
||||
protected async Task Pause()
|
||||
{
|
||||
await ApiClient.PauseTorrents(Hashes);
|
||||
@@ -203,6 +208,7 @@ namespace Lantean.QBTMudBlade.Components
|
||||
protected async Task Copy(Func<Torrent, object?> selector)
|
||||
{
|
||||
await Copy(string.Join(Environment.NewLine, GetTorrents().Select(selector)));
|
||||
ActionsMenu?.CloseMenu();
|
||||
}
|
||||
|
||||
protected async Task Export()
|
||||
@@ -260,8 +266,8 @@ namespace Lantean.QBTMudBlade.Components
|
||||
new Divider(),
|
||||
new Action("Set location", Icons.Material.Filled.MyLocation, Color.Info, EventCallback.Factory.Create(this, SetLocation)),
|
||||
new Action("Rename", Icons.Material.Filled.DriveFileRenameOutline, Color.Info, EventCallback.Factory.Create(this, Rename)),
|
||||
new Action("Category", Icons.Material.Filled.List, Color.Info, categories),
|
||||
new Action("Tags", Icons.Material.Filled.Label, Color.Info, tags),
|
||||
new Action("Category", Icons.Material.Filled.List, Color.Info, categories, true),
|
||||
new Action("Tags", Icons.Material.Filled.Label, Color.Info, tags, true),
|
||||
new Action("Automatic Torrent Management", Icons.Material.Filled.Check, firstTorrent.AutomaticTorrentManagement ? Color.Info : Color.Transparent, EventCallback.Factory.Create(this, ToggleAutoTMM)),
|
||||
new Divider(),
|
||||
new Action("Limit upload rate", Icons.Material.Filled.KeyboardDoubleArrowUp, Color.Info, EventCallback.Factory.Create(this, LimitUploadRate)),
|
||||
@@ -289,15 +295,38 @@ namespace Lantean.QBTMudBlade.Components
|
||||
new Action("Export", Icons.Material.Filled.SaveAlt, Color.Info, EventCallback.Factory.Create(this, Export)),
|
||||
};
|
||||
|
||||
if (Preferences?.QueueingEnabled == false)
|
||||
{
|
||||
options.RemoveAt(18);
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ParentType
|
||||
{
|
||||
/// <summary>
|
||||
/// Renders toolbar contents without the <see cref="MudToolBar"/> wrapper.
|
||||
/// </summary>
|
||||
ToolbarContents,
|
||||
/// <summary>
|
||||
/// Renders a <see cref="MudToolBar"/>.
|
||||
/// </summary>
|
||||
Toolbar,
|
||||
StandaloneToolbar,
|
||||
/// <summary>
|
||||
/// Renders a <see cref="MudMenu"/>.
|
||||
/// </summary>
|
||||
Menu,
|
||||
/// <summary>
|
||||
/// Renders a <see cref="MudToolBar"/> with <see cref="MudIconButton"/> for basic actions and a <see cref="MudMenu"/> for actions with children.
|
||||
/// </summary>
|
||||
MixedToolbarContents,
|
||||
/// <summary>
|
||||
/// Renders toolbar contents without the <see cref="MudToolBar"/> wrapper with <see cref="MudIconButton"/> for basic actions and a <see cref="MudMenu"/> for actions with children.
|
||||
/// </summary>
|
||||
MixedToolbar,
|
||||
InitialIconsOnly,
|
||||
}
|
||||
|
||||
public class Divider : Action
|
||||
@@ -309,7 +338,7 @@ namespace Lantean.QBTMudBlade.Components
|
||||
|
||||
public class Action
|
||||
{
|
||||
public Action(string name, string icon, Color color, EventCallback callback)
|
||||
public Action(string name, string? icon, Color color, EventCallback callback)
|
||||
{
|
||||
Name = name;
|
||||
Icon = icon;
|
||||
@@ -318,23 +347,26 @@ namespace Lantean.QBTMudBlade.Components
|
||||
Children = [];
|
||||
}
|
||||
|
||||
public Action(string name, string icon, Color color, IEnumerable<Action> children)
|
||||
public Action(string name, string? icon, Color color, IEnumerable<Action> children, bool useTextButton = false)
|
||||
{
|
||||
Name = name;
|
||||
Icon = icon;
|
||||
Color = color;
|
||||
Callback = default;
|
||||
Children = children;
|
||||
UseTextButton = useTextButton;
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
|
||||
public string Icon { get; }
|
||||
public string? Icon { get; }
|
||||
|
||||
public Color Color { get; }
|
||||
|
||||
public EventCallback Callback { get; }
|
||||
|
||||
public IEnumerable<Action> Children { get; }
|
||||
|
||||
public bool UseTextButton { get; }
|
||||
}
|
||||
}
|
23
Lantean.QBTMudBlade/Components/TorrentInfo.razor
Normal file
23
Lantean.QBTMudBlade/Components/TorrentInfo.razor
Normal file
@@ -0,0 +1,23 @@
|
||||
@if (Torrent is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
<MudToolBar Dense="true" DisableGutters="true" WrapContent="true">
|
||||
@{
|
||||
var (icon, color) = DisplayHelpers.GetStateIcon(Torrent.State);
|
||||
}
|
||||
<MudIcon Color="@color" Icon="@icon" />
|
||||
<MudText Class="pl-5 no-wrap">@Torrent.Name</MudText>
|
||||
<MudDivider Vertical="true" />
|
||||
<MudText Class="pl-5 no-wrap">@DisplayHelpers.Size(Torrent.Size)</MudText>
|
||||
<MudDivider Vertical="true" />
|
||||
@{
|
||||
var value = Torrent.Progress;
|
||||
var progressColor = value < 1 ? Color.Success : Color.Info;
|
||||
<MudProgressLinear title="Progress" Color="@(progressColor)" Value="@((value) * 100)" Class="progress-expand" Size="Size.Large">
|
||||
@DisplayHelpers.Percentage(value)
|
||||
</MudProgressLinear>
|
||||
;
|
||||
}
|
||||
</MudToolBar>
|
27
Lantean.QBTMudBlade/Components/TorrentInfo.razor.cs
Normal file
27
Lantean.QBTMudBlade/Components/TorrentInfo.razor.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Lantean.QBTMudBlade.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace Lantean.QBTMudBlade.Components
|
||||
{
|
||||
public partial class TorrentInfo
|
||||
{
|
||||
[Parameter]
|
||||
[EditorRequired]
|
||||
public string Hash { get; set; } = default!;
|
||||
|
||||
[CascadingParameter]
|
||||
public MainData MainData { get; set; } = default!;
|
||||
|
||||
protected Torrent? Torrent => GetTorrent();
|
||||
|
||||
private Torrent? GetTorrent()
|
||||
{
|
||||
if (Hash is null || !MainData.Torrents.TryGetValue(Hash, out var torrent))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return torrent;
|
||||
}
|
||||
}
|
||||
}
|
@@ -80,7 +80,8 @@ namespace Lantean.QBTMudBlade.Components
|
||||
{
|
||||
_timerCancellationToken.Cancel();
|
||||
_timerCancellationToken.Dispose();
|
||||
await Task.Delay(0);
|
||||
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
_disposedValue = true;
|
||||
|
@@ -43,7 +43,8 @@ namespace Lantean.QBTMudBlade.Components
|
||||
{
|
||||
_timerCancellationToken.Cancel();
|
||||
_timerCancellationToken.Dispose();
|
||||
await Task.Delay(0);
|
||||
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
_disposedValue = true;
|
||||
|
@@ -225,5 +225,10 @@ namespace Lantean.QBTMudBlade
|
||||
|
||||
return (List<PropertyFilterDefinition<T>>?)dialogResult.Data;
|
||||
}
|
||||
|
||||
public static async Task InvokeRssRulesDialog(this IDialogService dialogService)
|
||||
{
|
||||
await Task.Delay(0);
|
||||
}
|
||||
}
|
||||
}
|
@@ -13,5 +13,20 @@ namespace Lantean.QBTMudBlade.Interop
|
||||
{
|
||||
await runtime.InvokeVoidAsync("qbt.triggerFileDownload", url, filename);
|
||||
}
|
||||
|
||||
public static async Task Open(this IJSRuntime runtime, string url, bool newTab = false)
|
||||
{
|
||||
string? target = null;
|
||||
if (newTab)
|
||||
{
|
||||
target = url;
|
||||
}
|
||||
await runtime.InvokeVoidAsync("qbt.open", url, target);
|
||||
}
|
||||
|
||||
public static async Task RenderPiecesBar(this IJSRuntime runtime, string id, string hash, int[] pieces)
|
||||
{
|
||||
await runtime.InvokeVoidAsync("qbt.renderPiecesBar", id, hash, pieces);
|
||||
}
|
||||
}
|
||||
}
|
@@ -10,10 +10,10 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
|
||||
<PackageReference Include="ByteSize" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.3" PrivateAssets="all" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.4" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.4" PrivateAssets="all" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
|
||||
<PackageReference Include="MudBlazor" Version="6.17.0" />
|
||||
<PackageReference Include="MudBlazor" Version="6.19.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@@ -11,13 +11,15 @@
|
||||
|
||||
<CascadingValue Value="Torrents">
|
||||
<CascadingValue Value="MainData">
|
||||
<CascadingValue Value="CategoryChanged" Name="CategoryChanged">
|
||||
<CascadingValue Value="StatusChanged" Name="StatusChanged">
|
||||
<CascadingValue Value="TagChanged" Name="TagChanged">
|
||||
<CascadingValue Value="TrackerChanged" Name="TrackerChanged">
|
||||
<CascadingValue Value="SearchTermChanged" Name="SearchTermChanged">
|
||||
<CascadingValue Value="@(MainData?.LostConnection ?? false)" Name="LostConnection">
|
||||
@Body
|
||||
<CascadingValue Value="Preferences">
|
||||
<CascadingValue Value="CategoryChanged" Name="CategoryChanged">
|
||||
<CascadingValue Value="StatusChanged" Name="StatusChanged">
|
||||
<CascadingValue Value="TagChanged" Name="TagChanged">
|
||||
<CascadingValue Value="TrackerChanged" Name="TrackerChanged">
|
||||
<CascadingValue Value="SearchTermChanged" Name="SearchTermChanged">
|
||||
<CascadingValue Value="@(MainData?.LostConnection ?? false)" Name="LostConnection">
|
||||
@Body
|
||||
</CascadingValue>
|
||||
</CascadingValue>
|
||||
</CascadingValue>
|
||||
</CascadingValue>
|
||||
|
@@ -37,6 +37,8 @@ namespace Lantean.QBTMudBlade.Layout
|
||||
|
||||
protected Status Status { get; set; } = Status.All;
|
||||
|
||||
protected QBitTorrentClient.Models.Preferences? Preferences { get; set; }
|
||||
|
||||
protected string Version { get; set; } = "";
|
||||
|
||||
protected string? SearchText { get; set; }
|
||||
@@ -69,6 +71,7 @@ namespace Lantean.QBTMudBlade.Layout
|
||||
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
Preferences = await ApiClient.GetApplicationPreferences();
|
||||
Version = await ApiClient.GetApplicationVersion();
|
||||
var data = await ApiClient.GetMainData(_requestId);
|
||||
MainData = DataManager.CreateMainData(data);
|
||||
|
@@ -9,10 +9,10 @@
|
||||
}
|
||||
@if (Hash is not null)
|
||||
{
|
||||
<TorrentActions Type="ParentType.Toolbar" Hashes="@([Hash])" />
|
||||
<TorrentActions Type="ParentType.InitialIconsOnly" Hashes="@([Hash])" />
|
||||
}
|
||||
<MudDivider Vertical="true" />
|
||||
<MudText Class="pl-5">@Name</MudText>
|
||||
<MudText Class="pl-5 no-wrap">@Name</MudText>
|
||||
</MudToolBar>
|
||||
|
||||
<CascadingValue Value="RefreshInterval">
|
||||
|
@@ -49,7 +49,7 @@ namespace Lantean.QBTMudBlade.Pages
|
||||
#if DEBUG
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await DoLogin("admin", "A9tExgXcZ");
|
||||
await DoLogin("admin", "p22bMTJDK");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -10,6 +10,8 @@ namespace Lantean.QBTMudBlade.Pages
|
||||
{
|
||||
public partial class TorrentList
|
||||
{
|
||||
private const string _columnStorageKey = "TorrentList.Columns";
|
||||
|
||||
[Inject]
|
||||
protected IApiClient ApiClient { get; set; } = default!;
|
||||
|
||||
@@ -22,6 +24,9 @@ namespace Lantean.QBTMudBlade.Pages
|
||||
[Inject]
|
||||
protected NavigationManager NavigationManager { get; set; } = default!;
|
||||
|
||||
[CascadingParameter]
|
||||
public QBitTorrentClient.Models.Preferences? Preferences { get; set; }
|
||||
|
||||
[CascadingParameter]
|
||||
public IEnumerable<Torrent>? Torrents { get; set; }
|
||||
|
||||
@@ -38,11 +43,31 @@ namespace Lantean.QBTMudBlade.Pages
|
||||
|
||||
protected bool ToolbarButtonsEnabled => SelectedItems.Count > 0 || SelectedTorrent is not null;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (!await LocalStorage.ContainKeyAsync(_columnStorageKey))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var selectedColumns = await LocalStorage.GetItemAsync<HashSet<string>>(_columnStorageKey);
|
||||
if (selectedColumns is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SelectedColumns = selectedColumns;
|
||||
}
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (SelectedColumns.Count == 0)
|
||||
{
|
||||
SelectedColumns = _columns.Where(c => c.Enabled).Select(c => c.Id).ToHashSet();
|
||||
if (Preferences?.QueueingEnabled == false)
|
||||
{
|
||||
SelectedColumns.Remove("#");
|
||||
}
|
||||
}
|
||||
_sortSelector ??= _columns.First(c => c.Enabled).SortSelector;
|
||||
}
|
||||
@@ -183,6 +208,8 @@ namespace Lantean.QBTMudBlade.Pages
|
||||
}
|
||||
|
||||
SelectedColumns = (HashSet<string>)result.Data;
|
||||
|
||||
await LocalStorage.SetItemAsync(_columnStorageKey, SelectedColumns);
|
||||
}
|
||||
|
||||
protected void ShowTorrent()
|
||||
|
@@ -123,3 +123,29 @@ td.no-wrap {
|
||||
.field-switch {
|
||||
|
||||
}
|
||||
|
||||
.piecesbarWrapper {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.piecesbarCanvas {
|
||||
height: 100%;
|
||||
image-rendering: pixelated;
|
||||
inset: 0;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.sub-menu {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.sub-menu::after {
|
||||
content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h24v24H0V0z' fill='none'/%3E%3Cpath d='M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z'/%3E%3C/svg%3E");
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
position: absolute;
|
||||
top: -2px;
|
||||
right: -5px;
|
||||
transform: rotate(270deg);
|
||||
}
|
@@ -30,6 +30,8 @@
|
||||
</div>
|
||||
<script src="_framework/blazor.webassembly.js"></script>
|
||||
<script src="_content/MudBlazor/MudBlazor.min.js"></script>
|
||||
<script src="js/piecesbar.js"></script>
|
||||
<script src="js/interop.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
@@ -1,6 +1,8 @@
|
||||
const qbt = {};
|
||||
if (window.qbt === undefined) {
|
||||
window.qbt = {};
|
||||
}
|
||||
|
||||
qbt.triggerFileDownload = (url, fileName) => {
|
||||
window.qbt.triggerFileDownload = (url, fileName) => {
|
||||
const anchorElement = document.createElement('a');
|
||||
anchorElement.href = url;
|
||||
anchorElement.download = fileName ?? '';
|
||||
@@ -8,10 +10,35 @@ qbt.triggerFileDownload = (url, fileName) => {
|
||||
anchorElement.remove();
|
||||
}
|
||||
|
||||
qbt.getBoundingClientRect = (id) => {
|
||||
window.qbt.getBoundingClientRect = (id) => {
|
||||
const element = document.getElementById(id);
|
||||
|
||||
return element.getBoundingClientRect();
|
||||
}
|
||||
|
||||
window.qbt = qbt;
|
||||
window.qbt.open = (url, target) => {
|
||||
window.open(url, target);
|
||||
}
|
||||
|
||||
window.qbt.renderPiecesBar = (id, hash, pieces) => {
|
||||
const parentElement = document.getElementById(id);
|
||||
if (window.qbt.hash !== hash) {
|
||||
if (parentElement) {
|
||||
while (parentElement.lastElementChild) {
|
||||
parentElement.removeChild(parentElement.lastElementChild);
|
||||
}
|
||||
}
|
||||
window.qbt.hash = hash;
|
||||
window.qbt.piecesBar = new window.qbt.PiecesBar([], {
|
||||
height: 24
|
||||
});
|
||||
window.qbt.piecesBar.clear();
|
||||
}
|
||||
|
||||
if (parentElement && !parentElement.hasChildNodes()) {
|
||||
const el = window.qbt.piecesBar.createElement();
|
||||
parentElement.appendChild(el);
|
||||
}
|
||||
|
||||
window.qbt.piecesBar.setPieces(pieces);
|
||||
}
|
273
Lantean.QBTMudBlade/wwwroot/js/piecesbar.js
Normal file
273
Lantean.QBTMudBlade/wwwroot/js/piecesbar.js
Normal file
@@ -0,0 +1,273 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2022 Jesse Smick <jesse.smick@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give permission to
|
||||
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
||||
* modified versions of it that use the same license as the "OpenSSL" library),
|
||||
* and distribute the linked executables. You must obey the GNU General Public
|
||||
* License in all respects for all of the code used other than "OpenSSL". If you
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
if (window.qbt === undefined) {
|
||||
window.qbt = {};
|
||||
}
|
||||
|
||||
window.qbt.piecesBarUniqueId = 0;
|
||||
|
||||
class PiecesBar {
|
||||
STATUS_DOWNLOADING = 1;
|
||||
STATUS_DOWNLOADED = 2;
|
||||
|
||||
// absolute max width of 4096
|
||||
// this is to support all browsers for size of canvas elements
|
||||
// see https://github.com/jhildenbiddle/canvas-size#test-results
|
||||
MAX_CANVAS_WIDTH = 4096;
|
||||
|
||||
constructor(pieces, parameters) {
|
||||
|
||||
this.id = 'piecesbar_' + (window.qbt.piecesBarUniqueId++);
|
||||
this.width = 0;
|
||||
this.height = 0;
|
||||
this.downloadingColor = 'green';
|
||||
this.haveColor = 'blue';
|
||||
this.borderSize = 1;
|
||||
this.borderColor = '#999';
|
||||
|
||||
if (parameters && (typeof(parameters) === 'object')) {
|
||||
Object.assign(this, parameters)
|
||||
}
|
||||
|
||||
this.height = Math.max(this.height, 12);
|
||||
this.setPieces(pieces);
|
||||
}
|
||||
|
||||
createElement() {
|
||||
this.obj = document.createElement('div');
|
||||
this.obj.className = 'piecesbarWrapper';
|
||||
this.obj.id = this.id;
|
||||
this.obj.style = 'border: ' + this.borderSize.toString() + 'px solid ' + this.borderColor + '; height: ' + this.height.toString() + 'px';
|
||||
|
||||
this.canvas = document.createElement('canvas');
|
||||
this.canvas.id = this.id + '_canvas';
|
||||
this.canvas.className = 'piecesbarCanvas';
|
||||
this.canvas.width = (this.width - (2 * this.borderSize)).toString();
|
||||
|
||||
this.obj.appendChild(this.canvas);
|
||||
|
||||
if (this.width > 0) {
|
||||
this.setPieces(this.pieces);
|
||||
} else {
|
||||
setTimeout(() => { this.checkForParent(this.id); }, 1);
|
||||
}
|
||||
|
||||
return this.obj;
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.setPieces([]);
|
||||
}
|
||||
|
||||
setPieces(pieces) {
|
||||
if (!Array.isArray(pieces)) {
|
||||
this.pieces = [];
|
||||
} else {
|
||||
this.pieces = pieces;
|
||||
}
|
||||
this.refresh(true);
|
||||
}
|
||||
|
||||
refresh(force) {
|
||||
if (!this.obj?.parentNode) {
|
||||
return;
|
||||
}
|
||||
|
||||
const pieces = this.pieces;
|
||||
|
||||
// if the number of pieces is small, use that for the width,
|
||||
// and have it stretch horizontally.
|
||||
// this also limits the ratio below to >= 1
|
||||
const width = Math.min(this.obj.offsetWidth, this.pieces.length, this.MAX_CANVAS_WIDTH);
|
||||
if ((this.width === width) && !force) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.width = width;
|
||||
|
||||
// change canvas size to fit exactly in the space
|
||||
this.canvas.width = width - (2 * this.borderSize);
|
||||
|
||||
const canvas = this.canvas;
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
const imageWidth = canvas.width;
|
||||
|
||||
if (imageWidth.length === 0)
|
||||
return;
|
||||
|
||||
let minStatus = Infinity;
|
||||
let maxStatus = 0;
|
||||
|
||||
for (const status of pieces) {
|
||||
if (status > maxStatus) {
|
||||
maxStatus = status;
|
||||
}
|
||||
|
||||
if (status < minStatus) {
|
||||
minStatus = status;
|
||||
}
|
||||
}
|
||||
|
||||
// if no progress then don't do anything
|
||||
if (maxStatus === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if all pieces are downloaded, fill entire image at once
|
||||
if (minStatus === this.STATUS_DOWNLOADED) {
|
||||
ctx.fillStyle = this.haveColor;
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Linear transformation from pieces to pixels.
|
||||
*
|
||||
* The canvas size can vary in width so this figures out what to draw at each pixel.
|
||||
* Inspired by the GUI code here https://github.com/qbittorrent/qBittorrent/blob/25b3f2d1a6b14f0fe098fb79a3d034607e52deae/src/gui/properties/downloadedpiecesbar.cpp#L54
|
||||
*
|
||||
* example ratio > 1 (at least 2 pieces per pixel)
|
||||
* +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
|
||||
* pieces | 2 | 1 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 2 |
|
||||
* +---------+---------+---------+---------+---------+---------+
|
||||
* pixels | | | | | | |
|
||||
* +---------+---------+---------+---------+---------+---------+
|
||||
*
|
||||
* example ratio < 1 (at most 2 pieces per pixel)
|
||||
* This case shouldn't happen since the max pixels are limited to the number of pieces
|
||||
* +---------+---------+---------+---------+----------+--------+
|
||||
* pieces | 2 | 1 | 1 | 0 | 2 | 2 |
|
||||
* +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
|
||||
* pixels | | | | | | | | | | |
|
||||
* +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
|
||||
*/
|
||||
|
||||
const ratio = pieces.length / imageWidth;
|
||||
|
||||
let lastValue = null;
|
||||
let rectangleStart = 0;
|
||||
|
||||
// for each pixel compute its status based on the pieces
|
||||
for (let x = 0; x < imageWidth; ++x) {
|
||||
// find positions in the pieces array
|
||||
const piecesFrom = x * ratio;
|
||||
const piecesTo = (x + 1) * ratio;
|
||||
const piecesToInt = Math.ceil(piecesTo);
|
||||
|
||||
const statusValues = {
|
||||
[this.STATUS_DOWNLOADING]: 0,
|
||||
[this.STATUS_DOWNLOADED]: 0
|
||||
};
|
||||
|
||||
// aggregate the status of each piece that contributes to this pixel
|
||||
for (let p = piecesFrom; p < piecesToInt; ++p) {
|
||||
const piece = Math.floor(p);
|
||||
const pieceStart = Math.max(piecesFrom, piece);
|
||||
const pieceEnd = Math.min(piece + 1, piecesTo);
|
||||
|
||||
const amount = pieceEnd - pieceStart;
|
||||
const status = pieces[piece];
|
||||
|
||||
if (status in statusValues)
|
||||
statusValues[status] += amount;
|
||||
}
|
||||
|
||||
// normalize to interval [0, 1]
|
||||
statusValues[this.STATUS_DOWNLOADING] /= ratio;
|
||||
statusValues[this.STATUS_DOWNLOADED] /= ratio;
|
||||
|
||||
// floats accumulate small errors, so smooth it out by rounding to hundredths place
|
||||
// this effectively limits each status to a value 1 in 100
|
||||
statusValues[this.STATUS_DOWNLOADING] = Math.round(statusValues[this.STATUS_DOWNLOADING] * 100) / 100;
|
||||
statusValues[this.STATUS_DOWNLOADED] = Math.round(statusValues[this.STATUS_DOWNLOADED] * 100) / 100;
|
||||
|
||||
// float precision sometimes _still_ gives > 1
|
||||
statusValues[this.STATUS_DOWNLOADING] = Math.min(statusValues[this.STATUS_DOWNLOADING], 1);
|
||||
statusValues[this.STATUS_DOWNLOADED] = Math.min(statusValues[this.STATUS_DOWNLOADED], 1);
|
||||
|
||||
if (!lastValue) {
|
||||
lastValue = statusValues;
|
||||
}
|
||||
|
||||
// group contiguous colors together and draw as a single rectangle
|
||||
if ((lastValue[this.STATUS_DOWNLOADING] === statusValues[this.STATUS_DOWNLOADING])
|
||||
&& (lastValue[this.STATUS_DOWNLOADED] === statusValues[this.STATUS_DOWNLOADED])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const rectangleWidth = x - rectangleStart;
|
||||
this._drawStatus(ctx, rectangleStart, rectangleWidth, lastValue);
|
||||
|
||||
lastValue = statusValues;
|
||||
rectangleStart = x;
|
||||
}
|
||||
|
||||
// fill a rect at the end of the canvas
|
||||
if (rectangleStart < imageWidth) {
|
||||
const rectangleWidth = imageWidth - rectangleStart;
|
||||
this._drawStatus(ctx, rectangleStart, rectangleWidth, lastValue);
|
||||
}
|
||||
}
|
||||
|
||||
_drawStatus(ctx, start, width, statusValues) {
|
||||
// mix the colors by using transparency and a composite mode
|
||||
ctx.globalCompositeOperation = 'lighten';
|
||||
|
||||
if (statusValues[this.STATUS_DOWNLOADING]) {
|
||||
ctx.globalAlpha = statusValues[this.STATUS_DOWNLOADING];
|
||||
ctx.fillStyle = this.downloadingColor;
|
||||
ctx.fillRect(start, 0, width, ctx.canvas.height);
|
||||
}
|
||||
|
||||
if (statusValues[this.STATUS_DOWNLOADED]) {
|
||||
ctx.globalAlpha = statusValues[this.STATUS_DOWNLOADED];
|
||||
ctx.fillStyle = this.haveColor;
|
||||
ctx.fillRect(start, 0, width, ctx.canvas.height);
|
||||
}
|
||||
}
|
||||
|
||||
checkForParent(id) {
|
||||
const obj = document.getElementById(id);
|
||||
if (!obj) {
|
||||
return;
|
||||
}
|
||||
if (!obj.parentNode) {
|
||||
return setTimeout(function () { checkForParent(id); }, 1);
|
||||
}
|
||||
|
||||
this.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
window.qbt.PiecesBar = PiecesBar;
|
||||
|
||||
Object.freeze(window.qbt.PiecesBar);
|
Reference in New Issue
Block a user