@page "/site/{SiteInfoId:int}/content-groups" @using BLAIzor.Components.Layout @using BLAIzor.Models @using BLAIzor.Services @using Microsoft.AspNetCore.Components.Authorization @layout AdminLayout @inject ContentEditorService contentEditorService @inject NavigationManager Navigation @attribute [Authorize] @if (isLoading) {

Loading content groups...

} else { @foreach (var group in groups) { if (selectedGroupId == group.Id) {
} else {
@group.Name
@group.Type
} } } @code { [Parameter] public int SiteInfoId { get; set; } private List groups = new(); private bool isLoading = true; private int? selectedGroupId = null; private void SelectGroup(int groupId) { selectedGroupId = groupId; } private void DeselectGroup() { selectedGroupId = null; } protected override async Task OnInitializedAsync() { isLoading = true; groups = (await contentEditorService.GetContentGroupsBySiteInfoIdAsync(SiteInfoId)) .Where(g => g.SiteInfoId == SiteInfoId) .OrderByDescending(g => g.LastUpdated) .ToList(); isLoading = false; } private void EditGroup(ContentGroup group) { Navigation.NavigateTo($"/content-group/{group.Id}/items"); } private async Task SaveGroup(ContentGroup group) { group.LastUpdated = DateTime.UtcNow; group.Version = group.Version + 1; var result = await contentEditorService.UpdateContentGroupByIdAsync(group); if(result != null) ; } private async Task DeleteGroup(ContentGroup group) { var result = await contentEditorService.DeleteContentGroupByIdAsync(group.Id); ; groups.Remove(group); } private async Task AddNewGroup() { var newGroup = new ContentGroup { SiteInfoId = SiteInfoId, Name = "New Group", Slug = $"group-{DateTime.UtcNow.Ticks}", Type = "manual", VectorSize = 384, EmbeddingModel = "default", CreatedAt = DateTime.UtcNow, LastUpdated = DateTime.UtcNow, Version = 1 }; var result = await contentEditorService.CreateContentGroupAsync(newGroup); if(result!=null) { groups.Insert(0, newGroup); } } }