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

View File

@ -6,9 +6,7 @@
</TitleContent> </TitleContent>
<DialogContent> <DialogContent>
<MudContainer Style="overflow-y: scroll"> <ArchiveBrowser ArchiveId="ArchiveId" OnFileSelected="FileSelected" />
<ArchiveBrowser ArchiveId="ArchiveId" OnFileSelected="FileSelected" />
</MudContainer>
</DialogContent> </DialogContent>
<DialogActions> <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 > .mud-input-control-input-container > div.mud-input.mud-input-text,
.mud-table-cell .mud-input-control { .mud-table-cell .mud-input-control {
margin-top: 0; margin-top: 0;
}
.mud-dialog-fullscreen .mud-dialog-title + div > div,
.mud-dialog-fullscreen .mud-dialog-content {
max-height: calc(100vh - 64px);
} }