Updated admin page to be more streamlined and added the beginning of the blogging features
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
@namespace OpenArchival.Blazor.ArtifactGroupingDisplay
|
||||
@page "/archive/{GroupingIdString}"
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using OpenArchival.DataAccess;
|
||||
@using OpenArchival.Blazor.FileViewer
|
||||
@using MudBlazor
|
||||
|
||||
@inject IArtifactGroupingProvider GroupingProvider;
|
||||
@inject NavigationManager NavigationManager;
|
||||
|
||||
@if (_artifactGrouping is not null)
|
||||
{
|
||||
@@ -53,7 +52,9 @@
|
||||
|
||||
</MudContainer>
|
||||
}
|
||||
|
||||
@inject IArtifactGroupingProvider GroupingProvider;
|
||||
@inject NavigationManager NavigationManager;
|
||||
@inject IDbContextFactory<ApplicationDbContext> ContextFactory;
|
||||
@code {
|
||||
[Parameter]
|
||||
public string GroupingIdString { get; set; }
|
||||
@@ -68,7 +69,25 @@
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
_groupingId = int.Parse(GroupingIdString);
|
||||
var grouping = await GroupingProvider.GetGroupingAsync(_groupingId);
|
||||
await using var context = await ContextFactory.CreateDbContextAsync();
|
||||
var grouping = await context.ArtifactGroupings
|
||||
.Include(g => g.Category)
|
||||
.Include(g => g.IdentifierFields)
|
||||
.Include(g => g.Type)
|
||||
.Include(g => g.ChildArtifactEntries)
|
||||
.ThenInclude(e => e.StorageLocation)
|
||||
.Include(g => g.ChildArtifactEntries)
|
||||
.ThenInclude(e => e.Type)
|
||||
.Include(g => g.ChildArtifactEntries)
|
||||
.ThenInclude(e => e.Files)
|
||||
.Include(g => g.ChildArtifactEntries)
|
||||
.ThenInclude(e => e.Tags)
|
||||
.Include(g => g.ChildArtifactEntries)
|
||||
.ThenInclude(e => e.ListedNames)
|
||||
.Include(g => g.ChildArtifactEntries)
|
||||
.ThenInclude(e => e.Defects)
|
||||
.Include(g => g.ViewCount)
|
||||
.FirstOrDefaultAsync(g => g.Id == _groupingId);
|
||||
|
||||
if (grouping is null)
|
||||
{
|
||||
@@ -77,6 +96,17 @@
|
||||
|
||||
_artifactGrouping = grouping!;
|
||||
|
||||
if (_artifactGrouping.ViewCount is null)
|
||||
{
|
||||
var viewCount = new ArtifactGroupingViewCount() {Grouping=grouping, Views=1};
|
||||
_artifactGrouping.ViewCount = viewCount;
|
||||
context.Add(viewCount);
|
||||
} else
|
||||
{
|
||||
_artifactGrouping.ViewCount.Views++;
|
||||
}
|
||||
await context.SaveChangesAsync();
|
||||
|
||||
StateHasChanged();
|
||||
|
||||
await base.OnParametersSetAsync();
|
||||
|
||||
Reference in New Issue
Block a user