mirror of
https://github.com/lantean-code/qbtmud.git
synced 2025-10-23 04:52:22 +00:00
97 lines
3.5 KiB
Plaintext
97 lines
3.5 KiB
Plaintext
@page "/"
|
|
@layout ListLayout
|
|
|
|
<MudToolBar DisableGutters="true" Dense="true">
|
|
<MudIconButton Icon="@Icons.Material.Outlined.AddLink" OnClick="AddTorrentLink" Title="Add torrent link" />
|
|
<MudIconButton Icon="@Icons.Material.Outlined.AddCircle" OnClick="AddTorrentFile" Title="Add torrent file" />
|
|
<MudDivider Vertical="true" />
|
|
<TorrentActions Type="RenderType.InitialIconsOnly" Hashes="GetSelectedTorrents()" />
|
|
<MudDivider Vertical="true" />
|
|
<MudIconButton Icon="@Icons.Material.Outlined.Info" Color="Color.Inherit" Disabled="@(!ToolbarButtonsEnabled)" OnClick="ShowTorrent" Title="View torrent details" />
|
|
<MudIconButton Icon="@Icons.Material.Outlined.ViewColumn" Color="Color.Inherit" OnClick="ColumnOptions" Title="Choose Columns" />
|
|
<MudSpacer />
|
|
<MudTextField Value="SearchText" TextChanged="SearchTextChanged" Immediate="true" DebounceInterval="1000" Placeholder="Filter torrent list" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Search" IconSize="Size.Medium" Class="mt-0"></MudTextField>
|
|
</MudToolBar>
|
|
<MudTable
|
|
Items="OrderedTorrents"
|
|
T="Torrent"
|
|
Hover="true"
|
|
FixedHeader="true"
|
|
HeaderClass="table-head-bordered"
|
|
Dense="true"
|
|
Breakpoint="Breakpoint.None"
|
|
Bordered="true"
|
|
Loading="@(Torrents is null)"
|
|
SelectOnRowClick="false"
|
|
Striped="true"
|
|
Square="true"
|
|
LoadingProgressColor="Color.Info"
|
|
MultiSelection="true"
|
|
SelectedItems="SelectedItems"
|
|
SelectedItemsChanged="SelectedItemsChanged"
|
|
HorizontalScrollbar="true"
|
|
OnRowClick="RowClick"
|
|
RowStyleFunc="RowStyle"
|
|
Virtualize="true"
|
|
Class="torrent-list">
|
|
<ColGroup>
|
|
<col style="width: 30px" />
|
|
@foreach (var column in GetColumns())
|
|
{
|
|
var style = column.Width.HasValue ? $"width: {column.Width.Value}px" : null;
|
|
<col style="@style" />
|
|
}
|
|
</ColGroup>
|
|
<HeaderContent>
|
|
@foreach (var column in GetColumns())
|
|
{
|
|
<MudTh>
|
|
@if (column.SortSelector is not null)
|
|
{
|
|
<MudTableSortLabel T="Torrent" SortDirectionChanged="@(c => SetSort(column.SortSelector, c))">@column.Header</MudTableSortLabel>
|
|
}
|
|
else
|
|
{
|
|
@column.Header
|
|
}
|
|
</MudTh>
|
|
}
|
|
</HeaderContent>
|
|
<RowTemplate>
|
|
@foreach (var column in GetColumns())
|
|
{
|
|
<MudTd DataLabel="@column.Header" Class="@column.Class">
|
|
@column.RowTemplate(column.GetRowContext(context))
|
|
</MudTd>
|
|
}
|
|
</RowTemplate>
|
|
</MudTable>
|
|
|
|
@code {
|
|
private static RenderFragment<RowContext<Torrent>> ProgressBarColumn
|
|
{
|
|
get
|
|
{
|
|
return context => __builder =>
|
|
{
|
|
var value = (float?)context.GetValue();
|
|
var color = value < 1 ? Color.Success : Color.Info;
|
|
<MudProgressLinear title="Progress" Color="@(color)" Value="@((value ?? 0) * 100)" Class="progress-expand" Size="Size.Large">
|
|
@DisplayHelpers.Percentage(value)
|
|
</MudProgressLinear>;
|
|
};
|
|
}
|
|
}
|
|
|
|
private static RenderFragment<RowContext<Torrent>> IconColumn
|
|
{
|
|
get
|
|
{
|
|
return context => __builder =>
|
|
{
|
|
var (icon, color) = DisplayHelpers.GetStateIcon((string?)context.GetValue());
|
|
<MudIcon Icon="@icon" Color="@color" />
|
|
};
|
|
}
|
|
}
|
|
} |