Split pane archive browser

dashboard
Pat Hartl 2023-02-07 01:34:20 -06:00
parent c3b4c6dea2
commit a0145a83dc
3 changed files with 38 additions and 37 deletions

View File

@ -3,41 +3,36 @@
@using System.IO.Compression;
@inject ArchiveService ArchiveService;
<MudGrid>
<MudItem xs="4">
<MudTreeView Items="Root.Children" Hover="true" @bind-SelectedValue="SelectedDirectory" T="ArchiveDirectory">
<ItemTemplate>
<MudTreeViewItem Value="@context" Items="@context.Children" Text="@context.Name" T="ArchiveDirectory" OnClick="() => ChangeDirectory(context)"></MudTreeViewItem>
</ItemTemplate>
</MudTreeView>
</MudItem>
<MudStack Row="true" Style="max-height: 100%">
<MudTreeView Items="Directories" Hover="true" @bind-SelectedValue="SelectedDirectory" T="ArchiveDirectory" Style="min-width: 18%">
<ItemTemplate>
<MudTreeViewItem Value="@context" Items="@context.Children" Text="@context.Name" T="ArchiveDirectory" OnClick="() => ChangeDirectory(context)"></MudTreeViewItem>
</ItemTemplate>
</MudTreeView>
<MudItem xs="8">
<MudTable Items="@CurrentPathEntries" Hover="true">
<HeaderContent>
<MudTable Items="@CurrentPathEntries" Hover="true" Class="flex-grow-1" FixedHeader="true" Elevation="0" Height="calc(100vh - 64px)">
<HeaderContent>
<MudTh></MudTh>
<MudTh>Name</MudTh>
<MudTh>Size</MudTh>
<MudTh>Modified</MudTh>
@if (OnFileSelected.HasDelegate)
{
<MudTh></MudTh>
<MudTh>Name</MudTh>
<MudTh>Size</MudTh>
<MudTh>Modified</MudTh>
@if (OnFileSelected.HasDelegate)
{
<MudTh></MudTh>
}
</HeaderContent>
<RowTemplate>
<MudTd><MudIcon Icon="@GetIcon(context)" /></MudTd>
<MudTd>@GetFileName(context)</MudTd>
<MudTd>@ByteSize.FromBytes(context.Length)</MudTd>
<MudTd>@context.LastWriteTime</MudTd>
@if (OnFileSelected.HasDelegate)
{
<MudTd><MudButton OnClick="() => OnFileSelected.InvokeAsync(context.FullName)">Select</MudButton></MudTd>
}
</RowTemplate>
</MudTable>
</MudItem>
</MudGrid>
}
</HeaderContent>
<RowTemplate>
<MudTd><MudIcon Icon="@GetIcon(context)" /></MudTd>
<MudTd>@GetFileName(context)</MudTd>
<MudTd>@ByteSize.FromBytes(context.Length)</MudTd>
<MudTd>@context.LastWriteTime</MudTd>
@if (OnFileSelected.HasDelegate)
{
<MudTd><MudButton OnClick="() => OnFileSelected.InvokeAsync(context.FullName)">Select</MudButton></MudTd>
}
</RowTemplate>
</MudTable>
</MudStack>
@code {
[Parameter] public Guid ArchiveId { get; set; }
@ -73,7 +68,10 @@
if (SelectedDirectory == null)
SelectedDirectory = selectedDirectory;
CurrentPathEntries = Entries.Where(e => e.FullName.StartsWith(SelectedDirectory.FullName) && e.FullName != SelectedDirectory.FullName);
if (SelectedDirectory.FullName == "")
CurrentPathEntries = Entries.Where(e => !e.FullName.TrimEnd('/').Contains('/'));
else
CurrentPathEntries = Entries.Where(e => e.FullName.StartsWith(SelectedDirectory.FullName) && e.FullName != SelectedDirectory.FullName);
}
private string GetFileName(ZipArchiveEntry entry)

View File

@ -6,9 +6,7 @@
</TitleContent>
<DialogContent>
<MudContainer Style="overflow-y: scroll">
<ArchiveBrowser ArchiveId="ArchiveId" OnFileSelected="FileSelected" />
</MudContainer>
<ArchiveBrowser ArchiveId="ArchiveId" OnFileSelected="FileSelected" />
</DialogContent>
<DialogActions>

View File

@ -1,4 +1,9 @@
.mud-table-cell .mud-input-control > .mud-input-control-input-container > div.mud-input.mud-input-text,
.mud-table-cell .mud-input-control {
margin-top: 0;
}
.mud-dialog-fullscreen .mud-dialog-title + div > div,
.mud-dialog-fullscreen .mud-dialog-content {
max-height: calc(100vh - 64px);
}