Updated admin page to be more streamlined and added the beginning of the blogging features

This commit is contained in:
Vincent Allen
2025-10-21 13:32:39 -04:00
parent 0e24ce2073
commit b34449808f
224 changed files with 27064 additions and 396 deletions

View File

@@ -41,7 +41,10 @@
</MudExpansionPanel>
@if (_totalResults > 0)
{
<MudText Typo="Typo.subtitle2" Class="my-2">@_totalResults results found</MudText>
<MudGrid Justify="Justify.FlexStart" Class="mt-1 ml-1 mb-2">
<MudText Typo="Typo.subtitle2" Class="my-2">@_totalResults results found</MudText>
<MudButton Class="ml-1" StartIcon="@Icons.Material.Filled.Clear" OnClick="OnClearResults" Variant="Variant.Filled" Color="Color.Primary" Size="Size.Small">Clear</MudButton>
</MudGrid>
}
@if (_artifactGroupings.Count > 0)
{
@@ -57,6 +60,13 @@
<MudPaper Class="d-flex justify-center py-2 mt-4" Elevation="0">
<MudPagination Count="_totalPages" Page="_currentPage" SelectedPageChanged="OnPageChangedAsync" />
</MudPaper>
}
else
{
@foreach (SearchPageSliderEntry entry in _sliderEntries)
{
<SearchPageSlider SliderEntry="entry"></SearchPageSlider>
}
}
@inject IDbContextFactory<ApplicationDbContext> ContextFactory;
@@ -85,6 +95,8 @@
private int _totalResults { get; set; } = 0;
private const int PageSize = 20;
private List<SearchPageSliderEntry> _sliderEntries { get; set; } = [];
// Field to store the current filter logic
private Expression<Func<ArtifactGrouping, bool>> _currentFilterPredicate;
@@ -94,6 +106,9 @@
{
await PerformSearchAsync();
}
await using var context = await ContextFactory.CreateDbContextAsync();
_sliderEntries = await context.SearchPageSliderEntries.Include(e=>e.FilterTags).ToListAsync();
}
private async Task HandleSearchKeyDown(Microsoft.AspNetCore.Components.Web.KeyboardEventArgs args)
@@ -155,7 +170,7 @@
{
await LoadPageAsync(page);
}
/// <summary>
/// Fetches a specific page of data from the database using the currently set filter.
/// </summary>
@@ -180,6 +195,13 @@
.Take(PageSize)
.ToListAsync();
StateHasChanged();
}
private void OnClearResults(Microsoft.AspNetCore.Components.Web.MouseEventArgs args)
{
_totalResults = 0;
_artifactGroupings.Clear();
StateHasChanged();
}
}

View File

@@ -0,0 +1,62 @@
@using Microsoft.EntityFrameworkCore
@using OpenArchival.DataAccess
@using MudBlazor
@using OpenArchival.Blazor.ArtifactGroupingDisplay
<MudPaper Class="pa-4 ma-2 rounded" Elevation="3" Style="overflow-x:auto">
<MudText Typo="Typo.h6">@SliderEntry.Title</MudText>
<MudDivider/>
@if (!string.IsNullOrEmpty(SliderEntry.Description))
{
<MudText Typo="Typo.caption">@SliderEntry.Description</MudText>
}
<MudStack Row="true" Spacing="4" Style="flex-wrap: nowrap;">
@foreach (ArtifactGrouping grouping in ArtifactGroupings)
{
<div style="min-width: 300px;">
<ArtifactGroupingSearchResult ArtifactGrouping="grouping" Height="300"></ArtifactGroupingSearchResult>
</div>
}
</MudStack>
</MudPaper>
@inject IDbContextFactory<ApplicationDbContext> ContextFactory;
@code {
[Parameter]
public required SearchPageSliderEntry SliderEntry { get; set; }
private List<ArtifactGrouping> ArtifactGroupings { get; set; } = [];
protected override async Task OnParametersSetAsync()
{
await using var context = await ContextFactory.CreateDbContextAsync();
// First, handle the case where there are no tags to filter by.
if (SliderEntry.FilterTags == null || !SliderEntry.FilterTags.Any())
{
ArtifactGroupings = new List<ArtifactGrouping>();
return;
}
// It's much more efficient to get the IDs of the tags first.
var requiredTagIds = SliderEntry.FilterTags.Select(t => t.Id).ToList();
int requiredTagCount = requiredTagIds.Count;
ArtifactGroupings = await context.ArtifactGroupings
.Include(g => g.ChildArtifactEntries)
.ThenInclude(e => e.Tags)
.Include(g=>g.ChildArtifactEntries)
.ThenInclude(e=>e.Files)
.Where(grouping =>
grouping.ChildArtifactEntries.Any(entry =>
entry.Tags.Count(tag => requiredTagIds.Contains(tag.Id)) == requiredTagCount
)
)
// AsSplitQuery() is a performance optimization for complex queries with multiple Includes.
.AsSplitQuery()
.ToListAsync();
StateHasChanged();
}
}