Disable browse button if archive file is missing
This commit is contained in:
parent
fef2171588
commit
0e9f8b612c
2 changed files with 19 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
@using LANCommander.Models;
|
@using LANCommander.Models;
|
||||||
@using System.IO.Compression;
|
@using System.IO.Compression;
|
||||||
@inject ModalService ModalService
|
@inject ModalService ModalService
|
||||||
|
@inject ArchiveService ArchiveService
|
||||||
|
|
||||||
<Space Style="display: flex">
|
<Space Style="display: flex">
|
||||||
<SpaceItem Style="flex-grow: 1">
|
<SpaceItem Style="flex-grow: 1">
|
||||||
|
@ -8,7 +9,7 @@
|
||||||
</SpaceItem>
|
</SpaceItem>
|
||||||
@if (ArchiveId != Guid.Empty) {
|
@if (ArchiveId != Guid.Empty) {
|
||||||
<SpaceItem>
|
<SpaceItem>
|
||||||
<Button OnClick="() => BrowseForFile()" Type="@ButtonType.Primary" Icon="@IconType.Outline.FolderOpen" />
|
<Button OnClick="() => BrowseForFile()" Type="@ButtonType.Primary" Icon="@IconType.Outline.FolderOpen" Disabled="!ArchiveExists" />
|
||||||
</SpaceItem>
|
</SpaceItem>
|
||||||
}
|
}
|
||||||
</Space>
|
</Space>
|
||||||
|
@ -20,6 +21,14 @@
|
||||||
[Parameter] public string ArchiveBrowserTitle { get; set; } = "Choose File";
|
[Parameter] public string ArchiveBrowserTitle { get; set; } = "Choose File";
|
||||||
[Parameter] public bool AllowDirectories { get; set; } = false;
|
[Parameter] public bool AllowDirectories { get; set; } = false;
|
||||||
|
|
||||||
|
bool ArchiveExists { get; set; } = false;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
if (ArchiveId != Guid.Empty)
|
||||||
|
ArchiveExists = await ArchiveService.Exists(ArchiveId);
|
||||||
|
}
|
||||||
|
|
||||||
private async void BrowseForFile()
|
private async void BrowseForFile()
|
||||||
{
|
{
|
||||||
var modalOptions = new ModalOptions()
|
var modalOptions = new ModalOptions()
|
||||||
|
|
|
@ -88,6 +88,15 @@ namespace LANCommander.Services
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<bool> Exists(Guid archiveId)
|
||||||
|
{
|
||||||
|
var archive = await Get(archiveId);
|
||||||
|
|
||||||
|
var path = GetArchiveFileLocation(archive);
|
||||||
|
|
||||||
|
return File.Exists(path);
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<ZipArchiveEntry>> GetContents(Guid archiveId)
|
public async Task<IEnumerable<ZipArchiveEntry>> GetContents(Guid archiveId)
|
||||||
{
|
{
|
||||||
var archive = await Get(archiveId);
|
var archive = await Get(archiveId);
|
||||||
|
|
Loading…
Add table
Reference in a new issue