Implemented file view loading animation
This commit is contained in:
@@ -35,6 +35,7 @@
|
|||||||
<table class="table align-middle table-row-dashed fs-6 gy-5 dataTable no-footer" style="width: 100%;">
|
<table class="table align-middle table-row-dashed fs-6 gy-5 dataTable no-footer" style="width: 100%;">
|
||||||
<tbody class="fw-semibold text-gray-600">
|
<tbody class="fw-semibold text-gray-600">
|
||||||
<LazyLoader Load="Load">
|
<LazyLoader Load="Load">
|
||||||
|
<ContentBlock @ref="ContentBlock" AllowContentOverride="true">
|
||||||
<tr class="even">
|
<tr class="even">
|
||||||
<td class="w-10px">
|
<td class="w-10px">
|
||||||
</td>
|
</td>
|
||||||
@@ -117,6 +118,7 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
|
</ContentBlock>
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@@ -138,6 +140,7 @@
|
|||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public FileAccess Access { get; set; }
|
public FileAccess Access { get; set; }
|
||||||
|
|
||||||
@@ -169,15 +172,19 @@
|
|||||||
private Dictionary<FileData, bool> ToggleStatusCache = new();
|
private Dictionary<FileData, bool> ToggleStatusCache = new();
|
||||||
private bool AllToggled = false;
|
private bool AllToggled = false;
|
||||||
|
|
||||||
|
private ContentBlock ContentBlock;
|
||||||
|
|
||||||
public async Task Refresh()
|
public async Task Refresh()
|
||||||
{
|
{
|
||||||
|
ContentBlock?.SetBlocking(true);
|
||||||
|
|
||||||
var list = new List<FileData>();
|
var list = new List<FileData>();
|
||||||
|
|
||||||
foreach (var fileData in await Access.Ls())
|
foreach (var fileData in await Access.Ls())
|
||||||
{
|
{
|
||||||
if (Filter != null)
|
if (Filter != null)
|
||||||
{
|
{
|
||||||
if(Filter.Invoke(fileData))
|
if (Filter.Invoke(fileData))
|
||||||
list.Add(fileData);
|
list.Add(fileData);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -196,6 +203,8 @@
|
|||||||
|
|
||||||
await InvokeAsync(StateHasChanged);
|
await InvokeAsync(StateHasChanged);
|
||||||
OnSelectionChanged?.Invoke();
|
OnSelectionChanged?.Invoke();
|
||||||
|
|
||||||
|
ContentBlock?.SetBlocking(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Load(LazyLoader arg)
|
private async Task Load(LazyLoader arg)
|
||||||
@@ -273,4 +282,4 @@
|
|||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
52
Moonlight/Shared/Components/Partials/ContentBlock.razor
Normal file
52
Moonlight/Shared/Components/Partials/ContentBlock.razor
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
@if (AllowContentOverride)
|
||||||
|
{
|
||||||
|
if (IsBlocking)
|
||||||
|
{
|
||||||
|
<div class="overlay overlay-block">
|
||||||
|
<div class="overlay-wrapper p-5">
|
||||||
|
@(ChildContent)
|
||||||
|
</div>
|
||||||
|
<div class="overlay-layer">
|
||||||
|
<div class="spinner-border text-primary" role="status">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@ChildContent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="@(IsBlocking ? "overlay overlay-block" : "")">
|
||||||
|
<div class="@(IsBlocking ? "overlay-wrapper p-5" : "")">
|
||||||
|
@(ChildContent)
|
||||||
|
</div>
|
||||||
|
@if (IsBlocking)
|
||||||
|
{
|
||||||
|
<div class="overlay-layer">
|
||||||
|
<div class="spinner-border text-primary" role="status">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
@code
|
||||||
|
{
|
||||||
|
[Parameter]
|
||||||
|
public RenderFragment ChildContent { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public bool AllowContentOverride { get; set; } = false;
|
||||||
|
|
||||||
|
private bool IsBlocking = false;
|
||||||
|
|
||||||
|
public async Task SetBlocking(bool b)
|
||||||
|
{
|
||||||
|
IsBlocking = b;
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user